public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
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
matt_a (author)
Tue Nov 27 19:13:03 -0800 2007
commit  fd18b395c904393fa433cc76473b5af0333a2efd
tree    092e5e5c0324665c8fbebf2458b401410655e70f
parent  f2e6b17f36f7f1888a1200e321041e9c608b729e
...
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
0
@@ -1,3 +1,8 @@
0
+* Nov 27, 2007 *
0
+* Handle properly ImageScience thumbnails resized from a gif file [Matt Aimonetti]
0
+* Save thumbnails file size properly when using ImageScience [Matt Aimonetti]
0
+* fixed s3 config file loading with latest versions of Rails [Matt Aimonetti]
0
+
0
 * April 2, 2007 *
0
 
0
 * don't copy the #full_filename to the default #temp_paths array if it doesn't exist
...
82
83
84
85
 
 
 
 
86
87
88
...
198
199
200
 
 
201
202
203
...
82
83
84
 
85
86
87
88
89
90
91
...
201
202
203
204
205
206
207
208
0
@@ -82,7 +82,10 @@ module Technoweenie # :nodoc:
0
             when nil
0
               processors = Technoweenie::AttachmentFu.default_processors.dup
0
               begin
0
- include Technoweenie::AttachmentFu::Processors.const_get("#{processors.first}Processor") if processors.any?
0
+ if processors.any?
0
+ attachment_options[:processor] = "#{processors.first}Processor"
0
+ include Technoweenie::AttachmentFu::Processors.const_get(attachment_options[:processor])
0
+ end
0
               rescue LoadError, MissingSourceFile
0
                 processors.shift
0
                 retry
0
@@ -198,6 +201,8 @@ module Technoweenie # :nodoc:
0
         basename = filename.gsub /\.\w+$/ do |s|
0
           ext = s; ''
0
         end
0
+ # ImageScience doesn't create gif thumbnails, only pngs
0
+ ext.sub!(/gif$/, 'png') if attachment_options[:processor] == "ImageScienceProcessor"
0
         "#{basename}_#{thumbnail}#{ext}"
0
       end
0
 
...
133
134
135
136
 
137
138
139
...
133
134
135
 
136
137
138
139
0
@@ -133,7 +133,7 @@ module Technoweenie # :nodoc:
0
 
0
           begin
0
             @@s3_config_path = base.attachment_options[:s3_config_path] || (RAILS_ROOT + '/config/amazon_s3.yml')
0
- @@s3_config = YAML.load_file(@@s3_config_path)[ENV['RAILS_ENV']].symbolize_keys
0
+ @@s3_config = @@s3_config = YAML.load_file(@@s3_config_path)[RAILS_ENV].symbolize_keys
0
           #rescue
0
           # raise ConfigFileNotFoundError.new('File %s not found' % @@s3_config_path)
0
           end
...
28
29
30
 
 
 
 
31
 
32
33
34
35
36
 
 
37
38
39
...
28
29
30
31
32
33
34
35
36
37
38
39
40
 
41
42
43
44
45
0
@@ -28,12 +28,18 @@ module Technoweenie # :nodoc:
0
           # Performs the actual resizing operation for a thumbnail
0
           def resize_image(img, size)
0
             # create a dummy temp file to write to
0
+ # ImageScience doesn't handle all gifs properly, so it converts them to
0
+ # pngs for thumbnails. It has something to do with trying to save gifs
0
+ # with a larger palette than 256 colors, which is all the gif format
0
+ # supports.
0
             filename.sub! /gif$/, 'png'
0
+ content_type.sub!(/gif$/, 'png')
0
             self.temp_path = write_to_temp_file(filename)
0
             grab_dimensions = lambda do |img|
0
               self.width = img.width if respond_to?(:width)
0
               self.height = img.height if respond_to?(:height)
0
- img.save temp_path
0
+ img.save self.temp_path
0
+ self.size = File.size(self.temp_path)
0
               callback_with_args :after_resize, img
0
             end
0
 

Comments

    No one has commented yet.