我发现在我的Rails应用程序中的错误,由于Rails应用程序和宝石升级和无证代码从以前的开发人员。我有很多已经被处理,但使用attachment_fu不正确尺寸的图像。所有自升级需要上载的图像的被正确地调整大小。

没有任何人有任何想法重新处理所有图像的文件夹中,并将其调整到正确的尺寸?我讨厌不得不手动所有做这些。

谢谢! 辛迪

有帮助吗?

解决方案

attachment_fu使用imagemagic,所以你(可能)已经安装。以下是如何通过命令行 http://www.imagemagick.org/使用脚本/命令行-processing.php

其他提示

我有同样的问题。这是一个小方法,我写去,重新生成一大堆,包括调整到新的缩略图,并纠正等问题一样腐败父图像尺寸。

希望它能帮助! 山姆, @samotage

def self.rebuild_thumbnails
    images = UserUpload.find(:all)
    processed = 0
    not_processed = 0
    puts "---------------------------------"
    puts "rebuilding thumbnails"
    puts " "
    images.each do |image|
      this_type = image.type.to_s
      puts "processing upload: #{image.id} of type: #{this_type}"
      if image.thumbnailable?
        puts "bingo! It's thumbnailable, now rebuilding."
        image.thumbnails.each { |thumbnail| thumbnail.destroy }
        puts "Re-generating main image witdh and height"
        image.save
        puts "Regenerating thumbnails..."
        image.attachment_options[:thumbnails].each { |suffix, size| image.create_or_update_thumbnail(image.create_temp_file, suffix, *size) }
        processed += 1
        puts "Now processed #{processed} images"
        puts ""
      else
        not_processed += 1
      end
    end
    return processed
  end

我发现这个代码位上主旨。它的工作很好,我能够在亚马逊S3

调整Attachment_fu资源

上主旨 Rake任务代码

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top