|
Posted by Chuck Anderson on 07/20/07 06:21
petersprc wrote:
> 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.
>
Thanks. (I take it that's yours.) It'll take me a little while to wrap
my head around that, but I will.
> By the way, for a generic resize script with more options and file
> caching, use:
>
> http://phpthumb.sourceforge.net/
>
Some things I like doing myself, but that sure is a robust,
all-encompassing thumbnail generator. I think it does, too much.
Thanks,
Chuck
> 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
>> *****************************
>>
>
>
>
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Everyone's journey should be different,
so that we all are enriched
in new and endless ways
*****************************
[Back to original message]
|