Jimmy's Blog Jimmy Ruska's Blog
Resizing images in PHP Posted on Thursday, February 14 2008
Learn to Play Songs by Ear: Ear Training

Let's say you want to post pictures to your blog, but they exceed the width by far too much, and you don't want to resize smaller images. The solution is image magick which works on linux, mac and windows. You can access it directly using exec() functions in php or you can use a frontend, wrapper, whats-am-a-call-its like magick wand and imagick. I just use the command line.

Example

mogrify.exe -format jpg -quality 80 -resize "700>" -sharpen 0x0.5 "C:\images\*.*"

This says I want to convert all files in C:\images into jpegs of quality 80. If the width is greater than 700 resize it to 700. Sharpen all images.

Mogrify overwrites the files while convert generates new ones. See this page for all command line utilities and arguments. Imagemagick is something all developers should use. For an insane amount of simple examples see the imagemagick examples page. If you use one of the wrappers the documentation with examples is provided with the download.

I had used it to figure out how youtube calculates which frame to use as a thumbnail. I generated thousands of numbered bitmaps and made them into an avi to try to find the correlation.




Tags: image magick, imagemagic, imagemagick, imageick, cli commandline, command line interface



stumble digg delicious


Blog by Jimmy Ruska
Add me: Youtube, Twitter, Facebook, MySpace

Share:

More OMFG-Good Links

See all Posts in the Funny Pictures category.
Download mp3s faster than limewire using google.
I've made 100+ free video tutorials.
See the best of the internet today on one page.