LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   ImageMagick convert and eps (http://www.linuxquestions.org/questions/linux-software-2/imagemagick-convert-and-eps-929296/)

Daravon 02-14-2012 09:20 AM

ImageMagick convert and eps
 
I'm trying to compile a \LaTeX document. As you know, \LaTeX wants images in .eps format. I naively attempted to use convert to convert my jpgs to eps format, but I'm having a weirdness. The image dimensions change randomly, and the file size gets inflated like 10x in some cases.

Code:

chaz@optimus:~/docs/teX/robot/jpgs$ ls
badrake.jpg  bentwasher.jpg  betterrake2.jpg  screen.jpg  screws.jpg  stations.jpg  teachpoint2.jpg
chaz@optimus:~/docs/teX/robot/jpgs$ for blah in `ls *.jpg`; do blarg=`echo $blah | sed 's/\..\{3\}$//'`; convert $blah $blarg.eps; done
chaz@optimus:~/docs/teX/robot/jpgs$ ls
badrake.eps  bentwasher.eps  betterrake2.eps  screen.eps  screws.eps  stations.eps  teachpoint2.eps
badrake.jpg  bentwasher.jpg  betterrake2.jpg  screen.jpg  screws.jpg  stations.jpg  teachpoint2.jpg
chaz@optimus:~/docs/teX/robot/jpgs$ identify ./*
./badrake.eps PS 1023x714 1023x714+0+0 16-bit DirectClass 800KB 0.000u 0:00.000
./badrake.jpg[1] JPEG 1023x714 1023x714+0+0 8-bit DirectClass 127KB 0.000u 0:00.000
./bentwasher.eps[2] PS 150x113 150x113+0+0 16-bit DirectClass 35.7KB 0.000u 0:00.000
./bentwasher.jpg[3] JPEG 1000x750 1000x750+0+0 8-bit DirectClass 501KB 0.000u 0:00.000
./betterrake2.eps[4] PS 180x127 180x127+0+0 16-bit DirectClass 40.5KB 0.000u 0:00.000
./betterrake2.jpg[5] JPEG 1201x846 1201x846+0+0 8-bit DirectClass 213KB 0.000u 0:00.000
./screen.eps[6] PS 879x560 879x560+0+0 16-bit DirectClass 873KB 0.000u 0:00.000
./screen.jpg[7] JPEG 879x560 879x560+0+0 8-bit DirectClass 141KB 0.000u 0:00.000
./screws.eps[8] PS 750x544 750x544+0+0 16-bit DirectClass 416KB 0.000u 0:00.000
./screws.jpg[9] JPEG 750x544 750x544+0+0 8-bit DirectClass 69.1KB 0.000u 0:00.000
./stations.eps[10] PS 120x90 120x90+0+0 16-bit DirectClass 27.8KB 0.000u 0:00.000
./stations.jpg[11] JPEG 800x600 800x600+0+0 8-bit DirectClass 202KB 0.000u 0:00.000
./teachpoint2.eps[12] PS 150x113 150x113+0+0 16-bit DirectClass 32.5KB 0.000u 0:00.000
./teachpoint2.jpg[13] JPEG 1000x750 1000x750+0+0 8-bit DirectClass 147KB 0.000u 0:00.000
or that file format
chaz@optimus:~/docs/teX/robot/jpgs$ du -h ./*
4.3M        ./badrake.eps
136K        ./badrake.jpg
4.4M        ./bentwasher.eps
500K        ./bentwasher.jpg
6.0M        ./betterrake2.eps
216K        ./betterrake2.jpg
2.9M        ./screen.eps
148K        ./screen.jpg
2.4M        ./screws.eps
76K        ./screws.jpg
2.8M        ./stations.eps
208K        ./stations.jpg
4.4M        ./teachpoint2.eps
152K        ./teachpoint2.jpg
chaz@optimus:~/docs/teX/robot/jpgs$

For example, one image went from JPEG 1201x846 to PS 180x127, yet the file size went from 216K to 6M! Other images didn't change in geometry at all. What's going on here?

MensaWater 02-14-2012 11:50 AM

It's been a while since I've worked with it but my notes show ImageMagick comes with a command called "mogrify" that lets you specify sizes:

For example:
mogrify -resize "60x88" image.png

One thing I noticed at the time was that it made the resulting image 60x25 because it kept the original ratios on image size which is what I really wanted. I haven't worked on eps files but did want to mention this as at the time I kept looking for a "resize" command and it took me a bit of work to figure out mogrify was what I really needed.

Daravon 02-14-2012 04:57 PM

The thing is I'm NOT trying to resize anything. I just used convert, which should have just converted the format. The odd thing is that some images were resized and some weren't. I understand that a .eps file could be bigger than a .jpg due to the format, compression, etc but I didn't expect 200k to 6M disk usage inflation.

Is there some other tool for making this conversion, or am I using this wrong?

evo2 02-14-2012 07:54 PM

Hi,

this is not really an answer to the question you posted, but a possible different approach.

Have you considered using pdflatex? pdflatex will let you use \includegraphics{} png, jpg, pdf and many more.
Instead of producing a dvi output file it produces a pdf. If you also have ps/eps input images that you \includegraphics{} you can convert them to pdf (ps/eps -> pdf conversion using epstopdf is quite clean).

I switched from using latex/dvips/dvipdf to pdflatex about 5 years ago and have never looked back.

HTH,

Evo2.

Daravon 02-15-2012 07:56 AM

I have considered it. I assumed I would need to do some things to "port" my source to use pdflatex. If not, I guess there's really no disadvantage. I will try to compile my existing documents with pdflatex and see what happens.

MensaWater 02-15-2012 11:13 AM

Quote:

Originally Posted by Daravon (Post 4602450)
The thing is I'm NOT trying to resize anything.

I understood that - I was suggesting you might be able to resize the result of convert back to the size you want.

evo2 02-15-2012 07:23 PM

Hi,

Quote:

Originally Posted by Daravon (Post 4602952)
I have considered it. I assumed I would need to do some things to "port" my source to use pdflatex. If not, I guess there's really no disadvantage.

Your .tex files should be fine unless you use things like pstricks.

Quote:

I will try to compile my existing documents with pdflatex and see what happens.
Please post back to let us know how it goes.

Cheers,

Evo2.

Daravon 02-16-2012 04:06 PM

So you would compress the file by sizing it down and then back up?

That might work but I use mogrify -compression jpeg -quality 50 to compress file size without scaling down.

By the way, I compressed my starting jpegs down about 50% in file size and re-converted to EPS. There was no difference in the size of the resulting EPS files. EPS files are just big!

Also, identify does not report EPS files size sensibly. EPS might not even have the property of size, for all I know.


All times are GMT -5. The time now is 03:40 AM.