Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Keeping image ratio's
Old 08-18-2007, 01:49 PM Keeping image ratio's
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
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!
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 08-19-2007, 01:45 AM Re: Keeping image ratio's
intrinzic's Avatar
Novice Talker

Posts: 6
Name: Donna Maddox
Trades: 0
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;

 
?>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
intrinzic is offline
Reply With Quote
View Public Profile Visit intrinzic's homepage!
 
Old 08-19-2007, 07:34 AM Re: Keeping image ratio's
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
thanks!
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Keeping image ratio's
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





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



Page generated in 0.11022 seconds with 12 queries