Closed TonyValenti closed 7 months ago
@TonyValenti We can only help you here, if you can provide a reproduction, which shows the issue without PdfSharpCore. We do not have anything to do with PdfSharpCore and cannot dig into their source code to find the issue. If you cannot find a reproduction with only ImageSharp source code, it may be is better if you open an issue over at PdfSharpCore.
Hi @brianpopow - I'm continuing to dig into this, comparing the output from v1.0.4 and v3.1.1 Variants.zip
I noticed that simply loading the image and resaving it is returning different results between the two versions: Variants.zip
Specifically, the Bit Depth is different:
Given that v1 has a bit depth of 24, how do I make V3 do that?
I tried this:
using var OriginalImage = SixLabors.ImageSharp.Image.Load(File);
using var NewImage = OriginalImage.CloneAs<Rgb24>();
NewImage.SaveAsJpeg($@"C:\Test - {Version}.jpg");
but the bit depth still comes out as 8 in 3.1.1.
v1 didn’t support 8bit encoding so defaulted to 24bit.
You should refer to the docs for encoding options. The pixel format represents the in-memory layout only not the encoded format. https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder.html?q=Jpegencoder
Thanks @JimBobSquarePants ! What settings would mimic the 1.0.4 defaults?
Actually, I think I found what I need.
Another question: Is there a utility method anywhere that can allow me to convert Pixel Resolution Units?
For example, I'd like to convert 3780 Pixels per Meter to Pixels per Inch.
Not public but you can copy this. https://github.com/SixLabors/ImageSharp/blob/1baba9e02d8b1ccc1078b125235b60b9b88f7f1f/src/ImageSharp/Common/Helpers/UnitConverter.cs
I’m assuming we can close this now?
Yes! Thank you so much for your help.
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.1.1 Does Not Work. 1.0.4 Does
Other ImageSharp packages and versions
See Above
Environment (Operating system, version and so on)
Win 11
.NET Framework version
.NET7
Description
This is a doozy!
When embedding certain JPEGs in a PDF, when using ImageSharp 1.0.4, the JPEGs render correctly.
However, when using ImageSharp 3.1.1, the JPEGs have a RED background instead of a white one.
Here is what the PDF looks like when using ImageSharp 1.0.4:![image](https://github.com/SixLabors/ImageSharp/assets/13609558/4ec72463-8988-4a12-a521-b0ac000fdcec)
And here is what it looks like with ImageSharp 3.1.1:![image](https://github.com/SixLabors/ImageSharp/assets/13609558/66748b95-a39e-4913-8997-355f5b89bf52)
I am using a slightly modified branch of PdfSharp which adds support for the latest build of ImageSharp.
The custom branch can be obtained from: https://github.com/TonyValenti/PdfSharpCore
The branch is a stock branch except it adds support for legacy ImageSharp and modern ImageSharp verions. The only differences between the build for ImageSharp 1.0.4 and 3.1.1 are these two files:
which you will notice are identical except for a minor ImageSharp signature change.
Steps to Reproduce
Get these repo:
When you run ConsoleApp2 in![image](https://github.com/SixLabors/ImageSharp/assets/13609558/0d5dfd4a-31cc-481a-a93f-8ba01a981456)
ImageSharpRed
, you can select the framework version:When you select 5.0 (which is powered by ImageSharp 1.0.4) everything works correctly. When you select 7.0 (which is powered by ImageSharp 3.1.1) this issue occurs.
Images
Here is a ZIP containing the image. 000809D7.zip