Original
HTML downscale
PHP resample
PHP resize
Script used to downscale
<?php function resizeImage($mImg, $iNewWidth, $iNewHeight, $sSaveLocation) { $sImgLocation = $mImg; $bResult = true; if (getimagesize($sImgLocation) != false) { $aDimensions = getimagesize($sImgLocation); $iOriginalWidth = $aDimensions[0]; $iOriginalHeight = $aDimensions[1]; $iFileType = $aDimensions[2]; //Open the image switch ($iFileType) { case 1: $rImage = imagecreatefromgif($sImgLocation); break; case 2: $rImage = imagecreatefromjpeg($sImgLocation); break; case 3: $rImage = imagecreatefrompng($sImgLocation); break; default: $bResult = false; break; } if ($bResult) { $rNewImage = imagecreatetruecolor($iNewWidth, $iNewHeight); if ($iFileType == 1 || $iFileType == 3) { imagealphablending($rNewImage, false); imagesavealpha($rNewImage, true); $rTransparent = imagecolorallocatealpha($rNewImage, 255, 255, 255, 127); imagefilledrectangle($rNewImage, 0, 0, $iNewWidth, $iNewWidth, $rTransparent); } ///// HERE the magic happens $bResult = imagecopyresized($rNewImage, $rImage, 0, 0, 0, 0, $iNewWidth, $iNewHeight, $iOriginalWidth, $iOriginalHeight); //For resampling instead of resize, I just replaced this function if ($bResult) { switch ($iFileType) { case 1: imagegif($rNewImage, $sSaveLocation); break; case 2: imagejpeg($rNewImage, $sSaveLocation); break; case 3: imagepng($rNewImage, $sSaveLocation); break; default: $bResult = false; break; } } } } else { $bResult = false; } return $bResult; } resizeImage("500x500.png", 250,250, "250x250-downscaled-by-php-lessQ.png");