I am trying to create images programmatically in Python using the Pillow library , but I am having problems with the image quality of the text inside the image.
I want to save the image that I generate in PNG, so I set the DPI when saving according to this , but whether I save with dpi = (72.72) or dpi = (600 600), it visually looks the same.
My code for this is as follows:
from PIL import Image, ImageDraw, ImageFont def generate_empty_canvas(width, height, color='white'): size = (width, height) return Image.new('RGB', size, color=color) def draw_text(text, canvas): font = ImageFont.truetype('Verdana.ttf', 10) draw = ImageDraw.Draw(canvas) if '\n' not in text: draw.text((0, 0), text, font=font, fill='black') else: draw.multiline_text((0, 0), text, font=font, fill='black') def create_sample(): text = 'aaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbb\nccccccccccccccccccccc' canvas = generate_empty_canvas(200, 50) draw_text(text, canvas) canvas.save('low_quality.png', dpi=(72, 72)) canvas.save('high_quality.png', dpi=(600, 600))
Low_quality.png:

High_quality.png:

As you can see in the images, the quality has not changed. What am I doing wrong here?
Where to set DPI so that the image really has dpi = 600?