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.
PPM to JPEG/JPG conversion for Python 3.4.1
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.
Documention says it supports 3.4, but not 3.4.1? –
Thiosinamine
@Thiosinamine compatibility is by minor version (python versions are
major.minor.micro
, so 3.4.1 is minor version 3.4). So, if it says 3.4, it'll work with 3.4.0, 3.4.1, 3.4.2, etc. –
Decry Didn't work because i had too many channels. I figured it out though using cv2 and PIL –
Capful
You can use OpenCV
i = cv.imread('im0001.ppm')
cv.imwrite('im0001.jpg',i)
Tried that makes the image be very very bright. Any ideas? –
Capful
Alright i figured it out i converted the files to png with cv2 and then to jpg with Pillow
from PIL import Image im = Image.open("image_path") im.convert('RGB').save("image_name.jpg","JPEG") #this converts png image as jpeg
–
Capful © 2022 - 2024 — McMap. All rights reserved.