【问题标题】:Paperclip/ImageMagick problems on WindowsWindows 上的 Paperclip/ImageMagick 问题
【发布时间】:2012-07-18 16:32:35
【问题描述】:

我设法在我的头像上实现了一个圆角后期处理。它在我的 Mac 上运行良好,但在 Windows 上没有骰子。

看起来是这样的

def self.convert_options(px = 10)
  trans = ""
  trans << " \\( +clone -alpha extract "
  trans << "-draw 'fill black polygon 0,0 0,#{px} #{px},0 fill white circle #{px},#{px} #{px},0' "
  trans << "\\( +clone -flip \\) -compose Multiply -composite "
  trans << "\\( +clone -flop \\) -compose Multiply -composite "
  trans << "\\) -alpha off -compose CopyOpacity -composite "
end

基于http://www.imagemagick.org/Usage/thumbnails/#rounded & Rounded corners with Paperclip

我开始犯的一大堆错误

convert.exe: unable to open image `\\(': No such file or directory @ error/blob.c/OpenBlob/2638.

我认为这可能与 Windows 转义字符有关?所以将 \ 更改为 ^ 但得到了这个错误

convert.exe: unable to open image `black': No such file or directory @ error/blob.c/OpenBlob/2638.

ImageMagick 正在工作,否则。它管理更简单的处理/调整大小。如果我使用 GIT BASH 将命令直接输入到 shell 中,那么该行会毫无问题地生成圆角文件。

【问题讨论】:

    标签: ruby-on-rails-3 shell imagemagick paperclip dos


    【解决方案1】:

    睡个好觉(在尝试了数千种组合之后)让我想到了这个

    def self.convert_options_win(px = 10)
      trans = " "
      trans << " ( +clone -alpha extract -draw \"fill black polygon 0,0 0,#{px} #{px},0 fill white circle #{px},#{px} #{px},0 \"  "
      trans << " ( +clone -flip ) -compose Multiply -composite  "
      trans << " ( +clone -flop ) -compose Multiply -composite ) "
      trans << " -alpha off -compose CopyOpacity -composite  "
    end
    

    效果很好。行首不需要连续字符,因为它们都被截断为单行字符串。 Windows shell 更喜欢“双引号”而不是“单引号”,所以只需要转义字符串中的那些。尝试了这么多组合,没想到这么简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-07
      • 1970-01-01
      • 2015-01-08
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      相关资源
      最近更新 更多