Page 1 of 1
Bumping up resolution ...
Posted: 2008-07-16T05:14:24-07:00
by dbee
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 ...
At the moment I'm using ...
Code: Select all
convert pics/* -density 300*300 -thumbnail 850X850 -compress zip -strip albumshopper/*.jpg
Is there a native ImageMagick way to do this ? Is my script above optimal or is there something I'm missing ?
Thanks,
Re: Bumping up resolution ...
Posted: 2008-07-16T10:16:15-07:00
by fmw42
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
see string formats at
http://www.imagemagick.org/script/escape.php
Re: Bumping up resolution ...
Posted: 2008-07-16T16:29:14-07:00
by anthony
WARNING:
- 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