Class: Pixage::Convert

Inherits:
Object
  • Object
show all
Defined in:
lib/pixage/images/convert.rb

Instance Method Summary collapse

Instance Method Details

#check_sizes(images) ⇒ Object



8
9
10
11
12
# File 'lib/pixage/images/convert.rb', line 8

def check_sizes(images)
	expected = MiniMagick::Image.new(images[:expected])
	actual = MiniMagick::Image.new(images[:actual])
	expected.dimensions != actual.dimensions
end

#resize_images(images, options = {:resize => "desc", :force => "false"}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pixage/images/convert.rb', line 14

def resize_images(images,options={:resize => "desc", :force => "false"})
	expected = MiniMagick::Image.new(images[:expected])
	actual = MiniMagick::Image.new(images[:actual])
	switch = 0
	if options[:resize]=="desc"
		switch = expected.dimensions <=> actual.dimensions
	elsif options[:resize]=="asc"
		switch = actual.dimensions <=> expected.dimensions
	end

	case switch
	when 1
		if options[:force]=="true"
			expected.resize(actual.dimensions.join('x')+"!")
		else
			expected.resize(actual.dimensions.join('x'))
		end
	when -1
		if options[:force]=="true"
			actual.resize(expected.dimensions.join('x')+"!")
		else
			actual.resize(expected.dimensions.join('x'))
		end
	end
end