在Linux上转换JPEG颜色空间(从Adobe RGB到sRGB)

16
我正在从大型照片中生成缩略图和中等大小的图片。这些较小的照片用于在线画廊中显示。许多摄影师使用Adobe RGB提交JPEG图像。有人问我是否可以将缩略图和中等大小的图像使用sRGB,因为某些浏览器中的图像看起来“平淡无奇”。

我目前正在使用ImageMagick创建较小的版本。它有一个-colorspace选项,但似乎不能满足我的需求。

还有其他方法吗?您认为这值得吗?

4个回答

13

1
这个命令附加了icc配置文件(在这种情况下是sRGB),但图像查看工具的问题在于它们不会更新信息。基本上,一个图像有多个附加的配置文件。其中一些是简单的xml文件,记录用户在Photoshop中所做的一切,记录其颜色配置文件等等。如果您附加二进制文件sRGB.icc,它实际上会添加配置文件,但是ImageMagick甚至Photoshop(可能有菜单可更新信息)不会更新其他配置文件(基本上是xml),因此图像查看器仍然显示以前的配置文件。 - Pramod
2
为了获得最佳输出,我在将使用Adobe RGB色彩空间拍摄的佳能T3i的JPG图像转换时,声明了输入和输出配置文件convert image.jpg -profile <adobe.icc> -profile <sRGB.icc> new_image.jpg - Rafael Xavier
1
@RafaelXavier,你从哪里得到sRGB.icc和adobe.icc?如果我从原始照片提取配置文件,它会是adobe.icc。那么sRGB.icc从哪里来? - Sahil
@Sahil 很好的问题,我现在不记得从哪里得到它了。虽然,在谷歌中很容易找到它们 sRGB http://www.color.org/srgbprofiles.xalter#v4pref 和 Adobe https://www.adobe.com/support/downloads/detail.jsp?ftpID=3680 - Rafael Xavier
1
只是为了明确,这里的主要答案是错误的。你真的应该遵循 Rafael Xavier 在2013年9月9日上面发布的答案:https://dev59.com/rXRA5IYBdhLWcg3wzhXZ#x5rknYgBc1ULPQZFQxwe - bhouston
4
对于我来说,我只需要执行 convert image.jpg -profile <sRGB.icc> new_image.jpg 命令,因为原有的颜色配置文件已嵌入到图片中。如果我先加入 Adobe RGB 配置文件,ImageMagick 会进行两次转换(如果我正确地理解了文档的话)。 - Henrik

9

你尝试过使用Little CMS吗?这个命令可以将具有特殊颜色配置文件(例如Adobe RGB 1998)的图像转换为没有颜色配置文件但有效颜色相同的图像:

jpgicc -q100 input.jpg output.jpg

我在这里将JPEG质量设置为100。

4
下面的ImageMagick论坛线程详细讨论了这个问题:http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16464 我现在使用这个bash脚本将任何图片(包括CMYK)转换为sRGB:http://alma.ch/scripts/any2srgb 对于没有嵌入式配置文件的图片,它需要icc文件。这些可以在网上轻松找到。例如,在Adobe的网站上:http://www.adobe.com/cfusion/search/index.cfm?term=icc+profile&siteSection=support%3Adownloads 以下是完整脚本未经测试的摘要(不包括其调整大小和其他选项)。它需要配置文件和ImageMagick。在基于Debian的系统上: 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

1
@Boris:它已经在第四段中了:“apt-get install icc-profiles”。至少对于基于Debian的发行版是这样。 - mivk

0

对于我来说,使用Krita重新导出图像似乎足够好:

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

Krita是一款开源的Photoshop/Paint软件,具有(极其有限的)命令行界面。您可以使用以下命令进行安装:

sudo apt install krita

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接