Permalink
Browse files

Cleanup and error handling

  • Loading branch information...
1 parent 5962926 commit aeab8f7cfcec4ac59bc7f09bd2503ab5d8c8abe4 @drpentode committed Feb 18, 2011
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/attachment_on_the_fly.rb
@@ -79,20 +79,27 @@ def generate_image(kind, height = 0, width = 0)
return new_path
end
+ command = ""
+
if kind == "height"
# resize_image infilename, outfilename , 0, height
command = "#{convert_command_path}convert -colorspace RGB -geometry x#{height} -quality 100 -sharpen 1 #{original} #{newfilename} 2>&1 > /dev/null"
- `#{command}`
elsif kind == "width"
# resize_image infilename, outfilename, width
command = "#{convert_command_path}convert -colorspace RGB -geometry #{width} -quality 100 -sharpen 1 #{original} #{newfilename} 2>&1 > /dev/null"
- `#{command}`
elsif kind == "both"
# resize_image infilename, outfilename, height, width
command = "#{convert_command_path}convert -colorspace RGB -geometry #{width}x#{height} -quality 100 -sharpen 1 #{original} #{newfilename} 2>&1 > /dev/null"
- `#{command}`
+ end
+
+ `#{command}`
+
+ if $? != 0
+ raise AttachmentOnTheFlyError.new("Execution of convert failed")
end
return new_path
end
end
+
+class AttachmentOnTheFlyError < StandardError; end

0 comments on commit aeab8f7

Please sign in to comment.