Paperclip (imagemagick) 生成暗图像

Paperclip (imagemagick) generates dark images

我正在使用回形针 gem 来调整图像大小。 问题是调整后的图像 "dark"。我附上了原始图像和调整大小后的两个示例。

这是生成图像的代码:

has_attached_file :result,
  :styles => {
    :medium => { :geometry => '262' },
  },
  :hash_secret => "xxx",
  :url => "/system/:class/:attachment/:id_partition/:style/:hash.:extension",
  :hash_data => ":class/:attachment/:style/:id"
validates_attachment :result, :content_type => { :content_type => /\Aimage\/.*\Z/ }

我可以在日志中看到这一行:

Command :: convert '/tmp/xxx.png[0]' -auto-orient -resize "262" '/tmp/xxx20150110-9669-z4rtiy'

尝试像这样将 -colorspace sRGB 添加到您的 convert 命令中以 强制 颜色空间:

convert input.png -resize 262 -colorspace sRGB output.png

你的命令在我的(非常当前的)ImageMagick 版本上工作正常,但如果我输入 -colorspace RGB 它也会在这里变暗。我相信默认颜色空间在最近版本的 IM 中发生了变化。