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

@@ -31,3 +31,7 @@ gem "whenever", :require => false
group :development do
gem 'pry'
end
group :osx do
gem 'mini_magick'
end

View File

@@ -76,6 +76,8 @@ GEM
method_source (0.6.0)
ruby_parser (>= 2.0.5)
mime-types (1.16)
mini_magick (3.3)
subexec (~> 0.1.0)
mocha (0.9.12)
multi_json (1.0.3)
net-http-digest_auth (1.1.1)
@@ -130,6 +132,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.1.0)
super_exception_notifier (3.0.13)
actionmailer
rake
@@ -165,6 +168,7 @@ DEPENDENCIES
mechanize
memcache-client
meta_search!
mini_magick
mocha
nokogiri
pg

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