Permalink
Browse files

fixed image_science related bugs, and a s3 config file issue.

git-svn-id: http://svn.techno-weenie.net/projects/plugins/attachment_fu@3064 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information...
1 parent f2e6b17 commit fd18b395c904393fa433cc76473b5af0333a2efd matt_a committed Nov 28, 2007
View
@@ -1,3 +1,8 @@
+* Nov 27, 2007 *
+* Handle properly ImageScience thumbnails resized from a gif file [Matt Aimonetti]
+* Save thumbnails file size properly when using ImageScience [Matt Aimonetti]
+* fixed s3 config file loading with latest versions of Rails [Matt Aimonetti]
+
* April 2, 2007 *
* don't copy the #full_filename to the default #temp_paths array if it doesn't exist
@@ -82,7 +82,10 @@ def has_attachment(options = {})
when nil
processors = Technoweenie::AttachmentFu.default_processors.dup
begin
- include Technoweenie::AttachmentFu::Processors.const_get("#{processors.first}Processor") if processors.any?
+ if processors.any?
+ attachment_options[:processor] = "#{processors.first}Processor"
+ include Technoweenie::AttachmentFu::Processors.const_get(attachment_options[:processor])
+ end
rescue LoadError, MissingSourceFile
processors.shift
retry
@@ -198,6 +201,8 @@ def thumbnail_name_for(thumbnail = 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] == "ImageScienceProcessor"
"#{basename}_#{thumbnail}#{ext}"
end
@@ -133,7 +133,7 @@ def self.included(base) #:nodoc:
begin
@@s3_config_path = base.attachment_options[:s3_config_path] || (RAILS_ROOT + '/config/amazon_s3.yml')
- @@s3_config = YAML.load_file(@@s3_config_path)[ENV['RAILS_ENV']].symbolize_keys
+ @@s3_config = @@s3_config = YAML.load_file(@@s3_config_path)[RAILS_ENV].symbolize_keys
#rescue
# raise ConfigFileNotFoundError.new('File %s not found' % @@s3_config_path)
end
@@ -28,12 +28,18 @@ def process_attachment_with_processing
# Performs the actual resizing operation for a thumbnail
def resize_image(img, size)
# create a dummy temp file to write to
+ # ImageScience doesn't handle all gifs properly, so it converts them to
+ # pngs for thumbnails. It has something to do with trying to save gifs
+ # with a larger palette than 256 colors, which is all the gif format
+ # supports.
filename.sub! /gif$/, 'png'
+ content_type.sub!(/gif$/, 'png')
self.temp_path = write_to_temp_file(filename)
grab_dimensions = lambda do |img|
self.width = img.width if respond_to?(:width)
self.height = img.height if respond_to?(:height)
- img.save temp_path
+ img.save self.temp_path
+ self.size = File.size(self.temp_path)
callback_with_args :after_resize, img
end

0 comments on commit fd18b39

Please sign in to comment.