Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I want change resolution of photos to 300dpi if the resolution is greater than 300dpi. But if the resolution is less than 300dpi, then i just want to leave it ...
You need to use some unix or your api. For example:
# find the image resolution
xres=`convert yourimage -format "%[xresolution]" info:`
yres=`convert yourimage -format "%[yresolution]" info:`
# test if greater than 300 and convert
if [ $xres -gt 300 -o $yres -gt 300 ]; then
convert yourimage -density 300 resultimage
fi
If your image is JPEG, using IM to change resoultion will make the jpeg quality worse due to a read/write cycle with its lossy compression. Better to use jhead or some other program.
Photoshop often ignores the JPEG density, if it has its own profile present in the image.
Changing a images resolution does not change the image at all, just the size of the pixels when some real world device wants to determine its real world size. That is just changing density smaller, will make an image larger in real world terms, even tough the number of pixels in the image has not changed.
To resize the image (in terms of the number of pixels) so the real world size does not change with a resolution change, use -resample instead of -density or -set density. see IM examples Resample - Changing an images resolution
If you are changing density to reduce data size, use -resample