Dave
Dave

Reputation: 14178

Converting JPEG colorspace (Adobe RGB to sRGB) on Linux

I am generating thumbnails 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 have been asked if the thumbnail and medium size images can use sRGB as the images as is appear "flat" in some browsers.

I'm currently using ImageMagick to create the smaller versions. It has a -colorspace option, but that doesn't seem to do what I want.

Is there any other way to do this? Also, do you think this is worthwhile?

Upvotes: 16

Views: 32065

Answers (4)

user3064538
user3064538

Reputation:

Re-exporting the image using Krita seems to work well enough for me:

 krita my_img.jpg --export --export-filename my_img_in_srgb.jpg

Krita is an open source Photoshop/Paint, with a(n extremely limited) command line interface. Install it with

sudo apt install krita

Upvotes: 0

mivk
mivk

Reputation: 14899

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

Upvotes: 4

HaBaLeS
HaBaLeS

Reputation: 1839

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.

Upvotes: 13

Kris Wallsmith
Kris Wallsmith

Reputation: 8965

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.

Upvotes: 9

Related Questions