Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Easy Date   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 05-20-2004, 11:02 AM   #1 (permalink)
Contributing Member
 
ATLien's Avatar
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 2,279
iTrader: 0 / 0%
Latest Blog:
Feed has moved

ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien
PHP Image Resize Issue

[code:1:c36122c4ac]function resize($fname, $output, $max_width, $max_height, $quality = 75) {

getimagesize($fname);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}

$im = imagecreatefromjpeg($fname);
$dst = imagecreatetruecolor($tn_width,$tn_height);
imagecopyresampled($dst, $im, 0, 0, 0, 0,$tn_width,$tn_height,$width,$height);
imagejpeg($dst, $output, $quality);
imagedestroy($im);
imagedestroy($dst);
}
[/code:1:c36122c4ac]

Ok, someone gave me the above code to create a thumb. I want to know what varible I would use to echo the path to the image created in the function. Can anyone help me?
__________________
ATLien is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-20-2004, 11:39 AM   #2 (permalink)
Inactive
 
samer's Avatar
 
Join Date: 10-13-03
Location: Lebanon
Posts: 4,099
iTrader: 0 / 0%
Latest Blog:
None

samer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nicesamer is just really nice
i think its $im or $dst.. not sure though (even though i have worked with the GD library)
samer is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-03-2004, 09:01 PM   #3 (permalink)
Inactive
 
Join Date: 06-03-04
Posts: 22
iTrader: 0 / 0%
Latest Blog:
None

Trueliar is liked by many
Re: PHP Image Resize Issue

Quote:
Originally Posted by ATLien
[code:1:a430e8278f]function resize($fname, $output, $max_width, $max_height, $quality = 75) {

getimagesize($fname);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}

$im = imagecreatefromjpeg($fname);
$dst = imagecreatetruecolor($tn_width,$tn_height);
imagecopyresampled($dst, $im, 0, 0, 0, 0,$tn_width,$tn_height,$width,$height);
imagejpeg($dst, $output, $quality);
imagedestroy($im);
imagedestroy($dst);
}
[/code:1:a430e8278f]

Ok, someone gave me the above code to create a thumb. I want to know what varible I would use to echo the path to the image created in the function. Can anyone help me?
Easy thing .....

just correct the code here at the 2nd line in the function

->> getimagesize($fname);

getimagesize returns an array that is used in the rest of the function

correct ->> $size = getimagesize($fname);

it's just a mistyping error.


the output file is the 2nd argument

for ex should be used as follow:
resize("/mypath/image1.jpg","/mypath/thumbs/image1-thumb.jpg", 80,80,100);


I suggest to add some code for the proportions if you intend to have a nice looking thumb

cy
Trueliar is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to resize images x360 Web Design Lobby 12 07-07-2007 12:53 PM
Hi, can someone resize this please? louise501 Graphic Design Forum 11 11-09-2006 06:47 PM
Resize Image Please Centertainment Graphic Design Forum 8 08-31-2006 08:17 AM
How to make BckGrn image resize to browser window? seonewbee Web Design Lobby 4 07-19-2005 10:47 AM
Help, How do you get an image to resize to your specific scr Rocknrob Web Design Lobby 20 12-17-2003 10:51 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 03:11 PM.
© Copyright 2008 V7 Inc