6.14.47 imagecreatefromstring()Crée une image à partir d'une chaîne[ Exemples avec imagecreatefromstring ] PHP 4 >= 4.0.4, PHP 5
resource
imagecreatefromstring (
string
image
)
imagecreatefromstring
retourne un identifiant d'image
représentant l'image obtenu depuis la chaîne
image
.
Le type de l'image sera automatiquement détecté si vous avez compilé PHP avec les supports :
JPEG, PNG, GIF, WBMP et GD2.
Une ressource d'image sera retourné en cas de succès.
FALSE
est retourné si
le type de l'image n'est pas supporté, si les données ne sont pas dans un format reconnu
ou si l'image est corrompue et donc ne peut être chargée.
Exemple avec imagecreatefromstring |
<?php $data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='; $data = base64_decode($data);
$im = imagecreatefromstring($data); if ($im !== false) { header('Content-Type: image/png'); imagepng($im); } else { echo 'Une erreur est survenue.'; } ?>
|
|