Showing posts with label rmagick. Show all posts
Showing posts with label rmagick. Show all posts

Thursday, 9 August 2007

RMagick 2.0 beta released with memory control functions

Yesterday was announced RMagick2.0.0 beta1 release.

Among others new features I've found interesting the "new methods to help control and monitor memory usage" I'm looking forward to playing with them when I'll be back from my holiday in late august.

RMagick has been quite often considered prone to memory leaks, but it seems that memory leaks are not the actual cause of the high memory consumption of RMagick it will be interesting to see what is now available to keep under control the memory used by this amazing library.

Wednesday, 16 May 2007

attachment_fu and Rmagick FAT thumbnails

I'm using attachment_fu on the project I'm currently working on, using it to process the images the users upload.

As backend I use Rmagick, since it was already used in the same app. At some point I felt curious about the size in kb of the thumbnails generated, to estimate the increase of bandwidth the new feature would add on the server.

I quickly spotted the size of the generated jpegs was unreasonable for the pixel size of them.

It turned out that attachment_fu + Rmagick on Ubuntu 6.0.6 and Ruby 1.4 aren't compressing jpegs.

To fix here's a one line patch on attachment_fu.

this patch sets the jpeg quality to 85%


[~]$ cat atch_fu/attachment_fu_rmagick_compression.patch
Index: lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
===================================================================
--- lib/technoweenie/attachment_fu/processors/rmagick_processor.rb (revision 2864)
+++ lib/technoweenie/attachment_fu/processors/rmagick_processor.rb (working copy)
@@ -45,9 +45,9 @@
else
img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols, rows) }
end
- self.temp_path = write_to_temp_file(img.to_blob)
+ self.temp_path = write_to_temp_file(img.to_blob {self.quality = 85})
end
end
end
end
-end
\ No newline at end of file
+end