Thumbnail Maker
Based on the tutorial How to create a gallery of thumbnail images on this site, the PHP script Thumbnail Maker provides a ready-to-use program that is applied to an image file or a whole directory, according to the arguments of the command.
Features of the script
The script resizes an image or creates a thumbnail, and it applies to one file or all images in a directory according to:
- the height passed
in parameter,
- or the width,
- or both the height
and width.
In the latter case images are resized retaining the original proportions and possibly centered and trimmed to obtain the necessary dimensions, which is essential to create a gallery of uniform thumbnails.
Command and options
The syntax is:
php resizer.php [options] (image-file | path | *)
The options are the dimensions of the new image.
We must interpret the command like this:
Resize depending on the options and ...
- the name of an
image file,
- or the path to the
content of a folder containing images,
- or with * the images
in the current directory.
In case one wants to simply resize the image, a single option is passed for the new height or width.
Examples:
-w100
The new image has a width of 100 pixels, the height will be adjusted to maintain proportions.
-h100
The new image will have a height of 100 pixels, and the width will be adapted.
-w100 -h100
The thumbnail will have a height and a width of 100 pixels. The proportions will be preserved, but the image will be centered and cropped at borders. The tutorial explains in detail the procedure and shows the PHP code that performs this processing.
If not parameter of dimension are given, the default settings (150 x 150) will be used.
Licensing
The script resizer.php is licensed under the GNU General Public License 2.0.
Use this script
freely but keep the copyright notice in the source code.
Download
Changes
- 1.1 - May 9, 2008 - We can pass as argument the name of a single file with a path.
- 1.0 - May 6, 2008 - First release.
(c) 2008 Denis Sureau - Scriptol.com