Topic: Suggestion for small change to Foto_upload class code (Read 902 times)
Just another rainy day
Posts: 1
10 credits Members referred : 0
« on: Nov 12, 2006, 01:37:56 AM »
I have been doing some work with photo uploading and resizing using Easy PHP Upload. It has preformed exaclty as needed but I have made one modification to the source and thought I should share it with the community.
The check_dimensions function within the Foto_upload class uses a simple $x_check < $y_check to decide which side of the image should be sized down to its max setting. If an image is 1000px wide and 950px tall with max settings of 100 x 100 this works fine. It sees the image is wider than tall and sizes it down to 100px wide and 95 px tall.
The issue I have run into is that if you are working with max x and y values that are not equal this logic fails. The settings I am using are x_max at 100 and y_max at 60. If if a image happens to be 1000px wide and 950px tall, like before, the function still resizes the image to 100 x 95 leaving the y value above the set max.
The solution I am using is to choose which side to scale down to the max based on proportion: if( $this->x_max_thumb_size / $this->x_size > $this->y_max_thumb_size / $this->y_size ){ //y stuff }else{ //x stuff } So instead of whichever side is bigger it chooses whichever side has a greater gap from it's max setting
What do you think? Is this a better way to go about it? ~Corey
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6486
39748 credits Members referred : 374