imagecopyresized converts image to black and white

From: Date: Thu, 27 Feb 2003 08:47:28 +0000
Subject: imagecopyresized converts image to black and white
Groups: php.install 
Request: Send a blank email to php-install+get-10215@lists.php.net to get a copy of this message
I'm using imagecopyresized/resampled under PHP4.2.3 to convert an image uploaded via a file upload control to 90x90 pixels for storage in a MySQL database, but am finding when imagecopyresized or imagecopyresampled is used to scale the image, the result is converted to greyscale. Sample code.... $photo = $_FILES["photo"]; if($photo["type"]=="image/jpeg") $image=imagecreatefromjpeg($photo["tmp_name"]); else if($photo["type"]=="image/pjpeg") $image=imagecreatefromjpeg($photo["tmp_name"]); if($image) { // convert image to 90x90 JPEG $target=imagecreate(90,90); imagecopyresized($target,$image,0,0,0,0,90,90,imagesx($image),imagesy($image )); imagejpeg($target,$photo["tmp_name"]); $fd=fopen($photo["tmp_name"],"r"); $imagestring=addslashes(fread($fd,filesize($photo["tmp_name"]))); fclose($fd); imagedestroy($target); imagedestroy($image); } If I remove the resize/resample, then the colours are correct. The resize code works fine on another system using GD <2.0 PHPinfo.... ./configure' '--with-gd' '--enable-gd-native-ttf' '--enable-track-vars' '--enable-sysvsem' '--enable-sysvshm' '--with-zlib' '--prefix=/opt/php-4.2' '--with-config-file-path=/usr/local/etc/httpd/conf' '--enable-memory-limit' '--with-db2=/usr' '--with-db3=/usr' '--with-gdbm=/usr' '--with-ndbm=/usr' '--with-dbase' '--with-xml' '--with-expat-dir=/usr' '--enable-debugger' '--enable-ftp' '--enable-sockets' '--with-ttf' '--with-jpeg-dir=/usr' '--enable-bcmath' '--enable-mbstring' '--enable-mbregex' '--with-openssl' '--enable-trans-sid' '--with-mysql=/usr' '--with-xpm-dir=/usr/X11R6' '--with-png' '--with-png-dir=/usr' '--with-imap' '--with-dom=/usr' '--with-bz2' '--with-curl' '--with-mhash=/usr' '--with-mcrypt=/usr' '--with-pgsql' '--with-ming' '--with-gmp' '--with-gettext' '--with-iconv' '--with-kerberos' '--with-pspell' '--enable-xslt' '--with-xslt-sablot' '--with-freetype-dir=/usr' '--with-apxs=/usr/sbin/apxs' Apache 1.3.27 GD is reported as 2.0 or higher.

« previous php.install (#10215) next »