Sha256: 8dd9d1dee8a5a2113aa5be053fc9968e71bf4afb1aa8904a956883afea2317c9

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

class ImageVoodoo
  java_import com.google.appengine.api.images.Image
  java_import com.google.appengine.api.images.ImagesService
  java_import com.google.appengine.api.images.ImagesServiceFactory
  java_import com.google.appengine.api.images.Transform

  ImageService = ImagesServiceFactory.images_service

  #--
  # Value Add methods for this backend
  #++

  ##
  # *GAE* Automatically adjust contrast and color levels.
  def i_am_feeling_lucky
    transform(ImagesServiceFactory.make_im_feeling_lucky)
  end

  #--
  # Implementations of standard features
  #++

  private

  def flip_horizontally_impl
    transform(ImagesServiceFactory.make_horizontal_flip)
  end
  private :flip_horizontally_impl

  def flip_vertically_impl
    transform(ImagesServiceFactory.make_vertical_flip)
  end

  def resize_impl(width, height)
    transform(ImagesServiceFactory.make_resize(width, height))
  end

  def with_crop_impl(left, top, right, bottom)
    transform(ImagesServiceFactory.make_crop(left, top, right, bottom))
  end

  def self.with_bytes_impl(bytes)
    image = ImageServicesFactory.make_image(bytes)
    ImageVoodoo.new image, image.format.to_s.upcase
  end

  def from_java_bytes
    String.from_java_bytes @src.image_data
  end

  #
  # Make a duplicate of the underlying src image
  #
  def dup_src
    ImageServicesFactory.make_image(from_java_bytes)
  end

  def transform(transform, target=dup_src)
    ImageService.apply_transform(transform, target)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
image_voodoo-0.8.7 lib/image_voodoo/gae.rb
image_voodoo-0.8.6 lib/image_voodoo/gae.rb
image_voodoo-0.8.5 lib/image_voodoo/gae.rb