Image Thumbnail Script

Thumbnail Maker

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

Download Thumbnail Maker Archive

Versions