Converting JPEG colorspace (Adobe RGB to sRGB) on Linux

前端 未结 4 1551
忘了有多久
忘了有多久 2020-12-05 05:44

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 J

4条回答
  •  自闭症患者
    2020-12-05 06:25

    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
    

提交回复
热议问题