technoweenie / attachment_fu

Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
http://weblog.techno-weenie.net
MIT License
1.02k stars 337 forks source link

bug in ImageScience when it processes .gifs #15

Open palidanx opened 14 years ago

palidanx commented 14 years ago

In ImageScience, gif thumbnails are saved in png

In http://github.com/technoweenie/attachment_fu/blob/master/lib/technoweenie/attachment_fu.rb

There is a bug in line

Gets the thumbnail name for a filename. 'foo.jpg' becomes 'foo_thumbnail.jpg'

  def thumbnail_name_for(thumbnail = nil)
    return filename if thumbnail.blank?
    ext = nil
    basename = filename.gsub /.\w+$/ do |s|
      ext = s; ''
    end
    # ImageScience doesn't create gif thumbnails, only pngs
    ext.sub!(/gif$/, 'png') if attachment_options[:processor] == "ImageScience"
    "#{basename}_#{thumbnail}#{ext}"
  end

attachment_options[:processor] returns a symbol and the comparison fails

it works if you do...

ext.sub!(/gif$/, 'png') if attachment_options[:processor].to_s == "ImageScience"

palidanx commented 14 years ago

Further correction. in attachment.rb if you specify it as a symbol you get this problem only :processor => :ImageScience,