How to resize image using php?

Here is a simple script to resize the given image. This requires PHP5, GD library.

First download the file and include to your code.

Usage example:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
// *** Include the class
include("resize-class.php");
 
// *** 1) Initialise / load image
$resizeObj = new resize('sample.jpg');
 
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> resizeImage(200, 200, 'crop');
// *** 3) Save image
$resizeObj -> saveImage('sample-resized.jpg', 100);
?>

One Response to “How to resize image using php?”

Leave a Reply