Jump to content


Photo

ImageCreateFromJpeg From URL


  • Please log in to reply
2 replies to this topic

#1 Beijufas

Beijufas
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 September 2006 - 01:16 AM

Hello all!  ;D

Well my problem is I have some images on a database, and I want to rezise them on the fly, so I make some research and I have this code here:

<?php
$id=$_GET['id'];
$temp_endereco=$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$lastposc=strrpos($temp_endereco,'/');
$endereco=substr($temp_endereco,0,$lastposc+1)."viewimg.php?id=".$id;


$width = 40;
$height = 30;
$x = $width/2;
$y = $height/2;

$fp = fsockopen($endereco, 80, $errno, $errstr, 30);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {

$src = ImageCreateFromJpeg($fp);
$tmb = ImageCreateTrueColor($width,$height);
ImageCopy($tmb, $src, 0, 0, $x, $y, $width, $height);
header('Content-type: image/jpeg');
ImageJpeg($tmb, null, 100);
ImageDestroy($src);
ImageDestroy($tmb);
ImageDestroy($thumb);
}
?>

The idea is to access the file viewimg.php that give me the image and them whit the ImageCreateFromJpeg and the other code resize the image and show it on a web page.

The problem is that dosn't work  ???

I also try to access the viewimg.php like this:
$src = ImageCreateFromJpeg($endereco);

but it heve me an authorization error, I have made a search over the net and in a bugs page on php.net they say that I have to upgrade some dll's, but that is not a option becouse the server is a shared server.

I hope that any one can help me!

Thanks in advance for every body


#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 16 September 2006 - 03:32 AM

you could try imagecreatefromstring(file_get_contents($endereco));

#3 Beijufas

Beijufas
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 September 2006 - 03:24 PM

Thanks a lot!!

the imagecreatefromstring(file_get_contents($endereco)); dosen't work becouse it have some problems acessing the file, but I do this:

imagecreatefromstring($image);

where $image is the data from the database and it works just fine  ;D

Thanks a lot




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users