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

Decide type of image not using URL extension #81

Open
kolesnikov-pasha opened this issue Dec 16, 2023 · 5 comments
Open

Decide type of image not using URL extension #81

kolesnikov-pasha opened this issue Dec 16, 2023 · 5 comments

Comments

@kolesnikov-pasha
Copy link

Some links could not have any extension and provide, for example, svg images. In this case, image won't be shown correctly.

Example of link: https://img.recraft.ai/k0Ksvp7ONUcklX29-XZ42n0cxZC4DkiR1UnHLgBHv0I/rs:fit:768:768:0/raw:1/plain/abs://staging/images/85e93fd8-a732-4cb6-aaac-45e9285a4aaf

@luca992
Copy link
Member

luca992 commented Dec 17, 2023

yeah, right now it depends on extensions to determine type. If you have any suggestions on how to determine type from the file itself that would be helpful.

@kolesnikov-pasha
Copy link
Author

The one thing I have in my mind is to

  1. check all caches for the key. If it is present then decide type based on cache type
  2. if no cached image for this key, download file and decide its type based on the content, I guess it shouldn't be hard (for example, svg files always start with <svg and so on)

I'll try to research this question and make PR later this week

@kolesnikov-pasha
Copy link
Author

Maybe it is possible to use this tool or to port its part on Kotlin: https://imagemagick.org/script/identify.php

@eskatos
Copy link

eskatos commented Jan 21, 2024

HTTP Content-Type header could be a good source of information for this

@luca992
Copy link
Member

luca992 commented Jan 22, 2024

HTTP Content-Type header could be a good source of information for this

Yeah that could help for network requests 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants