Converting JPEG colorspace (Adobe RGB to sRGB) on Linux

前端 未结 4 1540
忘了有多久
忘了有多久 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 05:58

    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.

    0 讨论(0)
  • 2020-12-05 05:58

    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
    
    0 讨论(0)
  • 2020-12-05 06:02

    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.

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题