On Wed, 20 Mar 2002, Nicolai Schlenzig wrote:

> When I create a new GD::Image drawing whatever on it and trying to print
> it - it will be prepended to my html header for the page. I then tried
> to put it in $m->out to have in printed within Mason, but that simply
> printed the raw PNG in all its glory as text on screen.
>
> I tried fiddeling with content_type, but I guess that wont work if I set
> this after I have already printed something on the page - hence the
> content_type will not even be effective for that page.
>
> What I still miss doing/trying is making a seperate file/component which
> only job will be to make the PNG, but I don't really see what I would
> gain from that, because that will pretty much also just print a PNG
> "within" my HTML page.

First of all, there's a mason users list
(http://www.masonhq.com/resources/mailing_lists.html).

Second, you don't seem to understand how images in a web page works.
When your browser sees <img src="foo"> it makes a _seperate_ request for
foo from the web server.

The image is not somehow magically inlined in the page and served with the
request for the page itself.

What you need is a seperate top-level Mason component that generates the
image.  Use this as the value for the src attribute like <img
src="foo.comp?size=2">.  Then make sure that foo.comp prints the correct
headers.

And yes, you need to use $m->out, not print (this is documented in the
Mason docs).


/*==================
www.urth.org
we await the New Sun
==================*/

Reply via email to