【问题标题】:Converting JPEG colorspace (Adobe RGB to sRGB) on Linux在 Linux 上转换 JPEG 颜色空间(Adobe RGB 到 sRGB)
【发布时间】:2010-10-23 11:53:36
【问题描述】:

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

我目前正在使用 ImageMagick 创建较小的版本。它有一个-colorspace 选项,但这似乎不是我想要的。

还有其他方法可以做到这一点吗?另外,你觉得这样做值得吗?

【问题讨论】:

    标签: imagemagick jpeg


    【解决方案1】:

    您可以使用 ImageMagic -profile 选项:

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

    更多详情请看这里: http://www.imagemagick.org/Usage/formats/#color_profile.

    【讨论】:

    • 此命令附加 icc 配置文件(在本例中为 sRGB),但图像查看器工具的问题在于它们不更新信息。基本上一张图片附有多个配置文件。有些是简单的 xml 文件,记录用户在 Photoshop 中所做的一切,记录其颜色配置文件等。如果附加二进制文件 sRGB.icc 它实际上会添加配置文件,但 imagemagick 甚至 Photoshop(可能有更新信息的菜单)不会更新其他配置文件(基本上是 xml),因此图像查看器无论如何都会显示以前的配置文件。
    • 为了获得最佳输出,我声明:输入和输出配置文件convert image.jpg -profile &lt;adobe.icc&gt; -profile &lt;sRGB.icc&gt; new_image.jpg 当我转换我的佳能 T3i 使用 Adob​​e RGB 颜色空间拍摄的 JPG 图像时。
    • @RafaelXavier 你从哪里得到 sRGB.icc 和 adobe.icc?如果我从原始照片中提取个人资料,它将是 adobe.icc。 sRGB.icc 来自哪里?
    • 为了清楚起见,这里的主要答案是错误的。您真的应该关注 Rafael Xavier 于 2013 年 9 月 9 日在上面发布的回答:stackoverflow.com/questions/817727/…
    • 对我来说,我只需要做convert image.jpg -profile &lt;sRGB.icc&gt; new_image.jpg,因为现有的配置文件嵌入在文件中。如果我首先包含 Adob​​e RGB 配置文件,ImageMagick 将转换两次(如果我正确阅读了文档)。
    【解决方案2】:

    您是否尝试过使用Little CMS?此命令会将具有特殊颜色配置文件(即 Adob​​e RGB 1998)的图像转换为没有颜色配置文件但有效颜色相同的图像:

    jpgicc -q100 input.jpg output.jpg
    

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

    【讨论】:

      【解决方案3】:

      ImageMagick 论坛中的以下主题详细讨论了这一点:http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16464

      我现在使用这个 bash 脚本将任何图片(包括 CMYK)转换为 sRGB: http://alma.ch/scripts/any2srgb

      对于没有嵌入配置文件的图像,它需要 icc 配置文件。这些可以在网上很容易地找到。例如在 Adob​​e 的网站上: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
      

      【讨论】:

      • 您还应该在答案中添加有关如何下载sRGB.icmISOwebcoated.icc 文件的说明。
      • @Boris :它已经在第 4 段中:apt-get install icc-profiles。好吧,至少对于基于 Debian 的发行版而言。
      【解决方案4】:

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

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

      Krita 是一个开源的 Photoshop/Paint,带有一个(非常有限的)命令行界面。安装它

      sudo apt install krita
      

      【讨论】: