X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/a38724bea6c09b479a93948b6ef4ef61edd24f39..e75d29998f5348be83dde4b6fd8f5aa437c2dc74:/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb index 7999edb..53227b2 100644 --- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb +++ b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb @@ -7,7 +7,7 @@ module Technoweenie # :nodoc: base.send :extend, ClassMethods base.alias_method_chain :process_attachment, :processing end - + module ClassMethods # Yields a block containing an RMagick Image for the given binary data. def with_image(file, &block) @@ -35,19 +35,23 @@ module Technoweenie # :nodoc: callback_with_args :after_resize, img end if image? end - + # Performs the actual resizing operation for a thumbnail def resize_image(img, size) size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum) if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum)) size = [size, size] if size.is_a?(Fixnum) img.thumbnail!(*size) + elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75 + dimensions = size[1..size.size].split("x") + img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i) else - img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols, rows) } + img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) } end - self.temp_path = write_to_temp_file(img.to_blob) + img.strip! unless attachment_options[:keep_profile] + temp_paths.unshift write_to_temp_file(img.to_blob) end end end end -end \ No newline at end of file +end