Jump to content

Fatal error call to undefined function imagecreatejpg()


Techmate

Recommended Posts

I have GD enabled but for some reason I get this error?

 

<?php

 

 

ini_set('display_errors', 1 );

 

//upload image

 

$to =  $_FILES['image']['name'];

$where = $_FILES['image']['tmp_name'];

 

//move uploaded image

move_uploaded_file($where, "images/$to");

 

// call function

mark("images/$to");

 

//add mark()here later

 

function mark($location){

 

$watermark = imagecreatefromgif("watermark.gif");

$watermarkheight = imagesy($watermark); //height of watermark

$watermarkwidth = imagesx($watermark); //width of watermark

 

$image = imagecreatetruecolor($watermarkwidth, $watermarkheight);

$image = imagecreatefromjpg($location);

 

// get image size

 

$size = getimagesize($location);

 

$xpos = $size[0] - $watermarkwidth - 10; //10px away from right

$ypos = $size[1] - $watermarkheight - 10; //10px away from bottom

 

// merge watermark with original image

 

imagecopymerge($image, $watermark, $xpos, $ypos, 0, 0, $watermarkwidth, $watermarkheight, 100);

 

// save watermarked image

imagejpeg($image, $location);

 

//clearing buffer

imagedestroy($image);

imagedestroy($watermark);

}

 

 

 

?>

<form  action="watermark.php" method ="POST" enctype="multipart/form-data">

<input type="hidden" name="upload" value="1">

<input type="file" name="image">

<input type="submit" value="Watermark">

</form>

Link to comment
Share on other sites

From the manual: http://www.php.net/manual/en/function.imagecreatefromjpeg.php

Note: JPEG support is only available if PHP was compiled against GD-1.8 or later

 

Check phpinfo() to verify jpg support is enabled and what version of GD you are using.

 

I GD Version 2.0 not sure why i still get the error.

 

GD Support enabled

GD Version 2.0

FreeType Support enabled

FreeType Linkage with freetype

FreeType Version 2.4.2

T1Lib Support enabled

GIF Read Support enabled

GIF Create Support enabled

JPEG Support enabled

libJPEG Version 6b

PNG Support enabled

libPNG Version 1.2.44

WBMP Support enabled

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.