Imagemagick在Mac中没有此类文件或目录错误 [英] Imagemagick no such file or directory error in Mac

查看:204
本文介绍了Imagemagick在Mac中没有此类文件或目录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用carrierwave从我的rails应用程序上传图像,然后将该图像传递给resque以在后台调整它们的大小。图像正确上传。当resque试图调整它的大小时,mini_magick说没有这样的文件或目录

I'm using carrierwave to upload images from my rails app, and later pass that image to resque for resizing them in the background. The image gets uploaded properly. The problem when resque tries to resize it, mini_magick says that "No such file or directory"

这是我处理上传的ImageController代码

This is my ImageController code which handles the upload

#create image and embed into story
def create
    img_attr =  params[:image]
    img_attr[:media] = params[:image][:media].first if params[:image][:media].class == Array

    image = Image.new img_attr
    @story.images << image
    if @story.save
        Resque.enqueue(ImageQueue,image.id)
        respond_to do |format|
            format.json {
                render :json => [image.to_jq_upload].to_json
            }
        end
    else
        render :json => [{:error => 'custom_failure'}], :status => 304
    end

end

这是我的Resque代码

And this is my Resque code

class ImageQueue
@queue = :image_queue
def self.perform(image_id)
    image = Image.find image_id
    image.recreate_delayed_versions!
    image.save
end
end

以及上传路径设置在这里

And the upload path is set here

def store_dir
    "uploads/stories/#{model.viewable_id}/res"
end

这是我得到的错误堆栈

No such file or directory - /uploads/stories/533d5b8756617390c0070000/res/636a8fe128.jpg
/Users/skmvasu/.rvm/gems/ruby-2.0.0-p451/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `initialize'
/Users/skmvasu/.rvm/gems/ruby-2.0.0-p451/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
/Users/skmvasu/.rvm/gems/ruby-2.0.0-p451/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
/Users/skmvasu/repo/mangoweb/app/uploaders/image_uploader.rb:97:in `original_dimensions'
/Users/skmvasu/.rvm/gems/ruby-2.0.0-p451/gems/carrierwave-0.10.0/lib/carrierwave/uploader/processing.rb:84:in `block in process!'
/Users/skmvasu/.rvm/gems/ruby-2.0.0-p451/gems/carrierwave-0.10.0/lib/carrierwave/uploader/processing.rb:76:in `each'
/Users/skmvasu/.rvm/gems/ruby-2.0.0-p451/gems/carrierwave-0.10.0/lib/carrierwave/uploader/processing.rb:76:in `process!'

奇怪的是,同样的代码在我的Linux机箱中工作,我的生产盒也运行Linux,但不在我的新Mac上。这是ImageMagick的问题吗?我正在通过Homebrew安装它。我甚至尝试卸载它并使用源重新安装它,但这也不起作用。

The weird thing is the same code works in my Linux box, and my production box which also runs Linux, but not on my new Mac. Is it a problem with ImageMagick? I'm installing it through Homebrew. I even tried uninstalling it and reinstalling it with source, but that didn't work either.

我不确定我在这里做错了什么?请帮我解决这个问题。

I'm not sure what I'm doing wrong here? Please help me solve this issue.

推荐答案

根据错误,

No such file or directory - /uploads/stories/533d5b8756617390c0070000/res/636a8fe128.jpg

636a8fe128.jpg 在给定路径中不存在,即 / uploads / stories / 533d5b8756617390c0070000 / res

Either 636a8fe128.jpg is not there at the given path i.e., /uploads/stories/533d5b8756617390c0070000/res or

/ uploads / stories / 533d5b8756617390c0070000 / res 此路径中的一个或所有目录都不存在。我建议去终端并浏览路径,看看它是否允许你更改目录,直到你到达 res 目录。如果是,则在 res 目录内执行 ls -l <​​/ code>并查看输出是否显示 636a8fe128 .jpg 文件。

/uploads/stories/533d5b8756617390c0070000/res one or all of the directories in this path are not there. I would recommend go to terminal and navigate through the path and see if it allows you to change directory till you reach res directory. If yes, then inside res directory do ls -l and see if the output shows 636a8fe128.jpg file.

更新

指定完整路径包括 Rails.root

def store_dir 
  "#{Rails.root}/public/uploads/stories/#{model.viewable_id}/res" 
end

没有#{Rails.root} / public / ,生成的路径是 /uploads/stories/533d5b8756617390c0070000/res/636a8fe128.jpg 第一个 / 指向服务器的根目录。

without #{Rails.root}/public/, path generated was /uploads/stories/533d5b8756617390c0070000/res/636a8fe128.jpg where the first / points to the root directory of the server.

这篇关于Imagemagick在Mac中没有此类文件或目录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆