How to use imagic writeImage () function?

This works if I save the script in the same directory as the image being manipulated. And the resulting image "foo.jpg" is also created in the same place.

<?php $im = new imagick('image.jpg'); $im->thumbnailImage( 200, 0); $im->writeImage("foo.jpg"); ?> 

But what if the script is in one place, and the image I want to work with is in another, and the location where I want to save the thumbnail is somewhere else, how do I specify these paths?

Doing something like this does not work:

 $im = new imagick('path/to/image.jpg'); 
+7
source share
1 answer

There may be a problem with the file system. Try to get the file pointer in php first and check for problems

 $fileHandle = fopen("path/to/image.jpg", "w"); 

Then you can use the Imagick function (version 6.3.6 or later);

 $im->writeImageFile($filehandle); 
+5
source

All Articles