Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FloatDomainError (Infinity)

I use carrierwave and mini_magick to upload images. In development everything is fine, but in production it raises FloatDomainError (Infinity) when i try to upload an image. I have several projects hosted at the same server and everything is fine with uploading. I use Rails 3.0.10. Any ideas how can i fix it? Thanks

like image 274
Sergey Kishenin Avatar asked Aug 30 '11 03:08

Sergey Kishenin


3 Answers

I had the same problem. The problem is mini_magick. If the image file it runs identify on is erroneous, identify will output some kind of error, e.g.

identify: Corrupt JPEG data: 7929 extraneous bytes before marker 0xed `image.jpg' @ warning/jpeg.c/EmitMessage/230.
11811 8665

mini_magick tries to parse the error message as the dimension, and the result is 0. This results in a division by zero which results in the exception you mentioned. This is the reason why it only fails with some images.

identify has a -quiet options to turn off these warning messages. I have forked mini_magick at https://github.com/fschwahn/mini_magick and added the quiet option. I hope this change will be pulled in (or the problem will be fixed in a more elegant way). However, for now you can use my fork by adding the following to your Gemfile:

gem 'mini_magick', :git => 'git://github.com/fschwahn/mini_magick.git'
like image 57
fabi Avatar answered Oct 21 '22 03:10

fabi


Fixed that with replacing resize_and_fill to resize_and_pad. Still don't understand its strange behavior.

like image 32
Sergey Kishenin Avatar answered Oct 21 '22 04:10

Sergey Kishenin


I was using the Ubuntu Imagemagick package version 6.7. I upgraded to 6.8 following the instructions here: https://askubuntu.com/questions/267746/how-can-i-install-the-latest-upstream-version-of-imagemagick-without-compiling and it worked.

like image 30
joslinm Avatar answered Oct 21 '22 03:10

joslinm