Skip to content

MarkerGeneratorAPIView returns PNG image with incorrect MIME type "image/jpeg" in base64 data URI #852

@vjpixel

Description

@vjpixel

Description

In src/core/views/api_views.py, the MarkerGeneratorAPIView.post() method saves the processed image as PNG but declares the MIME type as image/jpeg in the base64 data URI. This mismatch can cause display issues in browsers that strictly validate the MIME type.

Location

File: src/core/views/api_views.py
Class: MarkerGeneratorAPIView
Method: post()
Branch: develop

Current Code

# Image is saved as PNG:
transformed_image.save(in_mem_file, format="PNG")

# But the MIME type is declared as JPEG:
transformed_image = f"data:image/jpeg;base64,{base64_encoded_result_str}"

Problem

The image is encoded as PNG (format="PNG") but the data URI prefix declares it as image/jpeg. This is a MIME type mismatch. Some browsers may refuse to render the image correctly, and any downstream code that checks the MIME type will receive incorrect information.

Suggested Fix

Change the MIME type in the data URI to match the actual image format:

transformed_image = f"data:image/png;base64,{base64_encoded_result_str}"

Alternatively, if JPEG is the desired format, change the save format:

transformed_image.save(in_mem_file, format="JPEG")
transformed_image = f"data:image/jpeg;base64,{base64_encoded_result_str}"

Severity

Medium — May cause the generated marker preview to not display correctly in strict browsers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AR viewerbugSomething isn't workingpriority: highHigh priority - should be addressed soonpriority: mediumMedium priority - standard priority

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions