DIAGNijmegen / website-content

This repository stores all the content for the diag websites.
MIT License
5 stars 74 forks source link

crop_thesis_covers.py returns a black+white image when cropping #475

Closed keelinm closed 1 year ago

keelinm commented 1 year ago

Marina found that when she uploaded Lief22.png to the content/images/theses folder the script crop_thesis_covers returns it in a black and white version.

keelinm commented 1 year ago

I did a short investigation and noticed a few things:

  1. The script only looks for png images. Nikolas uploaded most phd covers in bulk in png format a few months ago. I noticed that Chle22 thesis cover was uploaded in jpeg format so I think this script did not even run on that file?? I think we should re-upload it in png format.
  2. Nikolas uploaded thesis covers quite small (e.g. Balt19c.png was uploaded at 282x400 pixels in original format) while the recent ones added are much larger. I think it's better to keep them smaller before uploading.
  3. I could reproduce the bug. Comparing the output on Balt19c.png (which works fine) and Lief22.png (which comes out black and white) the stdout reports the following: Resized Balt19c.png from (400, 282, 3) to (397, 282, 3) Resized Lief22.png from (1934, 1345) to (1894, 1345) So it seems like Lief22.png is in some different format (doesn't have 3 channels when opened by imageio) although it looks like a normal colour image in my viewer.

I stopped here because I don't have familiarity with imageio and thought @martvanrijthoven might recognize this issue more quickly?

keelinm commented 1 year ago

For convenience I attach the original uploads of both thesis covers here: One that works and reads as 3 channels (Balt19c.png), one that does not, and reads as 2 channels (Lief22.png)

Balt19c Lief22

martvanrijthoven commented 1 year ago

Image did not contain color channels, fixed now. Also added jpeg and jpg support in crop thesis script