Reply
Keeping image ratio's
Old 08-18-2007, 02:49 PM Keeping image ratio's
KkillgasmM's Avatar
Ultra Talker

Posts: 386
Name: El Phantasmo
Location: England, north west
Does anyone know the calculation to use for keeping image sizes?

Let's say I wanted to give an image a width of 300pixels, but keep the proportionate height.

I've looked at sample scripts but they all go into way too much detail, and I can't really be bothered sifting through all of the code just to see where the calculation comes in!
__________________
New Portfolio
KkillgasmM is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-19-2007, 02:45 AM Re: Keeping image ratio's
intrinzic's Avatar
Novice Talker

Posts: 6
Name: Donna Maddox
Hello, basically you need to get the maximum height since you already have the maximum width, to do this try the code below.

PHP Code:

<?php

//Get image information
$image_info getimagesize("path_to_image");

//Get original width and height of the image
list($width,$height,,,,,,) = $image_info;

// Specify the maximum width of the image
$maxwidth "300";

/* Get the percentage so we will know what to multiply to $height to get the maximum height*/
$percentage $maxwidth $width;

// Get the maximum height
$maxheight $height $percentage;

 
?>
intrinzic is offline
Reply With Quote
View Public Profile Visit intrinzic's homepage!
 
Old 08-19-2007, 08:34 AM Re: Keeping image ratio's
KkillgasmM's Avatar
Ultra Talker

Posts: 386
Name: El Phantasmo
Location: England, north west
thanks!
__________________
New Portfolio
KkillgasmM is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Keeping image ratio's
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11533 seconds with 12 queries