Project

General

Profile

Feature #12529 ยป 39ef6a5564c6b8a8ab74ee728640f01d1fb0b56f.diff

Alex Shulgin, 2012-12-06 23:55

View differences:

lib/redmine/thumbnail.rb
unless File.exists?(directory)
FileUtils.mkdir_p directory
end
size_option = "#{size}x#{size}>"
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -thumbnail #{shell_quote size_option} #{shell_quote target}"
unless system(cmd)
logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}")
return nil
if Object.const_defined?(:Magick)
if image = Magick::Image.read(source)
image.first.thumbnail(size, size).write(target)
end
else
size_option = "#{size}x#{size}>"
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -thumbnail #{shell_quote size_option} #{shell_quote target}"
unless system(cmd)
logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}")
return nil
end
end
end
target
......
def self.convert_available?
return @convert_available if defined?(@convert_available)
@convert_available = system("#{shell_quote CONVERT_BIN} -version") rescue false
logger.warn("Imagemagick's convert binary (#{CONVERT_BIN}) not available") unless @convert_available
@convert_available = Object.const_defined?(:Magick)
unless @convert_available
@convert_available = system("#{shell_quote CONVERT_BIN} -version") rescue false
logger.warn("Imagemagick's convert binary (#{CONVERT_BIN}) not available") unless @convert_available
end
@convert_available
end
    (1-1/1)