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.
This functionality maybe available but I don't know how to use your class yet....Anyway
I was wondering if there is a way to use image resize when and only when the image is larger than X or larger than Y. Example:
$handle->image_ratio_x = TRUE;
$handle->image_ratio_y = TRUE;
$handle->file_max_size = (int)$ImageArr['Size']; // 1024 = 1KB
$handle->image_y = 300;
$handle->image_x = 400;
if ( $handle->image_x < $ImageW ) {
#resize image according to x ratio I think
} elseif ( $handle->image_y < $ImageY ){
#resize image according to y ratio I think
} else {
# Do nothing the images is smaller than max limits
}
Basically, it would be nice to have this built into the class I think..... You supply image max X Y and a resize only occures if the image X is larger than max X or image Y is larger than max Y or image X Y are both larger than max XY...
I hope that makes sence, I'm currently working with your vers 24Reply
2. Otherwise, you can set un maximum number of pixels, using image_ratio_pixels. So the image will be resized to approximate this maximum number of pixels.
Yes, it should be 100% backward compatible. In fact, just some marginal effects (background color for transparent images) might differ, but that is because 0.24 was buggy, and 0.25 fixes these bugs, and a large part of the image processing has been rewritten.
0.25 is Release Candidate only, so there might be issues. This said, it has been out for two weeks now, and so far there are no new bugs found, nor any reports of incompatibilities.
Upgrade to 0.25 will be encouraged; upgrade to 0.25 RC1 is suggested. I will release the proper 0.25 in one week or two.Reply
Yes, I am using PHPDocumentor, with some post-editing.
Speaking of which, I plan to add to this site a more comprehensive documentation, set of examples, etc... as well as a configuration generator. Hopefully, I will have time to complete this for the 0.25 release...Reply
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:
I was wondering if there is a way to use image resize when and only when the image is larger than X or larger than Y.
Example:
Basically, it would be nice to have this built into the class I think.....
You supply image max X Y and a resize only occures if the image X is larger than max X or image Y is larger than max Y or image X Y are both larger than max XY...
I hope that makes sence, I'm currently working with your vers 24
First, you should not have more than one image_ratio_xxxx used together. So your code:
should be:
To do what you describe, you have two possibilities:
1. Resize only if the picture is larger than the specified sizes, using image_ratio_no_zoom_in
2. Otherwise, you can set un maximum number of pixels, using image_ratio_pixels. So the image will be resized to approximate this maximum number of pixels.
0.25 is Release Candidate only, so there might be issues. This said, it has been out for two weeks now, and so far there are no new bugs found, nor any reports of incompatibilities.
Upgrade to 0.25 will be encouraged; upgrade to 0.25 RC1 is suggested. I will release the proper 0.25 in one week or two.
Are you using phpDocumenter script?
Speaking of which, I plan to add to this site a more comprehensive documentation, set of examples, etc... as well as a configuration generator. Hopefully, I will have time to complete this for the 0.25 release...
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):