Sha256: 81d0f603a380c473fcbd7519d7ffc6ea95b6603652a77b8d5bd5732bc5a5762e

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 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

  def i_am_feeling_lucky
    transform(ImagesServiceFactory.make_im_feeling_lucky)
  end

  # Implementations of standard features

  def flip_horizontally_impl
    transform(ImagesServiceFactory.make_horizontal_flip)
  end

  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)
    ImageVoodoo.new ImageServicesFactory.make_image(bytes)
  end

  private

  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

2 entries across 2 versions & 1 rubygems

Version Path
image_voodoo-0.7 lib/image_voodoo/gae.rb
image_voodoo-0.6 lib/image_voodoo/gae.rb