2014-12-08 09:17:19 +11:00
|
|
|
module Jekyll
|
|
|
|
class ResponsiveImage
|
|
|
|
class ImageProcessor
|
|
|
|
include ResponsiveImage::Utils
|
|
|
|
|
2016-09-26 06:23:47 +10:00
|
|
|
def process(absolute_image_path, relative_image_path, config)
|
|
|
|
raise SyntaxError.new("Invalid image path specified: #{absolute_image_path}") unless File.file?(absolute_image_path)
|
2014-12-08 09:17:19 +11:00
|
|
|
|
|
|
|
resize_handler = ResizeHandler.new
|
2016-09-26 06:23:47 +10:00
|
|
|
img = Magick::Image::read(absolute_image_path).first
|
2014-12-08 09:17:19 +11:00
|
|
|
|
|
|
|
{
|
2016-09-26 06:23:47 +10:00
|
|
|
original: image_hash(config['base_path'], relative_image_path, img.columns, img.rows),
|
2014-12-08 09:17:19 +11:00
|
|
|
resized: resize_handler.resize_image(img, config),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2016-09-26 06:23:47 +10:00
|
|
|
def self.process(absolute_image_path, relative_image_path, config)
|
|
|
|
self.new.process(absolute_image_path, relative_image_path, config)
|
2014-12-08 09:17:19 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|