class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I tried this and it works on most of my images, but I have one image with 1130x450 that ends up with 150x59. One way to fix this is to use a "fake" image_x really huge (12000 for instance), but I dont know if this might have an side effect. How should this be done? Do I need an "if" to test the sizes first? Thank you once again for the great class.Reply
Yes, it is normal in fact, I can confirm the behaviour.
Here is what happens: If you use image_ratio_no_zoom_in, then it takes in account image_x and image_y. Since image_x is by default set at 150 pixels, it resizes your picture so that it is not taller than 70 pixels, but also not wider than 150px.
So you have two solutions.
This one, which sets an extra large maximum width:
This is the code I'm using:
I tried this and it works on most of my images, but I have one image with 1130x450 that ends up with 150x59.
One way to fix this is to use a "fake" image_x really huge (12000 for instance), but I dont know if this might have an side effect.
How should this be done? Do I need an "if" to test the sizes first?
Thank you once again for the great class.
Here is what happens:
If you use image_ratio_no_zoom_in, then it takes in account image_x and image_y. Since image_x is by default set at 150 pixels, it resizes your picture so that it is not taller than 70 pixels, but also not wider than 150px.
So you have two solutions.
This one, which sets an extra large maximum width:
Or this one, which calculates the width (but will zoom in if the original height is less than 70px):