Increasing DPI results in doubling of image size
Posted: 2016-11-02T11:53:16-07:00
I'll start off by letting you know I'm new to Imagemagick.
What I'm trying to do with the software is change the dpi of scanned images. Ideally I'd like to apply a horizontal and vertical dpi, as our image has different horizontal and vertical pixel dimensions, but it's fine if square pixels are my only option. Anyway, the camera has a object pixel size of ~5.2um/pixel, or 4880dpi. The images are 8192x9216, and about 73MB each. When I open them in Photoshop, the program reports 72dpi as the pixel size.
The issue is that when I load them into our image analysis software, it sees the image as 96x96dpi, which causes the physical scale to be much too large. If I resize the dpi in photoshop by setting the physical width to 1.68 inches, the image opens properly in our image analysis software. The dpi is a little off at ~4875dpi, but that's fine. So, of course, I COULD use photoshop and batch process, but opening 73MB images is painfully slow from our network.
I have been able to edit the dpi with Imagemagick through two different lines of code. The issue is that through either method, the image size goes up to 136MB, while with photoshop, the image size stays the same. I'd like to use Imagemagick for the speed and convenience of being able to incorporate into a scripted action, but the file size increase isn't going to work.
Here is the code:
and
I've also tried -set density, and sometimes, the dpi shows up as 12405.4, which is 2.54 times the dpi I'm trying to set...obviously a units issue. Still, the code works, and the pixel size does reduce so that the print size is 1.6777 x 1.89 inches, but the file size increases.
Is there any way to keep the file size from going up? I would think that reducing the dpi would cause it to increase, because then the print size would be much larger, right?
What I'm trying to do with the software is change the dpi of scanned images. Ideally I'd like to apply a horizontal and vertical dpi, as our image has different horizontal and vertical pixel dimensions, but it's fine if square pixels are my only option. Anyway, the camera has a object pixel size of ~5.2um/pixel, or 4880dpi. The images are 8192x9216, and about 73MB each. When I open them in Photoshop, the program reports 72dpi as the pixel size.
The issue is that when I load them into our image analysis software, it sees the image as 96x96dpi, which causes the physical scale to be much too large. If I resize the dpi in photoshop by setting the physical width to 1.68 inches, the image opens properly in our image analysis software. The dpi is a little off at ~4875dpi, but that's fine. So, of course, I COULD use photoshop and batch process, but opening 73MB images is painfully slow from our network.
I have been able to edit the dpi with Imagemagick through two different lines of code. The issue is that through either method, the image size goes up to 136MB, while with photoshop, the image size stays the same. I'd like to use Imagemagick for the speed and convenience of being able to incorporate into a scripted action, but the file size increase isn't going to work.
Here is the code:
Code: Select all
mogrify -density 4884x3907 -units PixelsPerInch C:\2\*.bmp
Code: Select all
Convert C:\2\image.bmp -units PixelsPerInch -density 4884 C:\2\out.bmp
Is there any way to keep the file size from going up? I would think that reducing the dpi would cause it to increase, because then the print size would be much larger, right?