Repository navigation
Conversation
On iOS every numeric Image.compress option (maxWidth, maxHeight, quality, progressDivider) was silently replaced by its default, so images always came out bounded by 1280 px at quality 0.8. Nitro hands JS numbers to Swift as Double, and ImageCompressorOptions read them with `as? Int` / `as? Float`, which never match a Double. Read them through NSNumber instead, as VideoMain already does for its options. The harness image test already passed maxWidth/maxHeight 8 for a 16×16 fixture but only checked that the output was non-empty; it now asserts the bound. Fixes numandev1#417 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TheWygoda
marked this pull request as ready for review
October 2, 2026 11:18
TheWygoda
marked this pull request as draft
October 2, 2026 11:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On iOS every numeric option passed to
Image.compress(maxWidth,maxHeight,quality,progressDivider) is silently replaced by its default, so images always come out bounded by 1280 px at quality 0.8. This is the bug reported in #417.Cause: Nitro hands JS numbers to Swift as
Double(AnyValue.number(Double)). Neithernormalize()nor theNSDictionaryround-trip inHybridCompressor.dictionary(from:)boxes them intoNSNumber.ImageCompressorOptions.fromDictionarythen reads them withas? Int/as? Float. Those casts never match aDouble, so every value falls back to its??default.These paths are not affected:
getInt.VideoMainalready reads its numeric options throughNSNumber.Fix: read the four numeric options through
NSNumber(.intValue/.floatValue), which bridges aDouble, anIntand anNSNumberalike. Defaults and all other options are unchanged.Test: the harness image test already compressed the 16×16 fixture with
maxWidth/maxHeight: 8, but only asserted that the output was non-empty. It now asserts the 8 px bound, so it fails without this fix.Changelog
[iOS] [Fixed] -
Image.compresshonoursmaxWidth,maxHeight,qualityandprogressDividerinstead of always using their defaultsTest Plan
Ran the local JS PR gate,
yarn test:pr: 13/13 tests pass, typecheck is clean, lint reports 0 errors (the 9 warnings are pre-existing, in other files).Ran the harness on an iOS simulator,
yarn test:harness:ios: 9/9 pass. Setup: iPhone 17 Pro on iOS 26.5, picked viaRN_HARNESS_IOS_DEVICE/RN_HARNESS_IOS_VERSION; Xcode 26.6; example app built with the samexcodebuildcommand asbuild-ios.yml.ImageCompressorOptions.swiftand the new assertion fails 1 test (8 pass) withexpected 1280 to be less than or equal to 8. Without the fix, manual mode used the 1280 default bound and scaled the 16×16 fixture up to 1280 px.Replayed the exact option hand-off in a standalone Swift script: a Nitro
Double, throughnormalize()and theNSDictionaryround-trips, into the patchedImageCompressorOptions.fromDictionary.maxWidth/maxHeight: 480,quality: 0.7Applied the same change to 2.0.3 through a patch in an app (RN 0.86.3, react-native-nitro-modules 0.37.1, iOS 26.5 simulator). Compressing a 5712×4284 JPEG with
maxWidth/maxHeight: 480gave 1280×960 before and 480×361 after.🤖 Generated with Claude Code