We can convert a png image to eps with python pillow. Here is an example:
Python Pillow Convert PNG to EPS: A Completed Guide
How to convert an eps image to png with pillow? In this tutorial, we will tell you how to do.
Prepare an eps image
from PIL import Image image_eps = 'logo-CMYK.eps' im = Image.open(image_eps)
In code above, we use pillow to open an eps image called ‘logo-CMYK.eps‘. Then, we will convert it to png.
Convert CMYK color mode to RGBA
The color mode of ‘logo-CMYK.eps‘ is CMYK, we will convert it to RGBA, which is a color mode used in png image.
fig = im.convert('RGBA')
Convert eps to png
After having converted color mode, we can convert eps to png.
image_png= 'logo-rgb.png' fig.save(image_png, lossless = True)
Run this python script, we will find the eps file is converted to png.
Here is the effect.
If you find OSError: Unable to locate Ghostscript on paths when converting, you can read this tutorial to fix it.
Fix OSError: Unable to locate Ghostscript on paths for Python Beginners
I got the “OSError: Unable to locate Ghostscript on paths” error, but clicking on your link it gives a forbidden page (error 403). Have you got a solution for this? Thank you.
My site give you a 403 error? You can use: “conda install -c conda-forge ghostscript” command to install ghostscript. Please install anaconda first.
Do you know how to convert a eps to a jpg?
try:
image_png= 'logo-rgb.jpg'
fig.save(image_png, lossless = True)
or convert eps to png first, then convert png to jpg.