G'day guys,
I could not find the root problem, but I thought I would post it here so its known about.
My host has imagick, but the ImageMagick supported formats are as follows ( from phpinfo() ):
3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BMP, BMP2, BMP3, BRF, CAL, CALS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPT, EPT2, EPT3, ERF, EXR, FAX, FITS, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICO, ICON, INFO, INLINE, IPL, ISOBRL, JNX, JPEG, JPG, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MTV, MVG, NEF, NRW, NULL, ORF, OTB, PALM, PANGO, PATTERN, PCD, PCDS, PCL, PCX, PDB, PDF, PDFA, PEF, PES, PJPEG, RADIAL-GRADIENT, RAF, RW2, SHTML, SR2, SRF, UBRL, WMV, X3F
You will notice no PNG in that list.
But the function below (from yiisoft/yii2/captcha/Captcha.php) returns "imagick":
public static function checkRequirements()
{
if (extension_loaded('imagick')) {
$imagick = new \Imagick();
$imagickFormats = $imagick->queryFormats('PNG');
if (in_array('PNG', $imagickFormats)) {
return 'imagick';
}
}
if (extension_loaded('gd')) {
$gdInfo = gd_info();
if (!empty($gdInfo['FreeType Support'])) {
return 'gd';
}
}
throw new InvalidConfigException('Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required.');
}
So you see even though I do not have support for PNG, it is thinking that I do. I have even tried adding exit(); above the return statement to see if that was the path it was taking, and it does indeed use that path.
But something else interesting is the following (inside requirements.php) sets $imagickMemo and $imagickOK stays false:
if (extension_loaded('imagick')) {
$imagick = new Imagick();
$imagickFormats = $imagick->queryFormats('PNG');
if (in_array('PNG', $imagickFormats)) {
$imagickOK = true;
} else {
$imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.';
}
}
So you see, on the same system the same basic piece of code seems to give two different results, so I am thinking something else is also going on. I do notice the first one is using namespace where the other one does not.
As to the underlying cause, I wish you guys good luck, I have had to swap the code so GD evaluating happens first for it to work for me.
Peace, n099y.
I just found out when this starts happening: It only happens when I am logged in.
I do not see how this is causing it thou.
do you see any error?
@n099y Windows or Linux Version PHP, Version php_imagick.dll ?
No error, it just redirects back to the root index view.
Its the Linux version
Imagick from phpinfo():
imagick module enabled
imagick module version 3.1.2
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.8.8-7 Q16 x86_64 2015-01-27 http://www.imagemagick.org
ImageMagick copyright Copyright (C) 1999-2014 ImageMagick Studio LLC
ImageMagick release date 2015-01-27
ImageMagick number of supported formats: 114
ImageMagick supported formats 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BMP, BMP2, BMP3, BRF, CAL, CALS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPT, EPT2, EPT3, ERF, EXR, FAX, FITS, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICO, ICON, INFO, INLINE, IPL, ISOBRL, JNX, JPEG, JPG, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MTV, MVG, NEF, NRW, NULL, ORF, OTB, PALM, PANGO, PATTERN, PCD, PCDS, PCL, PCX, PDB, PDF, PDFA, PEF, PES, PJPEG, RADIAL-GRADIENT, RAF, RW2, SHTML, SR2, SRF, UBRL, WMV, X3F
PHP system info from phpinfo():
PHP Version 5.5.24
System Linux homer.zuver.net.au 2.6.32-531.23.3.lve1.3.6.el6.x86_64 #1 SMP Mon Sep 29 16:27:54 CEST 2014 x86_64
Build Date Apr 20 2015 06:24:36
Configure Command './configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/opt/alt/php55' '--exec-prefix=/opt/alt/php55' '--bindir=/opt/alt/php55/usr/bin' '--sbindir=/opt/alt/php55/usr/sbin' '--sysconfdir=/opt/alt/php55/etc' '--datadir=/opt/alt/php55/usr/share' '--includedir=/opt/alt/php55/usr/include' '--libdir=/opt/alt/php55/usr/lib64' '--libexecdir=/opt/alt/php55/usr/libexec' '--localstatedir=/var' '--with-openssl=/usr' '--with-curl=/opt/alt/curlssl/usr' '--sharedstatedir=/usr/com' '--mandir=/opt/alt/php55/usr/share/man' '--infodir=/opt/alt/php55/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/opt/alt/php55/etc' '--with-config-file-scan-dir=/opt/alt/php55/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--with-t1lib=/opt/alt/t1lib/usr' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-pcre-regex=/opt/alt/pcre/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-sockets=shared' '--enable-sysvsem=shared' '--enable-sysvshm=shared' '--enable-sysvmsg=shared' '--with-kerberos' '--enable-shmop' '--enable-calendar' '--with-libxml-dir=/opt/alt/libxml2/usr' '--enable-xml' '--with-mcrypt=shared,/usr' '--with-tidy=shared,/usr' '--with-mhash' '--with-readline' '--enable-dbx=shared' '--with-zlib-dir=/usr' '--enable-opcache' '--with-mssql=shared,/opt/alt/freetds/usr' '--with-interbase=shared,/opt/alt/firebird/usr' '--with-pdo-firebird=shared,/opt/alt/firebird/usr' '--with-pdo-dblib=shared,/opt/alt/freetds/usr' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbregex' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--enable-dom=shared' '--with-pgsql=shared' '--enable-wddx=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--with-icu-dir=/opt/alt/libicu/usr' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/opt/alt/sqlite/usr' '--enable-json=shared' '--enable-zip=shared' '--with-pspell=shared' '--enable-phar=shared' '--enable-posix=shared' '--with-unixODBC=shared,/usr' '--enable-fileinfo=shared' '--enable-intl=shared' '--enable-sqlite3=shared,/opt/alt/sqlite/usr' '--with-enchant=shared,/usr' '--with-recode=shared,/usr'
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /opt/alt/php55/etc
Loaded Configuration File /opt/alt/php55/etc/php.ini
Scan this dir for additional .ini files /opt/alt/php55/etc/php.d
Additional .ini files parsed /opt/alt/php55/etc/php.d/alt_php.ini
PHP API 20121113
PHP Extension 20121212
Zend Extension 220121212
Zend Extension Build API220121212,NTS
PHP Extension Build API20121212,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 https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, zip, phar
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
Your problem is not Yii2, is your imagick that has no support for PNG,
Your compile imagick, Example Centos:
yum remove ImageMagick
yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.6.3-5.tar.gz
tar zxvf ImageMagick-6.6.3-5.tar.gz
cd ImageMagick-6.6.3-5
./configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes
make clean
make
make install
Regards
Your not understanding the problem man.
I have gotten around the issue, but the problem is even thou I do not have imagick PNG support, yii2 thinks that I do, it has checked the requirements and said yes I have it .. but I do NOT.
it doesnt adress your problem but if this is implemented you dont have to override the core anymore
https://github.com/yiisoft/yii2/issues/8284
Yes, that is something.
Where was this fixed ?
It was not. We can't reproduce it so can't fix it.
this happened to me too, running on virtual machine, ubuntu 14.04, nginx and php 7. just installed the basic yii2 app.
At first I got the error on mbstring and have fixed that just by installing php7.0-mbstring and then everything works fine but when I clicked on contact page this new error comes up
Invalid Configuration – yii\base\InvalidConfigException
Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required.
I just installed php7.0-gd and it works again
Sam, I'm getting this too on the staging server I'm trying to set up for you:
http://screencast.com/t/kdH0Xx71
sudo apt install php-gd
sudo service apache2 restart
hi I installed yii2 in my mac. I got this error as well. Did anyone fix it?
Please help
Thanks
Keith
Most helpful comment
Your problem is not Yii2, is your imagick that has no support for PNG,
Your compile imagick, Example Centos:
yum remove ImageMagick
yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.6.3-5.tar.gz
tar zxvf ImageMagick-6.6.3-5.tar.gz
cd ImageMagick-6.6.3-5
./configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes
make clean
make
make install
Regards