lib/image_voodoo.rb in image_voodoo-0.8.9 vs lib/image_voodoo.rb in image_voodoo-0.9.0

- old
+ new

@@ -29,11 +29,11 @@ # === Non-block return (not image_science compatible) # # img = ImageVoodoo.with_image(ARGV[0]) # negative_img = img.negative class ImageVoodoo - attr_accessor :quality + attr_writer :quality # used by quality(value) include Java JFile = java.io.File @@ -93,24 +93,23 @@ end # Creates a square thumbnail of the image cropping the longest edge to # match the shortest edge, resizes to size, and yields/returns the new image. def cropped_thumbnail(size) - l, t, r, b = calculate_thumbnail_dimentions + l, t, r, b = calculate_thumbnail_dimensions target = with_crop(l, t, r, b).thumbnail(size) block_given? ? yield(target) : target end - def calculate_thumbnail_dimensions + private def calculate_thumbnail_dimensions half = (width - height).abs / 2 if width > height [half, 0, half + height, height] else [0, half, width, half + width] end end - private :calculate_thumbnail_dimensions # Flips the image horizontally and yields/returns the new image. def flip_horizontally target = guard { flip_horizontally_impl } block_given? ? yield(target) : target @@ -155,11 +154,11 @@ # Resizes the image to width and height and yields/returns the new image. def resize(width, height) target = guard { resize_impl(width, height) } block_given? ? yield(target) : target - rescue NativeException => ne + rescue java.lang.Exception => ne # figure out why this is here at all? raise ArgumentError, ne.message end # Rotates the image by angle (specified in degrees). def rotate(angle) @@ -225,10 +224,10 @@ # *_impl providers only need provide the implementation if it can # support it. Otherwise, this method will detect that the method is # missing. def self.guard(&block) - return block.call + block.call rescue NoMethodError => e "Unimplemented Feature: #{e}" end def guard(&block)