-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DPI doesn't work for CMYK save #3970
Comments
Looks like this is because the image is in CMYK mode - from PIL import Image
im = Image.new("CMYK", (100, 100))
im.save("out.jpg", dpi=(300, 300))
new_im = Image.open("out.jpg")
print("out.jpg", new_im.info.get('dpi')) # out.jpg None |
radarhere
changed the title
Image.save jpeg file dpi param doesn't work
DPI doesn't work for CMYK save
Jul 15, 2019
You may or may not be interested in this as an immediate solution - remove the 'quality' argument, convert to RGB, and it works - from PIL import Image
img = Image.open("test1.jpg")
print("test1.jpg", img.info.get('dpi'))
other_img = Image.open("test2.jpg")
print("test2.jpg", other_img.info.get('dpi'))
img.paste(other_img.resize((200, 200), Image.LANCZOS), (0, 0))
img.convert("RGB").save("test3.jpg", dpi=(300, 300))
new_img = Image.open("test3.jpg")
print("test3.jpg", new_img.info.get('dpi')) |
but I need to save it in CMYK format for my users to print. |
Is saving it as TIFF an option? from PIL import Image
img = Image.open("test1.jpg")
print("test1.jpg", img.info.get('dpi'))
other_img = Image.open("test2.jpg")
print("test2.jpg", other_img.info.get('dpi'))
img.paste(other_img.resize((200, 200), Image.LANCZOS), (0, 0))
img.save("test3.tiff", dpi=(300, 300), quality="keep")
new_img = Image.open("test3.tiff")
print("test3.tiff", new_img.info.get('dpi')) |
Actually, I've realised that this is a duplicate of #1676 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What did you do?
save a jpeg image where param dpi
What did you expect to happen?
the new jpg image dpi same as the dpi param
What actually happened?
new file doesn't have dpi info
What are your OS, Python and Pillow versions?
sample_file.zip
The text was updated successfully, but these errors were encountered: