l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 15: Cloud Computing and Hosting
Next Installfest:
TBA
Latest News:
Nov. 18: Officers elected
Page last updated:
2005 Apr 09 01:11
Events
 Meetings
 Installfests
 Demos
 Photos
Services
 Library
 LERT
 Jobs
 Documents
Interact
 Mailing Lists
 - Search
 - Archives
 Chat (IRC)
 Social Networks
About Us
 Members
 Projects
 Testimonials
 Call for Speakers
 Why Not MS?
 Finances
 Sponsors

^Home
?Search
?News & RSS
?Calendar
@Contact Us
$Buy Stuff
=Printable


The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Changing the print resolution of JPEG images by script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Changing the print resolution of JPEG images by script



Henry House wrote:
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
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
facebook
LUGOD Group on Facebook

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
1105 Kennedy Place, Suite 1, Davis, CA 95616
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!