php - Edges appear in image after resizing -



php - Edges appear in image after resizing -

i have implemented next function:

private static function generatepicture($sizekey, $src, $initialwidth, $initialheight, $imagetype) { $destination = adimage::addsizekey($sizekey, $src); if (file_exists($destination)) { return; } $finalsize = adimage::$sizes[$sizekey]; $initialratio = $initialwidth / $initialheight; $finalratio = $finalsize["w"] / $finalsize["h"]; $newimage = imagecreatetruecolor($finalsize["w"], $finalsize["h"]); imagealphablending( $newimage, false ); imagesavealpha( $newimage, true ); $oldimage = imagecreatefromstring(file_get_contents($src)); if ($initialratio >= $finalratio) { $scale = $finalsize["h"] / $initialheight; $surpluss = abs($initialwidth - ($initialheight * $finalratio)); imagecopyresized($newimage, $oldimage, 0, 0, $surpluss / 2, 0, $finalsize["w"], $finalsize["h"], $initialwidth - $surpluss, $initialheight); } else { $scale = $finalsize["w"] / $initialwidth; $surpluss = abs($initialheight - ($initialwidth / $finalratio)); imagecopyresized($newimage, $oldimage, 0, 0, 0, $surpluss / 2, $finalsize["w"], $finalsize["h"], $initialwidth, $initialheight - $surpluss); } switch ($imagetype) { case imagetype_jpeg: { imagejpeg($newimage, $destination, 100); break; } case imagetype_png: { imagepng($newimage, $destination); break; } case imagetype_gif: { imagegif($newimage, $destination); break; } default: { imagejpeg($newimage, $destination, 100); break; } } }

however, edges appear, lines not straight, if straight. believe can solve problem combination of high-pass filter, low-pass filter , salt & piper filter, not sure how implement png, jpeg , gif. start studying pattern of these files , apply filter separately. wonder if there improve solution.

i did not need image processing. using wrong function.

instead of

imagecopyresized

i utilize now

imagecopyresampled

and quality of images has improved.

php image-processing lowpass-filter highpass-filter

Comments

Popular posts from this blog

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -