Discussion:
imagejpeg() output
Steven Simmons
2005-01-15 16:39:16 UTC
Permalink
I'm trying to write an object oriented system for saving my uploaded
files to a blog.

I am using php to resize the original photos and save a thumbnail .

When I get all done, I want to do something like this:

$tempImageData = imagejpeg( $imageResource, '', 75 );
$outputHandler -> save ( $tempImageData );

Where the $outputHandler is an object that knows how/where to save the file.
However, I've noticed that imagejpeg() only returns a number 1.

This worked on my previous server, but I'm guessing my new server has a
newer version of php.

What am I doing wrong? How can i pass the raw jpeg data to a function?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Greg Donald
2005-01-17 02:10:31 UTC
Permalink
Post by Steven Simmons
I'm trying to write an object oriented system for saving my uploaded
files to a blog.
I am using php to resize the original photos and save a thumbnail .
$tempImageData = imagejpeg( $imageResource, '', 75 );
$outputHandler -> save ( $tempImageData );
Where the $outputHandler is an object that knows how/where to save the file.
However, I've noticed that imagejpeg() only returns a number 1.
This worked on my previous server, but I'm guessing my new server has a
newer version of php.
What am I doing wrong? How can i pass the raw jpeg data to a function?
To resize the image you have to create a new image handler to write
the new jpeg data to. You can create that image handler with
imagecreatetruecolor() for example.

imagejpeg() is for outputting the data to the browser.
--
Greg Donald
Zend Certified Engineer
http://destiney.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Richard Lynch
2005-01-17 03:50:02 UTC
Permalink
Post by Steven Simmons
$tempImageData = imagejpeg( $imageResource, '', 75 );
$outputHandler -> save ( $tempImageData );
Where the $outputHandler is an object that knows how/where to save the file.
However, I've noticed that imagejpeg() only returns a number 1.
With a blank filename, I think imagejpeg() dumps your JPEG to the browser
and returns true/false for success/failure. http://php.net/imagejpeg

You'd need to use http://php.net/ob_start and friends to do what you're
trying to do.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Rasmus Lerdorf
2005-01-17 07:42:05 UTC
Permalink
Post by Steven Simmons
I'm trying to write an object oriented system for saving my uploaded
files to a blog.
I am using php to resize the original photos and save a thumbnail .
$tempImageData = imagejpeg( $imageResource, '', 75 );
$outputHandler -> save ( $tempImageData );
Where the $outputHandler is an object that knows how/where to save the file.
However, I've noticed that imagejpeg() only returns a number 1.
This worked on my previous server, but I'm guessing my new server has a
newer version of php.
What am I doing wrong? How can i pass the raw jpeg data to a function?
What worked on your previous server? ImageJpeg has never returned the
image data. It has always either written it to the file you specify, or
if you don't specify one it will output it directly at that point. If you
want to capture it in a variable you will need to use output buffering.
See php.net/ob_start

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