• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Text in Bild hinzufügen

dumbledore

Mitglied
Hallo ich habe hier einen Code. Dieser Code vereint zwei Bilder.
Nun will ich, dass auf diesem Bild noch ein manueller Text hinzugefügt wird.

Das hinzufügen des Textes funktioniert nicht. Das zusammenfügen des Bild schon.

Was genau mache ich falsch?

PHP:
<?php

function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){
    $cut = imagecreatetruecolor($src_w, $src_h);
    imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
    imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
    imagecopymerge($dst_im, $cut, $dst_x, $dst_y, 0, 0, $src_w, $src_h, $pct);
}

$qr = $_POST['qr'];


$image1 = imagecreatefrompng('hintergrund.png'); //300 x 300
$image2 = imagecreatefrompng($qr); //150 x 150


      // Allocate A Color For The Text
      $white = imagecolorallocate($png_image, 0, 0, 0);

      // Set Path to Font File
      $font_path = 'font.TTF';

      // Set Text to Be Printed On Image
      $text = "text12345678";

      // Print Text On Image
      imagettftext($image1, 19, 0, 5, 400, $white, $font_path, $text);


$merged_image = imagecreatetruecolor(200, 400);
imagealphablending($merged_image, false);
imagesavealpha($merged_image, true);

imagecopy($merged_image, $image1, 0, 0, 0, 0, 200, 400);
imagecopymerge_alpha($merged_image, $image2, 30, 140, 0, 0, 148, 148, 100);

header('Content-Type: image/png');
imagepng($merged_image);

?>
 
Werbung:
Werbung:
Zurück
Oben