1478 posts The right tools with none of the gimmicks
  • Sold between 50 000 and 100 000 dollars
  • Elite Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Bought between 10 and 49 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • United States
+1 more
PixelBin says
Edit: http://www.pastie.org/556812

I’m trying to write a resizing script. I actually wrote one that worked fine in Safari and Firefox, but IE8 failed to make it work so I had to rewrite it.

The goal of this script is to be able to resize *any image ratio (no matter how crazy) to fit into a 720 by 480 container. The whole image has to show aswell.

Right now, the code works for everything except images that are over 480px tall and ridiculously wide.

Help would be pretty freakin’ sweet. :)
A few things to note:

1. Try debugging your JS using firebug. You will find that on line 11 you have an error with image, which is undefined. The alert command is never run at this point.

2. You really should be using ’;’ at the end of your line executions. Even though they aren’t required in JS, it is bad practice and a bad idea. Javascript does some wacky things when you leave it up to itself to insert semicolons.

Like I said, try debugging your JS with firebug, I think it will help you out here :)
...Thanks. I guess I didn’t myself clear—this isn’t all of the code. This script is part of another huge script that works fine, that’s why image isn’t defined. It’s defined earlier, which is irrelevant to this script.

Anyway, I’ll just figure it out myself. Doesn’t seem like anyone here has seen an image resizing script in their lives…

Thanks for everyone’s help, I appreciate it!

That last line is a little insulting, I have built an entire image gallery manager and resizer, so I do know all about image resizing, and it really should be done on the server side anyway if you are going to be scaling a bunch of images.

Also, how are we supposed to know that is not all the code if you didn’t give it?

No matter what I still suggest you start following best coding practices and ending your line statements with ’;’

Best of luck with your script :)
I didn’t mean it in a negative way. I meant nobody understands me or what I’m trying to do so it’s best for me to just do it myself. There’s different ways to do it, so maybe that’s why it’s not familiar to you.

I didn’t show the rest of the script because it’s unnecessary and irrelevant to the actual resizing script. Of course, without the rest of the script (which is too big to copy), you won’t be able to test the resizing script.

So in a way, this whole thread was a huge failure.

Thanks for your time, Drew. :)

2541 posts
  • United States
  • Attended a Community Meetup
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
+4 more
CreatingDrew says

No worries, I think I just misunderstood you.

I think this will be hard to solve without the entire code (at least for me). If you feel like posting it, cool, if not, best of luck to you and what you are trying to accomplish :)

1478 posts The right tools with none of the gimmicks
  • Sold between 50 000 and 100 000 dollars
  • Elite Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Bought between 10 and 49 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • United States
+1 more
PixelBin says
No worries, I think I just misunderstood you. I think this will be hard to solve without the entire code (at least for me). If you feel like posting it, cool, if not, best of luck to you and what you are trying to accomplish :)
Realistically, my good is more than enough already. I was just trying to get every single possible image ratio that someone would want to resize, but I’ve spent far too much time on just 1% of my theme. Every possible type of ratio except one works, and that’s good enough. If one of my buyers requests it, then I’ll spend time but for all I know, this feature won’t even be used. It’s just an extra.
2 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
  • Indonesia
  • Referred between 1 and 9 users
QuickCodes says

Yes, there is!

Here is one of the way to declare it

if(condition) {

} else if (condition) {

} else (condition) {

}

4 posts
  • Bought between 10 and 49 items
  • Brazil
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 and 100 dollars
FelipeMarcos says

Yes, there is!

Here is one of the way to declare it

if(condition) {

} else if (condition) {

} else (condition) {

}

Look at the date

by
by
by
by
by
by