Jump to content

ImageCreateFromJpeg From URL


Beijufas

Recommended Posts

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:

[code]
<?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);
}
?>
[/code]

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:
[code]$src = ImageCreateFromJpeg($endereco);[/code]

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.