一、关于styles设置,缩略图的切割策略
有两个符号,一个是‘#’,另一个是‘>’,说明如下:
[quote]trailing #, thumbnail will be centrally cropped, ensuring the requested dimensions.
trailing >, thumbnail will only be modified if it is currently larger requested dimensions. (i.e. the :small thumb for a 120×80 original image will be unchanged)[/quote]
还有其他的符号:
[url]http://www.imagemagick.org/Usage/resize/[/url]
另外如果仅仅写“120x”生成的图片会缩略成120像素宽的图,高度进行自动调整
如果写"x80"生成的图片会缩略成80像素高的图,宽度自动调整
二、批量处理图片的task任务
[quote]You can (re)generate your thumbnails en masse with Paperclip’s rake tasks. Using our example class above:
or to refresh all of your defined styles in one go (:thumb, :small, :medium from the above example)
and to refresh only missing styles:
a list of styles will be defined or updated in a file “/public/system/paperclip_attachments.yml”
If you are using the gem required version of paperclip the rake tasks may not be auto-loaded, but you can copy them into your lib/tasks directory if needed.
If you need more manual control or have a lot of thumbnails and only want to process a few, you can use #reprocess! like so:
[/quote]
有两个符号,一个是‘#’,另一个是‘>’,说明如下:
[quote]trailing #, thumbnail will be centrally cropped, ensuring the requested dimensions.
trailing >, thumbnail will only be modified if it is currently larger requested dimensions. (i.e. the :small thumb for a 120×80 original image will be unchanged)[/quote]
还有其他的符号:
[url]http://www.imagemagick.org/Usage/resize/[/url]
另外如果仅仅写“120x”生成的图片会缩略成120像素宽的图,高度进行自动调整
如果写"x80"生成的图片会缩略成80像素高的图,宽度自动调整
二、批量处理图片的task任务
[quote]You can (re)generate your thumbnails en masse with Paperclip’s rake tasks. Using our example class above:
rake paperclip:refresh:thumbnails CLASS=User
or to refresh all of your defined styles in one go (:thumb, :small, :medium from the above example)
rake paperclip:refresh CLASS=User
and to refresh only missing styles:
a list of styles will be defined or updated in a file “/public/system/paperclip_attachments.yml”
rake paperclip:refresh:missing_styles
If you are using the gem required version of paperclip the rake tasks may not be auto-loaded, but you can copy them into your lib/tasks directory if needed.
If you need more manual control or have a lot of thumbnails and only want to process a few, you can use #reprocess! like so:
users_to_reprocess.each do |user|
user.photo.reprocess!
end
[/quote]