我在rails 3中遇到回形针问题。当我上传文件时,我的处理器抛出错误,因为imagemagick get命令:
“复合-gravity South /home/xxx/xxx/public/images/watermark.png /tmp/a s20121207-5819-1dq7y81.jpg /tmp/a s20121207-5819-1dq7y8120121207-5819-1juqw7a”
复合:无法打开图像`/tmp/a':
处理器:
def make
dst = Tempfile.new([@basename, @format].compact.join("."))
dst.binmode
if @watermark_path
command = "composite"
params = "-gravity #{@position} #{@watermark_path} #{fromfile} "
params += tofile(dst)
begin
p " >>>>>>>>>>>>>>>>> #{command} #{params}"
success = Paperclip.run(command, params)
rescue PaperclipCommandLineError
success = false
end
unless success
raise PaperclipError, "There was an error processing the watermark for #{@basename}" if @whiny
end
return dst
else
return @file
end
end
def fromfile
File.expand_path(@file.path)
end
def tofile(destination)
File.expand_path(destination.path)
end
它仅在文件名包含空格或其他非 alfanum 字符时发生。/tmp/a 应该是 /tmp/a b.jpg。
我试过http://www.davesouth.org/stories/make-url-friendly-filenames-in-paperclip-attachments等等,但处理器中的文件名仍然是错误的
有任何想法吗?或适用于这个问题的处理器?:(