透视扭曲在Rails MiniMagick项目中不起作用

时间:2014-05-25 18:49:03

标签: ruby-on-rails imagemagick minimagick

我正在尝试将此代码用于我的rails项目,但是我收到以下错误:

image_process.html.erb:62: syntax error, unexpected tSTRING_BEG, expecting keyword_end
c.distort :Perspective "0,0 -30,20  0,200 -30,179  40...

这是我的代码:

left_piece = MiniMagick::Image.open("public/#{@asset.file_name.url}")
left_piece.crop("50x500+0+0")
left_piece.combine_options do |c|
c.alpha "set"
c.virtual_pixel "transparent"
c.distort :Perspective "0,0 -30,20  0,200 -30,179  40,200 0,200  40,0 0,0"
end

我正在尝试按照本教程创建一个3d框http://www.imagemagick.org/Usage/distorts/#perspective

不确定我做错了什么..请帮助!!

编辑:

当我尝试

c.distort :Perspective, "0,0 -30,20  0,200 -30,179  40,200 0,200  40,0 0,0"

我收到以下错误:

mogrify.exe: unable to open image `-30,20': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `-30,20' @ error/constitute.c/ReadImage/555.
mogrify.exe: unable to open image `0,200': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `0,200' @ error/constitute.c/ReadImage/555.
mogrify.exe: unable to open image `-30,179': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `-30,179' @ error/constitute.c/ReadImage/555.
mogrify.exe: unable to open image `40,200': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `40,200' @ error/constitute.c/ReadImage/555.
mogrify.exe: unable to open image `0,200': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `0,200' @ error/constitute.c/ReadImage/555.
mogrify.exe: unable to open image `40,0': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `40,0' @ error/constitute.c/ReadImage/555.
mogrify.exe: unable to open image `0,0': No such file or directory @ error/blob.c/OpenBlob/2642.
mogrify.exe: no decode delegate for this image format `0,0' @ error/constitute.c/ReadImage/555.
mogrify.exe: invalid argument for option Affine : 'require at least 1 CPs' @ error/distort.c/GenerateCoefficients/530.

1 个答案:

答案 0 :(得分:0)

如果有其他人遇到此修复程序

c.distort :Perspective "0,0,-30,20,0,200,-30,179,40,200,0,200,40,0,0,0"