public
Description: Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.
Homepage: http://wiki.github.com/Squeegy/fleximage
Clone URL: git://github.com/Squeegy/fleximage.git
Image file now has a little bit of sanitization when its uploaded.  It's 
converted to RGB and 72 dpi.

Thanks to Ezra Freedman!
Squeegy (author)
Mon Jun 02 14:27:26 -0700 2008
commit  6c6051daa04dc5b5eb419275bf33b7710c842bea
tree    f4c5ea5df59786f7f34d4178c632c4c13570d395
parent  fe563024079feda6f0406f6917cf265dd7657201
...
223
224
225
 
 
 
 
 
226
227
228
...
223
224
225
226
227
228
229
230
231
232
233
0
@@ -223,6 +223,11 @@ module Fleximage
0
             @uploaded_image = Magick::Image.from_blob(file.read).first
0
           end
0
           
0
+          # Sanitize image data
0
+          @uploaded_image.colorspace  = Magick::RGBColorspace
0
+          @uploaded_image.density     = '72'
0
+          
0
+          # Save meta data to database
0
           set_magic_attributes(file)
0
           
0
           # Success, make sure everything is valid
...
38
39
40
41
 
 
 
 
42
43
44
...
38
39
40
 
41
42
43
44
45
46
47
0
@@ -38,7 +38,10 @@ class Test::Unit::TestCase #:nodoc:
0
     
0
     when :web_photo
0
       'http://www.google.com/intl/en_ALL/images/logo.gif'
0
-      
0
+    
0
+    when :cmyk
0
+      MockFile.new("#{RAILS_ROOT}/../fixtures/cmyk.jpg")
0
+    
0
     end
0
   end
0
   
...
19
20
21
 
 
 
 
 
 
 
 
 
22
...
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -19,4 +19,13 @@ class FleximageFileUploadFromLocalTest < Test::Unit::TestCase
0
     assert_equal 1, p.errors.size
0
     assert_equal 'was not a readable image', p.errors.on(:image_file)
0
   end
0
+  
0
+  def test_should_correct_colorspace_and_dpi
0
+    p = PhotoBare.new(:image_file => files(:cmyk))
0
+    image = p.load_image
0
+    assert_equal Magick::RGBColorspace, image.colorspace
0
+    assert_equal '72x72', image.density
0
+    assert_equal 300, image.columns
0
+    assert_equal 300, image.rows
0
+  end
0
 end

Comments