@@ -23,13 +23,14 module Redmine | |||||
23 | extend Redmine::Utils::Shell |
|
23 | extend Redmine::Utils::Shell | |
24 |
|
24 | |||
25 | CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze |
|
25 | CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze | |
|
26 | ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png) | |||
26 |
|
27 | |||
27 | # Generates a thumbnail for the source image to target |
|
28 | # Generates a thumbnail for the source image to target | |
28 | def self.generate(source, target, size) |
|
29 | def self.generate(source, target, size) | |
29 | return nil unless convert_available? |
|
30 | return nil unless convert_available? | |
30 | unless File.exists?(target) |
|
31 | unless File.exists?(target) | |
31 |
# Make sure we only invoke Imagemagick if th |
|
32 | # Make sure we only invoke Imagemagick if the file type is allowed | |
32 |
unless File.open(source) {|f| MimeMagic.by_magic(f).try(: |
|
33 | unless File.open(source) {|f| ALLOWED_TYPES.include? MimeMagic.by_magic(f).try(:type) } | |
33 | return nil |
|
34 | return nil | |
34 | end |
|
35 | end | |
35 | directory = File.dirname(target) |
|
36 | directory = File.dirname(target) |
General Comments 0
You need to be logged in to leave comments.
Login now