Image Thumbnail Script

Based on the tutorial How to create a thumbnail gallery of images on this site, the Thumbnail Maker script in PHP provides a ready-made program that applies to the image file or the entire directory, depending on the command passed.
In addition, starting with version 1.2, it can also convert the format of images on the fly.
Script functions
The script resizes the image or creates a thumbnail or applies to all images in the specified folder depending on:
- height transmitted in parameter,
- or width,
- or of appropriate height and width.
In the latter case, the images change, keeping the initial proportions and possibly centered and cropped to get the necessary dimensions, which is necessary to create a gallery of identical thumbnails.
Command and parameters
Syntax:
php resizer.php [options] (fichier-image | chemin | *)
The settings relate to the dimensions of the new image and possibly the new format.
The command should be interpreted as follows:
Resize based on options...
- is the name of the image file
-Path to the image or directory containing the images
- with * images in the current directory.
Measurement parameters
In case you just want to resize the image, you go to either the new height or the new width as an option.
Examples:
-w100
The new image will be 100 pixels wide, the height is suitable for maintaining proportions.
-h100
The new image will be 100 pixels high and the width will be adapted.
-w100 -h100
The thumbnail will have a height and width of 100 pixels. The proportions will remain, but the image will be centered and smoothed at the ends. The tutorial explains in detail the way it works and shows the PHP code that performs this processing.
If no measurement parameters are specified, the default parameters (150 x 150) will be used.
Conversion options
You can change the image format by creating thumbnails, or use the script as a format conversion tool without resizing.
Supported image formats - GIF, PNG, JPG:
-g convertir en gif. -p convertir en png. -j convertir en jpg.
Example:
php resizer.php -j monimage.png
If you specify a conversion parameter and do not specify a measurement parameter, the original dimensions are retained, while the image format is not specified as the default thumbnail dimensions.
So in the example, the image is converted to JPG and its dimensions are saved.
License
The resizer.php script is licensed under the GNU GPL 2.0.
Use this script freely, but keep the copyright notice in the source code.
Loading
Versions
- 1.4 - July 30, 2011.
Transparency is now maintained for GIF and PNG images.
Now the default dimensions are the dimensions of the original image, not 150x150 (for ease of conversion). - 1.3 - March 30, 2009 - Width and height alignment no longer requires image format provision.
- 1.2 - May 22, 2008 - Conversion options added.
- 1.1 - May 9, 2008 - as a parameter, you can specify the name of one file with a path.
- 1.0 - May 6, 2007 - First version.