Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 纸夹;处理…“的缩略图时出错。”;_Ruby On Rails_Ruby_Paperclip - Fatal编程技术网

Ruby on rails 纸夹;处理…“的缩略图时出错。”;

Ruby on rails 纸夹;处理…“的缩略图时出错。”;,ruby-on-rails,ruby,paperclip,Ruby On Rails,Ruby,Paperclip,我在Windows7上运行Ruby1.8.7和Rails2.3.5 当我在web应用程序(不是我写的)中上载图片时,我会出现以下错误: # Performs the conversion of the +file+ into a thumbnail. Returns the Tempfile # that contains the new image. def make src = @file dst = Tempfile.new([@basename, @format ? &q

我在Windows7上运行Ruby1.8.7和Rails2.3.5

当我在web应用程序(不是我写的)中上载图片时,我会出现以下错误:

    # Performs the conversion of the +file+ into a thumbnail. Returns the Tempfile
# that contains the new image.
def make
  src = @file
  dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
  dst.binmode

  begin
    parameters = []
    parameters << source_file_options
    parameters << ":source"
    parameters << transformation_command
    parameters << convert_options
    parameters << ":dest"

    parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")

    success = Paperclip.run("convert", parameters, :source => "#{File.expand_path(src.path)}[0]", :dest => File.expand_path(dst.path))
  rescue PaperclipCommandLineError => e
    raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny
  end

  dst
end
[回形针]标识-格式%wx%h“C:/Windows/Temp/stream20110104-3660-1j1ap8i-0.jpg[0]”2>NUL

[回形针]转换“C:/Windows/Temp/stream20110104-3660-1j1ap8i-0.jpg[0]”-调整“100x140>”大小C:/Windows/Temp/stream20110104-3660-1j1ap8i-02010104-3660-rmkivh-0”2>NUL

[回形针]处理时收到错误:处理回形针时出错 缩略图用于

当我在cmdshell中尝试convert命令时,它可以工作。 我将web应用程序安装到两台虚拟机和一台服务器(均为Win 7)上,结果到处都是错误

在另一台配置相同的PC上(也可以是Win7),尽管工作正常

你知道是什么导致了这个问题吗

这是缩略图.rb中产生此错误的代码:

    # Performs the conversion of the +file+ into a thumbnail. Returns the Tempfile
# that contains the new image.
def make
  src = @file
  dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
  dst.binmode

  begin
    parameters = []
    parameters << source_file_options
    parameters << ":source"
    parameters << transformation_command
    parameters << convert_options
    parameters << ":dest"

    parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")

    success = Paperclip.run("convert", parameters, :source => "#{File.expand_path(src.path)}[0]", :dest => File.expand_path(dst.path))
  rescue PaperclipCommandLineError => e
    raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny
  end

  dst
end
#将+文件+转换为缩略图。返回临时文件
#包含新图像的。
def制造
src=@file
dst=Tempfile.new([@basename,@format?”。#{@format}”:“”)
dst.binmode
开始
参数=[]

参数是否安装了ImageMagick?它是否在您的系统路径中?

是否安装了ImageMagick?它在您的系统路径中吗?

Windows有自己的
转换工具,因此需要将ImageMagick放在
路径
中比System32文件夹更高的位置

验证应用程序是否使用与其他命令行相同的
路径运行。如果您将其作为服务运行,则有可能不是

此外,请验证您是否可以手动处理生成的临时文件。在输出中没有显示故障的详细信息,它只是说它失败了


一旦发生错误,请尝试运行相同的命令。从输出来看还不清楚发生了什么。还可以查看identify是否正确识别了文件。

Windows有自己的
转换工具,因此需要将ImageMagick放在
路径
中比System32文件夹更高的位置

验证应用程序是否使用与其他命令行相同的
路径运行。如果您将其作为服务运行,则有可能不是

此外,请验证您是否可以手动处理生成的临时文件。在输出中没有显示故障的详细信息,它只是说它失败了


一旦发生错误,请尝试运行相同的命令。从输出来看还不清楚发生了什么。还可以查看identify是否正确标识了文件。

我知道这是一个旧线程,但我遇到了同样的问题。ImageMagicK已安装并正常运行,重新排列路径变量没有帮助。事实证明,我所需要做的就是关闭运行“rails服务器”的CMD shell,然后重新打开它。自从安装imagemagick和paperclip之后,我就没有这样做过。在重新初始化您使用的CMD shell之前,新的路径变量不可用。

我知道这是一个旧线程,但我遇到了同样的问题。ImageMagicK已安装并正常运行,重新排列路径变量没有帮助。事实证明,我所需要做的就是关闭运行“rails服务器”的CMD shell,然后重新打开它。自从安装imagemagick和paperclip之后,我就没有这样做过。在重新初始化您使用的CMD shell之前,新的路径变量不可用。

您可以在/config/initializers中的某个位置定义imagemagick的路径

case Config::CONFIG['host_os']
    when /darwin/   # MacOS & macports
        Paperclip.options[:command_path] = "/usr/local/bin"
    when /mswin|mingw/  # Windows
        Paperclip.options[:command_path] = "Your path "
end

您可以在/config/initializers中的某个位置定义ImageMagick的路径

case Config::CONFIG['host_os']
    when /darwin/   # MacOS & macports
        Paperclip.options[:command_path] = "/usr/local/bin"
    when /mswin|mingw/  # Windows
        Paperclip.options[:command_path] = "Your path "
end

是的,是的。我尝试了与shell中日志中相同的convert命令,效果很好。我尝试了与shell中日志中相同的convert命令,效果很好。重新排列路径条目解决了问题。非常感谢。嗯,奇怪的是,你发现这有帮助,但仍然将答案授予其他帖子:(重新排列路径条目解决了问题。非常感谢。嗯,奇怪的是,你发现这有帮助,但仍然将答案授予其他帖子:(