?
Solved

imagecreatefromstring undefinded?

Posted on 2004-08-12
5
Medium Priority
?
1,346 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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

762 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