Univention Bugzilla – Bug 36273
allow PNG as user photo
Last modified: 2015-07-07 17:34:17 CEST
It is currently only possible to use JPEG as user photo. If the user uploads a PNG photo she first sees the photo but when saving it she gets an error message "Bild des Benutzers (JPEG-Format): Der Wert muss eine Base64-kodierte JPEG Datei sein".
JPEG does not allow transparency and is larger for some files.
(In reply to Florian Best from comment #1) > JPEG does not allow transparency and is larger for some files. JPEG is more adapted to real-world images and it comes with an appropriate (lossy) compression for these. PNG comes with a lossless compression and is better suited for "artificial" graphics, i.e., with homogeneous coloured areas or sharp edges. Therefore, I see technically no reason why to support PNG.
(In reply to Alexander Kläser from comment #2) > Therefore, I see technically no reason why to support PNG. I've received reports that tester tried to upload a PNG image. I think UMC should convert the PNG to a JPEG image.
(In reply to Stefan Gohmann from comment #3) > (In reply to Alexander Kläser from comment #2) > > Therefore, I see technically no reason why to support PNG. > > I've received reports that tester tried to upload a PNG image. I think UMC > should convert the PNG to a JPEG image. Good idea.
For better usability, the correct file format needs to be verified directly when uploading the image.
Why converting? Why not accepting both formats? Converting has the disadvantage of information loss. Converting maybe fails due to different PNG formats? Maybe also security issues.
(In reply to Florian Best from comment #6) > Why converting? Why not accepting both formats? > Converting has the disadvantage of information loss. Converting maybe fails > due to different PNG formats? Maybe also security issues. I think we are using the attribute jpegPhoto from the inetorgperson schema.
(In reply to Stefan Gohmann from comment #7) > I think we are using the attribute jpegPhoto from the inetorgperson schema. Yep: https://tools.ietf.org/html/rfc2798#section-2.6
Created attachment 6583 [details] patch Attached a patch which uses PIL to convert PNG's to JPEG in memory. It adapts the jpegPhoto syntax. Should we create a new syntax class for it?
Patch has been applied (with more error handling) in svn r57500. YAML: 2015-01-22-univention-directory-manager-modules.yaml Package: univention-directory-manager-modules Version: 10.0.29-19.1283.201501221644 Branch: ucs_4.0-0 Scope: errata4.0-0 no cross dependencies.
In svn r57517 one debug line has been removed and IndexError is also catched as PIL raises this with an corrupted PNG file, too. I tested for myself to upload valid PNG files, non-PNG files, PNG files with only the PNG header ('\x89PNG\r\n\x1a\n') and corrupted PNG files (somewhere in the middle cutted).
Upload of .png files (valid, wrong format, truncated file, header only) OK YAML OK
<http://errata.univention.de/ucs/4.0/65.html>
I added a test script which tests setting of JPG, JPEG, PNG and unsetting in svn r61854.