Open gitgoap opened 8 months ago
@walterbender sir i think we can use imghdr module to detect the image type and base64 for decoding which will ensure proper conversion, what are you thoughts about it
previous PR for this issue Great initiative with the image format detection using imghdr!
@walterbender From what I can find about imghdr
, the python version is indeed deprecated.
I found an alternative for it though, some projects have replaced the use of imghdr
library with filetype
library.
We could also implement something similar.
Take a look at this -> https://github.com/lektor/lektor/issues/653#issuecomment-495396031
What's your opinion?
is the discussion you found about python only? we need a stable JS solution.
Can we use the PIL library for the same?
@walterbender
is the discussion you found about python only
Yes the discussion is about python only.
we need a stable JS solution.
I just assumed that as the file is written in python, I just needed to find an alternative to imghdr
lib.
But if a stable JS solution is required then from what I could find FileReader API
is a good way to find the type of the file, the drawback being that FileReader API
uses the Magic number-based
file type detection which is not foolproof.
I also found that there's an npm package of imghdr
which is not being actively maintained.
See -> https://www.npmjs.com/package/imghdr?activeTab=readme
Description
The current code within the
pluginify
function at line 173 suggests incomplete functionality for detecting image formats, specifically to distinguish between different formats such as SVG and PNG.Expected Behavior
The enhancement of the
pluginify
function should include accurate image format detection, particularly for detecting PNG format. Currently, the code assumes SVG format for images, but this functionality is incomplete and lacks the ability to handle PNG or other formats.Screenshots
Console log Errors:
N/A
Environment:
Checklist
Thank you for contributing to our project! We appreciate your help in improving it.
π See contributing instructions.
ππΎππΌ Questions: Community Matrix Server.