Added a fallback for mini_magic + ImageMagic for platforms where it is more than difficult to compile the ImageResizer
This commit is contained in:
4
Gemfile
4
Gemfile
@@ -31,3 +31,7 @@ gem "whenever", :require => false
|
|||||||
group :development do
|
group :development do
|
||||||
gem 'pry'
|
gem 'pry'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :osx do
|
||||||
|
gem 'mini_magick'
|
||||||
|
end
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ GEM
|
|||||||
method_source (0.6.0)
|
method_source (0.6.0)
|
||||||
ruby_parser (>= 2.0.5)
|
ruby_parser (>= 2.0.5)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
|
mini_magick (3.3)
|
||||||
|
subexec (~> 0.1.0)
|
||||||
mocha (0.9.12)
|
mocha (0.9.12)
|
||||||
multi_json (1.0.3)
|
multi_json (1.0.3)
|
||||||
net-http-digest_auth (1.1.1)
|
net-http-digest_auth (1.1.1)
|
||||||
@@ -130,6 +132,7 @@ GEM
|
|||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
|
subexec (0.1.0)
|
||||||
super_exception_notifier (3.0.13)
|
super_exception_notifier (3.0.13)
|
||||||
actionmailer
|
actionmailer
|
||||||
rake
|
rake
|
||||||
@@ -165,6 +168,7 @@ DEPENDENCIES
|
|||||||
mechanize
|
mechanize
|
||||||
memcache-client
|
memcache-client
|
||||||
meta_search!
|
meta_search!
|
||||||
|
mini_magick
|
||||||
mocha
|
mocha
|
||||||
nokogiri
|
nokogiri
|
||||||
pg
|
pg
|
||||||
|
|||||||
@@ -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
|
module Danbooru
|
||||||
def resize(file_ext, read_path, write_path, output_size, output_quality)
|
def resize(file_ext, read_path, write_path, output_size, output_quality)
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user