Php & ImageMagick

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Php & ImageMagick

Post by DSM »

Has anyone used this combination before. I am working on a project and have a fairly good idea of how it should work. But never having used imagemagick before I am a little sketchy on the proper procedure.

Any help is great appreciated.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

I use it to build thumbs, I simply use system calls from php.
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post by DSM »

Ok, maybe I am not understanding this as much as I thought I was.
Here's the scenario.

Have a image named car.jpg in dir images/upload
The image car.jpg is 300 x 300
I want to use imagemagick to convert the image to display it at 120x120 in a table. How do I call the imagemagcik command and can I do it on the fly?

Thanks
samscripts
Forum Commoner
Posts: 57
Joined: Tue Apr 23, 2002 4:34 pm
Location: London, UK

Post by samscripts »

I think the command you need is 'convert' which should exist in the imagemagick directory.

exec("/path/to/imagemagick/convert -scale 120x120 images/upload/car.jpg /path/to/save/in/car.jpg")

http://www.imagemagick.org/www/convert.htm

I'm not sure if its the -scale or the -resize argument that you need. As to doing it on the fly, I'm not sure if ImageMagick will output directly to the browser like this, but it probably can if you read the manual.

If not, you could just generate the thumbnail and save it to disk, then readfile() it, then delete the generated thumbnail.

hope this helps, Sam
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post by DSM »

hedge wrote:I use it to build thumbs, I simply use system calls from php.
Does look right to you,
$abpath = absoulte path to images.
I am taking image resizing and saving as thumbnail

Code: Select all

system("/usr/local/bin/imagemagick/convert -size 75x75 $abpath/$img1_name -resize 75x75 $abpath/$img1_thumbnail_name");
pa
Forum Newbie
Posts: 1
Joined: Wed Oct 02, 2002 7:41 pm

Post by pa »

Hello,

Maybe too late :)

Note there exists an image extension for php available on pear.php.net.

Besides that, there s also a library that let you use the same functions whatever image library you want (gd, netpbm, imagick ext, imagick command line) on pear. Image_Transform.

hth

pa
Post Reply