Converting JPEG colorspace (Adobe RGB to sRGB) on Linux

You can use the ImageMagic -profile option:

convert image.jpg -profile <adobe.icc> -profile <sRGB.icc> new_image.jpg

See here for more details: http://www.imagemagick.org/Usage/formats/#color_profile.


The following thread in the ImageMagick forum discusses exactly this in some detail: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16464

I now use this bash script to convert any picture (including CMYK) to sRGB: http://alma.ch/scripts/any2srgb

It requires icc profiles for images which don't have embedded profiles. These can be found easily on the web. For example on Adobe's site: http://www.adobe.com/cfusion/search/index.cfm?term=icc+profile&siteSection=support%3Adownloads

Here is a summary (untested) of what the full script does (without it's resize and other options). It requires profiles and ImageMagick. On Debian-based systems: apt-get install icc-profiles imagemagick.

#!/bin/bash

srgb=sRGB.icm
cmyk=ISOwebcoated.icc

# extract possible color profile
profile="${f/%.*/.icc}"
convert "$f" "icc:$profile" 2>/dev/null

if cmp -s "$profile" "$srgb" ; then
    # embedded profile is already srgb. Nothing to do
    exit
fi

if [ -s "$profile" ]; then
    # we have an embedded profile, so ImageMagick will use that anyway
    convert "$f" -profile "$srgb" +profile '*' "$outfile"
else
    # no embedded profile in source
    if identify -format "%r" "$f" | grep -q CMYK; then
        # CMYK file without embedded profile
        convert "$f" -profile "$cmyk" -profile "$srgb" "$outfile"
    fi
fi

Have you tried using Little CMS? This command will convert an image with a special color profile (i.e. Adobe RGB 1998) to one with no color profile but the same effective colors:

jpgicc -q100 input.jpg output.jpg

I'm setting JPEG quality to 100 here.