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

Enhance create_image_block to Dynamically Detect Image Type #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rajkstats
Copy link
Contributor

  • Use imghdr to detect the image type automatically (with a fallback to PNG if detection fails).
  • This update improves flexibility by properly handling various image formats rather than hardcoding JPEG.

@jamesmurdza
Copy link
Collaborator

imghdr has to be imported, right?

@rajkstats
Copy link
Contributor Author

you're right— imghdr must be explicitly imported, while imghdr is part of the standard library we don't need to add in poetry dependencies

  • In our earlier implementation, although imghdr wasn't imported, we were passing in a base64‑encoded string instead of the raw image bytes. Because of that, imghdr.what() was not actually able to detect the image type and ended up defaulting to "png"
  • Fixed that by passing the raw bytes to imghdr.what(), which should allow it to properly detect the image type
  • Comment out debug prints used for logging the detected image type to ensure its detecting image type properly (tested for both jpg and png in tests)

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

Successfully merging this pull request may close these issues.

2 participants