Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Dymanically Generated Images in Website

by dorward (Curate)
on May 12, 2006 at 09:10 UTC ( [id://548931]=note: print w/replies, xml ) Need Help??


in reply to Dymanically Generated Images in Website

The data: URL Scheme - but Internet Explorer doesn't support it, so in practise a seperate request for each image is the way to go.

Replies are listed 'Best First'.
Re^2: Dymanically Generated Images in Website
by PerlPilgrim (Acolyte) on Jun 26, 2007 at 21:44 UTC
    Hello,

    I know it is over a year later, but this post helped me solve my own problem - wanting to create various sizes of images, or even to scale images to a constant size.

    It sounds like since your script generates HTML and images both, you want a way to embed the binary images into the HTML. I am not sure I know of a way to do that. I have done scripts where you use a parameter to trigger an image or HTML based upon the value of the parameter, and then just call the script with the parameter indicating "image" from the page generated by the script in "HTML" mode.

    Or, you could split the script into two separate scripts. I know, not very clean.

    For those interested in my resizing-on-the-fly solution, it is here:
    #!/usr/local/bin/perl # Usage: http://www.yoururl.com/cgi-bin/image_resize.cgi?FILE=/path/to +/image.jpg&SIZE=300 use Image::Resize; use Image::Size; use CGI::Simple; my $q = new CGI::Simple; my $file = $q->param('FILE'); # Path to file on server file system my $size = $q->param('SIZE'); # Desired size of image my ($x, $y, $type) = imgsize($file); $size = ($x > $y) ? $x : $y if (($x < $size) || ($y < $size)); # Will not scale greater than 100% my $image = Image::Resize->new($file); my $gd = $image->resize($size, $size, 1); # 1 = maintain aspect ratio binmode STDOUT; if ((uc($type) eq 'JPG') || (uc($type) eq 'JPEG')) { print(qq|Content-Type: image/jpeg\n\n|); print $gd->jpeg(); } elsif (uc($type) eq 'PNG') { print(qq|Content-Type: image/png\n\n|); print $gd->png(); } elsif (uc($type) eq 'GIF') { print(qq|Content-Type: image/gif\n\n|); print $gd->gif(); }
    I hope this is useful to someone. Enjoy!

    Regards,

    Mark, Webberville, Michigan USA
Re^2: Dymanically Generated Images in Website
by blazar (Canon) on May 12, 2006 at 12:11 UTC

    I seem to remember having seen people achieve something similar with JavaScript. I'm not really sure. Whatever, even if so then the same portability problems would arise...

      I have used preloading of images in javascript on some pretty big sites. It is worth a look. SOmething similar can be done with CSS.

      jdtoronto

Re^2: Dymanically Generated Images in Website
by debiandude (Scribe) on May 12, 2006 at 09:17 UTC
    Hrm... I guess I will just leave it be for now. Thanks for the info!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-29 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found