Mattias Malm#990
Since JPEG images don't support alpha channel, and simply saving an image with alpha as JPEG results in a blend to black, I would like to use DiscardAlpha() to blend the image to white before saving it as JPEG.
The blending works great, but every time i use DiscardAlpha() the ColorProfile property is set to NULL and the JPEG file doesn't have the assigned profile embedded. Is there a reason for this, is it a bug or am I doing something wrong?
Sample code (c#):
The blending works great, but every time i use DiscardAlpha() the ColorProfile property is set to NULL and the JPEG file doesn't have the assigned profile embedded. Is there a reason for this, is it a bug or am I doing something wrong?
Sample code (c#):
// Open image
Bitmap gmImage = new Bitmap(Server.MapPath("RgbFileWithAlpha.psd"));
// Turn color management on
gmImage.ColorManagement.ColorManagementEnabled = true;
// Set transformation intent
gmImage.ColorManagement.TransformationIntent = Aurigma.GraphicsMill.Transforms.ColorTransformationIntent.Perceptual;
// Set default ICC profile if it's not embedded
if (gmImage.ColorProfile == null && gmImage.IsRgb)
gmImage.ColorProfile = new ColorProfile(Server.MapPath("ColorProfiles/sRGB IEC61966-21.icm"));
// Set destination ICC profile and convert
gmImage.ColorManagement.RgbColorProfile = new ColorProfile(Server.MapPath("Adobe RGB (1998).icm"));
gmImage.ColorManagement.ConvertToContinuous(ColorSpace.Rgb, gmImage.HasAlpha, false);
// Save file in correct format
if (gmImage.HasAlpha)
gmImage.Channels.DiscardAlpha(Aurigma.GraphicsMill.Color.FromRgb(255, 255, 255));
gmImage.Save(Server.MapPath("NewFile.jpg"), new JpegEncoderOptions(90, false));
// Clean up
gmImage.Dispose();