PHP 7.4.33
Preview: simpleimage.php Size: 3.35 KB
/home/godevadmin/public_html/include/simpleimage.php

<?php
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
* 
* This program is free software; you can redistribute it and/or 
* modify it under the terms of the GNU General Public License 
* as published by the Free Software Foundation; either version 2 
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
* GNU General Public License for more details: 
* http://www.gnu.org/licenses/gpl.html
*
*/
 
 
/* $e = array ( 1 => 'gif', 'jpeg', 'png', 'swf', 'psd', 'bmp'
            'tiff', 'tiff', 'jpc', 'jp2', 'jpf', 'jb2', 'swc',
            'aiff', 'wbmp', 'xbm');
			*/
			//define(IMAGETYPE_GIF,1);
			//define(IMAGETYPE_JPEG,2);
			//define(IMAGETYPE_PNG,3);
			
 
class SimpleImage {
   
   var $image;
   var $image_type;
 
   function load($filename) {
      $image_info = getimagesize($filename);

if($image_info[2])
      $this->image_type = $image_info[2];
      if( $this->image_type == IMAGETYPE_JPEG ) {
         $this->image = imagecreatefromjpeg($filename);
      } elseif( $this->image_type == IMAGETYPE_GIF ) {
         $this->image = imagecreatefromgif($filename);
      } elseif( $this->image_type == IMAGETYPE_PNG ) {
         $this->image = imagecreatefrompng($filename);
      }
   }
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
   
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image,$filename,$compression);
      } elseif( $image_type == IMAGETYPE_GIF ) {
         imagegif($this->image,$filename);         
      } elseif( $image_type == IMAGETYPE_PNG ) {
         imagepng($this->image,$filename);
      }   
      if( $permissions != null) {
         chmod($filename,$permissions);
      }
   }
   function output($image_type=IMAGETYPE_JPEG) {
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image);
      } elseif( $image_type == IMAGETYPE_GIF ) {
         imagegif($this->image);         
      } elseif( $image_type == IMAGETYPE_PNG ) {
         imagepng($this->image);
      }   
   }
   function getWidth() {
      return imagesx($this->image);
   }
   function getHeight() {
      return imagesy($this->image);
   }
   function resizeToHeight($height) {
      $ratio = $height / $this->getHeight();
      $width = $this->getWidth() * $ratio;
      $this->resize($width,$height);
   }
   function resizeToWidth($width) {
      $ratio = $width / $this->getWidth();
      $height = $this->getheight() * $ratio;
      $this->resize($width,$height);
   }
   function scale($scale) {
      $width = $this->getWidth() * $scale/100;
      $height = $this->getheight() * $scale/100; 
      $this->resize($width,$height);
   }
   function resize($width,$height) {
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
      $this->image = $new_image;   
   }      
   function get_file_extension($file_name) {
	return substr(strrchr($file_name,'.'),1);
}
}
?>

Directory Contents

Dirs: 1 × Files: 25

Name Size Perms Modified Actions
ckeditor DIR
- drwxrwxr-x 2023-11-07 20:00:00
Edit Download
649 B lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
649 B lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
4.71 KB lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
4.10 KB lrwxrwxr-x 2025-01-22 14:39:16
Edit Download
3.97 KB lrwxrwxr-x 2023-11-22 20:59:28
Edit Download
4.04 KB lrwxrwxr-x 2024-02-22 09:17:20
Edit Download
73.66 KB lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
46.75 KB lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
1.79 KB lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
1.79 KB lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
69.77 KB lrwxrwxr-x 2023-11-07 19:59:58
Edit Download
11.18 KB lrwxrwxr-x 2023-11-18 00:41:42
Edit Download
25.88 KB lrwxrwxr-x 2025-12-08 14:24:06
Edit Download
14.21 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
4.54 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
43.90 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
6.63 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
554 B lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
3.36 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
3.28 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
1.08 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
3.35 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
2.18 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
2.39 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download
15.41 KB lrwxrwxr-x 2023-11-07 20:00:00
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).