تحتاج إلى أفكار لإعادة معالجة الصور باستخدام المرفقات _FU

StackOverflow https://stackoverflow.com/questions/2830564

سؤال

لقد اكتشفت خطأً في تطبيق Rails بسبب تطبيق Rails وترقيات الأحجار الكريمة والرمز غير الموثق من المطورين السابقين. لدي الكثير من الصور التي تمت معالجتها ، ولكن ليس الحجم بشكل صحيح باستخدام Attachment_FU. جميع الصور التي تم تحميلها منذ أن تحتاج إلى تغيير حجم الترقية بشكل صحيح.

هل لدى أي شخص أي أفكار لإعادة معالجة جميع الصور داخل المجلدات وتغيير حجمها إلى الأحجام الصحيحة؟ أكره أن أفعل كل هذا يدويًا.

شكرًا!! سيندي

هل كانت مفيدة؟

المحلول

يستخدم AttanceMent_FU ImageMagic ، لذلك (ربما) قمت بالفعل بتثبيته. إليك كيفية استخدامه عبر سطر الأوامر http://www.imagemagick.org/script/command-line-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

لقد وجدت هذا الجزء من الكود على gist. لقد نجحت بشكل جيد بالنسبة لي لتغيير حجم موارد actactment_fu على Amazon S3

رمز مهمة Rake على GIST

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top