Transparentes PNG mit PHP
Hier erfahren sie wie man mit PHP ein transparentes PNG erzeugen kann.
Man kann mit PHP auch transparente PNG Dateien erstellen, dazu verwenden wir folgenden Code:
- <?php
-
- $img = imagecreate(500, 500);
-
- $color['lime'] = imagecolorallocate($img, 0x00, 0xFF, 0x00);
-
- $color['black'] = imagecolorallocate($img, 0x00, 0x00, 0x00);
-
- imagestring($img, 2, 25, 25, "Dieser Text steht auf einen transparenten PNG ...", $color['black']);
-
- imagecolortransparent($img, $color['lime']);
-
- header("Content-type: image/png");
- imagepng($img);
- imagedestory($img);
- ?>
Erzeugt wird hier ein 500x500 Pixel großes PNG mit transparentem Hintergrund und dem Text "Dieser Text steht auf einen transparenten PNG ..." darauf.