1

Here is the code

  has_attached_file :image,
                        :path => ":rails_root/public/images/:id/:filename",
                        :url  => "/images/:id/:filename",
                        :styles => { :small => "300x168>", :large => "1000x560>" }

Here is my console log

Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; file -b --mime '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-1gg7ekt.png'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm.png[0]' 2>/dev/null
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; identify -format %m '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm.png[0]'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; convert '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm.png[0]' -auto-orient -resize "300x168>" '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm20150617-13080-8q41x9'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; file -b --mime '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm20150617-13080-8q41x9'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm.png[0]' 2>/dev/null
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; identify -format %m '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm.png[0]'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; convert '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm.png[0]' -auto-orient -resize "1000x560>" '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm20150617-13080-q57vxf'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; file -b --mime '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-197v1bm20150617-13080-q57vxf'
Command :: PATH=/opt/imagemagick-6.9/bin:$PATH; file -b --mime '/tmp/2251fc5821941d6bd28b2ee3cb25bf7620150617-13080-1o3we23.png'

I need to store small,large and original image to my project public directory but it store only the original

4

2 回答 2

0

检查您的图像魔法是否正确安装,因为调整大小取决于图像魔法。

一口气刷新所有定义的样式(上例中的:thumb、:small、:medium)

rake paperclip:refresh CLASS=Modelname

并且只刷新缺失的样式:样式列表将在文件“/public/system/paperclip_attachments.yml”中定义或更新</p>

rake paperclip:refresh:missing_styles

此外,如果您只想重新处理一种样式,您可以这样做:

users_to_reprocess.each do |user|
  user.image.reprocess! :small
end
于 2015-06-17T07:19:14.273 回答
0

您可以在模型中使用:stylesgem paperclip。喜欢,

has_attached_file :photo,
  :styles => {
    :thumb=> "100x100#",
    :small  => "150x150>",
    :medium => "300x300>",
    :large =>   "400x400>" }

您的照片网址将如下所示:/public/photos/(event#)/(size_name)/image_name

你必须安装ImageMagickrb-magick移植才能做到这一点。

有关更多详细信息,您可以参考此链接Upload Image using Paperclip gem

于 2015-06-17T07:46:55.443 回答