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);
?>
Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in