[GH-ISSUE #48] Feature request: PNG upload #3334

Closed
opened 2026-03-20 23:04:39 +01:00 by sascha_hemi · 7 comments
Owner

Originally created by @jonasniesner on GitHub (May 23, 2023).
Original GitHub issue: https://github.com/OpenEPaperLink/OpenEPaperLink/issues/48

Originally assigned to: @nlimper on GitHub.

Expanding jpg2buffer to also work with PNG's would be great because jpg is not that great for compressing text and often creates unwanted artifacts

Originally created by @jonasniesner on GitHub (May 23, 2023). Original GitHub issue: https://github.com/OpenEPaperLink/OpenEPaperLink/issues/48 Originally assigned to: @nlimper on GitHub. Expanding jpg2buffer to also work with PNG's would be great because jpg is not that great for compressing text and often creates unwanted artifacts
sascha_hemi added the enhancementwontfix labels 2026-03-20 23:04:39 +01:00
Author
Owner

@nlimper commented on GitHub (May 23, 2023):

I will look into it. I think Larry made a lightweight png parse library. But having said that, if a jpeg has unwanted artifacts, it's mostly caused by bad generator software or bad settings. Even a moderately compressed jpeg containing text can be made without artifacts.

<!-- gh-comment-id:1559828728 --> @nlimper commented on GitHub (May 23, 2023): I will look into it. I think Larry made a lightweight png parse library. But having said that, if a jpeg has unwanted artifacts, it's mostly caused by bad generator software or bad settings. Even a moderately compressed jpeg containing text can be made without artifacts.
Author
Owner

@seeers commented on GitHub (May 27, 2023):

i also have problems with jpg, i can't get a nice output without artifacts. ( Python Image / paint )
bmp or png would certainly be better

<!-- gh-comment-id:1565639730 --> @seeers commented on GitHub (May 27, 2023): i also have problems with jpg, i can't get a nice output without artifacts. ( Python Image / paint ) bmp or png would certainly be better
Author
Owner

@atc1441 commented on GitHub (May 27, 2023):

As a quick fix you can save the images as monochrome bmp in paint and then save them again as jpg, the red will be gone but the image gets nice

<!-- gh-comment-id:1565642795 --> @atc1441 commented on GitHub (May 27, 2023): As a quick fix you can save the images as monochrome bmp in paint and then save them again as jpg, the red will be gone but the image gets nice
Author
Owner

@seeers commented on GitHub (May 27, 2023):

thank you, that works!
Now I just need to generate nice text jpgs from python

<!-- gh-comment-id:1565644189 --> @seeers commented on GitHub (May 27, 2023): thank you, that works! Now I just need to generate nice text jpgs from python
Author
Owner

@nlimper commented on GitHub (May 27, 2023):

I'm not a python programmer, but I asked ChatGPT nicely. After some extra convincing about my intentions, it came up with this working example.

The tricks:

  • create a paletted image, so the fonts are not rendered antialiassed.
  • save with quality="maximum" to keep the hard edges

download: jpg_demo.zip

I will add the demo to the repo.
output

<!-- gh-comment-id:1565657794 --> @nlimper commented on GitHub (May 27, 2023): I'm not a python programmer, but I asked ChatGPT nicely. After some extra convincing about my intentions, it came up with this working example. The tricks: - create a paletted image, so the fonts are not rendered antialiassed. - save with quality="maximum" to keep the hard edges download: [jpg_demo.zip](https://github.com/jjwbruijn/OpenEPaperLink/files/11582895/jpg_demo.zip) I will add the demo to the repo. ![output](https://github.com/jjwbruijn/OpenEPaperLink/assets/4137036/68d2579e-b8aa-4f32-bad9-25e782690a0c)
Author
Owner

@seeers commented on GitHub (May 27, 2023):

Sure:

from PIL import Image, ImageDraw, ImageFont

width, height = 296, 128
img = Image.new("RGB", (width, height), "white")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("arial.ttf", 35)

text_color = (0, 0, 0)
draw.text((20, height - 99), "Temperatur", font=font, fill=text_color)

temperature_text = "20°C"
text_color = (0, 0, 0)
draw.text((20, height - 60), temperature_text, font=font, fill=text_color)

img.save("temp_testimage.jpg")
<!-- gh-comment-id:1565658072 --> @seeers commented on GitHub (May 27, 2023): Sure: ``` from PIL import Image, ImageDraw, ImageFont width, height = 296, 128 img = Image.new("RGB", (width, height), "white") draw = ImageDraw.Draw(img) font = ImageFont.truetype("arial.ttf", 35) text_color = (0, 0, 0) draw.text((20, height - 99), "Temperatur", font=font, fill=text_color) temperature_text = "20°C" text_color = (0, 0, 0) draw.text((20, height - 60), temperature_text, font=font, fill=text_color) img.save("temp_testimage.jpg") ```
Author
Owner

@nlimper commented on GitHub (May 27, 2023):

our messages crossed, but: see above.

<!-- gh-comment-id:1565665571 --> @nlimper commented on GitHub (May 27, 2023): our messages crossed, but: see above.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/OpenEPaperLink#3334