Commit eb83d16a by jyurek

More error checking

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@183 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent 93710de5
......@@ -314,13 +314,18 @@ module Thoughtbot #:nodoc:
def make_thumbnail attachment, orig_io, geometry
operator = geometry[-1,1]
geometry, crop_geometry = geometry_for_crop(geometry, orig_io) if operator == '#'
begin
command = "convert - -scale '#{geometry}' #{operator == '#' ? "-crop '#{crop_geometry}'" : ""} -"
ActiveRecord::Base.logger.info("Thumbnail: '#{command}'")
thumb = IO.popen(command, "w+") do |io|
orig_io.rewind
io.write(orig_io.read)
io.close_write
StringIO.new(io.read)
end
rescue SystemCallError => e
raise PaperclipError.new(attachment, "Error creating thumbnail. #{e}")
end
if ::Thoughtbot::Paperclip.options[:whiny_thumbnails]
raise PaperclipError.new(attachment, "Convert returned with result code #{$?.exitstatus}: #{thumb.read}") unless $?.success?
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment