I'm trying to send some binary data to ImageMagick's mogrify command, which resizes the image. Then I'd like the resulting data to be output to a browser or stored in a variable. If anyone can help me I'd be sooo very greatful 😉
Here's the code I'm playing with:
<?
// get contents of a file into a string
$filename = "/tmp/tiger1.jpg";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
// with or without this line, the browser shows a missing image icon
// which makes me think that it's receiving some form of image, ???
//header("Content-type: image/jpeg");
// echoing $contents works fine with or without the above header line
//echo $contents;
// this passthru will produce a missing icon in IE5.5, a good sign i guess 😉
// the jpg:- makes mogrify use stdout, the 2>&1 shows the error messages
//passthru("echo $contents | /usr/local/bin/mogrify -sample 100x100! jpg:- 2>&1");
// if i run the passthru line below i get the following error from mogrify (imagemagick)
// mogrify: Not a JPEG file: starts with 0x62 0x6c (-).
// mogrify: Missing an image file name.
// which is another good sign because i think that means that the above passthru
// is actually passing some valid JPEG data. hmmm..
//passthru("echo blahhhhh | /usr/local/bin/mogrify -sample 100x100! jpg:- 2>&1");
?>
I've hit the point of diminishing returns for today, maybe I'll wake up tommorrow with the solution (:
Thanks for your time,
Phil..