473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Downloading image from URL not saving entire image?

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;
}

Aug 28 '07 #1
1 1461
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.
js*******@attglobal.net
==================
Aug 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: deko | last post by:
I have a table that contains a bunch of pictures. When the user selects a particular image in a form, I need a way to extract the selected bitmap image (stored in an OLE Object table field) to the...
2
by: Dave | last post by:
Dear Sirs, Is there a way to get the width and height of an image without downloading the image, or with just downloading a minimal portion of the image? For instance, I have a list of 10,000...
0
by: TJ | last post by:
Hi, I've written code web-based uploading and downloading. Here is some code for it. For saving file into MS-SQL database, SaveFileIntoDB(HttpPostedFile file) { int fileLength =...
23
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.