Image Density

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
ds1design
Posts: 5
Joined: 2014-08-27T07:39:21-07:00
Authentication code: 6789
Location: Ontario, Canada

Image Density

Post by ds1design » 2014-08-27T07:43:27-07:00

I am trying to reduce image density (image is uploaded from camera at 300dpi).
I want to conform all images to 72 dpi while processing.
This is the code I have, but the resulting image remains 300dpi when tested in Photoshop.

Any help would be greatly appreciated.

use Image::Magick;
$status = $image->Read($img);
$status = $image->Resample('72x72');
$status = $image->Set(colorspace=>'RGB');
$status = $image->Set(quality=>'100');
$status = $image->Write($img);

snibgo
Posts: 11711
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image Density

Post by snibgo » 2014-08-27T07:53:06-07:00

Has the input already been Photoshopped? If so, it may have written its own internal metadata, which IM doesn't update, but "-strip" might remove.
snibgo's IM pages: im.snibgo.com

ds1design
Posts: 5
Joined: 2014-08-27T07:39:21-07:00
Authentication code: 6789
Location: Ontario, Canada

Re: Image Density

Post by ds1design » 2014-08-27T09:18:30-07:00

No the image is direct from the camera. I also tried Set(density=>"72x72"); method to no avail.
Thanks,

Alex Charlton
www.ds1design.com

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

Re: Image Density

Post by fmw42 » 2014-08-27T09:21:39-07:00

What are the input and output formats?

ds1design
Posts: 5
Joined: 2014-08-27T07:39:21-07:00
Authentication code: 6789
Location: Ontario, Canada

Re: Image Density

Post by ds1design » 2014-08-27T09:31:09-07:00

JPG in and JPG out.
Thanks,

Alex Charlton
www.ds1design.com

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

Re: Image Density

Post by fmw42 » 2014-08-27T10:48:58-07:00

Can you post your images to some free hosting service such as dropbox.com and put the URLs here? Or post the information from identify -verbose for your images.

What version of Imagemagick, libjpeg and platform are you using?

ds1design
Posts: 5
Joined: 2014-08-27T07:39:21-07:00
Authentication code: 6789
Location: Ontario, Canada

Re: Image Density

Post by ds1design » 2014-08-27T11:50:52-07:00

ImageMagick 6.2.8 05/08/12 Q16
This is one of the images I was testing with http://dev.riverquestchallenge.com/uploads/P1010117.JPG
See here for identify -verbose http://dev.riverquestchallenge.com/cgi- ... ze_test.pl
I am not sure how to confirm libjpeg or platform - do you mean which *nix??
Thanks for any and all input.
Thanks,

Alex Charlton
www.ds1design.com

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

Re: Image Density

Post by fmw42 » 2014-08-27T12:12:13-07:00

That version of IM is over 600 versions old. It is ancient. It could be there was a bug in that version and the only recourse would be to upgrade. But I do not know Perlmagick and cannot say if your code is correct or not. So some Perlmagick user would have to confirm. Can you provide the simplest code you have for just that task with filenames and actual argument included. That would make it easier for someone else to confirm your code.

Yes, I meant what flavor or Unix. I know for some it is easier to upgrade than for others.

Have you tried the equivalent of your Perlmagick in the command line to see if that works OK or not?

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

Re: Image Density

Post by fmw42 » 2014-08-27T12:18:31-07:00

In IM 6.8.9.7 Q16 Mac OSX, this command works fine.

Code: Select all

convert P1010117.JPG -resample 72x72 -quality 100 test.jpg
The IM verbose information shows:

Code: Select all

Image: test.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 704x528+0+0
  Resolution: 72x72
  Print size: 9.77778x7.33333
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
Since your input image is already RGB, you do not need to set colorspace RGB. But if you do, it should be right after reading the input image.

If you are trying to be sure that any CMYK image is convert to RGB, then you should use the equivalent of -colorspace RGB and not -set colorspace RGB. I do not know what the equivalents are for PerlMagick.

ds1design
Posts: 5
Joined: 2014-08-27T07:39:21-07:00
Authentication code: 6789
Location: Ontario, Canada

Re: Image Density

Post by ds1design » 2014-08-28T07:02:27-07:00

Yes, maybe related to version, looking into it as running the following command creates new image but resolution does not change:

convert P1010117.JPG -resample 72x72 -quality 100 test_P1010117.JPG
Thanks,

Alex Charlton
www.ds1design.com

Post Reply