CosmoCoffee Forum Index CosmoCoffee

 
 FAQFAQ   SearchSearch  MemberlistSmartFeed   MemberlistMemberlist    RegisterRegister 
   ProfileProfile   Log inLog in 
Arxiv New Filter | Bookmarks & clubs | Arxiv ref/author:

jpeg compression in pdf files
 
Post new topic   Reply to topic    CosmoCoffee Forum Index -> Teaching, Papers and Presentations
View previous topic :: View next topic  
Author Message
David Larson



Joined: 25 Sep 2004
Posts: 11
Affiliation: Johns Hopkins University

PostPosted: October 27 2004  Reply with quote

For the few presentations I've made so far, I have created a .pdf file for my talk (using the seminar document class in latex) and presented it with acrobat reader. This seems to work fairly well.

However, when creating a pdf file with the linux utilities "dvipdf" or "pstopdf", some of my figures get compressed much further, which degrades their resolution. If I look closely, I see the same artifacts that one sees in an overly compressed jpeg image. This applies to images (such as maps of the CMB) which have been converted from .png or .jpg files to encapsulated postscript and included in the document. My postscript file for the presentation looks fine; it's just the pdf file that has too much compression.

Has anyone else run into this problem and solved it?
Back to top
View user's profile  
Ben Gold



Joined: 25 Sep 2004
Posts: 97
Affiliation: University of Minnesota

PostPosted: October 28 2004  Reply with quote

You can probably avoid most problems by using "pdftex" or "pdflatex" to simply make the .pdf files straight from the TeX source. I'd highly recommend using these. You might already have them installed and not even know it.

If you really can't go that route, try using "dvips -Ppdf" when you turn your dvi files into postscript. This tells dvips that you're ultimately intending to convert to pdf format and fixes some issues that can occur when using "pstopdf" on the file, although I don't know if it will address your particular problem.

Also, if you're really stuck, I think "pdf2ps -dPDFSETTINGS=/printer" or "pdf2ps -dPDFSETTINGS=/prepress" might help.
Back to top
View user's profile [ Hidden ] Visit poster's website
David Larson



Joined: 25 Sep 2004
Posts: 11
Affiliation: Johns Hopkins University

PostPosted: October 28 2004  Reply with quote

Thank you. While pdftex doesn't work (I wrote in latex) and pdflatex gives me the wrong page size and doesn't include the images, the "ps2pdf -dPDFSETTINGS=/prepress" and "ps2pdf -dPDFSETTINGS=/printer" do improve the quality of the jpeg images. They are probably the simplest solution to the problem.

I did a little more research. To do a lossless compression of the images, I used
ps2pdf -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode

To be able to finely control the compression of the images, I had to come up with an incantation similar to the following, which should all be on one line (to convert ABC.ps to ABC.pdf):
cat ABC.ps | gs -sDEVICE=pdfwrite -sOutputFile=ABC.pdf -dAutoFilterColorImages=false -c "<< /ColorImageDict << /QFactor 0.1 /Blend 1 /HSample [1 1 1 1] /VSample [1 1 1 1] >> >> setdistillerparams" -

Adjusting the QFactor away from 0.1 adjusts the quality of compression, but I don't know what range of values it can take (although 0.9 is default).

For some partially helpful information, see
http://casper.ghostscript.com/~ghostgum/pdftips.htm
and
http://www.cs.wisc.edu/~ghost/doc/cvs/Ps2pdf.htm

Having spent too much time on this, I will now go back to doing research.
Back to top
View user's profile  
Ben Gold



Joined: 25 Sep 2004
Posts: 97
Affiliation: University of Minnesota

PostPosted: October 29 2004  Reply with quote

Glad you got it working. For future reference, I should have mentioned that when you use pdftex or pdflatex with figures, you'll also want something like the following near the beginning of your TeX file:
Code:
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf, .jpg, .png}

After this point \includegraphics should work as you'd expect. To fix the page size issues it's probably best to take care of it once and for all by modifying your "pdftex.cfg" file. Mine happens to be in
Code:
/usr/local/teTeX/share/texmf.local/pdftex/config/
but this can change depending on your installation. Once you've found it, you can change a few lines to look like
Code:
page_width 8.5 true in
page_height 11 true in

There are also other options like "compress_level" that you can play with, see http://miktex.org/manual/pdftexcfg.html for a description of them. So this involves a little setup, but in the long run it's hopefully easier than dealing with obscure gs options.
Back to top
View user's profile [ Hidden ] Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    CosmoCoffee Forum Index -> Teaching, Papers and Presentations All times are GMT + 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group. Sponsored by WordWeb online dictionary and dictionary software.