Class: Utopia::Tags::Gallery::Processes::Thumbnail

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/tags/gallery.rb

Direct Known Subclasses

CropThumbnail, DocumentThumbnail, PhotoThumbnail

Instance Method Summary collapse

Constructor Details

#initialize(size = [800, 800]) ⇒ Thumbnail

Returns a new instance of Thumbnail.



13
14
15
# File 'lib/utopia/tags/gallery.rb', line 13

def initialize(size = [800, 800])
	@size = size
end

Instance Method Details

#call(img) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/utopia/tags/gallery.rb', line 17

def call(img)
	# Only resize an image if it is bigger than the given size.
	if (img.columns > @size[0] || img.rows > @size[1])
		img.resize_to_fit(*@size)
	else
		img
	end
end

#default_extension(path) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/utopia/tags/gallery.rb', line 26

def default_extension(path)
	ext = path.original.extension
	
	case ext
	when /pdf/i
		return "png"
	else
		return ext.downcase
	end
end