Rmagick 作物奇怪的行为
这是使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论