2014-12-08 09:17:19 +11:00
|
|
|
module Jekyll
|
|
|
|
class ResponsiveImage
|
|
|
|
class ImageProcessor
|
|
|
|
include ResponsiveImage::Utils
|
|
|
|
|
|
|
|
def process(image_path, config)
|
2014-12-08 09:40:41 +11:00
|
|
|
raise SyntaxError.new("Invalid image path specified: #{image_path}") unless File.exists?(image_path.to_s)
|
2014-12-08 09:17:19 +11:00
|
|
|
|
|
|
|
resize_handler = ResizeHandler.new
|
|
|
|
img = Magick::Image::read(image_path).first
|
|
|
|
|
|
|
|
{
|
2015-12-28 09:41:04 +11:00
|
|
|
original: image_hash(config['base_path'], image_path, img.columns, img.rows),
|
2014-12-08 09:17:19 +11:00
|
|
|
resized: resize_handler.resize_image(img, config),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.process(image_path, config)
|
|
|
|
self.new.process(image_path, config)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|