Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Image Uploader that Sizes the Photo Like An Avatar

by Anonymous Monk
on Jul 03, 2022 at 12:27 UTC ( [id://11145250]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise ones!

I'm looking to have users of my Web CGI script upload images using a form in their browser, and then prompt the users to crop whatever they upload to be square and no more than 600pixels in any dimension. I have no idea of any tools or modules I can use to do so.

Any advice? Thanks in advance!

  • Comment on Image Uploader that Sizes the Photo Like An Avatar

Replies are listed 'Best First'.
Re: Image Uploader that Sizes the Photo Like An Avatar
by hippo (Bishop) on Jul 03, 2022 at 13:50 UTC
Re: Image Uploader that Sizes the Photo Like An Avatar
by davies (Prior) on Jul 03, 2022 at 16:08 UTC
Re: Image Uploader that Sizes the Photo Like An Avatar
by kcott (Archbishop) on Jul 03, 2022 at 22:00 UTC

    Take a look at Image::Magick. Its description starts with (my emphasis):

    "This Perl extension allows the reading, manipulation and writing of a large number of image file formats using the ImageMagick library. It was originally developed to be used by CGI scripts for Web pages."

    A link to extensive documentation follows.

    I believe that module only handles raster formats; but happy to be proven wrong (I did have a quick look for a list of available formats: couldn't find one). I routinely use Image::LibRSVG to convert SVG (a vector format) to raster formats; I've no idea if that would be useful for you.

    — Ken

      Yes, Image::Magick will do this easily. I recommend actually, storing the full size image and hiding the resized image behind a webserver call (that might look like the all to an image or a RESTful GET call in an <img src...> tag. Note, image scale attacks exist, but I only mention them because they are an interesting adversary parlay against the bort.
Re: Image Uploader that Sizes the Photo Like An Avatar
by LanX (Saint) on Jul 03, 2022 at 12:33 UTC
    The crop part sounds rather like a JavaScript job ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Yes, in fact, this entire task sounds like a JavaScript job. From JavaScript, someone can put a local image from a hard drive to appear on the web page. Then the user can crop it, resize it using JavaScript. See Croppic.js. Then inside a canvas object, the JavaScript can get the new resized image pixel by pixel and convert it into any kind of format and upload it to the other side where your Perl script handles it. The JavaScript side of it is done by the Croppic library, so most of the work is already done for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145250]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2024-04-24 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found