Question

I need to generate thumbnail and medium sized images from large photos. These smaller photos are for display in an online gallery. Many of the photographers are submitting JPEG images using Adobe RGB. I would like to use sRGB for all thumbnails and medium size images

I am using dotnet (asp.net) and need a way to convert from Adobe RGB to sRGB without losing any quality.

Was it helpful?

Solution

Background info: Jpg files have 8 bits of red, green, and blue, whether sRGB,Adobe RGB, or plain ol' RGB. The ICC descriptor determines the color space. Sometimes this is embedded in the jpg file. Sometimes there is a flag to designate sRGB, Exif Colorspace tag a001 = 1. There is no standard flag for Adobe RGB, but some applications and cameras use 65535 (uncalibrated) for Adobe RGB in the exif tag A001.

To convert a jpg file from from one ICC profile (colorspace) to another, you can use CreateColorTransform to create a transorm between the color spaces. You will need to provide the ICC profile for the source (Adobe RGB) and destination (sRGB) color spaces.

After you have the transform, use TranslateBitmapBits to adjust the pixels. It may be easier to work with the image as a DIBSection.

This may be a bit complex to write in .asp, so it might be easier to use a graphics library that does this.

OTHER TIPS

Take a look at ColorConvertedBitmap class.

You should use the ImageMagic -profile option, I believe that -colorspace option will not help you there.

convert image.jpg -profile sRGB.icc rgb_image.jpg

Alternatively you can look for little color management engine

Have a look at The bitmap transform classes which has a short sample of using the ColorconvertedBitmap class with a profile.

On the server side you could call out to ImageMagick and let it do the conversion for you.

Here's a link to the -colorspace command line option

I haven't used this particular option, but it seems to do what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top