jekyll-responsive-image/lib/jekyll/responsive_image/image_processor.rb

21 lines
513 B
Ruby
Raw Normal View History

module Jekyll
module ResponsiveImage
class ImageProcessor
2016-09-28 07:04:09 +10:00
def self.process(path, config)
self.new.process(path, config)
end
2016-09-28 07:04:09 +10:00
def process(path, config)
raise SyntaxError.new("Invalid image path specified: #{path}") unless File.file?(path)
2016-09-28 07:04:09 +10:00
image = Magick::Image::read(path).first
{
2016-09-28 07:54:07 +10:00
original: Image.new(image.filename, image.columns, image.rows, config),
2016-09-28 07:04:09 +10:00
resized: ImageResizer.resize(image, config),
}
end
end
end
end