【发布时间】:2014-08-22 02:28:36
【问题描述】:
我正在使用回形针上传图片。我的存储空间在 S3。我正在使用带有回形针的 Jcrop 来裁剪图像,并遵循 #RailsCast182。
一切都很顺利,我已经解决了 RailsCast 中的一些问题。
我想处理裁剪文件并将其上传到 s3。
这是我的日志,显示图像被裁剪
Command :: file -b --mime-type '/tmp/249ac5b855195d2e761e123315dd229b20140701-3395-1mz9lji'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl[0]' 2>/dev/null
Command :: identify -format %m '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl[0]'
Command :: convert '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl[0]' -crop 2586x2586+2534+0 -auto-orient -resize "100x100>" '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl20140701-3395-stdr75'
convert.im6: geometry does not contain image `/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl' @ warning/transform.c/CropImage/574.
Command :: file -b --mime '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl20140701-3395-stdr75'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl[0]' 2>/dev/null
Command :: identify -format %m '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl[0]'
Command :: convert '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl[0]' -crop 2586x2586+2534+0 -auto-orient -resize "50x50>" '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl20140701-3395-bhth1i'
convert.im6: geometry does not contain image `/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl' @ warning/transform.c/CropImage/574.
Command :: file -b --mime '/tmp/4e6c43285b27dbc35603a428c4e4ca9920140701-3395-moimyl20140701-3395-bhth1i'
After that it shows that image is uploaded at s3 but it was the same org image that uploaded.
我的依恋模型:
class Attachment < ActiveRecord::Base
has_attached_file :file, styles: { medium: "100x100>", thumb: "50x50#" }, :processors => [:cropper]
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
def cropping?
!crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
end
end
#paperclip custom cropper
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
["-crop", "#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}"]
end
end
end
end
但回形针永远不会在 S3 更改图像。
我走遍了很多环节,但没有碰过天空。
期待来自伟大社区的帮助。
问候 亚当
【问题讨论】:
标签: ruby-on-rails-3 ruby-on-rails-4 amazon-s3 paperclip jcrop