hbz / lobid-gnd

UI and API to the Integrated Authority File (Gemeinsame Normdatei, GND)
http://lobid.org/gnd
Eclipse Public License 2.0
24 stars 5 forks source link

Error on implementation of SVG-Images from Wikimedia Commons #385

Open LibrErli opened 2 months ago

LibrErli commented 2 months ago

E.g. ZHB Luzern retrieves as example image the logo image stored as *svg on Wikimedia Commons. It seems that the lobid-imageproxy has troubles with implementing svg correctly.

dr0i commented 2 months ago

The image seems to be of type PNG:

$ curl -L 'https://commons.wikimedia.org/wiki/Special:FilePath/ZHB%20Luzern%20Logo%20farbig.svg?width=270' -o image
$ file image
image: PNG image data, 270 x 60, 8-bit colormap, non-interlaced

But lobid's imagesproxy tries to parse it, based on the file's name, as SVG - which consequently fails.

What we can do: change the imagesproxy to: a) determine type of image by taking the content-type header into account (and not just by parsing the URL to determine get the file's suffix) b) get rid of all HTML parameter (?.*) - that would leave us with curl -L 'https://commons.wikimedia.org/wiki/Special:FilePath/ZHB%20Luzern%20Logo%20farbig.svg which is a SVG

As a hip-shot I would say b) is easier to do, but then we might not fix all scenarios. On the other hand, a) may also be problematic, if not all images have a content-type header. (b) could also be just a fallback if a URLs path is not ending with a dot + three characters (aka file extension).

acka47 commented 4 weeks ago

What is the status of this, @phu2 @dr0i ?