imagecreatefromstring

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

imagecreatefromstringCreate a new image from the image stream in the string

Beschreibung

imagecreatefromstring(string $data): GdImage|false

imagecreatefromstring() returns an image identifier representing the image obtained from the given data. These types will be automatically detected if your build of PHP supports them: JPEG, PNG, GIF, BMP, WBMP, GD2, and WEBP.

Parameter-Liste

data

A string containing the image data.

Rückgabewerte

An image object will be returned on success. false is returned if the image type is unsupported, the data is not in a recognised format, or the image is corrupt and cannot be loaded.

Fehler/Exceptions

imagecreatefromstring() raises an E_WARNING level error, if the data is not in a recognized format.

Changelog

Version Beschreibung
8.0.0 On success, this function returns a GDImage instance now; previously, a resource was returned.
7.3.0 WEBP is supported now (if supported by the libgd in use).

Beispiele

Beispiel #1 imagecreatefromstring() example

<?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);
    
imagedestroy($im);
}
else {
    echo 
'An error occurred.';
}
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

Output of example : imagecreatefromstring()

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Seltsames Verhalten von execute() oder Fehler meinerseits

Hello You can check below steps - Check for errors after executing the statement. Bind parameters to placeholders in the SQL query. Confirm t ...

Geschrieben von nolanmaris am 20.05.2024 12:12:16
Forum: SQL / Datenbanken
Ein Problem mit der Lampe

Yes ..i was facing the same issue .

Geschrieben von nolanmaris am 20.05.2024 12:02:55
Forum: Off-Topic Diskussionen
Hello

Hello , I am new member here. I have around 8years of experience in developing User Interfaces for Mobile/Tablet/Desktop using HTML, CSS, JavaScri ...

Geschrieben von nolanmaris am 20.05.2024 12:01:22
Forum: User stellen sich vor
Daten einer Abfrage mit Hilfe von Thumbnails nebeneinander ausgeben

Warum soll ich float meiden? Siehe https://www.linkedin.com/pulse/css-float-vs-grid-flexbox-sachin-tiwari Falls es mit Englisch nicht so klappt: ...

Geschrieben von scatello am 18.05.2024 05:57:56
Forum: PHP Developer Forum