Skip to content

Preserve the source MIME type when adding images to AI context #7

Description

@cubrift

Problem

extractImageData in Util.js always prefixes downloaded image bytes with data:image/jpeg;base64, even when the WhatsApp message declares another image MIME type. This can mislabel PNG or WebP content and may cause downstream image consumers to decode it incorrectly.

Expected behavior

Images added to chat history should retain the MIME type supplied by the source message, with a safe fallback when that metadata is unavailable.

Suggested direction

Read the MIME type from the selected imageMessage (including quoted images) and use it when building the data URL. Keep the current JPEG fallback for messages without a MIME value.

Acceptance criteria

  • Declared MIME types such as image/png and image/webp are preserved.
  • Images without MIME metadata still use a safe fallback.
  • Both direct images and quoted images are handled.
  • A focused unit test covers at least one non-JPEG MIME type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodexUse for codex-generated issues only.good first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions