|
Posted by petersprc on 07/19/07 18:44
You can use this code, but change the command:
http://groups.google.com/group/comp.lang.php/browse_thread/thread/add9df907a8fb755/58cf2cff276c5003?rnum=1#58cf2cff276c5003
That will only print the header if the command starts generating good
output.
By the way, for a generic resize script with more options and file
caching, use:
http://phpthumb.sourceforge.net/
On Jul 19, 1:30 am, Chuck Anderson <websiteaddr...@seemy.sig> wrote:
> I am trying to use ImageMagick to create thumbnails on the fly - without
> having to save the image to a file.
>
> I have gotten it to work by using passthru($cmd, $retval), but I want to
> use something else that will give me the complete output returned as a
> string that I can convert to a GD lib image resource so I can verify the
> operation worked before sending the Content-type header for the image.
>
> This works:
> ---------------------------------------------------------
> // $photo = path to image file
> $cmd = "convert.exe -size 250x250 \"$photo\"" .
> ' -resize 125x125' .
> ' -strip' .
> ' -unsharp 0.2x0.6+1.0' .
> ' -quality 87 JPG:-';
>
> header("Content-type: image/jpeg");
> passthru($cmd, $retval);
> ---------------------------------------------------------
>
> Using this, the resized image is displayed in my browser.
>
> However, I would rather get the binary output from ImageMagick into a
> variable and then test retval (or use some other method) to determine if
> the operation was successful.
>
> I've tried shell_exec ...
> $output = shell_exec($cmd);
> ... but the data in $output appears truncated (ÿØÿà?JFIF?,,??ÿÛ?C?
> - is all there is). ??
>
> Has anyone done anything like this? Any suggestions?
>
> --
> *****************************
> Chuck Anderson · Boulder, CO
> http://www.CycleTourist.com
> *****************************
[Back to original message]
|