Python Convert EPS to PNG with Pillow: A Beginner Guide – Python Tutorial

By | August 30, 2020

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.

python pillow convert eps to png

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

4 thoughts on “Python Convert EPS to PNG with Pillow: A Beginner Guide – Python Tutorial

  1. Baguette

    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.

    1. admin Post author

      My site give you a 403 error? You can use: “conda install -c conda-forge ghostscript” command to install ghostscript. Please install anaconda first.

    1. admin Post author

      try:
      image_png= 'logo-rgb.jpg'
      fig.save(image_png, lossless = True)

      or convert eps to png first, then convert png to jpg.

Leave a Reply