I'm migrating a Wordpress site from one server another and I've run to to a problem with some of the images not being displayed. The images are being piped though a PHP script to dynamically resize them. After some investigation I've noticed that the issue is only effecting PNG images and found errors relating to gd-png in the webserver logs. As a test I created a simple php script (at the bottom of this post) which just opens a PNG with imagecreatefrompng and every time access the script via a browser I get the following errors...
I have tried several different png's from several different sources in case the png's where the problem, but alias it seems to effect all png's regardless of origin.
Most interestingly, if I run the same script from the command line (su'd to the webserver user!) I do not get the errors (I get the raw PNG but that's expected).
I'm not sure if that makes it a PHP problem or an apache24 problem, but I can't think of any reason why running the script via the webserver should cause such a problem. No permission issues are in play.
I have two webservers setup very similar, both experience the same problem.
My apologies if this is not the correct place to report such a problem. I have also posted this problem to PHP's Bug Tracking System (https://bugs.php.net/bug.php?id=70276) but I'm not 100% sure its a PHP problem (because it works via the CLI).
Note, I spent quite a few hours on this yesterday evening and was running PHP 5.6.11 at the time but I have this morning upgraded to 5.6.12 , however the problem persists.
Any advice gratefully received!
Regards
Steve
Test script:
Code:
PHP Warning: imagecreatefrompng(): gd-png: fatal libpng error: bad parameters to zlib in .../test.php on line 10
Code:
PHP Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in .../test.php on line 10
Code:
PHP Warning: imagecreatefrompng(): 'test.png' is not a valid PNG file in .../test.php on line 10
I have tried several different png's from several different sources in case the png's where the problem, but alias it seems to effect all png's regardless of origin.
Most interestingly, if I run the same script from the command line (su'd to the webserver user!) I do not get the errors (I get the raw PNG but that's expected).
I'm not sure if that makes it a PHP problem or an apache24 problem, but I can't think of any reason why running the script via the webserver should cause such a problem. No permission issues are in play.
I have two webservers setup very similar, both experience the same problem.
My apologies if this is not the correct place to report such a problem. I have also posted this problem to PHP's Bug Tracking System (https://bugs.php.net/bug.php?id=70276) but I'm not 100% sure its a PHP problem (because it works via the CLI).
Note, I spent quite a few hours on this yesterday evening and was running PHP 5.6.11 at the time but I have this morning upgraded to 5.6.12 , however the problem persists.
Any advice gratefully received!
Regards
Steve
# uname -a
Code:
FreeBSD indigo 10.0-RELEASE-p17 FreeBSD 10.0-RELEASE-p17 #0: Tue Jan 27 13:45:18 UTC 2015
# httpd -V
Code:
Server version: Apache/2.4.16 (FreeBSD)
Server built: Aug 14 2015 23:52:56
Server's Module Magic Number: 20120211:47
Server loaded: APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
-D APR_USE_FLOCK_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr/local"
-D SUEXEC_BIN="/usr/local/bin/suexec"
-D DEFAULT_PIDLOG="/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="/var/run/apache_runtime_status"
-D DEFAULT_ERRORLOG="/var/log/httpd-error.log"
-D AP_TYPES_CONFIG_FILE="etc/apache24/mime.types"
-D SERVER_CONFIG_FILE="etc/apache24/httpd.conf"
# php -i
Code:
phpinfo()
PHP Version => 5.6.12
System => FreeBSD indigo 10.0-RELEASE-p17 FreeBSD 10.0-RELEASE-p17 #0: Tue Jan 27 13:45:18 UTC 2015 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
Build Date => Aug 15 2015 12:38:40
Configure Command => './configure' '--with-layout=GNU' '--localstatedir=/var' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--enable-mysqlnd' '--with-libxml-dir=/usr/local' '--with-pcre-regex=/usr/local' '--with-zlib-dir=/usr' '--program-prefix=' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-regex=php' '--with-zend-vm=CALL' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd10.0' 'build_alias=amd64-portbld-freebsd10.0' 'CC=cc' 'CFLAGS=-O2 '-pipe' '-fstack-protector' '-fno-strict-aliasing'' 'LDFLAGS= '-fstack-protector'' 'LIBS=-lpthread' 'CPPFLAGS=' 'CPP=cpp' 'CXX=c++' 'CXXFLAGS=-O2 '-pipe' '-fstack-protector' '-fno-strict-aliasing''
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc
Loaded Configuration File => /usr/local/etc/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php
Additional .ini files parsed => /usr/local/etc/php/extensions.ini
PHP API => 20131106
PHP Extension => 20131226
Zend Extension => 220131226
Zend Extension Build => API220131226,NTS
PHP Extension Build => API20131226,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled
Registered PHP Streams => compress.bzip2, php, file, glob, data, http, ftp, https, ftps, compress.zlib, zip, phar
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => bzip2.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, convert.iconv.*, mcrypt.*, mdecrypt.*, zlib.*
...
...
...
gd
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.6.0
T1Lib Support => enabled
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 8
PNG Support => enabled
libPNG Version => 1.6.17
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30411
XBM Support => enabled
JIS-mapped Japanese Font Support => enabled
...
...
...
zlib
ZLib Support => enabled
Stream Wrapper => compress.zlib://
Stream Filter => zlib.inflate, zlib.deflate
Compiled Version => 1.2.8
Linked Version => 1.2.8
Test script:
Code:
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
function LoadPNG($imgname)
{
/* Attempt to open */
$im = imagecreatefrompng($imgname);
/* See if it failed */
if(!$im)
{ // create error image
$im = imagecreatetruecolor(1500, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 1500, 30, $bgc);
imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
}
return $im;
}
header('Content-Type: image/png');
$img = LoadPNG('test.png');
imagepng($img);
imagedestroy($img);
?>
Last edited by a moderator: