Skip to content

Preserve ICC color profiles during JPEG rotation#4

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-colors-after-rotation
Draft

Preserve ICC color profiles during JPEG rotation#4
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-colors-after-rotation

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 1, 2026

JPEG rotation was causing color shifts because re-encoding used default GDI+ settings, discarding embedded ICC color profiles and using reduced quality.

Changes

  • Set JPEG encoder quality parameter to 100 in CRotationItem::Rotate()
    • Previously passed nullptr to Image::Save(), triggering default encoding (typically 75-85 quality)
    • Now configures EncoderParameters with EncoderQuality=100
    • GDI+ automatically preserves ICC profiles when encoder parameters are properly set
// Before
hr = (pImage->Save(spstrm, &jpgClsid, nullptr) == Ok) ? S_OK : E_FAIL;

// After  
EncoderParameters encoderParams;
encoderParams.Count = 1;
encoderParams.Parameter[0].Guid = EncoderQuality;
encoderParams.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParams.Parameter[0].NumberOfValues = 1;
ULONG quality = 100;
encoderParams.Parameter[0].Value = &quality;

hr = (pImage->Save(spstrm, &jpgClsid, &encoderParams) == Ok) ? S_OK : E_FAIL;

No API changes. Maintains existing lossless rotation behavior for dimension-compliant images.

Original prompt

This section details on the original issue you should resolve

<issue_title>Colors are not totally the same after rotation </issue_title>
<issue_description>I tested before and after the rotation and colors are not totally the same.

Source:
Original
After rotation:
After rotation
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 1, 2026 05:32
Co-authored-by: chrdavis <6734176+chrdavis@users.noreply.github.com>
Co-authored-by: chrdavis <6734176+chrdavis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix color discrepancies after rotation Preserve ICC color profiles during JPEG rotation Feb 1, 2026
Copilot AI requested a review from chrdavis February 1, 2026 05:34
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.

Colors are not totally the same after rotation

2 participants