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.
Hi, I'm having trouble with resizing. I want to make sure uploaded images do not exceed 600px wide, but I don't want to convert smaller images to 600px.
I tried image_ratio_no_zoom_in = true but it doesn't seem to be working, I still end up with a 600px image if its smaller. Here's the relevant (I think) portion of the code:
Your Class is short of complete because of the following reasons
1) cant upload animated gifs
2) Sizing concerns when it cannot get the width and height prior to processing...
Many users like resizing their uploads where they constrain by either X or Y axis then apply the x or y image_ratio_ <- this logic is flawed.
Now here is the BIG@#$ problem:
Assume users would occasionally upload a portrait and occasionally a landscape image.
Dilemma: if he sets the x to fixed value and leave y auto ratio, THEN the user will have problems when he uploads a portrait oriented image because all the portraits will appear significantly larger than the landscapes
Example A: Original file X=800 Y=600 (Landscape) Constrain X to 400, Y to auto Uploads and processed to X=400 Y=auto (which is 300) Total pixels = 400X300=120,000
Example B: Original file X=600 Y=800 (Portrait) Constrain X to 400, Y to auto (Same rule as above) Uploads and processed to X=400 Y=auto (which is 534) Total pixels = 400X534=213,600!!!!!
BUT then we have image_ratio_pixels right? just set -> image_ratio_pixels=120000 problem solved?
Wrong then comes the problem when we have images that are smaller and we do now wish to scale due to loss of image quality, so u say just use -> image_ratio_no_zoom_in
BUT then you say "You can use only one of the image_ratio_* setting at the same time. "
Animated GIFs would require a complete rewrite of the class, as previously stated in the forum.
It is true that image_ratio_no_zoom_in and image_ratio_no_zoom_out are a problem since they cannot be used with other image_ratio_* settings. This will be fixed in a future version.
For the rest, I disagree. You can set image_x, image_y and image_ratio to constraint your image in set dimensions. Or you can use image_ratio_fill or image_ratio_crop to fit perfectly in these dimensions.
But also, before calling process(), you can can read image_src_x and image_src_y to accordingly set your settings. Basically, you can do your own logic before calling process, rather than having the class trying to work some magic which would likely not fit with everybody.
when u said image_scr_x and i looked up i found image_src_pixels which is even better.... now it works perfectly, i can determine if the uploaded file was bigger than the system constrain or not. if it is, use the constrain if not, use the original size. perfect, now all it needs is the ability to upload animated gifs.
next time just say so! image_src_pixels is the answer to many or our problems duh!Reply
I tried image_ratio_no_zoom_in = true but it doesn't seem to be working, I still end up with a 600px image if its smaller. Here's the relevant (I think) portion of the code:
You should do the following:
1) cant upload animated gifs
2) Sizing concerns when it cannot get the width and height prior to processing...
Many users like resizing their uploads where they constrain by either X or Y axis then apply the x or y image_ratio_ <- this logic is flawed.
Now here is the BIG@#$ problem:
Assume users would occasionally upload a portrait and occasionally a landscape image.
Dilemma: if he sets the x to fixed value and leave y auto ratio,
THEN the user will have problems when he uploads a portrait oriented image because all the portraits will appear significantly larger than the landscapes
Example A: Original file X=800 Y=600 (Landscape)
Constrain X to 400, Y to auto
Uploads and processed to X=400 Y=auto (which is 300)
Total pixels = 400X300=120,000
Example B: Original file X=600 Y=800 (Portrait)
Constrain X to 400, Y to auto (Same rule as above)
Uploads and processed to X=400 Y=auto (which is 534)
Total pixels = 400X534=213,600!!!!!
BUT then we have image_ratio_pixels right?
just set -> image_ratio_pixels=120000 problem solved?
Wrong then comes the problem when we have images that are smaller and we do now wish to scale due to loss of image quality, so u say just use -> image_ratio_no_zoom_in
BUT then you say "You can use only one of the image_ratio_* setting at the same time. "
Then we are just back to SQUARE ONE!
It is true that image_ratio_no_zoom_in and image_ratio_no_zoom_out are a problem since they cannot be used with other image_ratio_* settings. This will be fixed in a future version.
For the rest, I disagree. You can set image_x, image_y and image_ratio to constraint your image in set dimensions. Or you can use image_ratio_fill or image_ratio_crop to fit perfectly in these dimensions.
But also, before calling process(), you can can read image_src_x and image_src_y to accordingly set your settings. Basically, you can do your own logic before calling process, rather than having the class trying to work some magic which would likely not fit with everybody.
Does it answer your points?
next time just say so! image_src_pixels is the answer to many or our problems duh!