andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Resize to px within limits?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Drop Shadowed Thumbnail Creator
View previous topic :: View next topic  
Author Message
Thildemar
Newbie


Joined: 05 Oct 2005
Posts: 1

PostPosted: Wed Oct 05, 2005 1:52 am    Post subject: Resize to px within limits? Reply with quote

Just got your script working wonderfully, but would like one more feature...

I would like an image to resize to a max of X pixels.

Right now if I say to resize to 0, 150 a wide image can be huge and if I say resize to 150,150 it distorts. So basically I am looking for a way to make an image scale to fit in a box that is x,y pixels. I think this should be able to be done with a couple if statements to control the if the image scales x or y dependant on which is larger, I just don't know how to add them in.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Oct 24, 2005 5:45 am    Post subject: Reply with quote

Hi, and welcome to the board.

You want to do something like this:

PHP:
<?php $size getimagesize('picture.jpg');
if (
$size[0] > $size[1]) {
    
$ds->resizeToSize(1500);
} else {
    
$ds->resizeToSize(0150);
?>


Using a '0' as one of the parameters will keep that dimension proportional to the one you give a value for.

See this thread for more info:

http://php.amnuts.com/forums/viewtopic.php?t=106

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Drop Shadowed Thumbnail Creator All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group