1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<?phpheader('Content-type: image/jpeg');
$source = imagecreatefromjpeg('test.jpg');
$largeur = imagesx($source);
$hauteur = imagesy($source); $temporaireUn = imagecreatetruecolor($largeur, 50);
$temporaireDeux = imagecreatetruecolor($largeur, 50);
$resultat = imagecreatetruecolor($largeur, $hauteur+50);
$blancUn = imagecolorallocate($resultat, 255, 255, 255);
imagefill($resultat, 1, 1, $blancUn);$blancDeux = imagecolorallocate($temporaireDeux, 255, 255, 255);
imagefill($temporaireDeux, 1, 1, $blancDeux);
imagecopy ($resultat, $source, 0, 0, 0, 0, $largeur, $hauteur);
imagecopy ($temporaireUn, $source, 0, 0, 0, $hauteur-50, $largeur, 50);
imageflip($temporaireDeux, $temporaireUn);imagecopy ($resultat, $temporaireDeux, 0, $hauteur, 0, 0, $largeur, 50); imagejpeg($resultat);imagedestroy($resultat);
function imageflip(&$dest, &$src)
{$w = imagesx($src);
$h = imagesy($src);
$alpha = 127;
for($y=0; $y<$h; $y++)
{for ($x=0; $x<$w; $x++)
{$couleur = imagecolorsforindex($src, imagecolorat($src, $x, $y));
$couleurAlpha = imagecolorallocatealpha($dest, $couleur['red'], $couleur['green'], $couleur['blue'], $alpha);
imagesetpixel($dest, $x, ($h-$y), $couleurAlpha);
}
if($alpha > 1) $alpha--; }}//*/?> |
Partager