Graphics, Figures & TablesEPS and JPG in thesis

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

EPS and JPG in thesis

Post by snowfrog »

Hi,

I'm writing my thesis which includes a lot of pictures (originally in a jpeg format) and a lot of graphs (originally in eps format). My understanding of LaTeX is that there is no way I can compile a *tex file that includes both jpeg and eps, is that right?

Assuming that is right, I have to convert one or the other. I have tried the Imagemagick

Code: Select all

convert -quality 100 picture1.jpg picture2.eps
and also "save as" in Gimp.

My experience with converting though is that there is quality loss from the original picture / graph. I'm guessing I must be the umpteen person having this problem (although I couldn't see any previous post specifically related to this) so I would be interested to know what other LaTeX users needing both format (or high quality colour photos and graphs) have done in the past?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

EPS and JPG in thesis

Post by php1ic »

I've found for eps->jpeg, using ghostscript does better than gimp.

Code: Select all

gs -dBATCH -dNOPAUSE -r300 -sOutputFile=file.jpg -sDEVICE=jpeg -c "<< /PageSize [x y]  >> setpagedevice" -f file.eps
x and y are the coordinates of the upper right hand corner, assuming the lower left is at 0 0

-r300 is the resolution of the output file, I think in dpi.



This website is also good

http://www.tlhiv.org/rast2vec/
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

EPS and JPG in thesis

Post by snowfrog »

Thanks for the advice php1ic.

I have tried the command line you suggested

Code: Select all

gs -dBATCH -dNOPAUSE -r300 -sOutputFile=W_C_1_202.jpg -sDEVICE=jpeg -c "<< /PageSize [5 8]  >> setpagedevice" -f W_C_1_202.eps
and got the error message

Code: Select all

Error: /undefinedfilename in (W_C_1_202.eps)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1154/1684(ro)(G)--   --dict:0/20(G)--   --dict:70/200(L)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
I tried a variant of your code

Code: Select all

gs -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r300 -sOutputFile=W_C_1_202.jpg W_C_1_202.eps
that I found on a website and got the same error message

Do you have any idea where I'm going wrong?
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: EPS and JPG in thesis

Post by php1ic »

Looks like it can't find the eps file. It may seem like an obvious point, but are you sure it's in the same directory as you when you run the command?

P.S. The values of x and y need to be in points, 5 and 8 seem very small.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

EPS and JPG in thesis

Post by localghost »

It is very much better to convert the EPS files to PDF and then compile with pdflatex. This would keep the vector format of the images. Search the forum for »epstopdf« and you will find many appropriate solutions for this issue. If you really need to compile with latex, there is a very efficient way to convert JPG to EPS with ImageMagick.

Code: Select all

convert filename.jpg eps3:filename.eps
This converts the image to a Level 3 Postscript file.


Best regards
Thorsten
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

EPS and JPG in thesis

Post by snowfrog »

localghost wrote:It is very much better to convert the EPS files to PDF and then compile with pdflatex.
I think that could be the way forward for me! I had been using pdflatex and converting eps to jpeg before but the quality of the graphs really deteriorated with the conversion. I think converting to pdf looks far nicer.

Thanks to both of you for the helpful tips!
Post Reply