One of the more common operations that I need to do with JPEG images is to change their print resolution so that when printed (e.g., as included figures in a LaTeX document) they print at 300 dpi (for example) instead of 72 dpi.
To start with, DPI (dots per inch) implies that each pixel has a physical size, 1/72 of an inch or whatever. As far as I know, JPEG images have a size in pixels (e.g. 106 by 64 pixels for the watertower image on the LUGOD home page), but the pixels have no inherent physical size. Something outside of the image--probably the software used to embed the image into the document--is deciding how large the image should appear on the page. I would expect that you can adjust that, ie tell the software how large to print the image or what DPI to use.
- Is there any ways to change the print resolution, short of editing the JPEGs by hand, without recompressing them?
As far as I know, the only way to resize a jpeg is to unpack the pixel data and interpolate a new set of pixels at the desired resolution. If you save the new image as a jpeg then there's no way to avoid recompressing them.
- Is there any utility in existance that could do this from the command line? I tried the jpegtran program from libjpeg-progs in Debian, but it does not seem to have this capability.
To rescale images, I'd be inclined to use the pbm/pnm utilities. Start with jpegtopnm to convert the jpeg into pnm format. After that, there are utilites to rescale, rotate, crop, flip, edit the color map, etc. Finally you'd use pnmtojpeg to produce the final image (or pnmtopng or pnmtotiff or whatever). I had to rescale some images for my wife; here's the shell script I used:
for file in ../*.jpg; do echo $file f=$(basename $file .jpg)
jpegtopnm $file | pnmscale -width=145 | pnmtojpeg --optimize --progressive --quality=70 > $f-145.jpg
jpegtopnm $file | pnmscale -width=640 | pnmtojpeg --optimize --progressive --quality=80 > $f-640.jpg done
Since you're enlarging more than 3x, you'd want to include a pnmsmooth step after pnmscale.
_______________________________________________
vox-tech mailing list
[email protected]
http://lists.lugod.org/mailman/listinfo/vox-tech
