Skip to content

Support JP2 images as conversion sources - #28

Merged
pg94au merged 5 commits into
mainfrom
copilot/add-jp2-support-conversion
Nov 5, 2026
Merged

pg94au merged 5 commits into
mainfrom
copilot/add-jp2-support-conversion

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Convertster should accept JP2 files as source images while keeping JP2 unsupported as an output format. Existing JPG and PNG conversion settings should remain unchanged.

  • Decoding: Use Magick.NET for .jp2 inputs, then pass the decoded image to ImageSharp for output encoding.
    using var jp2Image = new MagickImage(filename);
    using var pngStream = new MemoryStream(jp2Image.ToByteArray(MagickFormat.Png));
    return await Image.LoadAsync(pngStream, token);
  • Integration: Add JP2 to the Explorer source allowlist and document it as input-only.
  • Coverage: Add tests for JP2-to-JPG and JP2-to-PNG conversions.

Co-authored-by: pg94au <5140674+pg94au@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for conversion from jp2 files as source type Support JP2 images as conversion sources Oct 29, 2026
Copilot AI requested a review from pg94au October 29, 2026 15:55
@pg94au

pg94au commented Nov 4, 2026

Copy link
Copy Markdown
Owner

@copilot Need to redo this because a change from ImageSharp to Magick.NET was made.

Copilot AI commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Need to redo this because a change from ImageSharp to Magick.NET was made.

I checked the current branch: Converter.cs still uses ImageSharp for non-JP2 inputs and JPG/PNG encoding, while Magick.NET is only used to decode JP2. The original issue also asks to retain/prefer ImageSharp. Do you want the conversion pipeline migrated fully to Magick.NET, or should I redo the JP2-only integration against a newer branch where that migration is already present?

@pg94au

pg94au commented Nov 4, 2026

Copy link
Copy Markdown
Owner

@copilot If you look at the main branch, the application was converted to use only Magick.NET because of a security vulnerability in ImageSharp. If you merge main into this branch, you'll see that ImageSharp is no longer used. So please rework this change to support jp2 based on what is currently in main.

…rt-conversion

# Conflicts:
#	ImageConverter.Tests/ImageConverter.Tests.csproj
#	ImageConverter/Converter.cs
#	ImageConverter/ImageConverter.csproj
#	ImageConverter/packages.config

Co-authored-by: pg94au <5140674+pg94au@users.noreply.github.com>

Copilot AI commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot If you look at the main branch, the application was converted to use only Magick.NET because of a security vulnerability in ImageSharp. If you merge main into this branch, you'll see that Im...

Merged main and aligned JP2 support with the Magick.NET-only converter; JP2 is decoded as a source while JPG/PNG remain the only targets. Merge commit: b138ce2.

@pg94au
pg94au requested a balanced review from Copilot November 5, 2026 01:07
@pg94au
pg94au marked this pull request as ready for review November 5, 2026 01:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The JP2 path still uses Magick.NET for output encoding instead of the required ImageSharp handoff, which must be implemented while preserving JPG quality and PNG compression settings.

1 open issue
What changed in this PR

This PR exposes JP2 as a source format in Convertster’s Explorer integration and adds conversion coverage, while keeping JPG and PNG as the supported outputs.

Changes:

  • Add .jp2 to the Explorer source allowlist and README.
  • Generate JP2 test images and add JPG/PNG conversion cases.
  • Add explicit Magick.NET references to the test project and reorder existing package entries.
File Description
ShellExtContextMenuHandler/​FileContextMenuExt.cpp Allow JP2 source files in Explorer.
README.md List JP2 among supported source formats.
ImageConverter.Tests/​TestSupport.cs Generate JP2 test images using Magick.NET.
ImageConverter.Tests/​packages.config Reorder existing Magick.NET package entries.
ImageConverter.Tests/​ImageConverter.Tests.csproj Add Magick.NET assembly references.
ImageConverter.Tests/​ImageConversionTests.cs Add JP2-to-JPG and JP2-to-PNG integration cases.
ImageConverter.Tests/​ConverterTests.cs Add JP2 cases to converter tests.

Review effort: Balanced

const wchar_t* dot = wcsrchr(file->c_str(), L'.');
// Allowed extensions (case-insensitive).
const wchar_t* allowedExts[] = { L".bmp", L".png", L".tif", L".tiff", L".webp" };
const wchar_t* allowedExts[] = { L".bmp", L".jp2", L".png", L".tif", L".tiff", L".webp" };
@pg94au
pg94au merged commit 6194f14 into main Nov 5, 2026
2 checks passed
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.

Add support for conversion from jp2 files as a source type

3 participants