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.
Before I build the class into my website, I would like to know what happens when resizing a portrait image. Reading the documentation, it seems that any image will be resized to the value of image_x. This would mean that it gets the same width as a resized landscape picture, resulting in different formats. E.g. if image_x is 400, a landscape image of 1024x768 would be resized to 400x300, but a portait image of 768x1024 would become 400x533, where it should actually be 300x400.
Am I right here? Or are the width and height automatically swapped to give the desired result?Reply
You can set image_x and image_y at the same time, using image_ratio. The image will then be resized to fit within the two dimensions, maintaining aspect ratio and orientation.
Note that you can also use image_ratio_crop instead of image_ratio. That would then make the image to be exactly 400x400, maintaining aspect ratio, and discarding excess image. Try it to see what it does. You can also try image_ratio_fill, which is more similar to image_ratio.Reply
Before I build the class into my website, I would like to know what happens when resizing a portrait image. Reading the documentation, it seems that any image will be resized to the value of image_x. This would mean that it gets the same width as a resized landscape picture, resulting in different formats. E.g. if image_x is 400, a landscape image of 1024x768 would be resized to 400x300, but a portait image of 768x1024 would become 400x533, where it should actually be 300x400.
Am I right here? Or are the width and height automatically swapped to give the desired result?
For instance:
will resize your images so that they fit within 400x400:
See this thread or this other one which describes a more advanced method.
Note that you can also use image_ratio_crop instead of image_ratio. That would then make the image to be exactly 400x400, maintaining aspect ratio, and discarding excess image. Try it to see what it does. You can also try image_ratio_fill, which is more similar to image_ratio.