views:

531

answers:

1

I am working on building gallery where the user uploads all the images. I had tried to use GD originally but found that it used way too much memory when dealing with images from a digital camera. So I have been looking into ImageMagick and ran into this problem.

My end goal is to resize the image and then upload it. I am not sure if this is possible with ImageMagick or not. I have gotten it to resize the image after upload but it doesn't save the resized image, just the original size.

This is the code I am currently using: ($image is the path to the file on my server)

$resource = NewMagickWand(); 
MagickReadImage($resource,$image); 
MagickSetImageCompressionQuality( $resource, 100);
$resource = MagickTransformImage($resource,'0x0','660x500');

Any input would be appreciated,
Levi

+1  A: 

Your code will send the modified image to the client (the web browser), but it will not save it to the server (replacing the original image, for example)

To save the image, use:

MagickWriteImage( $resource, 'new_image.jpg' );
Aziz