function resize2($filef, $new_width, $new_height, $thumb, $quality) { if ($info === false) return false; $img = null; switch($info[2]){ case IMAGETYPE_JPEG: $img = imagecreatefromjpeg($filef); break; case IMAGETYPE_GIF: $img = imagecreatefromgif($filef); break; case IMAGETYPE_PNG: $img = imagecreatefrompng($filef); break; default: return false; } $th = imagecreatetruecolor(150, 150); switch($info[2]){ case IMAGETYPE_JPEG: imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); imagejpeg($th, $filef, $quality); break; case IMAGETYPE_GIF: imagealphablending($th, true); imagetruecolortopalette($img, true, 256); imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); imagegif($th, $filef); break; case IMAGETYPE_PNG: imagealphablending($th, false); imagesavealpha($th, true); imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); imagepng($th, $filef); break; } imagedestroy($th); imagedestroy($img); return true; } if ($infoo[0]<=$infoo[1]) { $thumb_height = (150/$infoo[0])*$infoo[1]; resize2("../files/gallery/".$id."/thumb_".$file, 150, $thumb_height, "../files/gallery/".$id."/thumb_".$file, 95); } elseif ($infoo[0]>$infoo[1]) { $thumb_width=(150*$infoo[0])/$infoo[1]; resize2("../files/gallery/".$id."/thumb_".$file, $thumb_width, 150, "../files/gallery/".$id."/thumb_".$file, 95); }
Teraz chcę zrobić żeby robił to na tej samej zasadzie ale miniaturki 300x150px z tym że oczywiście powinien je obcinać proporcjonalnie. Gdy wrzucę imagecreatetruecolor(300, 150); To robi miniaturki o tej wysokości ale po prawej jest czarne tło - logiczne bo tam się kończy obrazek.
Jak to rozwiązać?