1479 posts The right tools with none of the gimmicks
  • Has referred 50+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+6 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
  • Has referred 10+ members
  • Has sold $100+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Located in United States
+9 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 :)

1479 posts The right tools with none of the gimmicks
  • Has referred 50+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+6 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
  • Has been part of the Envato Community for over 1 year
  • Has referred 1+ members
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
QuickCodes says

Yes, there is!

Here is one of the way to declare it

if(condition) {

} else if (condition) {

} else (condition) {

}

4 posts
  • Has been part of the Envato Community for over 2 years
  • Has sold $1+ on Envato Market
  • Located in Brazil
  • Has collected 10+ items on Envato Market
+1 more
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