CGI::U...eMagick(3pm)

πŸ“¦
version 2.18 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble

✨ CGI::Uploader::Transform::ImageMagick ✨

okay so bestie, this is the perl doc for CGI::Uploader::Transform::ImageMagick β€” and what it does is generate thumbnails with ImageMagick. iconic behavior honestly πŸ’…


πŸŽ€ METHODS πŸŽ€

πŸ’– gen_thumb() πŸ’–

first thing's first, you gotta pull the module in:

use CGI::Uploader::Transform::ImageMagick;

🌸 calling it as a class method 🌸

($thumb_tmp_filename)  = CGI::Uploader::Transform::ImageMagick->gen_thumb({
    filename => $orig_filename,
           w => $width,
           h => $height
    });

πŸ¦‹ calling it inside a CGI::Uploader "spec" πŸ¦‹

gen_files => {
  my_thumb => gen_thumb({ w => $width, h => $height }),
}

looking for a different syntax? πŸ‘€ go check out BACKWARDS COMPATIBILITY down below, i gotchu.


so what does this function actually do? it makes a copy of the image file you hand it, and resizes that copy to the width and height you gave it. that's it, that's the whole vibe ✨

gen_thumb can be called as an object method or as a class method. and if you're calling it as a class method? no cap, you do not need to call new() first β€” just go straight in, main character energy, no warm-up 🫢

Graphics::Magick is the first choice image service module. if that's not around, it tries Image::Magick next. backup plans, we love to see it πŸ’œ

🌈 Input: 🌈

  • filename β€” filename of source image
  • w β€” max width of thumbnail
  • h β€” max height of thumbnail
one or both of w or h is required. like, you genuinely cannot skip both, bestie 😭

⭐ Output: ⭐

  • filename of generated tmp file for the thumbnail
  • the initialized image generation object. (you generally shouldn't need this)

πŸ’€ BACKWARDS COMPATIBILITY πŸ’€

these older, more awkward syntaxes are still supported β€” yes even the crusty ones, we don't gatekeep πŸŽ€

as a class method:

($thumb_tmp_filename)  = CGI::Uploader::Transform::ImageMagick->gen_thumb(
   $orig_filename,
   [ w => $width, h => $height ]
   );

in a CGI::Uploader "spec":

'my_img_field_name' => {
    transform_method => \&gen_thumb,
    params => [ w => 100, h => 100 ],
  }

and the lil classic that every perl module ends on:

1;

k bye bestie, go make some thumbnails πŸ’–

this page came from the User Contributed Perl Documentation, it's perl v5.34.0, dated 2022-06-10, and the file itself is CGI::U...eMagick(3pm) β€” yes the name got cropped, she's mysterious like that πŸ’…βœ¨

πŸ“¦ where this page comes from