DEBUG and RELEASE modeWhen resize a screenshot from iPhone X or XS max, the resized image will get pink blur:
This is the code I used to resize the image:
public Stream CreateThumbnailForImage(Stream imageStream, int estimatedThumbnailWith)
{
try
{
Stream thumbnailStream = new MemoryStream((int)imageStream.Length);
thumbnailStream.Position = 0;
using (Image<Rgba32> image = Image.Load(imageStream))
{
var thumbnailRate = GetThumbnailRate(image.Width, estimatedThumbnailWith);
image.Mutate(x => x
.Resize(image.Width / thumbnailRate, image.Height / thumbnailRate, true));
imageStream.Position = 0;
var imageFormat = Image.DetectFormat(imageStream);
if (imageFormat != null)
{
image.Save(thumbnailStream, imageFormat);
}
else
{
image.Save(thumbnailStream, new JpegEncoder());
}
}
thumbnailStream.Position = 0;
return thumbnailStream;
}
catch (Exception ex)
{
return null;
}
}
private int GetThumbnailRate(int originailWidth, int estimatedThumbnailWith)
{
var thumbnailRate = originailWidth / estimatedThumbnailWith;
if (thumbnailRate == 0)
{
thumbnailRate = 1;
}
return thumbnailRate;
}
On the other hand, if resize a iPhone 6s's screenshot, the result will be okay.
Try the latest dev builds. I think you are suffering from an obscure issue we found that was affecting certain chipsets
Yeah, might be a duplicate of #871. Let us know. @vuthainam let us know if the latest dev build works correctly!
@vuthainam How did you get on with the latest build?
@vuthainam How did you get on with the latest build?
Sorry for late response. I tried to get the latest dev version but the 'pink blur' issue sill happen when save an image by PNG encoder (image source from iPhone X or iphone XS max, running environment is Azure WebService)
The strange thing is: if running environment is local IIS, image that encoded by PNG encoder will be fine.
On the other hand, when use JPG encoder to save image, the result will be fine too (on both Azure or Local machine)
@antonfirsov I think there is a regression in the library.
Using the version 1.0.0-dev002709 (base on discussions in #871) I get correct images on a raspberry pi (resizing jpegs).
But the latest myget (1.0.0-dev002762) has the pink blur again.
i can confirm that, the pink thing is back in the master branch.
edit:
A little bit more info. Im using again the arm32 docker image to reproduce it. It is enough to load an image and then save it to reproduce it.
The issue seems to only happen with JPG. Saving as PNG or BMP works fine.
Some good news: I have tried .NET Core 3.0 Preview and this issue does not happen anymore.
I have used the following build image: mcr.microsoft.com/dotnet/core/sdk:3.0-bionic
And this runtime: mcr.microsoft.com/dotnet/core/runtime:3.0-bionic-arm32v7
The release of .net core 3.0 is just around the corner, i think it will be next month.
Some good news: I have tried .NET Core 3.0 Preview and this issue does not happen anymore.
Well that's a silver lining at least.
We'll have to see what has changed in between 1.0.0-dev002709 and 1.0.0-dev002762 within the jpeg encoding pipeline to figure out what has happened.

I think i have tracked down the commit which introduced the issue: [e2651e7]
Before that commit it works: [07ec6511]
Its hard to understand why this particular commit triggers this pink issue. My first thought was that maybe a different version of System.Runtime.CompilerServices.Unsafe could be the reason, but the mentioned commit does not change the version. Also i have tried version '4.5.2' and the latest preview version, both do not change the pink issue.
If any one has an idea what i could try to identify the cause of this, let me know.
Yeah but it's definitely rooted in a CLR bug. We probably won't be able to fix it, and will suggest updating to .NET Core 3.0 for ARM users.
@vuthainam I just realized, that I completely missed that you are running in Azure Web Service. You are not using ImageSharp in your iOS app, right? What is the ProcessorArchitecture within your service?
Since .NET Core 2.0 is now out of support and .NET Core 3.0 is released @brianpopow confirmed the problem to be gone there I'm going to close this issue.
Most helpful comment
I think i have tracked down the commit which introduced the issue: [e2651e7]
Before that commit it works: [07ec6511]
Its hard to understand why this particular commit triggers this pink issue. My first thought was that maybe a different version of
System.Runtime.CompilerServices.Unsafecould be the reason, but the mentioned commit does not change the version. Also i have tried version '4.5.2' and the latest preview version, both do not change the pink issue.If any one has an idea what i could try to identify the cause of this, let me know.