pascalw / kindle-dash

Power efficient dashboard for Kindle 4 NT devices
MIT License
1.21k stars 34 forks source link

Image aspect ratio morphed/incorrect #14

Closed tobire closed 3 years ago

tobire commented 3 years ago

First of all: excellent software!

I created a simple python script to create images to display. Unfortunately, the image is somehow morphed: IMG_20210216_220700

This is the displayed file: db

I tried to load it directly from my python script aswell as directly from nginx and in both cases the image was morphed.

Would be nice if you have an idea on how to fix this :)

pascalw commented 3 years ago

Hi @tobire the Kindle only handles Grayscale PNGs correctly. Your PNG has an 8bit color/alpha profile. This is probably something you can specify in your Python code when generating the PNG. Alternatively you can convert the image using pngcrush: pngcrush -c 0 dash.png.

Let me know if that works!

tobire commented 3 years ago

It's kind of working now. The image is not as stretched anymore but there are still not all 600x800 Pixels visible. I added a border this time to make sure that I see it correctly: IMG_20210217_065735 db

Are there any more requirements to the image in order for it to get displayed correctly? Your example image is working fine btw.

tobire commented 3 years ago

Ah, nevermind, I made a mistake. I used Pillow to convert the image to grayscale however the code found in a StackOverflow answer apparently did not work correctly. After using pngcrush like you said, it's displayed correctly. Thanks for the help! :)

tobire commented 3 years ago

In case anyone else wants to convert their image to grayscale in Python, this code works:

from PIL import Image, ImageOps
ImageOps.grayscale(Image.open('image.png')).save('grayscale.png')
pascalw commented 3 years ago

Great! 👍