How to convert a JPEG2000 to JPEG in Python?

Devdatta Tengshe picture Devdatta Tengshe · Mar 12, 2014 · Viewed 7.2k times · Source

I have a JPEG 2000 Image, and want to convert it to a simple JPEG image, so that it will be visible in all browsers.

I tried looking at PythonMagic. I downloaded it from here and installed it, but couldn't find any documentation, on how to use it.

I have already used PIL in the past, but it doesn't support JPEG 2000.

The process needs to run on Windows 2008 R2, with Python 2.7. If another Python version needs to be installed, I can do that as well.

Answer

Tanveer Alam picture Tanveer Alam · Mar 12, 2014

pgmagick Here is the python library which you looking for.

I tried and it does covert .jp2 to .jpeg format.

from pgmagick import Image

img = Image('CB_TM432.jp2') # Input Image
img.write('CB_TM432.jpeg')  # Output Image