aufgefallen ist mir diesem problem beim aufsetzten eines magento online-shops, der nach einem upgrade auf php 5.3.1 plötzlich keine pdfs mehr produzieren konnte. statt dessen nu lapidar den dienst mit folgender fehlermeldung quittierte.
Undefined index: JPG Support in /usr/local/lib/php/Zend/Pdf/Resource/Image/Jpeg.php on line 60
Eine Befragung des Google-Orakels brachte dann auch schnell Linderung. Schuld ist wohl eine Änderung einens Strings der die API-Fähigkeiten beschreibt. So änderte sich “JPG” in “JPEG“, was dazu führt das das Zend Framework plötzlich der Meinung ist das das drunterliegende PHP nicht mehr richtig in der Lage ist JPG-Grafiken zu verarbeiten.
Im Bugtracker des Zendframeworks hat man auch gleich einen kleinen Patch parat (BUG ZF6715).
view source print ?
| 01 | Index: library/Zend/Pdf/Resource/Image/Jpeg.php |
| 02 | =================================================================== |
| 03 | --- library/Zend/Pdf/Resource/Image/Jpeg.php (revision 18072) |
| 04 | +++ library/Zend/Pdf/Resource/Image/Jpeg.php (working copy) |
| 05 | @@ -52,13 +52,13 @@ |
| 06 | */ |
| 07 | public function __construct($imageFileName) |
| 08 | { |
| 09 | - if (!function_exists('gd_info')) { |
| 10 | + if (!function_exists('gd_info') || !function_exists('imagetypes')) { |
| 11 | require_once 'Zend/Pdf/Exception.php'; |
| 12 | throw new Zend_Pdf_Exception('Image extension is not installed.'); |
| 13 | } |
| 14 |
| 15 | $gd_options = gd_info(); |
| 16 | - if (!$gd_options['JPG Support'] ) { |
| 17 | + if ((imagetypes() & IMG_JPG) == 0) { |
| 18 | require_once 'Zend/Pdf/Exception.php'; |
| 19 | throw new Zend_Pdf_Exception('JPG support is not configured properly.'); |
| 20 | } |
Wie man sehen kann ändern sich nur zwei Zeilen in der Datei Zend/Pdf/Resource/Image/Jpeg.php das kann man auch leicht mit einem einfachen Editor wie nano, vim oder mc manuell ausführen. Dazu in genannter Datei die Zeile 53 von
立即学习“PHP免费学习笔记(深入)”;
view source print ?
| 1 | if (!function_exists('gd_info')) { |
in
view source print ?
| 1 | if (!function_exists('gd_info') || !function_exists('imagetypes')) { |
und Zeile 59 von
view source print ?
| 1 | if (!$gd_options['JPG Support'] ) { |
in
view source print ?
| 1 | if ((imagetypes() & IMG_JPG) == 0) { |
abändern fertig ! Nun sollte alles wieder wie gewohnt arbeiten.
?
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号