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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
Take a look at ColorConvertedBitmap class.
Method 3
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
Method 4
Have a look at The bitmap transform classes which has a short sample of using the ColorconvertedBitmap class with a profile.
Method 5
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0