Module: Touchie

Defined in:
lib/touchie.rb,
lib/touchie/version.rb

Constant Summary collapse

VERSION =
"0.0.6"

Class Method Summary collapse

Class Method Details

.create_transparent_image(x, y) ⇒ Object



14
15
16
17
18
# File 'lib/touchie.rb', line 14

def self.create_transparent_image(x, y)
  Image.new(x, y) do |canvas|
    canvas.background_color= "Transparent"
  end
end

.extend_size_to_odd(image) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/touchie.rb', line 20

def self.extend_size_to_odd(image)
  x = image.columns
  y = image.rows

  x += 1 if x % 2 != 0
  y += 1 if y % 2 != 0

  base = create_transparent_image x, y
  base.composite(image, 0, 0, OverCompositeOp)
end

.find_odd_size_images(image_paths) ⇒ Object



7
8
9
10
11
12
# File 'lib/touchie.rb', line 7

def self.find_odd_size_images(image_paths)
  image_paths.map do |image_path|
    size = FastImage.size(image_path)
    image_path if !size.nil? && (size[0].odd? || size[1].odd?)
  end.reject(&:nil?)
end