Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Just as an aside, the ImageMagick ping method is the most efficient way to get size.
#!/usr/bin/perl -w use Image::Magick; my $x = $ARGV[0]; my $image = Image::Magick->new; #$image->Read($x); #my ($w,$h)= $image->Get('columns','height'); #print $x,' is ',$w.'x'.$h,"\n"; #this is very inneficient memory wise, use Ping ($width, $height, $size, $format) = $image->Ping($x); print $width,"\n", $height,"\n" ,$size,"\n", $format,"\n";
and here is a script I had in my library to do an actual distortion free resize.
#!/usr/bin/perl # I need to adjust an image to a minimum size, but without distoring i +t, # so I basically want to add space evenly around the existing image. # Using Resize is out since that will distort the image, so I gave # "Composite" a shot, use Image::Magick; use strict; use warnings; my $im = Image::Magick->new(); my $bg = Image::Magick->new(size => "200x400"); my $rc = $bg->Read("xc:white"); $rc = $im->Read($ARGV[0]); die $rc if $rc; $rc = $im->Resize("200x400"); warn $rc if $rc; $rc = $bg->Composite(gravity => "Center", image => $im); warn $rc if $rc; $rc = $bg->Write("$ARGV[0]-resized.png"); die $rc if $rc;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: determining size of image by zentara
in thread determining size of image by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others imbibing at the Monastery: (4)
    As of 2024-07-15 20:14 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.