This project has moved. For the latest updates, please go here.

Converting transparent PNG to Jpeg

Jul 3, 2015 at 8:45 AM
Hello

I tried to convert partially transparent PNG to Jpeg.
And I want transparent areas always to be white.

I used following parameters for convert.exe utility and it works for me:
convert 005.png -resize 800x600  -background white -flatten  005_resized.jpg
how can I do the same conversion using Magick.NET ?
Coordinator
Jul 3, 2015 at 10:45 AM
You can do this with the ColorAlpha method of MagickImage. This method wraps the code from the command line into a single method.
Jul 6, 2015 at 6:52 AM
Great. It works.

You have added a new TransfromColorSpace method(in version 7.0.0.0015), it works in case if source and target profiles is not null.
How can I transform image to SRBG color profile if it does not contain color profile(source profile is null) ?
Jul 6, 2015 at 7:39 AM
One more question:

I have a image with ColorProfile.AdobeRGB1998.

image.GetAttribute("icc:description") returns null.
image.ColorSpace is equals ColorSpace.sRGB.

How can I determine which color profile used for image in that case?
Coordinator
Jul 6, 2015 at 10:52 AM
You have added a new TransfromColorSpace method(in version 7.0.0.0015), it works in case if source and target profiles is not null.
How can I transform image to SRBG color profile if it does not contain color profile(source profile is null) ?
 
With the TransformColorSpace method you will have to specify a source and a target profile. The advantage of this method is that the source profile will not be used it the image already contains a profile. To transfer the image to sRGB you could use ColorProfile.SRGB as the target profile. You will have to pick the source profile yourself.
 
How can I determine which color profile used for image in that case?
 
It looks like you already answered your own question: I have a image with ColorProfile.AdobeRGB1998. But you must be asking something else. Can you clarify your question?
Jul 7, 2015 at 10:31 AM
It looks like you already answered your own question: I have a image with ColorProfile.AdobeRGB1998. But you must be asking something else. Can you clarify your question?
As I figured out the image had incorrect color profile: sRGB instead of AdobeRgb(as I thought).
That was the problem.
I saved the image with correct color profile and everything works now as it should.

Thanks for help.