inherit
39608
0
Nov 26, 2011 18:53:00 GMT -8
iDunk
Previously Computerpros
2,533
April 2005
computerpros
|
Post by iDunk on Jan 25, 2010 1:33:45 GMT -8
function resize_jpg($filename) { // Set a maximum height and width $width = 165; $height = 165;
// Content type header('Content-type: image/jpeg');
// Get new dimensions list($width_orig, $height_orig) = getimagesize($filename);
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($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, null, 100);
}
If I output the JPG to a file instead of to the browser, it works fine. If I try and output the JPG to the browser, it shows the "broken image" icon. :-\ This exact script used to work on my XAMPP machine.
-iDunk
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Jan 25, 2010 4:59:41 GMT -8
Turn on error displays, click "View source" of the JPEG file (or remove the JPEG Content-Type header), and see what the error is. It can be any number of things.
|
|
inherit
39608
0
Nov 26, 2011 18:53:00 GMT -8
iDunk
Previously Computerpros
2,533
April 2005
computerpros
|
Post by iDunk on Jan 28, 2010 21:38:41 GMT -8
No error is displayed. :-\ I set the error_reporting to E_ALL and I did the ini_set("display_errors", TRUE) thing. :-\
-iDunk
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Jan 29, 2010 11:41:27 GMT -8
Hmm. Well, do echo $width, 'x', $height, 'x', $width_orig, 'x', $height_orig; And see if any are erroneously set as 0 or summat.
The only other thing I see is imagejpeg(). I never use the second or third parameters. Maybe try without them? Or check to see if imagecopyresampled is missing a parameter or summat.
Do you have access to the INI file? On my old localhost, no matter what I set via ini_set, it wouldn't display errors ever (I never tried to edit the php.ini file for some reason). I noticed on my new one that display_errors was false my default, so I changed that and see errors fine now.
|
|