Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LibrErli opened this issue Apr 9, 2024 · 10 comments
Closed

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

LibrErli opened this issue Apr 9, 2024 · 10 comments
Assignees
Labels

Comments

@LibrErli
Copy link
Contributor

LibrErli commented Apr 9, 2024

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
Copy link
Member

dr0i commented Apr 15, 2024

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
Copy link
Contributor

acka47 commented Jun 4, 2024

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

@Phu2
Copy link
Contributor

Phu2 commented Aug 23, 2024

+1 for b)

@dr0i Where does the parameter come from?

Sorry for the delay. Somehow i missed this issue.

@Phu2
Copy link
Contributor

Phu2 commented Aug 23, 2024

SVGs don't have a size. Requesting SVGs using width parameter make Wikimedia deliver PNGs.

@dr0i
Copy link
Member

dr0i commented Aug 23, 2024

Parameter comes from depiction.thumbnail in https://lobid.org/gnd/4647881-4.json .
Looking at the data, it seems that if we would use depiction.id we would get the URL ending with the file extension. If that's always the case we could just switch to use this field (images would be a of greater size, but then the internet is fast enough and images are only served when using the web UI (few hits resulting from human interactions) and not the web API (possible millions of hits resulting from machine interactions)). WDYT @Phu2 ?

@Phu2
Copy link
Contributor

Phu2 commented Sep 3, 2024

Otherwise, it just needs this minor adjustment hbz/lobid@a5d0b23 in order to get the correct content type? But maybe i'm on the wrong track.

@dr0i
Copy link
Member

dr0i commented Sep 5, 2024

@Phu2 I like your proposal also. Please merge and deploy 👍

@Phu2
Copy link
Contributor

Phu2 commented Sep 24, 2024

@dr0i
Copy link
Member

dr0i commented Sep 24, 2024

+1

@Phu2
Copy link
Contributor

Phu2 commented Sep 24, 2024

Deployed to production.
Now this also works: https://lobid.org/imagesproxy?url=https://commons.wikimedia.org/wiki/Special:FilePath/ZHB%20Luzern%20Logo%20farbig.svg?width=270

Fixed by hbz/lobid@e1083c9 (sorry, used wrong reference in commit messgae)

@Phu2 Phu2 closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants