2014-12-08 09:17:19 +11:00
|
|
|
module Jekyll
|
2016-09-28 04:59:24 +10:00
|
|
|
module ResponsiveImage
|
2014-12-08 09:17:19 +11:00
|
|
|
class ImageProcessor
|
2016-09-28 07:04:09 +10:00
|
|
|
def self.process(path, config)
|
|
|
|
self.new.process(path, config)
|
|
|
|
end
|
2014-12-08 09:17:19 +11:00
|
|
|
|
2016-09-28 07:04:09 +10:00
|
|
|
def process(path, config)
|
|
|
|
raise SyntaxError.new("Invalid image path specified: #{path}") unless File.file?(path)
|
2014-12-08 09:17:19 +11:00
|
|
|
|
2016-09-28 07:04:09 +10:00
|
|
|
image = Magick::Image::read(path).first
|
2014-12-08 09:17:19 +11:00
|
|
|
|
|
|
|
{
|
2016-09-28 07:04:09 +10:00
|
|
|
original: Image.new,
|
|
|
|
resized: ImageResizer.resize(image, config),
|
2014-12-08 09:17:19 +11:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|