Reputation: 61
I am using Python Pillow to modify images. Whenever I save a jpeg the internal resolution is set to 72dpi. I am looking to see how I can set it to a different value. I realize this is just a number and that in many ways its meaningless. My motivation is to make follow-on work easier when I read the image into photoshop.
Upvotes: 5
Views: 15550
Reputation: 8002
I think you're probably looking for dpi.
from PIL import Image, ImageDraw
# Make a white background with a blue circle, just for demonstration
im = Image.new('RGB', (800, 600), (255, 255, 255))
draw = ImageDraw.Draw(im)
draw.ellipse((200, 100, 600, 500), (32, 32, 192))
# the default
im.save("image_72.jpeg")
# explicit dpi for high resolution uses like publishing
im.save("image_300.jpeg", dpi=(300, 300))
Both images contain the same pixels, and are the same size on disk, but are coded as different image sizes and resolutions. Many image viewers will display them the same way, but higher end software like The GiMP and Photoshop can detect the difference.
Upvotes: 6
Reputation: 632
'quality' is one of the options when you save the image using Pillow. http://pillow.readthedocs.io/en/4.2.x/handbook/image-file-formats.html?highlight=resolution#jpeg
Upvotes: 0