Ich habe ein Skript, mit dem ein echtes Farbbild erstellt wurde.Mein PHP kann kein echtes Farbbild erstellen
Aber nach dem Ändern des Servers zeigt die neue PHP-Installation das Bild nicht an. Hier
ist das Beispiel: http://www.europasprak.com/engine/system/utils/printBarImage.php?color=%239999FF&width=3&height=10
Der Quellcode ist:
<?PHP
require_once("website.php");
$color = LibEnv::getEnvHttpGET("color");
$width = LibEnv::getEnvHttpGET("width");
$height = LibEnv::getEnvHttpGET("height");
$color = urldecode($color);
if ($color && $width > 0 && $height> 0) {
LibImage::printBarImage($color, $width, $height);
}
// Print a bar image
static function printBarImage($color, $width, $height) {
// Create a blank image
$image = imagecreatetruecolor($width, $height);
if (strlen($color) == 6) {
$color = "#" . $color;
}
$r = intval(substr($color, 1, 2), 16);
$g = intval(substr($color, 3, 2), 16);
$b = intval(substr($color, 5, 2), 16);
$color = imagecolorallocate($image, $r, $g, $b);
// Fill up the image background
imagefilledrectangle($image, 0, 0, $width, $height, $color);
// Header indicating the image type
header("Content-type:image/jpeg");
// Create the image in the best jpeg quality
imagejpeg($image, NULL, 100);
// Destroy the image
imagedestroy($image);
}
?>
Meine PHP Version 5.6.20 Info hat folgendes zu sagen:
GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.5.2
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.50
WBMP Support enabled
XBM Support enabled
UPDATE: Ich kommentierte out die Bildausgabe und hinzugefügt ein vorhandenes externes Bild zu debuggen:
// imagejpeg($image, NULL, 100);
$img=imagecreatefromjpeg("http://www.google.com/logos/doodles/2016/faten-hamamas-85th-birthday-4804306106580992-hp2x.jpg");
imagejpeg($img, NULL, 100);
Und das Problem bleibt gleich.
Es hängt also wahrscheinlich nicht mit meinem GD Setup zusammen, sondern liegt am Inhaltstyp.
entfernte ich keine BOM Zeichen:
tail --bytes=+4 lib/image.php
tail --bytes=+4 system/utils/printBarImage.php
ich verschiedene charsets versucht:
iconv -f ISO-8859-1 -t utf-8 ... -o ...
EDIT: ich meine GD-Bibliothek aktualisiert:
GD Support enabled
GD headers Version 2.2.4
GD library Version 2.2.4
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.7.1
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version unknown
PNG Support enabled
libPNG Version 1.6.28
WBMP Support enabled
XPM Support enabled
libXpm Version 30411
XBM Support enabled
Mit error_log() I kann sehen, dass der $image = imagecreatetruecolor($width, $height);
Funktionsaufruf eine Ressourcen-ID # 678 erstellt und dass die $color = imagecolorallocate($image, $r, $g, $b);
Funktionsaufruf gibt einen Farbcode 6737049 zurück.
Dieses Problem blieb jedoch dasselbe.
Ich versuchte auch mit einer anderen Funktion anstelle von imagejpeg($image, NULL, 100);
und so versuchte ich zuerst imagepng($image);
und dann imagegif($image);
, aber das Problem blieb gleich wieder.
Wenn ich die header("Content-type:image/jpeg");
dann sieht kommentieren Sie die Ausgabe wie: ����JFIF``��
mit Quellcode:
����JFIF``��<CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 100
��C��C��
��
���}!1AQa"q2���#B��R��$3br�
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������
���w!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?�@����(��
(��?�
der Wahl Mein Browser ist Chrome.
Nun, wenn ich das Bild in Firefox öffnen, zeigt dies: The image ... cannot be displayed because it contains errors.
.
EDIT: Ich habe einige Fehlerberichterstattung und das Protokoll hatte dies zu zeigen:
PHP Parse error: imagepng(): gd-png error: cannot allocate libpng main struct
Welche Fehler bekommen Sie? – timclutton
Das Protokoll bleibt darauf leer. – Stephane
Ihr letztes Beispiel Code funktioniert gut für mich mit PHP 5. – Jocelyn