Il seguente codice funziona sul mio computer portatile, ma non funziona sul server remoto:Crop in cerchio (php)
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$filename = "../../content/".base64_decode($_GET["file"]);
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($ext=="jpg" || $ext=="jpeg") {
$image_s = imagecreatefromjpeg($filename);
} else if ($ext=="png") {
$image_s = imagecreatefrompng($filename);
}
$width = imagesx($image_s);
$height = imagesy($image_s);
$newwidth = 285;
$newheight = 232;
$image = imagecreatetruecolor($newwidth, $newheight);
imagealphablending($image,true);
imagecopyresampled($image,$image_s,0,0,0,0,$newwidth,$newheight,$width,$height);
// create masking
$mask = imagecreatetruecolor($width, $height);
$mask = imagecreatetruecolor($newwidth, $newheight);
$transparent = imagecolorallocate($mask, 255, 0, 0);
imagecolortransparent($mask, $transparent);
imagefilledellipse($mask, $newwidth/2, $newheight/2, $newwidth, $newheight, $transparent);
$red = imagecolorallocate($mask, 0, 0, 0);
imagecopy($image, $mask, 0, 0, 0, 0, $newwidth, $newheight);
imagecolortransparent($image, $red);
imagefill($image,0,0, $red);
// output and free memory
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
imagedestroy($mask);
?>
Essa mostra la seguente immagine sul mio portatile: http://i.stack.imgur.com/Aai1r.png
E questo è come viene mostrato sul server remoto: http://i.stack.imgur.com/77fbV.png
Cosa ne pensi? Qual è un problema?
Sul server sono presenti versioni GD diverse rispetto all'ENV locale? Questo è quasi sicuramente il problema. Potrebbe anche essere collegato alla trasparenza. – haltabush
local env ha la versione GD 2.0 e sul server 2.0.38. Entrambi supportano la trasparenza. –