PHP Classes

PHP Image Crop and Resize: Resize and crop images to a given size

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 552 This week: 1All time: 5,497 This week: 560Up
Version License PHP version Categories
image-crop-resize 1.0.0Free for non-comm...5HTTP, PHP 5, Graphics
Description 

Author

This class can resize and crop images to a given size.

It can open a local or a remote image file and resize it to a given width and height.

The class can also add a watermark, crop the image to a given position and convert the image to grey scale.

The resized image is stored in a server cache file. If the resized image is requested again, the class may return request headers stating that it did not change since last modification.

Picture of Rahman Haghparast
  Performance   Level  
Name: Rahman Haghparast <contact>
Classes: 10 packages by
Country: Iran Iran
Age: 43
All time rank: 751 in Iran Iran
Week rank: 416 Down4 in Iran Iran Down
Innovation award
Innovation award
Nominee: 2x

Example

<?php
require_once 'imageresize.class.php';
$imageResize = new ImageResize();
$imageResize->resize();


Details

The purpose of this class is to resize images on the fly using some parameters set in the query string. Installation: You just need to include imageresize.class.php in your codes, create a new instance of the class and call the resize() method of the class. You can check the sample.php file to see it in action. How to use: In order to download, crop and resize images you should include url, width, height and some other parameters in the query string. The parameters you can use are as follows: width=(int) pixels height=(int) pixels grey=1 watermark=1 watermark_position=either of [bottom-left,bottom-right,top-left,top-right,center] Note: You can use all the options together Examples: To download the image with its original size: http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg To resize the image to the width of 200 pixels and keep the aspect ratio http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg&width=200 To resize the image to the height of 300 pixels and keep the aspect ratio http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg&height=300 To resize the image to the width of 180 and height of 150 pixels and crop it intellegently http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg&width=180&height=150 To resize the image to the width of 400 and height of 300 pixels and crop it intellegently and convert it to grey http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg&width=400&height=300&grey=1 To resize the image to the width of 300 and height of 200 pixels and crop it from the original position of 40,80 (x,y) http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg&width=300&height=200&offsetX=40&offsetY=80 To add watermark to the cropped image at its bottom left. http://loclhost/imageresize/sample.php?url=http://newfm.ir/sample.jpg&width=180&height=150&watermark=1&watermark_position=bottom-left License: This program is free for non-commercial use. Please send any comments and questions to my email address: haghparast@gmail.com

  Files folder image Files  
File Role Description
Plain text file imageresize.class.php Class Main class
Accessible without login Plain text file readme.txt Doc. Documentation
Accessible without login Plain text file sample.php Example Sample file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:552
This week:1
All time:5,497
This week:560Up