Suchy Posted May 31, 2007 Share Posted May 31, 2007 Iam am having problem with displaying images, here is my code: $link = 'http://...../595886693.jpg' ; $photo = open ( $link ); function open ($temp) { $im = @imagecreatefromjpeg($temp); if ($im !== false) { return $im; } $im = @imagecreatefromgif($temp); if ($im !== false) { return $im; } $im = @imagecreatefrompng($temp); if ($im !== false) { return $im; } return false; } $x = imagesx($photo); $y = imagesy($photo); $x_max = 525; $y_max = $y * ($x_max/$x); $resize = imagecreatetruecolor($x_max, $y_max); imagecopyresampled($resize, $photo, 0, 0, 0, 0, $x_max, $y_max, $x, $y); imagejpeg($resize); This works great when I run this page (functions.php) but when I include it into another pae insted of the photo I get alot of garbage, like: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC $.' ",#(7),01444'9=82<.342ÿÛC 2!!22222222222222222222222222222222222222222222222222ÿÀ Why is this ? Link to comment https://forums.phpfreaks.com/topic/53724-solved-problem-displaying-images/ Share on other sites More sharing options...
Orio Posted May 31, 2007 Share Posted May 31, 2007 The browser thinks this is a HTML page. You gotta tell him it's a jpeg. Add in the beginning: header('Content-type: image/jpeg'); Orio. Link to comment https://forums.phpfreaks.com/topic/53724-solved-problem-displaying-images/#findComment-265485 Share on other sites More sharing options...
Suchy Posted May 31, 2007 Author Share Posted May 31, 2007 I tried that, and it was the same problem. Maybe because the header was in the wrong page. Where should I put it inside the page that the functions.php load? Link to comment https://forums.phpfreaks.com/topic/53724-solved-problem-displaying-images/#findComment-265488 Share on other sites More sharing options...
Orio Posted May 31, 2007 Share Posted May 31, 2007 Put it after the opening <?php Orio. Link to comment https://forums.phpfreaks.com/topic/53724-solved-problem-displaying-images/#findComment-265493 Share on other sites More sharing options...
Suchy Posted May 31, 2007 Author Share Posted May 31, 2007 It is still the same problem. Link to comment https://forums.phpfreaks.com/topic/53724-solved-problem-displaying-images/#findComment-265499 Share on other sites More sharing options...
Suchy Posted May 31, 2007 Author Share Posted May 31, 2007 Got it, inseatad of include I did: <img src="functions.php"> </img> Link to comment https://forums.phpfreaks.com/topic/53724-solved-problem-displaying-images/#findComment-265541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.