Hello,
I am trying to reduce the resolution of images to 72x72 using convert -resample 72x72
when I do this the image size does get reduced, but when using identify on the image it says the resolution is still something else. I've even tried running -density 72x72 to specify the new density, but that doesn't seem to work either.
Any ideas what might be going on here?
Thanks in Advance!
Problems with resampling to change resolution
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with resampling to change resolution
Resolution and Density are two different things.
convert image -resize 72x72! result
will make a new image whose dimensions are 72x72 pixels.
Density has to do with how many dots/in when printing. A nominal image will have a density of 72 dpi unless you specify something else with -density ( or if had something else to start with).
convert image -resize 72x72! result
will make a new image whose dimensions are 72x72 pixels.
Density has to do with how many dots/in when printing. A nominal image will have a density of 72 dpi unless you specify something else with -density ( or if had something else to start with).
Re: Problems with resampling to change resolution
Thanks for replying, fmw42.
My very limited understanding is that -resample changes the dpi. This means that with a lower dpi, the image quality may not be as good, but will be smaller since there are fewer dots that need to be recorded. The image size should stay the same, however. I do not want the images to be a different dimension, only smaller in diskspace.
-density doesn't necessarily change the resolution of an image, but rather tags the image as being of a certain resolution. This would be used to tell a printer how many dpi to print, or to use if you have an image format that doesn't contain resolution info to specify what the assumed resolution should be.
My problem is that after resampling a bunch of images to use for the web, some of them resample, say that their resolution is now 72x72, and they appear the same size on a website. Others, however, appear much smaller online now, which I'm guessing is because the resolution has been altered, but the header in the jpg says that the image is of a much greater resolution. I will admit this is just my guess, however.
Please correct me if I'm wrong about any of this.
My very limited understanding is that -resample changes the dpi. This means that with a lower dpi, the image quality may not be as good, but will be smaller since there are fewer dots that need to be recorded. The image size should stay the same, however. I do not want the images to be a different dimension, only smaller in diskspace.
-density doesn't necessarily change the resolution of an image, but rather tags the image as being of a certain resolution. This would be used to tell a printer how many dpi to print, or to use if you have an image format that doesn't contain resolution info to specify what the assumed resolution should be.
My problem is that after resampling a bunch of images to use for the web, some of them resample, say that their resolution is now 72x72, and they appear the same size on a website. Others, however, appear much smaller online now, which I'm guessing is because the resolution has been altered, but the header in the jpg says that the image is of a much greater resolution. I will admit this is just my guess, however.
Please correct me if I'm wrong about any of this.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with resampling to change resolution
Sorry, I am not all that familiar with -resample. Hopefully someone else will be able shed more light on this subject for you. I apologize. I misread your first message and thought you were using -resize and not -resample.
Re: Problems with resampling to change resolution
So I figured out that part of the problem involved photoshop header information. I had read mention of that but didn't realize it affected any file touched by photoshop. I stripped out the header information, but still I have the same problem. The images get resampled but appear smaller in size, which was what I thought resample was exactly supposed to keep from happening! Help!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with resampling to change resolution
see
http://www.imagemagick.org/Usage/resize/#resample
I think -resample (as it is built from -resize) will change the number of pixels in the image as well as the density to work with a piece of hardware that is keyed to a specific resolution. Thus the final resolution of the image in combination with the number of pixels will produce the resolution (density) that in combination matches the density needed for that hardware.
I hope this page helps. I am no expert on -resample, but found this page and wanted to point you to it. Perhaps someone else who is more experienced with -resample can comment.
http://www.imagemagick.org/Usage/resize/#resample
I think -resample (as it is built from -resize) will change the number of pixels in the image as well as the density to work with a piece of hardware that is keyed to a specific resolution. Thus the final resolution of the image in combination with the number of pixels will produce the resolution (density) that in combination matches the density needed for that hardware.
I hope this page helps. I am no expert on -resample, but found this page and wanted to point you to it. Perhaps someone else who is more experienced with -resample can comment.
Re: Problems with resampling to change resolution
So I finally got it to do what I wanted to: reduce the filesize of the images, while retaining the same dimensions. In order to do this I had to run a command like this:
convert -strip -density 72 -resample 72x72 oldfile.jpg newfile.jpg
It seems kind of strange that by setting the density to 72, and then resampling it to 72, it would perform this. I would think that since I declare the density to be 72, and then try to resample it to 72, that nothing would happen.
Could anyone explain this to me?
convert -strip -density 72 -resample 72x72 oldfile.jpg newfile.jpg
It seems kind of strange that by setting the density to 72, and then resampling it to 72, it would perform this. I would think that since I declare the density to be 72, and then try to resample it to 72, that nothing would happen.
Could anyone explain this to me?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with resampling to change resolution
I found the following information at
http://www.imagemagick.org/Usage/resize/#resample
"Note that only a small number of image file formats (such as JPEG, PNG, and TIFF) are capable of storing the image resolution or density with the image data.
For formats which do not support an image resolution, or which are multi-resolution (vector based) image formats, the original resolution of the image must be specified via the "-density" attribute (see Density Image Meta-data) before being read in. If no density attribute has been set IM will assume it has a default density of 72dpi. Setting the density AFTER reading such an image will only effect its output resolution, and not effect its final size in terms of pixels."
Also I believe that your convert syntax may be incorrect. Usually the input image comes right after convert, with the exception of the some parameters that need to be set beforehand. So I would expect you should have either
convert -strip -density 72 oldfile.jpg -resample 72x72 newfile.jpg
or possibly
convert oldfile.jpg -strip -density 72 -resample 72x72 newfile.jpg
http://www.imagemagick.org/Usage/resize/#resample
"Note that only a small number of image file formats (such as JPEG, PNG, and TIFF) are capable of storing the image resolution or density with the image data.
For formats which do not support an image resolution, or which are multi-resolution (vector based) image formats, the original resolution of the image must be specified via the "-density" attribute (see Density Image Meta-data) before being read in. If no density attribute has been set IM will assume it has a default density of 72dpi. Setting the density AFTER reading such an image will only effect its output resolution, and not effect its final size in terms of pixels."
Also I believe that your convert syntax may be incorrect. Usually the input image comes right after convert, with the exception of the some parameters that need to be set beforehand. So I would expect you should have either
convert -strip -density 72 oldfile.jpg -resample 72x72 newfile.jpg
or possibly
convert oldfile.jpg -strip -density 72 -resample 72x72 newfile.jpg
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Problems with resampling to change resolution
The problems are with the order of arguments.Slowfamily wrote:Could anyone explain this to me?
-density override the density set in images read in AFTER that setting, as such when you read your image it thinks it is 72 dpi already, so -resample doesn't do anything. Try...
Code: Select all
convert oldfile.jpg -strip -resample 72x72 newfile.jpg
Remember image reading is an operator, and unless in the special legacy mode (which may fail, such as in this case) Im will perform all operations in the order given.
If you know the resolution of the image when readin in, you can do...
Code: Select all
convert -density 300 oldfile.jpg -strip -resample 72x72 newfile.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/