Solved

imagecreatefromstring undefinded?

Posted on 2004-08-12
5
1,303 Views
Last Modified: 2013-12-12
Hi,

can someone tell me why this piece of code:


    /**
    * Loads an image from a string (e.g. database)
    * @param string the image
    * @param mime mime type of the image
    * @return boolean
    * @access public
    */
    function loadData ($image,$mime) {
        if ( in_array($mime,$this->types) ) {
            $this->source=imagecreatefromstring($image);
            $this->sourceWidth=imagesx($this->source);
            $this->sourceHeight=imagesy($this->source);
            $this->sourceMime=$mime;
            $this->initThumb();
            return true;
        } else {
            trigger_error('Image MIME type '.$mime.' not supported');
            return false;
        }
    }

produces an error telling me imagecreatefromstring is not defined? Urgent.
0
Comment
Question by:Wojciech Duda
5 Comments
 
LVL 3

Expert Comment

by:thecode101
ID: 11783907
What version of php are you using?
0
 
LVL 7

Expert Comment

by:madwax
ID: 11783913
Hi mcwojtekk,

The piece of code you have there is a part of a class, which I don't know if you have. On the row:
$this->source=imagecreatefromstring($image);

You are namely calling an function called: "imagecreatefromstring" with a parameter $image. This function must be defined somewhere and it isn't in the piece of code you have provided. If you have the function in the class try to put $this-> infront of so that you get:

$this->source=$this->imagecreatefromstring($image);

Good luck!
//madwax

Cheers!
0
 
LVL 8

Author Comment

by:Wojciech Duda
ID: 11784003
I have installed EasyPHP 1.7. I have the full class but it was coded by someone else. Now if I try to view the page this error comes up:

Fatal error: Call to undefined function: imagecreatefromstring() in c:\program files\easyphp1-7\www\*******_intranet\includes\lib\thumbnail.php on line 174

From what I understand this function is part of php, why the 'undefined' error?
0
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 500 total points
ID: 11784099
imagecreatefromstring requires the GD library.  You can check if this is enabled by using this code:

<?php
var_dump(gd_info());
?>

If that produces an undefined function error, you need to enable GD.  Find the file php.ini (probably in the windows directory) and check that the line extension=php_gd2.dll is not commented (does not have a leading semi-colon).  The version of PHP included with EasyPHP should have a built-in version of GD; if not, check the first link below for further instructions.

http://us2.php.net/manual/en/ref.image.php
http://us2.php.net/manual/en/function.imagecreatefromstring.php
0
 
LVL 8

Author Comment

by:Wojciech Duda
ID: 11785828
Editing the php.ini helped. Thanks a lot.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now