Downloading image from URL not saving entire image?

Downloading image from URL not saving entire image?

am 28.08.2007 17:09:21 von SBerry

I have an image proxy script I use to retrieve images from a remote
server and store locally on the first request. On the second request
(and all requests after) the image is returned from the local machine.

This has been working fine, but now I am using images that are 4+ MB
in size and the script is only saving a small portion of the image
rather than the entire thing.

Is there a limit to the size of the Image object?

------------- script snippet below -------------

if (! is_file($this->localDir . "/" . $image)) {
$image_remote = @imagecreatefromjpeg($this->remoteUrl . "/" .
$image);
$image_dir = dirname($this->localDir . "/" . $image);
$this->createWritableDirectory($image_dir);
imagejpeg($image_remote, $this->localDir . "/" . $image, $this-
>jpeg_quality);
header("Content-type: image/jpg");
header("Content-Length: ". filesize($this->localDir . "/" . $image));
imagejpeg($image_remote);
ob_end_flush();
return;
} else {
header("Content-type: image/jpg");
header("Content-Length: ". filesize($this->localDir . "/" . $image));
readfile($this->localDir . "/" . $image);
ob_end_flush();
return;
}

Re: Downloading image from URL not saving entire image?

am 28.08.2007 18:22:35 von Jerry Stuckle

sberry wrote:
> I have an image proxy script I use to retrieve images from a remote
> server and store locally on the first request. On the second request
> (and all requests after) the image is returned from the local machine.
>
> This has been working fine, but now I am using images that are 4+ MB
> in size and the script is only saving a small portion of the image
> rather than the entire thing.
>
> Is there a limit to the size of the Image object?
>
> ------------- script snippet below -------------
>
> if (! is_file($this->localDir . "/" . $image)) {
> $image_remote = @imagecreatefromjpeg($this->remoteUrl . "/" .
> $image);
> $image_dir = dirname($this->localDir . "/" . $image);
> $this->createWritableDirectory($image_dir);
> imagejpeg($image_remote, $this->localDir . "/" . $image, $this-
>> jpeg_quality);
> header("Content-type: image/jpg");
> header("Content-Length: ". filesize($this->localDir . "/" . $image));
> imagejpeg($image_remote);
> ob_end_flush();
> return;
> } else {
> header("Content-type: image/jpg");
> header("Content-Length: ". filesize($this->localDir . "/" . $image));
> readfile($this->localDir . "/" . $image);
> ob_end_flush();
> return;
> }
>

How much memory have you given PHP? The default (8M) probably isn't
enough for a 4M jpeg.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================