Este es el script que modifiqué desde otros, pero surge el error en la implementación en una página real, error que no aparece cuando se prueba el script aisladamente. El problema viene por el header que no sé cómo resolver (Cannot modify header information - headers already sent by....)
Código PHP:
<?php header('Content-type: image/png');
function watermark($origen,$marca){
$estampa = imagecreatefrompng($marca);
$im = imagecreatefromjpeg($origen);
$tam_1=getimagesize($origen);
$tam_2=getimagesize($marca);
$pos_1=($tam_1[0]-$tam_2[0])/2;
$pos_2=($tam_1[1]-$tam_2[1])/2;
$márgen_dcho = $pos_1;
$márgen_inf = $pos_2;
$sx = imagesx($estampa);
$sy = imagesy($estampa);
imagecopy($im, $estampa, imagesx($im) - $sx - $márgen_dcho, imagesy($im) - $sy - $márgen_inf, 0, 0, imagesx($estampa), imagesy($estampa));
imagepng($im);
imagedestroy($im);}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body><img src="imagenes/ABCpdre025634.jpg" width="400" height="266">
<?php watermark("imagenes/ABCpdre025634.jpg","imagenes/ALOVIU.png");?>
</body>
</html>
Alguna idea para que funcione?