Class: Utopia::Gallery::ResizeVector

Inherits:
ResizeImage show all
Defined in:
lib/utopia/gallery/process.rb

Instance Attribute Summary

Attributes inherited from ResizeImage

#method, #options, #size

Attributes inherited from Process

#name

Instance Method Summary collapse

Methods inherited from ResizeImage

#call

Methods inherited from Process

fresh?, link, mtime

Constructor Details

#initialize(*args, extension: ".png", scale: 1, **options) ⇒ ResizeVector

Returns a new instance of ResizeVector.



115
116
117
118
119
# File 'lib/utopia/gallery/process.rb', line 115

def initialize(*args, extension: ".png", scale: 1, **options)
	super(*args, **options)
	@extension = extension
	@scale = scale
end

Instance Method Details

#generate_output(resizer, output_path) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/utopia/gallery/process.rb', line 125

def generate_output(resizer, output_path)
	if output_image = resizer.send(@method, @size)
		output_image.write_to_file output_path, **@options
	else
		resizer.input_image.write_to_file output_path, **@options
	end
end

#relative_path(media) ⇒ Object



121
122
123
# File 'lib/utopia/gallery/process.rb', line 121

def relative_path(media)
	super + @extension
end

#resizer_for(media_path) ⇒ Object



133
134
135
# File 'lib/utopia/gallery/process.rb', line 133

def resizer_for(media_path)
	Vips::Thumbnail::Resizer.new(media_path, scale: @scale)
end