public function interlaceFix($file)
{
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if ($ext == 'png') {
$phpimage = imagecreatefrompng($file);
imagealphablending($phpimage, false);
imagesavealpha($phpimage, true);
if ($phpimage) {
imageinterlace($phpimage, 0);
ob_start();
imagepng($phpimage);
} else {
unset($phpimage);
}
} elseif ($ext == 'jpeg') {
$phpimage = imagecreatefromjpeg($file);
if ($phpimage) {
imageinterlace($phpimage, 0);
ob_start();
imagejpeg($phpimage);
} else {
unset($phpimage);
}
}
if (isset($phpimage)) {
imagedestroy($phpimage);
return ob_get_clean();
}
return false;
}