<?php
void imagepalettecopy ( GdImage $dst, GdImage $src )
where,
$dst = The destination image identifier
$src = The source image identifier
?>
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
define('PGIF', 'gif/');
define('PPNG', 'png/');
/* - - - - - - - - - - - - - - - - - - - - - -
PALETTE to PALETTE IMAGE
- - - - - - - - - - - - - - - - - - - - - - */
$img_s = PGIF . "GIF 025 01.gif";
$img_d = PGIF . "GIF 025 01 bw.gif";
$img_r = PPNG . "PNG 078 01 imagepalettecopy.png";
$quality = 8;
echo $img_s; ?><br><br>
<img src="<?php echo $img_s; ?>"
alt="<?php echo $img_s; ?>"
title="<?php echo $img_s; ?>"><br><br>
<?php
echo $img_d; ?><br><br>
<img src="<?php echo $img_d; ?>"
alt="<?php echo $img_d; ?>"
title="<?php echo $img_d; ?>"><br><br><br>
<?php
$id_d = imagecreatefromgif($img_d);
$id_s = imagecreatefromgif($img_s);
imagepalettecopy($id_d, $id_s);
imagepng($id_d, $img_r, $quality, PNG_FILTER_PAETH);
?>
<?php echo $img_r; ?><br><br>
<img src="<?php echo $img_r; ?>"
alt="<?php echo $img_r; ?>"
title="<?php echo $img_r; ?>">
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$ima02a = 'png/PNG 079 02.png';
$ima02b = 'png/PNG 079 02 imagepalettecopy.png';
$id_pal02a = imagecreate(99, 48);
$id_pal02b = imagecreate(99, 48);
$white = imagecolorallocate($id_pal02a, 255, 255, 255);
$blue = imagecolorallocate($id_pal02a, 0, 0, 255);
$red = imagecolorallocate($id_pal02a, 255, 0, 0);
imagepalettecopy($id_pal02b, $id_pal02a);
imagepng($id_pal02a, $ima02a);
imagefilledrectangle($id_pal02b, 33, 0, 66, 48, $white);
imagefilledrectangle($id_pal02b, 67, 0, 100, 48, $red);
imagepng($id_pal02b, $ima02b);
?><br><br>
<?php echo basename($ima02a); ?><br><br>
<img src="<?php echo $ima02a; ?>"
alt="<?php echo $ima02a; ?>"
title="<?php echo $ima02a; ?>"><br><br>
<?php echo basename($ima02b); ?><br><br>
<img src="<?php echo $ima02b; ?>"
alt="<?php echo $ima02b; ?>"
title="<?php echo $ima02b; ?>">
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_s = "png/PNG 080 03 a.png";
// 256 COLORS
$img_d = "png/PNG 080 03 b.png";
$img_r = "png/PNG 080 03 palettecopy.png";
$quality = 8;
echo $img_s; ?><br><br>
<img src="<?php echo $img_s; ?>"
alt="<?php echo $img_s; ?>"
title="<?php echo $img_s; ?>" width="400"><br><br>
<?php
echo $img_d; ?><br><br>
<img src="<?php echo $img_d; ?>"
alt="<?php echo $img_d; ?>"
title="<?php echo $img_d; ?>" width="400"><br><br><br>
<?php
$id_s = imagecreatefrompng($img_s);
$id_d = imagecreatefrompng($img_d);
imagepalettecopy($id_d, $id_s);
imagepng($id_d, $img_r, $quality, PNG_FILTER_PAETH);
?>
<?php echo $img_r; ?><br><br>
<img src="<?php echo $img_r; ?>"
alt="<?php echo $img_r; ?>"
title="<?php echo $img_r; ?>" width="400">
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_s = "png/PNG 080 04.png";
$img_d = "gif/GIF 026 04.gif";
$img_r = "jpeg/JPEG 038 04 imagepalettecopy.jpg";
$quality = 80;
echo $img_s; ?><br><br>
<img src="<?php echo $img_s; ?>"
alt="<?php echo $img_s; ?>"
title="<?php echo $img_s; ?>"><br><br>
<?php
echo $img_d; ?><br><br>
<img src="<?php echo $img_d; ?>"
alt="<?php echo $img_d; ?>"
title="<?php echo $img_d; ?>"><br><br><br>
<?php
$id_s = imagecreatefrompng($img_s);
$id_d = imagecreatefromgif($img_d);
imagepalettecopy($id_d, $id_s);
imagejpeg($id_d, $img_r, $quality);
echo $img_r; ?><br><br>
<img src="<?php echo $img_r; ?>"
alt="<?php echo $img_r; ?>"
title="<?php echo $img_r; ?>">