Hallo Community,
ich bin seit Tagen am verzweifeln, wieso der Tranparente Hintergrund bei mit am ende des Scripts schwarz wird, kann man da einer bitte helfen...
ich bin seit Tagen am verzweifeln, wieso der Tranparente Hintergrund bei mit am ende des Scripts schwarz wird, kann man da einer bitte helfen...
PHP-Code:
<?php
function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile='') {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
//$image = imagecreatefromjpeg($SourceFile);
$image = imagecreatefrompng($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$font = 'arialbd.ttf';
$font_size = 12;
imagettftext($image_p, $font_size, 0, 82, 16, $black, $font, $WaterMarkText);
if ($DestinationFile !== '') {
//imagejpeg ($image_p, $DestinationFile, 100);
imagepng ($image_p, $DestinationFile, 5);
} else {
//header('Content-Type: image/jpeg');
header('Content-Type: image/png');
//imagejpeg($image_p, null, 100);
imagepng($image_p, null, 5);
};
imagedestroy($image);
imagedestroy($image_p);
};
function watermarkImage_dt ($SourceFile_dt, $WaterMarkText_dt, $DestinationFile_dt='') {
list($width, $height) = getimagesize($SourceFile_dt);
$image_p_dt = imagecreatetruecolor($width, $height);
//$image_dt = imagecreatefromjpeg($SourceFile_dt);
$image_dt = imagecreatefrompng($SourceFile_dt);
imagecopyresampled($image_p_dt, $image_dt, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p_dt, 200, 200, 0);
$font = 'arial.ttf';
$font_size = 10;
imagettftext($image_p_dt, $font_size, 0, 94, 38, $black, $font, $WaterMarkText_dt);
if ($DestinationFile_dt !== '') {
// imagejpeg ($image_p_dt, $DestinationFile_dt, 100);
imagepng ($image_p_dt, $DestinationFile_dt, 5);
} else {
//header('Content-Type: image/jpeg');
header('Content-Type: image/png');
//imagejpeg($image_p_dt, null, 100);
imagepng($image_p_dt, null, 5);
};
imagedestroy($image_dt);
imagedestroy($image_p_dt);
};
?>
<form action='' method='post'>
Spanischer Posten: <input name='span' maxlength="21"/><br/>
Deutscher Posten: <input name='deut' maxlength="25"/>
<input type='submit' />
</form>
<?php
$span=$_POST["span"];
$deut=$_POST["deut"];
/*
$SourceFile = 'siegel_roh.jpg';
$DestinationFile = 'fertig.jpg';*/
$SourceFile = 'siegel_roh.png';
$DestinationFile = 'fertig.png';
$WaterMarkText = $span;
$SourceFile_dt = $DestinationFile;
$DestinationFile_dt = $DestinationFile;
$WaterMarkText_dt = "(".$deut.")";
watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile);
watermarkImage_dt ($SourceFile_dt, $WaterMarkText_dt, $DestinationFile_dt);
echo "fertig";
?>

Kommentar