Page 1 of 1

writeImage giving headache

Posted: 2009-02-13T01:23:01-07:00
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?

Re: writeImage giving headache

Posted: 2009-02-13T02:38:58-07:00
by mkoppanen
Hello,

can you explain clearly what do you expect to happen and what actually happens?

Re: writeImage giving headache

Posted: 2009-02-13T03:17:32-07:00
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.

Re: writeImage giving headache

Posted: 2009-02-13T10:58:20-07:00
by mkoppanen
What version of Imagick and ImageMagick are you running? Can you see a segmentation fault in the webserver log?

Re: writeImage giving headache

Posted: 2009-02-13T19:58:47-07:00
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