Skip to content

Encode NSImage.jpegData as JPEG instead of JPEG 2000 - #12

Merged
Jeehut merged 1 commit into
mainfrom
wip/nsimage-jpeg
Oct 15, 2026
Merged

Jeehut merged 1 commit into
mainfrom
wip/nsimage-jpeg

Conversation

@Jeehut

@Jeehut Jeehut commented Oct 14, 2026

Copy link
Copy Markdown
Member

Overview

NSImage.jpegData(compressionQuality:) encoded with .jpeg2000, so on macOS it returned JPEG 2000 data that many consumers (uploads, UIImage, web) cannot read, while the name promises JPEG like UIImage.jpegData. It now encodes with .jpeg.

Split out of #7.

How this was verified

ImageExtTests.jpegDataEncodesAsJPEG checks the JPEG magic bytes FF D8 FF.

Red, with main's ImageExt.swift:

✘ Expectation failed: Array(data.prefix(3)) == [0xFF, 0xD8, 0xFF]
✘ Test run with 1 test in 1 suite failed with 1 issue.

Green, this branch:

✔ Test run with 1 test in 1 suite passed.

The method used the .jpeg2000 file type, so callers expecting a JPEG
received a JPEG 2000 file that many consumers (browsers, upload APIs)
cannot read.
@Jeehut
Jeehut merged commit 50e1f66 into main Oct 15, 2026
5 checks passed
@Jeehut
Jeehut deleted the wip/nsimage-jpeg branch October 15, 2026 09:30
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.

1 participant