5, December 2008

Suggestion for small change to Foto_upload class code - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: Suggestion for small change to Foto_upload class code
« previous next »
Pages: [1] Print

Author 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: Male
Posts: 6486
39748 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Nov 12, 2006, 11:04:27 AM »

Thanks Corey I will check that.


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4768
Tags : php Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: Suggestion for small change to Foto_upload class code
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Dec 05, 2008, 04:59:56 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.995
Total Topics: 7.685
Total Members: 4.467
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: jschless81

26 Guests, 4 Users online :

10 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.