Skip to content

fix: get the supported format properly#53

Open
Arukuen wants to merge 2 commits into
developfrom
fix/52-bulk-heic
Open

fix: get the supported format properly#53
Arukuen wants to merge 2 commits into
developfrom
fix/52-bulk-heic

Conversation

@Arukuen
Copy link
Copy Markdown
Contributor

@Arukuen Arukuen commented Jun 5, 2026

fixes #52

Issue was the previous formatTo variable in line 231 filters out image/heic but not heic. The additional helper function ensures format mime type or value is properly used.

This issue is discovered because when WordPress converts HEIC to JPG (tested also when Cimo is disabled), the file's metadata still contains the file type as HEIC. And since Bulk Optimization converts with the same output format as the input, it tries to convert to HEIC.

image

Summary by CodeRabbit

Release Notes

  • Refactor
    • Enhanced image format detection and resolution for more reliable format conversions
    • Improved filename extension normalization for converted images

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

Warning

Review limit reached

@Arukuen, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 32 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a731e9c-6315-4b35-bd11-b6e82eb4998f

📥 Commits

Reviewing files that changed from the base of the PR and between 144e530 and 26f8019.

📒 Files selected for processing (1)
  • src/shared/converters/image-converter.js
📝 Walkthrough

Walkthrough

This PR centralizes image format resolution by introducing getSupportedFormat, a helper that maps MIME types or format values to supported format objects. The converter's convertImage and convert functions are then refactored to use this helper consistently for format lookups, validation, dispatch, and metadata assignment.

Changes

Image Format Resolution Consolidation

Layer / File(s) Summary
Format resolution helper
src/shared/converters/image-converter.js
New getSupportedFormat function resolves either a MIME type (image/*) or format value to its corresponding supported format object entry, with a fallback to the first supported format.
Converter integration of format resolution
src/shared/converters/image-converter.js
convertImage and convert are refactored to use getSupportedFormat for all format operations: browser support validation, PNG vs. canvas-based dispatch condition, output filename extension normalization (including jpegjpg), and both convertedFormat metadata and output File type assignment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • gambitph/Cimo#23: Both PRs modify format/MIME-type resolution and convertImage dispatch logic in src/shared/converters/image-converter.js.

Poem

🐰 A format resolver hops with care,
Unifying paths from here to there,
JPEG to JPG, each blob precise,
Supported formats, clean and nice!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding proper format resolution logic to correctly identify supported formats instead of the previous flawed approach.
Linked Issues check ✅ Passed The PR directly addresses issue #52 by fixing the format detection logic that was incorrectly filtering HEIC formats, preventing erroneous HEIC conversion attempts.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the format resolution logic; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/52-bulk-heic

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

🤖 Pull request artifacts

file commit
pr53-cimo-53-merge.zip 26f8019

github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/shared/converters/image-converter.js`:
- Around line 12-20: Normalize the incoming formatString inside
getSupportedFormat by trimming and lowercasing it, map common JPEG aliases
("jpg", "image/jpg") to the canonical "jpeg" before lookup, then perform the
existing MIME/value matching against supportedFormats (use supportedFormats.find
by mimeType or value) and fall back to supportedFormats[0] if nothing matches;
update getSupportedFormat to handle non-string inputs robustly (default to empty
string) and ensure comparisons are case-insensitive so convert() receives the
correct format metadata.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c6b2ad2-d51f-4350-afba-3c0803315a85

📥 Commits

Reviewing files that changed from the base of the PR and between a1406d4 and 144e530.

📒 Files selected for processing (1)
  • src/shared/converters/image-converter.js

Comment thread src/shared/converters/image-converter.js
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
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.

Bulk Optimization Error with HEIC

1 participant