Re: PerlMagick in an output filter

[prev] [thread] [next] [Date index for 2005/02/15]

From: Stas Bekman
Subject: Re: PerlMagick in an output filter
Date: 22:46 on 15 Feb 2005
Dean Maslic wrote:
> Hi,
> 
> Im trying to implement an output filter that modifies images using
> PerlMagick in a proxy environment.
> 
> Since magick reads an image from a file-handle/stdin I guess I need to
> write the response data to a temp-file, Im not sure if its better to
> use the stream api's $f->read(my $buffer, BUFF_LEN) or the
> bucket_brigades to loop thru the data and print to temp_file, or it
> doesn't matter ?

Dean, conceptionally it doesn't matter. The filter read() API internally 
implements bucket brigades traversal. It's just with read() API you aren't 
as flexible as with direct bb manipulation.

Ideally there should be a PerlIO layer/or TIE interface that does all the 
work for you, so $filter can be also used as a filehandle, from which you 
can read and write normally. I believe it's somewhere on our long term 
todo list, but you are always more than welcome send patches to implement 
it sooner.

> Once Im done with modifying the image object, how do I return the data
> to the browser? Can I just write to stdout (.$image->Write("png:-");)
> and somehow signal to Apache to skip any other filters in the
> pipeline?

If you decided to use the filter, you send the data out the same way you 
got it in, depending on which of the two filter kinds you've chosen 
(streamed or bb). See the filter docs for more info:
http://perl.apache.org/docs/2.0/user/handlers/filters.html
And please ask more specific questions if still in doubt.

        -- 
        __________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

PerlMagick in an output filter
Dean Maslic 14:32 on 15 Feb 2005

Re: PerlMagick in an output filter
Stas Bekman 22:46 on 15 Feb 2005

Generated at 10:23 on 16 Feb 2005 by mariachi v0.52