400){ $imagesr = 400 / $imagesx; } if ($imagesy * $imagesr > 100){ $imagesr = 100 / $imagesy; } if($imagesr == 1){ imagepng($imgcreate, $imgfile); imagedestroy($imgcreate); }else{ $img = imagecreatetruecolor(floor($imagesx * $imagesr), floor($imagesy * $imagesr)); imagesavealpha($img, true); imagefill($img, 1, 1, imagecolorallocatealpha($img, 255, 255, 255, 127)); imagecopyresized($img, $imgcreate, 0, 0, 0, 0, floor($imagesx * $imagesr), floor($imagesy * $imagesr), $imagesx, $imagesy); imagepng($img, $imgfile); imagedestroy($img); } readfile($imgfile); break; case 'online': case 'busy': case 'away': case 'offline': case 'media': case 'game': case 'office': if (!is_file('resources/icon/'.$sql_row['file'])){ $img = imagecreate(200, 25); imagefill($img, 1, 1, imagecolorallocate($img, 255, 255, 255)); imagestring($img, 4, 2, 5, 'Icon file not found', imagecolorallocate($img, 0, 0, 0)); imagepng($img); imagedestroy($img); die; } $imgcreate = imagecreatefrompng('resources/icon/'.$sql_row['file']); imagesavealpha($imgcreate, true); $imagesx = imagesx($imgcreate); $imagesy = imagesy($imgcreate); $imagesr = 1; if($imagesx > 400){ $imagesr = 400 / $imagesx; } if ($imagesy * $imagesr > 100){ $imagesr = 100 / $imagesy; } if($imagesr == 1){ imagepng($imgcreate, $imgfile); imagedestroy($imgcreate); }else{ $img = imagecreatetruecolor(floor($imagesx * $imagesr), floor($imagesy * $imagesr)); imagesavealpha($img, true); imagefill($img, 1, 1, imagecolorallocatealpha($img, 0, 0, 0, 127)); imagecopyresized($img, $imgcreate, 0, 0, 0, 0, floor($imagesx * $imagesr), floor($imagesy * $imagesr), $imagesx, $imagesy); imagepng($img, $imgfile); imagedestroy($img); } readfile($imgfile); break; default: $img = imagecreate(170, 25); imagefill($img, 1, 1, imagecolorallocate($img, 255, 255, 255)); imagestring($img, 5, 2, 1, 'Type not supported', imagecolorallocate($img, 0, 0, 0)); imagepng($img); imagedestroy($img); die; } } function imagettfbboxext($size, $fontfile, $text) { /*this function extends imagettfbbox and includes within the returned array the actual text width and height as well as the x and y coordinates the text should be drawn from to render correctly. This currently only works for an angle of zero and corrects the issue of hanging letters e.g. jpqg taken from http://mikeleigh.com/serendipity/index.php?/archives/20-php-function-imagettfbbox.html */ $bbox = imagettfbbox($size, 0, $fontfile, $text); //calculate x baseline if($bbox[0] >= -1) { $bbox['x'] = abs($bbox[0] + 1) * -1; } else { $bbox['x'] = abs($bbox[0] + 2); } //calculate actual text width $bbox['width'] = abs($bbox[2] - $bbox[0]); if($bbox[0] < -1) { $bbox['width'] = abs($bbox[2]) + abs($bbox[0]) - 1; } //caculate y baseline $bbox['y'] = abs($bbox[5] + 1); //calculate actaul text height $bbox['height'] = abs($bbox[7]) - abs($bbox[1]); if($bbox[3] > 0) { $bbox['height'] = abs($bbox[7] - $bbox[1]) - 1; } return $bbox; } ?>