Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Imager::Font examples

by neilwatson (Priest)
on Mar 03, 2003 at 15:30 UTC ( #240054=note: print w/replies, xml ) Need Help??


in reply to Re: Imager::Font examples
in thread Imager::Font examples

Thanks. A couple of questions:

How would you determine the size of the image file automatically, if the font size was dynamic, without reserving a large image size?

How do I send the image to a web browser without saving the file first?

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Re: Imager::Font examples
by domm (Chaplain) on Mar 04, 2003 at 07:41 UTC

    How would you determine the size of the image file automatically, if the font size was dynamic, without reserving a large image size?

    Hmm, never done that. One idea: Generate a very large image, draw the text, use $font->bounding_box to get the dimensions of the drawn string, and finally crop the image accordingly.

    How do I send the image to a web browser without saving the file first?

    Try something like this:

    my $img_data; $img->write(data=>\$img_data,type=>'png') or die "Cannot dump image: ", $img->errstr;

    Now you've got the image in $img_data, so you can print it to STDOUT (or via CGI). If operating under CGI, don't forget to set the proper content-type.

    -- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://240054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-09-27 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?