0

I am trying to resize the image using javascript, but I am getting errors

 var y;
            var y = new Image();
            y.src = s;
            var wd = y.width/600;
            var ht =  y.height/600;


    if(ht>wd){
        var rw=round(wd * (1/ht));
        var hw1 = ht * (1/ht);
        var hw=round(hw1);
    } else {
        var rw1 = (wd) * (1/wd); 
        rw=round(rw1);
        hw=round(ht * (1/wd));
    }

I am getting errors saying

Message: Object expected Line: 27 Char: 2 Code: 0

Where line 27 is rw=round(rw1);

Thanks Jean

2
  • Are your images always larger than 600x600 pixels? Commented Mar 20, 2010 at 13:34
  • Yes, Would the above code not be appropriate? Commented Mar 20, 2010 at 13:39

1 Answer 1

3

The round method is not a global function, it's a method in the Math object.

Change every round in your code to Math.round.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.