Skip to content

utils: Label screenshots with the real MIME type - #6

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/screenshot-jpeg-mime
Oct 13, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/screenshot-jpeg-mime

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

utils: Label screenshots with the real MIME type

GetSourceScreenshot labeled its data URL image/ plus the requested format name, so jpg gave image/jpg, which is not a MIME type (upstream obsproject/obs-websocket#1298). jfif, ppm, pgm, pbm, ico, cur, xbm and xpm were mislabeled the same way.

  1. utils: Move the screenshot MIME type into a helper: Utils::ImageFormat::MimeType(), same result for every format.
  2. utils: Label screenshots with the real MIME type: a fixed table from the image writer's format names to their registered types, with image/ plus the name for anything else. It is not QMimeDatabase (Requests: Give correct MIME in GetSourceScreenshot obsproject/obs-websocket#1337 by andrewsoncha) because that reads the system's shared-mime-info and answers application/octet-stream without it. Fix JPEG MIME type in screenshot data URIs obsproject/obs-websocket#1354 by iibaranov-IG fixes jpg only.

Tested in obs-rust/obs-studio with test_ws_image_mime (4 of 5 fail before, 5 of 5 pass after, both libobs lanes). The obs-rust/obs-studio PR that moves the submodule, opened once this merges, carries the test. Fixes obs-rust/obs-studio#523.

🤖 Generated with Claude Code

rdoupe and others added 2 commits October 13, 2026 05:05
GetSourceScreenshot built its data URL as "image/" + the requested
format. Move that into Utils::ImageFormat::MimeType() so it can be
tested on its own. Same result for every format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetSourceScreenshot labeled its data URL "image/" plus the requested
format name, so "jpg" gave "image/jpg", which is not a MIME type
(upstream obsproject/obs-websocket#1298); "jfif", "ppm", "ico" and the
other non-JPEG/PNG/BMP formats were mislabeled the same way. Map the
format names QImageWriter offers to their registered MIME types and
keep "image/" plus the name for anything else.

A fixed table rather than QMimeDatabase (as proposed in
obsproject/obs-websocket#1337): the database comes from the system's
shared-mime-info, and without it every lookup answers
application/octet-stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zackees
zackees merged commit 3e46553 into obs-rust:master Oct 13, 2026
zackees pushed a commit to rdoupe/obs-studio that referenced this pull request Oct 13, 2026
GetSourceScreenshot labelled its data URL "image/" plus the requested
format name, but the names are Qt image writer names (file extensions),
so "jpg" came back as "data:image/jpg", which is not a MIME type, and
"ppm" as "data:image/ppm". obs-rust/obs-websocket#6 maps the writer's
format names to their registered types with a fixed table (no
dependency on the system's MIME data).

Move the submodule from a4040cb (obs-rust/obs-websocket#9) to 3e46553,
the merge of obs-rust#6 on top of it, and add test_ws_image_mime, which builds
the helper from the plugin source on its own: 4 of 5 cases fail against
the fork's helper-only commit and all 5 pass here.

Reported upstream in obsproject/obs-websocket#1298 by cmack.

Fixes obs-rust#523.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=0bda6cde7d6d43558b289e6a4c5657ba5b79a390 secs=511 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791932642,"gate":"rust/all/fmt","host":"linux-x86_64","key":"56712ff4f494234c658dde9bf072511f27f83b32e5258647edaa0960ff822b1e","lane":"lint","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":36,"stamp":"7a0219afa75b08288667d44530d9d3dc","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"56712ff4f494234c658dde9bf072511f27f83b32e5258647edaa0960ff822b1e","lane":"lint","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":36,"stamp":"a28fdc6843d0a6a1efb8f56c1c23226c","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0a26a3da188ac6df7cacddf394b31ac8aee4f17722f8fcfb7e16f16c6545607d","lane":"rust-test","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":188,"stamp":"648509e8d3aa287a22e48e49b3d4b8c4","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"7a9f0013c352502c3d51ad804772dad6","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"e20920cba594d6cff6c18eaa58f06dda","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"97a31be153dbb8d7326d6ca770662db7","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"fcccde5645d69a4439666be55bb76a20","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"a281400a7593e0cc03ff5597876b023f","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"6bbeb0ed509658dbfbb9c9f55bad2381","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1b19e58298733d30e063360d21c4f9aada312536ef6a1ce1e471a24ff8dd5d5c","lane":"tier2-linux","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"d422d5aa241f41f79924b3f80fbea575","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
zackees added a commit to obs-rust/obs-studio that referenced this pull request Oct 13, 2026
GetSourceScreenshot labelled its data URL "image/" plus the requested
format name, but the names are Qt image writer names (file extensions),
so "jpg" came back as "data:image/jpg", which is not a MIME type, and
"ppm" as "data:image/ppm". obs-rust/obs-websocket#6 maps the writer's
format names to their registered types with a fixed table (no
dependency on the system's MIME data).

Move the submodule from a4040cb (obs-rust/obs-websocket#9) to 3e46553,
the merge of #6 on top of it, and add test_ws_image_mime, which builds
the helper from the plugin source on its own: 4 of 5 cases fail against
the fork's helper-only commit and all 5 pass here.

Reported upstream in obsproject/obs-websocket#1298 by cmack.

Fixes #523.


Local-Gate: v1 tree=0bda6cde7d6d43558b289e6a4c5657ba5b79a390 secs=511 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791932642,"gate":"rust/all/fmt","host":"linux-x86_64","key":"56712ff4f494234c658dde9bf072511f27f83b32e5258647edaa0960ff822b1e","lane":"lint","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":36,"stamp":"7a0219afa75b08288667d44530d9d3dc","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"56712ff4f494234c658dde9bf072511f27f83b32e5258647edaa0960ff822b1e","lane":"lint","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":36,"stamp":"a28fdc6843d0a6a1efb8f56c1c23226c","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0a26a3da188ac6df7cacddf394b31ac8aee4f17722f8fcfb7e16f16c6545607d","lane":"rust-test","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":188,"stamp":"648509e8d3aa287a22e48e49b3d4b8c4","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"7a9f0013c352502c3d51ad804772dad6","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"e20920cba594d6cff6c18eaa58f06dda","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"97a31be153dbb8d7326d6ca770662db7","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"fcccde5645d69a4439666be55bb76a20","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"a281400a7593e0cc03ff5597876b023f","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"6bbeb0ed509658dbfbb9c9f55bad2381","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1b19e58298733d30e063360d21c4f9aada312536ef6a1ce1e471a24ff8dd5d5c","lane":"tier2-linux","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"d422d5aa241f41f79924b3f80fbea575","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Zachary Vorhies <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: obs-websocket: GetSourceScreenshot labels jpg screenshots image/jpg (upstream obsproject/obs-websocket#1298)

2 participants