Skip to content

Bug: GetSourceScreenshot not giving correct MIME type for imageFormat: jpg #1298

Open

Description

@cmack

Operating System Info

Other

Other OS

Guix Linux

OBS Studio Version

Other

OBS Studio Version (Other)

30.1.2

obs-websocket Version

5.4.2 (as reported by API "GetVersion")

OBS Studio Log URL

https://obsproject.com/logs/vsY4qNMNL2cNp8pn

OBS Studio Crash Log URL

No response

Expected Behavior

Whether imageFormat: 'jpg' or imageFormat: 'jpeg' is submitted, the resulting encoded data uri gives the correct 'image/jpeg' MIME type.

If there are other supported image types listed in the "GetVersion" request having MIME types different than simply prepending image/ to it, it would be nice for them to have their correct MIME type, too.

Current Behavior

  1. When making a GetSourceScreenshot request with imageFormat: "jpg" the response's imageData field uses the "image/jpg" mimetype, which is incorrect.
  2. Making the same request with imageFormat: "jpeg" the response's imageData field has the correct "image/jpeg" mimetype

Steps to Reproduce

I enabled the debug setting in the submitted log file for the request / response payloads to be evident

  1. Make a an appropriate "GetSourceScreenshot" request with the imageFormat: "jpg"` key set
  2. Witness the response's imageData value beginning with "data:image/jpg;...."
  3. Feel the problem when trying to make an SVG element like:
 <image xlink:href="{verbatim-imageData-from-OBS-here}" :x 0 :y 0 :width 300 :height 300></image>

and seeing no resulting rendering from librsvg
4. Try step 1 - 3 again with imageFormat: "jpeg" at 1; see "data:image/jpeg..." at step 2; and a rendered image at step 3.

Anything else we should know?

I wish I could have tested with a more recent OBS but looking at the main branch, it looks like the "image/" prepend logic is still there and would affect the current version, too.

Activity

  1. andrewsoncha commented on Mar 24, 2026

    @andrewsoncha

    I tested the Requests mentioned above and they seem to have been fixed.

    GetSourceScreenshot Request body ("jpeg" MIME type)

    {
      "op": 6,
      "d": {
        "requestType": "GetSourceScreenshot",
        "requestId": "arbitraryRequestID",
        "requestData": {
          "sourceName": "Face",
          "imageFormat": "jpeg"
        }
      }
    }

    GetSourceScreenshot Response body ("jpeg" MIME type)

    {
        "d": {
            "requestId": "arbitraryRequestID",
            "requestStatus": {
                "code": 100,
                "result": true
            },
            "requestType": "GetSourceScreenshot",
            "responseData": {
                "imageData": "data:image/jpeg;base64,/9j/someBase64Image"
            }
        },
        "op": 7
    }

    The encoded data url starts with "data:image/jpeg", the correct requested MIME type.

    GetSourceScreenshot Request body ("jpg" MIME type)

    {
      "op": 6,
      "d": {
        "requestType": "GetSourceScreenshot",
        "requestId": "arbitraryRequestID",
        "requestData": {
          "sourceName": "Face",
          "imageFormat": "jpg"
        }
      }
    }

    GetSourceScreenshot Response body ("jpg" MIME type)

    {
        "d": {
            "requestId": "arbitraryRequestID",
            "requestStatus": {
                "code": 100,
                "result": true
            },
            "requestType": "GetSourceScreenshot",
            "responseData": {
                "imageData": "data:image/jpg;base64,/someBase64Image”
            }
        },
        "op": 7
    }

    The encoded data URL starts with "data:image/jpg", the correct requested MIME type.

    It can also be seen that within the requesthandler/RequestHandler_Sources.cpp it stores the requested Image Format, check if it is a supported format, and if so, pastes the requested image format as it is into the start of the encoded base64 data string.

    184   std::string imageFormat = request.RequestData["imageFormat"];
    185
    186	if (!IsImageFormatValid(imageFormat))
    187		return RequestResult::Error(RequestStatus::InvalidRequestField,
    188					    "Your specified image format is invalid or not supported by this system.");
    
    
    230 QString encodedPicture = QString("data:image/%1;base64,").arg(imageFormat.c_str()).append(encodedImgBytes.toBase64());

    Thus, the above bug has already been fixed. Proposing this issue be closed.

  2. cmack commented on Mar 24, 2026

    @cmack
    Author

    The encoded data URL starts with "data:image/jpg", the correct requested MIME type.

    I disagree with "correct". I apologize if I wasn't clear in my original filing but image/jpg is not an official MIME type. I am requesting that image/jpeg should be returned whether the request uses "jpg" or "jpeg" for the imageFormat field.

  3. andrewsoncha commented on Mar 24, 2026

    @andrewsoncha

    Oh! I apologize. I misunderstood the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions