On 4 May 2006 at 11:05, Glenn Linderman wrote:

> On approximately 5/4/2006 5:59 AM, came the following characters from
> the keyboard of Dermot Paikkos: > Hi > > ImageMagick 6.2.5 11/17/05 Q8
> > > The command-line utility convert -resample will set an images >
> resolution to the desired size about without resizing the image. > > I
> am trying to get the same effect using PerlMagick but when I use >
> $image->Resample('72x72') the images dimensions are changed >
> accordingly. Have I got the syntax wrong? > > I want the images to be
> 530 pixel along the widest axis with the > resolution at 72dpi. The
> images are jpeg and I would bother with this > step except Quark
> Xpress relies on the resolution when it renders an > image on the
> page. > > $image->Set(Type=>"TrueColor"); >
> $image->Profile(name=>'IPTC', >                                 profile=>'', 
> >                                ); >
> $x=$image->Resize(geometry=>"530x530"); > warn"$x"if"$x"; >
> $x=$image->Resample('72x72'); > > > Can anyone tell me if I am doing
> something wrong?
> 
> I'm no expert, so someone correct me if I'm wrong...
> 
> Well, you mention not wanting to resize the image... but then you
> mention "widest axis", and then you use a square size.
> 
> But you don't mention what the problem with the resulting image is. 
> I'm guessing that the problem might be that they get distorted, and
> come out square.  And I'm not sure, with that code, if they'd come out
> 530×530 or 72×72, I'm guessing the latter.

Correct. I think I did mention that the dimension where changes. 

> Whereas the command line options allow specification of a bounding
> box, and preserve aspect ratio, I think the APIs expect that you have
> enough coding horsepower to figure the width and height out yourself,
> and expect that you specify the exact size of the resulting image.  At
> least, I find that I have, for some reason, coded stuff like
> 
>          ( $width, $height ) = $image->Get('width', 'height');
>          $tmphei = int( $height * $maxwidth / $width );
>          $tmpwid = int( $width * $maxheight / $height );
>          print "wid: $width $maxwidth $tmpwid  hei: $height $maxheight
>          
> $tmphei\n"
>            if $debug;
>          $maxheight = $tmphei  if $tmphei < $maxheight;
>          $maxwidth = $tmpwid  if $tmpwid < $maxwidth;
>          GUtil::check_magick(
>            $image->Scale( width => $maxwidth, height => $maxheight ));
> 
> Following that with
> 
>          $image->Set( density => '72x72' );
> might do what you want.  check_magick just checks for errors, BTW.

The last bit is correct. What I wanted was to Set the Resolution 
attribute and that was where I was going wrong.

On the point about 'bounded box'

$image->Resize() in my experience works exactly as the command-line. 
That is:

"By default, the width and height are maximum values. That is, the 
image is expanded or contracted to fit the width and height value 
while maintaining the aspect ratio of the image".

So it isn't necessary to Get the image dimension if you know what you 
want the final image pixel size to be. IM will resize the image until 
it's widest axis meets the pixel size given.

Thanx.
Dp.
 


_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to