Feature #12529 ยป 39ef6a5564c6b8a8ab74ee728640f01d1fb0b56f.diff
lib/redmine/thumbnail.rb | ||
---|---|---|
31 | 31 |
unless File.exists?(directory) |
32 | 32 |
FileUtils.mkdir_p directory |
33 | 33 |
end |
34 |
size_option = "#{size}x#{size}>" |
|
35 |
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -thumbnail #{shell_quote size_option} #{shell_quote target}" |
|
36 |
unless system(cmd) |
|
37 |
logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}") |
|
38 |
return nil |
|
34 |
if Object.const_defined?(:Magick) |
|
35 |
if image = Magick::Image.read(source) |
|
36 |
image.first.thumbnail(size, size).write(target) |
|
37 |
end |
|
38 |
else |
|
39 |
size_option = "#{size}x#{size}>" |
|
40 |
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -thumbnail #{shell_quote size_option} #{shell_quote target}" |
|
41 |
unless system(cmd) |
|
42 |
logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}") |
|
43 |
return nil |
|
44 |
end |
|
39 | 45 |
end |
40 | 46 |
end |
41 | 47 |
target |
... | ... | |
43 | 49 | |
44 | 50 |
def self.convert_available? |
45 | 51 |
return @convert_available if defined?(@convert_available) |
46 |
@convert_available = system("#{shell_quote CONVERT_BIN} -version") rescue false |
|
47 |
logger.warn("Imagemagick's convert binary (#{CONVERT_BIN}) not available") unless @convert_available |
|
52 |
@convert_available = Object.const_defined?(:Magick) |
|
53 |
unless @convert_available |
|
54 |
@convert_available = system("#{shell_quote CONVERT_BIN} -version") rescue false |
|
55 |
logger.warn("Imagemagick's convert binary (#{CONVERT_BIN}) not available") unless @convert_available |
|
56 |
end |
|
48 | 57 |
@convert_available |
49 | 58 |
end |
50 | 59 |