PDA

View Full Version : if() to big resize image function...



sWo0p
December 20th, 2004, 02:53 AM
i need a resize function so i started with this.. but somehow it does'nt work.. whats wrong with this....



$imgsize = getimagesize($pieces[3]);
if($imgsize[0] < 300 || $imgsize[1] < 250) {
echo "<img src=\" ". $pieces[3] ." \" width=\85%\" height=\"85%\" hspace=\"2\" vspace=\"2\"></td>";
}else{
echo "</td>"; }
elseif($pieces[3] != '') {
echo "<img src=\" ". $pieces[3] ." \" hspace=\"2\" vspace=\"2\"></td>";
}else{
echo "</td>";
}


it must resize the $pieces[3] if its to big, if possible resize to within 300x300px... can someone help???

teiz77
December 20th, 2004, 04:04 AM
i need a resize function so i started with this.. but somehow it does'nt work.. whats wrong with this....



$imgsize = getimagesize($pieces[3]);
if($imgsize[0] < 300 || $imgsize[1] < 250) {
echo "<img src=\" ". $pieces[3] ." \" width=\85%\" height=\"85%\" hspace=\"2\" vspace=\"2\"></td>";
}else{
echo "</td>"; }
elseif($pieces[3] != '') {
echo "<img src=\" ". $pieces[3] ." \" hspace=\"2\" vspace=\"2\"></td>";
}else{
echo "</td>";
}


it must resize the $pieces[3] if its to big, if possible resize to within 300x300px... can someone help???


When you use percentages for image widths it takes the percentage of the available width. In many cases this is 85% of the width of the available screen size. In this thread is the sloution. You must hard code the size in pixels: http://www.kirupaforum.com/forums/showpost.php?p=693688&postcount=2

sWo0p
December 20th, 2004, 04:39 AM
looky looky it works :P thx :P this is what i did:



$size = getimagesize($pieces[3]);
$width = round($size[0] * 0.2);
$height= round($size[1] * 0.2);

if($pieces[3] != '') {
echo "<img src=\" ". $pieces[3] ." \" width=\"" . $width . "\" height=\"" . $height . "\" hspace=\"2\" vspace=\"2\"></td>";
}else{
echo "</td>";
}


again thx :P