Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PPM to JPEG/JPG conversion for Python 3.4.1

Tags:

python

jpeg

ppm

Does anyone know of any way to convert a ppm file to a jpeg/jpg using python 3.4.1 specifically? I've looked around and can only find solutions for previous version of python.

like image 592
star Avatar asked Nov 14 '14 19:11

star


2 Answers

You can use the Pillow module. The following should work:

from PIL import Image

im = Image.open("sweet_pic.ppm")
im.save("sweet_pic.jpg")

Read through the tutorial for more information.

like image 174
MattDMo Avatar answered Sep 24 '22 15:09

MattDMo


You can use OpenCV

i = cv.imread('im0001.ppm')
cv.imwrite('im0001.jpg',i)
like image 24
Rupesh Avatar answered Sep 26 '22 15:09

Rupesh