MagickWriteImage fails (sometimes)
Posted: 2007-03-12T13:13:55-07:00
Hello Magickwand group,
I have a perplexing problem. I am using Fedora Core 6, PHP 5.2, and apache 2.2.
I have Magicwand, Imagemagick, and GD in my php config.
I have two php pages, one where I read an image(s) and size(s), and resize the image, and do a write to a diff path (reads from testimage/mypix.jpg, and writes to 25/mypix.jpg)
$magick_wand = NewMagickWand();
MagickReadImage($magick_wand,$image);
$resizedImage = MagickTransformImage( $magick_wand, '0x0',"$size");
MagickSharpenImage($resizedImage, 0.0,1.0);
MagickWriteImage($resizedImage,$newpath);
in a loop, image by image, this works every time. I read a file in one directory, and then write it to
another directory in its "resized" format.
Then I have a page that reads the resized file, and then transforms the image to a thumbnail,
and writes it (supposed to write it!) to a different directory.
Code snippet:
function thumbMaker($id,$mod,$image)
{
$magick_wand = NewMagickWand();
$name = explode('/',$image);
$path = $mod .'/'. 'thumbs' . '/' . 'tn_'. \"".$name[1].\"";
$update = "UPDATE images3 SET thmbpath = " . "'". $path . "'" . " WHERE modfolder = $mod AND id = $id";
@mysql_query($update) or trigger_error("Error Perfoming Query: ". mysql_error(), E_USER_ERROR);
MagickReadImage($magick_wand,$image);
$thumbImage = MagickTransformImage( $magick_wand, '0x0', '150x150' );
MagickWriteImage($thumbImage,$path);
}
The mysql part seems to work fine. I pass the image name, id, etc to the function.
the image is read from one path (25/mypix.jpg), and supposed to be written to another path (25/thumbs/tn_mypix.jpg
this code seems the same as the sample above. I have played around with the permissions on the folders (apache.apache, the web user) and even tried setting privs for "all" to rw (do I need execute?)
the code that reads (on a diff php file) the base file, and writes a resized version of the file works fine.
It is when I read the resized file, and try to write the thumbnail, the MagickWrite command fails.
Any guidance on this will help.
thanks you ,
eholz1
I have a perplexing problem. I am using Fedora Core 6, PHP 5.2, and apache 2.2.
I have Magicwand, Imagemagick, and GD in my php config.
I have two php pages, one where I read an image(s) and size(s), and resize the image, and do a write to a diff path (reads from testimage/mypix.jpg, and writes to 25/mypix.jpg)
$magick_wand = NewMagickWand();
MagickReadImage($magick_wand,$image);
$resizedImage = MagickTransformImage( $magick_wand, '0x0',"$size");
MagickSharpenImage($resizedImage, 0.0,1.0);
MagickWriteImage($resizedImage,$newpath);
in a loop, image by image, this works every time. I read a file in one directory, and then write it to
another directory in its "resized" format.
Then I have a page that reads the resized file, and then transforms the image to a thumbnail,
and writes it (supposed to write it!) to a different directory.
Code snippet:
function thumbMaker($id,$mod,$image)
{
$magick_wand = NewMagickWand();
$name = explode('/',$image);
$path = $mod .'/'. 'thumbs' . '/' . 'tn_'. \"".$name[1].\"";
$update = "UPDATE images3 SET thmbpath = " . "'". $path . "'" . " WHERE modfolder = $mod AND id = $id";
@mysql_query($update) or trigger_error("Error Perfoming Query: ". mysql_error(), E_USER_ERROR);
MagickReadImage($magick_wand,$image);
$thumbImage = MagickTransformImage( $magick_wand, '0x0', '150x150' );
MagickWriteImage($thumbImage,$path);
}
The mysql part seems to work fine. I pass the image name, id, etc to the function.
the image is read from one path (25/mypix.jpg), and supposed to be written to another path (25/thumbs/tn_mypix.jpg
this code seems the same as the sample above. I have played around with the permissions on the folders (apache.apache, the web user) and even tried setting privs for "all" to rw (do I need execute?)
the code that reads (on a diff php file) the base file, and writes a resized version of the file works fine.
It is when I read the resized file, and try to write the thumbnail, the MagickWrite command fails.
Any guidance on this will help.
thanks you ,
eholz1