php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38108 Imagecreatefromjpeg / Imagejpeg not functioning properly
Submitted: 2006-07-15 01:44 UTC Modified: 2006-07-15 08:51 UTC
From: bcarlowise at yahoo dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.1.4 OS: SuSE Enterprise Linux 10.0
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bcarlowise at yahoo dot com
New email:
PHP Version: OS:

 

 [2006-07-15 01:44 UTC] bcarlowise at yahoo dot com
Description:
------------
Scenario:

  I have a MySQL database with a table that I store photos in. I am trying to extract the photo from the database and display the photo in a web page. I can get the code to display the raw stream if I "echo" the variable but it will not display the actual photo when I call the imagecreatefromjpeg and imagejpeg functions and pass the arguments according to the documentation.

SuSE Linux Enterprise 10.0
Apache 2.2.0-21.2
PHP 5.1.2-29 (php5-gd module installed)
GD 2.0.32-23


Reproduce code:
---------------
<!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>Image Display Test</title>
</head>

<body>


<?php

$db=mysql_connect("<server>", "<username>", "<password>") or die(mysql_error());
mysql_select_db("<schema>") or die(mysql_error());

$sql = "Select * from <table> where id= 1";
$result = mysql_query($sql);

//if (!$result) {
//    die('Invalid query: ' . mysql_error());
//}
//Else

$myrow = mysql_fetch_array($result);

$id = $myrow[0];
$gallery = $myrow[1];
$image = $myrow[2];
$hits = $myrow[3];

echo "id=$id", ", gallery=$gallery", ", hits=$hits";

if ($image!=false) {

  echo $image;   //**this will produce the raw stream**

  $source = imagecreatefromjpeg($image);
  imagejpeg($source, $source, 75);  //**this displays nothing but should display the image??**

  exit;
}

Else
  echo "No valid image found.";

?>

<p>&nbsp;

</p>
</body>
</html>

Expected result:
----------------
To have the photo displayed in the browser.

Actual result:
--------------
the raw stream is displayed from the echo statement but nothing is displayed from the imagejpeg function.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-15 08:51 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 06 05:00:02 2025 UTC