Module: Plugin::Thumbnailer

Defined in:
lib/httpthumbnailer/plugin/thumbnailer.rb

Defined Under Namespace

Modules: ImageProcessing Classes: ImageTooLargeError, InputImage, InvalidColorNameError, Service, Thumbnail, UnsupportedMediaTypeError, UnsupportedMethodError, ZeroSizedImageError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setup(app) ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/httpthumbnailer/plugin/thumbnailer.rb', line 364

def self.setup(app)
	Service.logger = app.logger_for(Service)
	InputImage.logger = app.logger_for(InputImage)
	Thumbnail.logger = app.logger_for(Thumbnail)

	@@service = Service.new(
		limit_memory: app.settings[:limit_memory],
		limit_map: app.settings[:limit_map],
		limit_disk: app.settings[:limit_disk]
	)

	@@service.processing_method('crop') do |image, width, height, options|
		image.resize_to_fill(width, height) if image.columns != width or image.rows != height
	end

	@@service.processing_method('fit') do |image, width, height, options|
		image.resize_to_fit(width, height) if image.columns != width or image.rows != height
	end

	@@service.processing_method('pad') do |image, width, height, options|
		image.resize_to_fit(width, height).replace do |resize|
			resize.render_on_background(options['background-color'], width, height)
		end if image.columns != width or image.rows != height
	end

	@@service.processing_method('limit') do |image, width, height, options|
		image.resize_to_fit(width, height) if image.columns > width or image.rows > height
	end
end

Instance Method Details

#thumbnailerObject



394
395
396
# File 'lib/httpthumbnailer/plugin/thumbnailer.rb', line 394

def thumbnailer
	@@service
end