beemer832 Posted June 11, 2010 Share Posted June 11, 2010 I am working with the simpleimage.php script to allow me to create two separate images from one uploaded image. I keep getting the following error in my httpd error logs: PHP Fatal error: Call to undefined function imagecreatefromjpeg() in /var/www/html/classifieds/SimpleImage.php on line 31. I just upgraded to php 5.2.13 after reading an issue with the GD library and support for JPEG's in 5.2.12. This did not fix the issue. SimpleImage.php file: <?php /* * File: SimpleImage.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 08/11/06 * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?> Then I am using this to actually change my file sizes in another script: <? //Convert full size image to 1-thumbnail size 2-similar size for all images. files will be saved in corresponding folders// include('SimpleImage.php'); $image = new SimpleImage(); $image->load('uploads/screenshot.jpg'); $image->resize(175, 115); $image->save('/images/thumb/screenshot.jpg'); ?> Let me know if I missed anything, only posted here a few times. Also I am VERY new to PHP, only been coding for about a month now. Thanks Josh SimpleImage.php website:http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php Quote Link to comment Share on other sites More sharing options...
thomashw Posted June 11, 2010 Share Posted June 11, 2010 Have you tried '=' instead of '->'? Quote Link to comment Share on other sites More sharing options...
beemer832 Posted June 11, 2010 Author Share Posted June 11, 2010 I just copied and pasted the examples listed on the website for the script. thanks josh Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 11, 2010 Share Posted June 11, 2010 What does a phpinfo(); statement show in the "gd" section for the GD Version and JPEG Support? Quote Link to comment Share on other sites More sharing options...
beemer832 Posted June 11, 2010 Author Share Posted June 11, 2010 interesting... there isn't a GD section....... Configure Command './configure' '--host=i686-redhat-linux-gnu' '--build=i686-redhat-linux-gnu' '--target=i386-redhat-linux' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--without-mime-magic' '--without-sqlite' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter' '--disable-json' '--without-pspell' Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 12, 2010 Share Posted June 12, 2010 there isn't a GD section....... There you go. That would explain why the gd functions your code called are not defined. Quote Link to comment Share on other sites More sharing options...
beemer832 Posted June 12, 2010 Author Share Posted June 12, 2010 Okay well that explains why it isn't working correctly. So now my question is, how do I get this version of PHP to support GD? I did a yum update php to install the newest version. Running Centos 5. thanks josh Quote Link to comment Share on other sites More sharing options...
beemer832 Posted June 14, 2010 Author Share Posted June 14, 2010 got the first issue squared away by running "yum install php-gd" (centos 5) That downloaded and installed GD support for PHP, then had to restart Apache for changes to take affect. Now I have a few more issues, but haven't had a chance to dig into them yet. Thanks for everyones help -josh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.