Crop and not change DPI

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
vascott1
Posts: 1
Joined: 2012-02-01T07:58:29-07:00
Authentication code: 8675308

Crop and not change DPI

Post by vascott1 » 2012-02-01T09:34:01-07:00

Hello. I am trying to crop images but not change the DPI.. Whgat I am seeing is an image is 200dpi and then after I perform the crop, the cropped output is 72 dpi.. My code looks like this...

my $imageCrop = $image->Clone();

$imageCrop->Crop( $pixelsWide . "x" . $pixelsHigh . "+" . abs($pixelsLeft) . "+" . abs($pixelsTop) );

$result = $imageCrop->Write("$TempDir$file");

This is having a huge impact for my process so any help would be appreicated.

Thanks, Scott.

aporthog
Posts: 37
Joined: 2012-05-30T08:24:46-07:00
Authentication code: 13

Re: Crop and not change DPI

Post by aporthog » 2012-05-30T09:21:16-07:00

I had this issue generating gif images. Any other format, jpeg, etc., should work fine.

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crop and not change DPI

Post by fmw42 » 2012-05-30T09:36:10-07:00

Seems to work fine in command line mode, IM 6.7.7.3 Q16 Mac OSX Snow Leopard


convert logo: -density 200 logo_tmp.png
identify -verbose logo_tmp.png
Image: logo_tmp.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 200x200


convert logo_tmp.png -gravity center -crop 300x300+0+0 logo_tmp_crop.png
identify -verbose logo_tmp_crop.png
Image: logo_tmp_crop.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 300x300+0+0
Resolution: 200x200

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Crop and not change DPI

Post by anthony » 2012-07-18T00:02:26-07:00

nothing you do is changing the DPI resolution of the images. Perhaps the image file format does not allow it?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply