Re: [PHP] A black thumbnail.

2006-01-28 Thread tedd

Hi again:

I said:


I'm trying to create a thumbnail from a jpeg stored in a long blob in mySQL.


---
-philip said:

imagecreatefromjpeg takes a *filename* not the actual contents of 
the file itself.


Yes, you are correct that in the statement:

$image = imagecreatefromjpeg($fileContent);

The variable $fileContent should be a file name -- but it's the 
contents of the file that the function uses. So, what's the 
difference between a filename and its contents? Is there a header I 
should add? Or does the routine require a read operation?


I'll look at some other functions.

Thanks for your help.

tedd
--

http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A black thumbnail.

2006-01-28 Thread tedd

Hi again:

I said:


I'm trying to create a thumbnail from a jpeg stored in a long blob in mySQL.


---
Richard said:

Dynamic Thumbnail generation:
http://www.weberdev.com/ViewArticle-388.htmlhttp://www.weberdev.com/ViewArticle-388.html

Yes, that's for generating a thumbnail from a file -- but I want to 
do it directly from a stored image from mySQL.


Any ideas?

Thanks for your help.

tedd
--

http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A black thumbnail.

2006-01-28 Thread tedd

Hi again:

I said:


I'm trying to create a thumbnail from a jpeg stored in a long blob in mySQL.


---
berber said:

Check out this article : http://www.weberdev.com/ViewArticle-3.html

This article is for uploading, storing and displaying images from 
mySQL, but no thumbnail.


Any ideas?

Thanks for your help.

tedd

--

http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] A black thumbnail.

2006-01-28 Thread Weber Sites LTD
I don't see any article / example that takes care of it all and also shows a
thumb :)
So the previous article shoed everything but the thumb, try this one for the
thumb :

http://www.weberdev.com/ViewArticle-388.html

berber 

-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 28, 2006 4:56 PM
To: php-general@lists.php.net
Subject: Re: [PHP] A black thumbnail.

Hi again:

I said:

I'm trying to create a thumbnail from a jpeg stored in a long blob in
mySQL.

---
berber said:

Check out this article : http://www.weberdev.com/ViewArticle-3.html

This article is for uploading, storing and displaying images from mySQL, but
no thumbnail.

Any ideas?

Thanks for your help.

tedd

--


http://sperling.com/

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A black thumbnail.

2006-01-27 Thread Philip Hallstrom

(skip down)


I'm trying to create a thumbnail from a jpeg stored in a long blob in mySQL.
What's wrong here? I get an image that's the correct size, but it's black.

Any ideas?

code

$dbQuery = SELECT image_type, image, image_width, image_height ;
$dbQuery .= FROM pictures ;
$dbQuery .= WHERE image_Id = $pic_id;
$result = mysql_query($dbQuery) or die(Couldn't get file list);

if(mysql_num_rows($result) == 1)
{
$fileType = @mysql_result($result, 0, image_type);
$fileContent = @mysql_result($result, 0, image);
$width_orig = @mysql_result($result, 0, image_width);
$height_orig = @mysql_result($result, 0, image_height);

// Set a maximum height and width
$width = 200;
$height = 200;

if ($width  ($width_orig  $height_orig))
  {
  $width = ($height / $height_orig) * $width_orig;
  }
else
  {
  $height = ($width / $width_orig) * $height_orig;
  }

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($fileContent);


imagecreatefromjpeg takes a *filename* not the actual contents of the file 
itself.  So $image is going to be invalid so your next command isn't going 
to do what you think which means you're going to get black as that's 
probably the first/default color of $image_p.


-philip


imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, 
$width_orig, $height_orig);


// Output
imagejpeg($image_p, null, 100);
}

/code
--

http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A black thumbnail.

2006-01-27 Thread Richard Correia
Hi Tedd,

Dynamic Thumbnail generation:
http://www.weberdev.com/ViewArticle-388.html




On 1/28/06, tedd [EMAIL PROTECTED] wrote:

 Hi:

 I'm trying to create a thumbnail from a jpeg stored in a long blob in
 mySQL.

 What's wrong here? I get an image that's the correct size, but it's black.

 Any ideas?

 Thanks.

 tedd

 code

 $dbQuery = SELECT image_type, image, image_width, image_height ;
 $dbQuery .= FROM pictures ;
 $dbQuery .= WHERE image_Id = $pic_id;
 $result = mysql_query($dbQuery) or die(Couldn't get file list);

 if(mysql_num_rows($result) == 1)
 {
 $fileType = @mysql_result($result, 0, image_type);
 $fileContent = @mysql_result($result, 0, image);
 $width_orig = @mysql_result($result, 0, image_width);
 $height_orig = @mysql_result($result, 0, image_height);

 // Set a maximum height and width
 $width = 200;
 $height = 200;

 if ($width  ($width_orig  $height_orig))
{
$width = ($height / $height_orig) * $width_orig;
}
 else
{
$height = ($width / $width_orig) * $height_orig;
}

 // Resample
 $image_p = imagecreatetruecolor($width, $height);
 $image = imagecreatefromjpeg($fileContent);
 imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
 $width_orig, $height_orig);

 // Output
 imagejpeg($image_p, null, 100);
 }

 /code
 --




RE: [PHP] A black thumbnail.

2006-01-27 Thread Weber Sites LTD
Check out this article : http://www.weberdev.com/ViewArticle-3.html

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP  MySQL Forums : http://www.weberforums.com
Learn PHP  MySQL Playing Trivia : http://www.webertrivia.com
Free Uptime Monitor : http://uptime.weberdev.com
 

-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 28, 2006 2:43 AM
To: php-general@lists.php.net
Subject: [PHP] A black thumbnail.

Hi:

I'm trying to create a thumbnail from a jpeg stored in a long blob in mySQL.

What's wrong here? I get an image that's the correct size, but it's black.

Any ideas?

Thanks.

tedd

code

$dbQuery = SELECT image_type, image, image_width, image_height ; $dbQuery
.= FROM pictures ; $dbQuery .= WHERE image_Id = $pic_id; $result =
mysql_query($dbQuery) or die(Couldn't get file list);

if(mysql_num_rows($result) == 1)
{
$fileType = @mysql_result($result, 0, image_type); $fileContent =
@mysql_result($result, 0, image); $width_orig = @mysql_result($result, 0,
image_width); $height_orig = @mysql_result($result, 0, image_height);

// Set a maximum height and width
$width = 200;
$height = 200;

if ($width  ($width_orig  $height_orig))
{
$width = ($height / $height_orig) * $width_orig;
}
else
{
$height = ($width / $width_orig) * $height_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height); $image =
imagecreatefromjpeg($fileContent);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);

// Output
imagejpeg($image_p, null, 100);
}

/code
--


http://sperling.com/

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php