回形针没有正确调整尺寸

问题描述:

我对我的应用使用回形针,图像不符合我设置的尺寸。我使用回形针和rmagick并安装了ImageMagik。当我跑到哪里转换回形针没有正确调整尺寸

C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe 
C:\Windows\System32\convert.exe 

Development.rb

Paperclip.options[:command_path] = "C:/Program Files/ImageMagick-6.8.9-Q16/convert.exe" 

的Gemfile

gem 'paperclip' 
gem 'rmagick', '~> 2.13.2', :platforms => :ruby 

User.rb

has_attached_file :avatar, styles: { medium: '210x260>', larger: "300x300>", thumb: "100x100>" }, default_url: "/assets/default.png" 
validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"] 

视图

<%= image_tag @user.avatar(**style**) %> 

我以不同的大小在两个不同的图像测试它,A(原:960x688)和B(最初:160x160的)

A(:拇指)变为100x72

B( :拇指)变为100×100

A(:介质)变为210x151

B(:介质)变为160×160

A(:大)成为300x300的

B(:大)成为300x300的

我试着重新上传图片后,我改变大小,但得到相同的结果。那么,回形针有不同大小的图像有问题,或者我的代码有问题吗?

+1

尝试把一个#上,而不是一个> – Richlewis 2014-10-08 22:14:28

+0

该固定他们到底d再处理,将被调整,但我不得不上传的图片再次每次我改变了风格的时间。如果我必须改变其他地方的风格,我是否需要继续上传图像? – teddybear 2014-10-08 22:28:13

你需要你的尺寸大小后更改尾随字符,所以你的情况,你需要

medium: 210x260# 

的文件中明确规定

Default behavior is to resize the image and maintain aspect ratio (i.e. the :medium version of a 300×150 image will be 200×100). Some commonly used options are: 

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) 

对于当前的图像您可以在此控制台

Image.all.each {|s| s.image.reprocess! } 

之后,您上传的任何其他图片将不会被要求根据您的需要

希望帮助