Class: AppEngine::Images::Image
- Inherits:
-
Object
- Object
- AppEngine::Images::Image
- Defined in:
- lib/appengine-apis/images.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply_transform(transform) ⇒ Object
- #crop(leftX, topY, rightX, bottomY) ⇒ Object
- #crop!(leftX, topY, rightX, bottomY) ⇒ Object
- #data ⇒ Object (also: #to_s)
- #deep_transform(transform) ⇒ Object
- #flip(direction = :horizontal) ⇒ Object
- #flip!(direction) ⇒ Object
- #height ⇒ Object
- #i_feel_lucky ⇒ Object
- #i_feel_lucky! ⇒ Object
-
#initialize(data) ⇒ Image
constructor
A new instance of Image.
- #resize(width, height) ⇒ Object
- #resize!(width, height) ⇒ Object
- #rotate(degree) ⇒ Object
- #rotate!(degree) ⇒ Object
- #width ⇒ Object
Constructor Details
Class Method Details
.open(filename) ⇒ Object
156 157 158 159 160 |
# File 'lib/appengine-apis/images.rb', line 156 def self.open(filename) File.open(filename) do |file| return new(file.read) end end |
Instance Method Details
#apply_transform(transform) ⇒ Object
174 175 176 |
# File 'lib/appengine-apis/images.rb', line 174 def apply_transform(transform) Image.new(data).deep_transform(transform) end |
#crop(leftX, topY, rightX, bottomY) ⇒ Object
213 214 215 |
# File 'lib/appengine-apis/images.rb', line 213 def crop(leftX, topY, rightX, bottomY) apply_transform IS::ImagesServiceFactory.make_crop(leftX, topY, rightX, bottomY) end |
#crop!(leftX, topY, rightX, bottomY) ⇒ Object
217 218 219 |
# File 'lib/appengine-apis/images.rb', line 217 def crop!(leftX, topY, rightX, bottomY) @image = crop(leftX, topY, rightX, bottomY) end |
#data ⇒ Object Also known as: to_s
229 230 231 |
# File 'lib/appengine-apis/images.rb', line 229 def data String.from_java_bytes @image.image_data end |
#deep_transform(transform) ⇒ Object
178 179 180 181 |
# File 'lib/appengine-apis/images.rb', line 178 def deep_transform(transform) IS::Service.apply_transform(transform, @image) self end |
#flip(direction = :horizontal) ⇒ Object
199 200 201 202 203 204 205 206 207 |
# File 'lib/appengine-apis/images.rb', line 199 def flip(direction = :horizontal) if direction.to_sym == :horizontal return apply_transform IS::ImagesServiceFactory.make_horizontal_flip elsif direction.to_sym == :vertical return apply_transform IS::ImagesServiceFactory.make_vertical_flip else raise ArgumentError, 'Direction must be :horizontal or :vertical' end end |
#flip!(direction) ⇒ Object
209 210 211 |
# File 'lib/appengine-apis/images.rb', line 209 def flip!(direction) @image = flip(direction) end |
#height ⇒ Object
162 163 164 |
# File 'lib/appengine-apis/images.rb', line 162 def height @image.getHeight end |
#i_feel_lucky ⇒ Object
221 222 223 |
# File 'lib/appengine-apis/images.rb', line 221 def i_feel_lucky apply_transform IS::ImagesServiceFactory.make_im_feeling_lucky end |
#i_feel_lucky! ⇒ Object
225 226 227 |
# File 'lib/appengine-apis/images.rb', line 225 def i_feel_lucky! @image = i_feel_lucky end |
#resize(width, height) ⇒ Object
183 184 185 |
# File 'lib/appengine-apis/images.rb', line 183 def resize(width, height) apply_transform IS::ImagesServiceFactory.make_resize(width, height) end |
#resize!(width, height) ⇒ Object
187 188 189 |
# File 'lib/appengine-apis/images.rb', line 187 def resize!(width, height) @image = resize(width, height) end |
#rotate(degree) ⇒ Object
191 192 193 |
# File 'lib/appengine-apis/images.rb', line 191 def rotate(degree) apply_transform IS::ImagesServiceFactory.make_rotate(degree) end |
#rotate!(degree) ⇒ Object
195 196 197 |
# File 'lib/appengine-apis/images.rb', line 195 def rotate!(degree) @image = rotate(degree) end |
#width ⇒ Object
166 167 168 |
# File 'lib/appengine-apis/images.rb', line 166 def width @image.getWidth end |