Rmagick 作物奇怪的行为

发布于 2024-12-23 16:51:59 字数 903 浏览 3 评论 0原文

这是使用 Rmagick v2.13.1,在 macosx 上使用 imagemagick 的标准安装。

sudo port install tiff -macosx imagemagick +q8 +gs +wmf. 

由于某种原因,当在载波内使用 rmagick 的裁剪时。如果我对尺寸进行硬编码以进行裁剪,它就可以工作,但是如果我将它分配给变量,它就不起作用。我做错了什么?

没有任何错误消息,它只是不裁剪它。

def crop

  resize_to_limit(600,600)
  manipulate! do |img|

    print model.crop_x.to_i
    print model.crop_y.to_i
    print model.crop_w.to_i
    print model.crop_h.to_i

    x = model.crop_x.to_i
    y = model.crop_y.to_i
    width = model.crop_w.to_i
    height = model.crop_h.to_i

    print "\n"
    print "x class 1"
    print x.class

    print x,y,width,height

   # x = 205
    print "printing x class 2nd"
    print x.class
   # y = 232
   # width = 107
   # height = 107

    args = [x,y,width,height]


    img = img.crop(*args)
    print x,y,width,height
   # img.crop!(205,232,107,107)
    img
  end
end

This is using Rmagick v2.13.1 using standard install for imagemagick on macosx.

sudo port install tiff -macosx imagemagick +q8 +gs +wmf. 

For some reason when using crop from rmagick inside carrierwave. If I hard code the dimensions to crop it works, however if I assign it to variables it doesn't work. What am I doing wrong?

There is no error message whatsoever, it just doesn't crop it.

def crop

  resize_to_limit(600,600)
  manipulate! do |img|

    print model.crop_x.to_i
    print model.crop_y.to_i
    print model.crop_w.to_i
    print model.crop_h.to_i

    x = model.crop_x.to_i
    y = model.crop_y.to_i
    width = model.crop_w.to_i
    height = model.crop_h.to_i

    print "\n"
    print "x class 1"
    print x.class

    print x,y,width,height

   # x = 205
    print "printing x class 2nd"
    print x.class
   # y = 232
   # width = 107
   # height = 107

    args = [x,y,width,height]


    img = img.crop(*args)
    print x,y,width,height
   # img.crop!(205,232,107,107)
    img
  end
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文