Entry
How can I scale an image to a different size in PHP?
How can I adjust the quality (and file size) of an image?
how can i find the height and width of an image?
how can i compare the height and width of an image?
Sep 28th, 2001 19:53
bal just-bal, Nathan Wallace, narender rauthan, Opec Kemp, Markus Schulte,
You can display an image as a different size just by setting the height
and width properties in the HTML IMG tag. This results in the complete
file being downloaded regardless of the final image size however. That
can make for some very large thumbnails...<g>
To adjust the image file size as well you'll need to install this lib on
your machine : Image Magick, it can be found at
http://www.imagemagick.org/
Here's a quick run down from their web site:
ImageMagickTM, version 4.2.8, is a robust collection of tools and
libraries to read, write, and manipulate an image in any of the more
popular image formats including GIF, JPEG, PNG, PDF, and Photo CD.
With ImageMagick you can create GIFs dynamically making it suitable
for Web applications.
You can also resize, rotate, sharpen, color reduce, or add special
effects to an image and save your completed work in the same or
differing image format.
Here are just a few examples of what ImageMagick can do:
* Convert an image from one format to another (e.g. TIFF to
JPEG)
* Resize, rotate, sharpen, color reduce, or add special effects
to an image
* Create a montage of image tumbnails
* Create a transparent image suitable for use on the Web
* Turn a group of images into a GIF animation sequence
* Create a composite image by combining several separate images
* Draw shapes or text on an image
* Decorate an image with a border or frame
* Describe the format and characteristics of an image
The X11 libs are only required if you build the full ImageMagick
package, including the graphic viewer. If all you're interested in is
the command-line tools, you can 'configure --without-x'
Once you install the neccessary libs, you will have a program called
"mogrifycation" which you can run from the command line. You can do all
sorts of img manipularion with this util ie resize, dither, reduce
resolution etc etc from the command line :).
So you could easily use the PHP system() call to execute the command and
get what you want.