本文介绍了Rails - WIndows 7 carrierwave,minimagick调整大小不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用我的rails应用程序设置上传照片。但是,载波上传器不会调整正在上传的照片的大小。当我不调用resize_to_fill函数时,照片会完美上传。有什么建议吗?

I tried to set up for uploading photos with my rails app. However, the carrierwave uploader does not resize the photos being uploaded. When I do not call the resize_to_fill function, the photos are uploaded perfectly. Any advice?

当用resize_to_fill提交照片时,会返回错误未能处理。我该如何解决?

When a photo is submitted with resize_to_fill, the error 'failed to be processed' is returned. How can i fix it?

我想我需要'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''文件。

I guess I need to 'require' 'carrierwave/processing/mini_magick' for calling resize_to_fill, but i don't know where to put this file.

gemfile

carrierwave,0.4.10

mini_magick,3.2.1

rails,2.3.14

gemfile
"carrierwave", "0.4.10"
"mini_magick", "3.2.1"
"rails", "2.3.14"

平台

win7 64位

红宝石1.8.7
imagemagick(path = C:\ ImageMagick-6.7.2-Q16)

Platform
win7 64bit
ruby 1.8.7imagemagick (path = C:\ImageMagick-6.7.2-Q16)

batterhead

batterhead

感谢您的回复。下面是我的编码,请指教。

我只是想我的组合win7 + imagemagick + mini_magick + carrierwave?我猜这个问题应该很容易被很多人复制。这些版本是否彼此不兼容?

thanks for your reply. Below is my coding, please advise.
i'm just thinking does the problem come from my combination of win7 + imagemagick + mini_magick + carrierwave? such a problem should have been reproduced easily by many people, i guess. are those versions incompatible with each other?

我刚刚测试了我的应用程序,并试图再次上传照片。返回的processing_error:

无法使用MiniMagick进行操作,也许它不是图像?原始错误:命令(识别-ping C:/Users/User/mini_magick20111018-4296-f18lsi-0.jpg)失败:{:output =>'identify'\\\244 \ 243 \ 254O \ 244 \ 272 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ >
当然jpg不是在C:/ Users / User文件夹中创建的。请帮忙。

i just tested my application and tried to upload a photo again. a processing_error returned:
Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: Command ("identify -ping C:/Users/User/mini_magick20111018-4296-f18lsi-0.jpg") failed: {:output=>"'identify' \244\243\254O\244\272\263\241\251Υ~\263\241\251R\245O\241B............", :status_code=>1}
of course the jpg was not created in C:/Users/User folder. please help.

{avatar_uploader.rb}
class AvatarUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  storage :file
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  process :resize_to_fill => [320, 240]

  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

{event_photo.rb}
class EventPhoto < ActiveRecord::Base
  attr_accessible :event_id, :avatar, :created_by, :updated_by

  belongs_to:event
  mount_uploader :avatar, AvatarUploader
end

{preinitializer.rb}
begin
  require 'rubygems'
  require 'bundler'
end


推荐答案

我遇到过类似的问题,虽然不是在Windows上,但这些信息可能有所帮助。

I've run into a similar issue, though not on Windows, though this information may help.

在MiniMagick的Github页面(https://github.com/probablycorey/mini_magick/)上,似乎MiniMagik依赖于mogrify命令。

From the Github page on MiniMagick (https://github.com/probablycorey/mini_magick/), it seems that MiniMagik relies on the "mogrify" command.

我调试问题的第一步是确保在我的开发,登台和生产系统上构建了正确的库,并且mogrify命令可用。

The first step in my debugging the issue was to ensure that the correct libraries were built on my dev, staging and production systems and that the "mogrify" command was available.

为了实现这一目标,在我的OS / X系统上,我必须卸载并重新安装ImageMagik,这是我用macports做的。

To get there, on my OS/X system, I had to uninstall and reinstall ImageMagik, which I did with macports.

我使用识别文件名验证了安装,然后在Rails控制台中执行了以下操作:

I verified the installation with "identify filename" and then did the following in Rails console:

filename = '/Users/me/tmp/testfile.jpg'
image = MiniMagick::Image.open(filename)

这篇关于Rails - WIndows 7 carrierwave,minimagick调整大小不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 07:37