Jump to content

Image Thumbnail Help


Jr-

Recommended Posts

Ok, I keep trying this:

 

 

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

 

 

<?

 

 

$myImage = "test.jpg";

 

function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality = 100)

{

    # function should be called createJpegThumbnail();

    # $quality = 100 is maximum quality

    # file size will come down for lower quality level

    $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");

    $thumbHeight = ($origHeight = imagesy($srcImg)) * ($thumbWidth / ($origWidth = imagesx($srcImg)));

    $thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);

    imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);

    imagejpeg($thumbImg, "$thumbDirectory/$imageName", $quality);

    imagedestroy($srcImg);

    imagedestroy($thumbImg);

}

 

createThumbnail("image", $myImage, "image", 50);

 

?>

 

 

</body>

</html>

 

 

 

 

...and I keep getting this error:

 

 

 

Warning: imagejpeg(): Unable to open 'image/test.jpg' for writing in /myDir/uploadTest_2.php on line 25

 

 

 

Does anyone know why it keeps erroring out on the imagejpeg() function? Any help is much appreciated.

 

Thanks,

Jr-

Link to comment
https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/
Share on other sites

You would have to change permissions of the file once it's on the server.

 

If you're uploading via FTP make sure that everybody has write permission on the file (or if it's numeric, the last digit must be 6). Usually in FTP (and the *nix world) this is called chmod.

Link to comment
https://forums.phpfreaks.com/topic/37496-image-thumbnail-help/#findComment-179327
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.