【问题标题】:Perspective distort not working in Rails MiniMagick project透视扭曲在 Rails MiniMagick 项目中不起作用
【发布时间】:2014-05-27 00:12:09
【问题描述】:

我正在尝试让此代码在我的 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.

【问题讨论】:

  • 尝试在:Perspective 后面加一个逗号。如:c.distort :Perspective, "0,0 -30,20 0,200 -30,179 40,200 0,200 40,0 0,0"
  • 查看编辑后的帖子,了解我在输入逗号时遇到的错误

标签: ruby-on-rails imagemagick minimagick


【解决方案1】:

万一其他人遇到这个问题,修复是

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 2018-10-16
    • 1970-01-01
    相关资源
    最近更新 更多