PNG to EPS with Python?

W

Will Stuyvesant

I have .PNG image I would like to convert to .EPS (Enhanced
PostScript), for inclusing in LaTeX documents. I feel that a portable
tool for this would be very welcome in the scientific community, where
they still LaTeX a lot! There is a png2eps tool for linux/unix, but I
can't find something that works on Windows. Perhaps somebody with
Cygwin can produce an .exe (I don't use Cygwin anymore myself)? I
wonder if this would be possible to do with Python, or maybe somebody
already did this? Instead of PNG also JPG, GIF, TIFF, etc. would be
welcome, as it is easy to convert PNG back and forth to those, even on
Windows :)
 
J

Just

I have .PNG image I would like to convert to .EPS (Enhanced
PostScript),

"Encapsulated PostScript", actually.
for inclusing in LaTeX documents. I feel that a portable
tool for this would be very welcome in the scientific community, where
they still LaTeX a lot! There is a png2eps tool for linux/unix, but I
can't find something that works on Windows. Perhaps somebody with
Cygwin can produce an .exe (I don't use Cygwin anymore myself)? I
wonder if this would be possible to do with Python, or maybe somebody
already did this? Instead of PNG also JPG, GIF, TIFF, etc. would be
welcome, as it is easy to convert PNG back and forth to those, even on
Windows :)

Have you looked at PIL yet?

Just
 
W

Will Stuyvesant

[Just]
Have you looked at PIL yet?

No, I had not, and thank you for the suggestion Just!

WOW, PIL is amazing! I was looking all over the internet for
"png2eps" etcetera, but my favorite programming language can do it
all with PIL!


A simple recipe to put a screenshot in your LaTeX file under Windows
(where there is no png2eps utility):

First of all you have to install PIL, get the Windows .exe and run it,
nice and simple.
Then copy the screenshot to your Windows clipboard with
<SHIFT><ALT><PrtSc> or whatever keycombo your keyboard has. Then
open MSPAINT.EXE, "paste" the image in there (via the Edit menu) and
"save as" a .PNG file via the File menu (for name I filled in
"myscreenshot"). Then open CMD.EXE and go to the directory where
you did save the .PNG and start the Python interpreter there. Now
just

This produces a hefty 9MB .eps file for my test screenshot, but when
you include it in your LaTeX with
\includegraphics[width=\textwidth]{myscreenshot.eps} and produce PDF
from the LaTeX (witht the MikTeX dvipdfm.exe) it amounts to only
about 90k for a PDF file with one page with the screenshot on it.
If you produce .PS from the LaTeX then it is still 9MB :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top