[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

imagecreatefromstring undefinded?

Posted on 2004-08-12
5
Medium Priority
?
1,367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

650 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