我正在尝试在Rails应用程序中实现Cropping功能。基本上我跟随railscast。 但是当它尝试裁剪图像时,请在控制台中查看。
Command :: file -b --mime '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-dffwla.jpg'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp.jpg[0]' 2>/dev/null
Command :: identify -format %m '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp.jpg[0]'
Command :: convert '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp.jpg[0]' -crop '300 x 300 + 200 + 31 '-auto-orient -resize "500x500>" '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp20150505-19502-bwuuga'
convert: InvalidArgument `-crop': 300 x 300 + 200 + 31 -auto-orient @ error/convert.c/ConvertImageCommand/1083.
[paperclip] An error was received while processing: #<Paperclip::Error: There was an error processing the thumbnail for 98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp>
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp.jpg[0]' 2>/dev/null
Command :: identify -format %m '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp.jpg[0]'
Command :: convert '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp.jpg[0]' -crop '300 x 300 + 200 + 31 '-auto-orient -resize "100x100>" '/var/folders/rc/y5p0pv054xb20rtgwhzx5pzc0000gn/T/98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp20150505-19502-8qahjf'
convert: InvalidArgument `-crop': 300 x 300 + 200 + 31 -auto-orient @ error/convert.c/ConvertImageCommand/1083.
[paperclip] An error was received while processing: #<Paperclip::Error: There was an error processing the thumbnail for 98fc51f68e50c6db6eb4594f625b4b7a20150505-19502-qz95yp>
这里的相关代码是:
# -*- coding: utf-8 -*-
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
r = super
if r.class == Array
r = r.join(' ')
end
crop_command + r.sub(/ -crop \S+/, '')
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
y = target.crop_y.to_i
x = target.crop_x.to_i
w = target.crop_w.to_i
h = target.crop_h.to_i
" -crop \"#{w}x#{h}+#{x}+#{y}\""
end
end
end
end
我注意到如果我在这一行的末尾插入一个空格:
&#34; -crop \&#34;#{w} x#{h} +#{x} +#{y} \&#34;&#34;
以无限循环输入的代码。然后,如果我停止服务器并访问该页面,我会看到图像被裁剪。
我搜索了这个并找到了一些有类似问题的人。所以我看看我的crop command
方法。我尝试了很多形式的格式&#39; crop
命令,但没有成功。
这里的任何帮助都会很棒。
由于