 |
Forums |
Admin Start New Thread
By: Anmol Anand
RE: RangeError for crop function in RoR [ reply ] 2008-10-08 18:55
|
thanks Tim , I have solved my problem.
Actually , the problem was that I was scaling the picture with wrong arguments .
Thanks Tim , you have helped me always, and if you remember me, in my last thread where I had problem with read function that it not taking user input , I had mentioned that I was making a web site .
So , the website is now ready.
Url : http://www.skid.org.in
It is a website for Autistic children and can and be run by 4 buttons .
It offers various functions(which have been done by other people) such as wikipedia browsing , email etc.
I have made the crop module and also picture editing module by using Rmagick .
The picture editing module will be uploaded in 1 or 2 days , it offers flipping and floping image , bluring image , making a border and charcoal effect to the image .
Once again Thanks Tim because without your help my project of website making would not have completed .
|
By: Tim Hunter
RE: RangeError for crop function in RoR [ reply ] 2008-10-08 16:19
|
|
A C long integer can contain numbers up to 2147483647. One of your arguments exceeds this number. It seems unlikely that you want to actually crop the image using such a number for one of the dimensions. Check your arithmetic and make sure that you're passing reasonable arguments to crop.
|
By: Anmol Anand
RE: RangeError for crop function in RoR [ reply ] 2008-10-08 11:42
|
Thanks for your reply Tim .
Please if you could help me with the error and tell me that what should I do in the function so that no matter how big the number may be there is no error .
Actually, I have wriiten same functions for left, roght and bottom crop which are getting same arguments and they are working properly
I have a presentation, after two days for my site and I want to integrate the topcrop function too , please help.
Please if you tell me a way to convert the long integer in bignum .
|
By: Anmol Anand
RangeError for crop function in RoR [ reply ] 2008-10-08 05:00
|
I have written the following function in RoR for my website . The function on execution gives an error for the Rmagick crop method , the error is wriiten after the function . I am using the same function(except for the change in name, rest everything is same) for cropping from left , right and bottom and they are working fine.
All the left , right , top and bottomcrop functions are given the same arguments but in case of topcrop these give an error and rest they work fine .
FUNCTION:
def topcrop(path,cropfile,percentcrop)
path = path.chomp
cropfile = cropfile.chomp
percentcrop = (100-percentcrop.to_i)/100.0
picwidth = 640 ; #width of the pic (in pixels)
picheight = 480; #height of the pic (pixels)
widthchanged = (picwidth*percentcrop) #new width (based on the percentage specified by the user)
heightchanged = (picheight*percentcrop) #new height (based on the percentage of cropping specified by the user)
img = Magick::Image.read(path).first #reads the image specfied by the user path
img = img.scale(640,480) #scales image to 640x480
img.write"/home/anmol/image.jpg" #scales image to 640x480
img.crop(SouthEastGravity,picwidth,heightchanged).write(cropfile)
end
ERROR :
RangeError (bignum too big to convert into `long'):
/app/controllers/crop_controller.rb:98:in `crop'
/app/controllers/crop_controller.rb:98:in `topcrop'
/app/controllers/crop_controller.rb:233:in `updownevent'
/app/controllers/application.rb:74:in `up'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/bas
e.rb:1166:in `send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/bas
e.rb:1166:in `perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/fil
ters.rb:579:in `call_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/fil
ters.rb:572:in `perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/ben
chmarking.rb:68:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/ben
chmarking.rb:68:in `perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/res
cue.rb:201:in `perform_action_without_caching'
|
|
 |