Jump to content

[SOLVED] Problem displaying images


Suchy

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.