Added a fallback for mini_magic + ImageMagic for platforms where it is more than difficult to compile the ImageResizer

This commit is contained in:
Robin Liao
2011-09-03 00:26:28 -07:00
parent 31863738c1
commit 8f4720b1d8
4 changed files with 24 additions and 1 deletions

View File

@@ -1,4 +1,8 @@
require 'danbooru_image_resizer/danbooru_image_resizer.so'
begin
require 'danbooru_image_resizer/danbooru_image_resizer.so'
rescue LoadError
require 'danbooru_image_resizer/danbooru_image_resizer_fallback'
end
module Danbooru
def resize(file_ext, read_path, write_path, output_size, output_quality)

View File

@@ -0,0 +1,11 @@
module Danbooru
def resize_image(extension, original_path, destination_path, width, height, quality)
require 'mini_magick'
image = MiniMagick::Image.open(original_path)
image.resize "#{width}x#{height}"
image.format extension
image.write destination_path
end
module_function :resize_image
end