writeImage giving headache

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
twistedr

writeImage giving headache

Post by twistedr »

Hi!
I am using the imagick to create thumbnails of images.
Here is the script:

Code: Select all

function createThumb($id){
		$resize=250;
		$im= new Imagick(); 
		$basepath="../_resources/_";
		$imagesin=$basepath . $id . "/_orignals/";
		$imagesout=$basepath . $id . "/_thumbnails/";
		$scan=scandir($imagesin);
		$p="/^.+\.((jpg)|(jpeg))$/";
		for($i=0;$i<count($scan);$i++){
			if(preg_match($p,$scan[$i])){
				$rfile=$imagesin . $scan[$i];
				$ofile=$imagesout . $scan[$i];
				if(file_exists($ofile)) continue;
				$im->readImage($rfile);
				$im->thumbnailImage(250, 0, false);
				$im->writeImage($imagesout)
			}
		}
	}
The $id passed is 'photography' or 'drawing' depending what i want.
The script is to scan through the directory and check if a similar named file exists in the thumbnail directory and if not then create a thumbnail.
But the problem is instead it just gives a thumb.php on being called.
When i comment out the writeImage part it works fine. I have tries changing the read write permissions of the directory.

i am on ubuntu 8.10 with php 5.2.6 and imagick 2.1.1-rc1.
What do i do?
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: writeImage giving headache

Post by mkoppanen »

Hello,

can you explain clearly what do you expect to happen and what actually happens?
Mikko Koppanen
My blog: http://valokuva.org
twistedr

Re: writeImage giving headache

Post by twistedr »

Sure.
I want the script to scan for image files in the originals directory, then check if a same named image exists in the thumbnails directory. If not then it shoud create a thumbnail. but instead of creating a thumbnail it justs ends up giving me a thumbs.php file to download.

I have a link that calls the function and it ends up giving me a "thumbs.php" file to download.
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: writeImage giving headache

Post by mkoppanen »

What version of Imagick and ImageMagick are you running? Can you see a segmentation fault in the webserver log?
Mikko Koppanen
My blog: http://valokuva.org
twistedr

Re: writeImage giving headache

Post by twistedr »

i am having imagemagick 6.3.7, the problem seems to have been solved now. Earlier i was using the directory on a mounted NTFS partition. Now that i have switched back on default ubuntu at /var/www it works great!

thanks for the help
Post Reply