Page 1 of 1
Image Density
Posted: 2014-08-27T07:43:27-07:00
by ds1design
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);
Re: Image Density
Posted: 2014-08-27T07:53:06-07:00
by snibgo
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.
Re: Image Density
Posted: 2014-08-27T09:18:30-07:00
by ds1design
No the image is direct from the camera. I also tried Set(density=>"72x72"); method to no avail.
Re: Image Density
Posted: 2014-08-27T09:21:39-07:00
by fmw42
What are the input and output formats?
Re: Image Density
Posted: 2014-08-27T09:31:09-07:00
by ds1design
JPG in and JPG out.
Re: Image Density
Posted: 2014-08-27T10:48:58-07:00
by fmw42
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?
Re: Image Density
Posted: 2014-08-27T11:50:52-07:00
by ds1design
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.
Re: Image Density
Posted: 2014-08-27T12:12:13-07:00
by fmw42
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?
Re: Image Density
Posted: 2014-08-27T12:18:31-07:00
by fmw42
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.
Re: Image Density
Posted: 2014-08-28T07:02:27-07:00
by ds1design
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