473,405 Members | 2,444 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,405 software developers and data experts.

Script Crashing

Okay, I posted this over at alt.php, but got nil response, so I'm posting it
hear again in hopes of getting a response. Sorry to anyone reading this
twice:

Okay...so on my website, where people can upload pictures, there is a fairly
major problem with the upload script. Specificaly the part of this script
that automatically generates thumbnails. For some reason, when someone
uploads a picture that is very large in dimensions, in the process of making
a thumbnail, the script crashes, and the browser gives an 'internal server
error' message. Here is the snippet of code that I've narrowed down as the
problem:
$width = $size[0]; //width of original image
$height = $size[1]; //height of original image

$width = round(($width/4)); //width for thumnail
$height = round(($height/4)); //height for thumbnail
$dst_img = ImageCreateTrueColor($width,$height); //creates new image
ImageCopyResized($dst_img, $src_img, 0,0,0,0, $width, $height, $size[0],
$size[1]); //creates thumbnail from original

ImageJpeg($dst_img, "users/$uname/$album/small/$pic_name", 60); //copies
thumnail to appropriate folder with quality adjustment

Now the funny thing is that this works fine on my own computer where I test
stuff out before making it live. When I upload it to my website however,
these large pictures crash. This makes me wonder if it's not some sort of
PHP config setting. The dimension in which I have found this is a problem
is, 2032x1524 pixels. Anyways, any help would be greatly appeciated, and
TIA.
--
<=============>
--Lee
http://www.inaneasylum.org

Goodbye, adios, bis bald, see ya later, wiedersehen, and everything in
between
Jul 17 '05 #1
4 1815
Lee Marsh <bu*************@fake.com> wrote:
ImageJpeg($dst_img, "users/$uname/$album/small/$pic_name", 60); //copies
thumnail to appropriate folder with quality adjustment

Now the funny thing is that this works fine on my own computer where I test
stuff out before making it live. When I upload it to my website however,
these large pictures crash. This makes me wonder if it's not some sort of
PHP config setting. The dimension in which I have found this is a problem
is, 2032x1524 pixels. Anyways, any help would be greatly appeciated, and
TIA.


Your only the second person to ask the same question this week :)

It's propably a memory limit, said dimension needs 12387072 bytes of
memory. Default is 8Mb max IIRC. You can check this by looking at the
error messages (set level to E_ALL and use a decend tool (like lynx
-source URL | less) or simply send it as "text" (remove image/foo
header))
Jul 17 '05 #2
Ugg, that's the problem though. It's on my host's server, and I don't have
the $$ for anything nicer than a virtual server which puts the config files
in their hands, and they're very obstinate about keeping their config files
the same. Do you have any idea how I might be able to calculate the
threshold and put some sorta check on that so the script doesn't crash?

Also, do you not think it's strange that although I can send photos that are
large, I can send files of equivelent file size (in this case 800KB)? On a
similar note, I messed around with it some more, and the script will
actually allow for images larger than the dimension I gave originally,
however, the thumnail is a blank black image rather than, well, an actual
thumnail? What do you think?
--
<=============>
--Lee
http://www.inaneasylum.org

Goodbye, adios, bis bald, see ya later, wiedersehen, and everything in
between
"Daniel Tryba" <pa**********@invalid.tryba.nl> wrote in message
news:42***********************@news6.xs4all.nl...
Lee Marsh <bu*************@fake.com> wrote:
ImageJpeg($dst_img, "users/$uname/$album/small/$pic_name", 60); //copies
thumnail to appropriate folder with quality adjustment

Now the funny thing is that this works fine on my own computer where I
test
stuff out before making it live. When I upload it to my website however,
these large pictures crash. This makes me wonder if it's not some sort of
PHP config setting. The dimension in which I have found this is a problem
is, 2032x1524 pixels. Anyways, any help would be greatly appeciated, and
TIA.


Your only the second person to ask the same question this week :)

It's propably a memory limit, said dimension needs 12387072 bytes of
memory. Default is 8Mb max IIRC. You can check this by looking at the
error messages (set level to E_ALL and use a decend tool (like lynx
-source URL | less) or simply send it as "text" (remove image/foo
header))

Jul 17 '05 #3
It's not surprising that the server can send/recieve files larger than
the limit you're talking about. In those cases, it'll often not keep
the entire file in memory at once, but stream parts of it as needed.

You could do your thumbnail script in two parts. The first part is a
sanity-check on the file. If the file has more than X pixels (pull the
width and height, and multiply them), then fail, otherwise make the
thumbnail. It's more of a way to gracefully deflect the problem than
really solving it.

~D

Jul 17 '05 #4
One thing to try is to get the thumbnail that is stored in JPEG files.
Digital cameras and software like Photoshop often place thumbnail
images into files to make them easier to browse through.

The following function tries to extract the thumbnail, returning a GD
image handle if successful. You will need to enable the exif extension.

function imagecreatefromjpegthumbnail($path) {
if($data = @exif_read_data($path, 'THUMBNAIL', false, true)) {
if($thumb_nail_data = @$data['THUMBNAIL']['THUMBNAIL']) {
return @imagecreatefromstring($thumb_nail_data);
}
}
return false;
}

Example:

$f = "C:/Documents and Settings/cleong/My Documents/My
Pictures/gonch2.jpg";
if($img = imagecreatefromjpegthumbnail($f)) {
header("Content-type: image/png");
imagepng($img);
}

Jul 17 '05 #5

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

Similar topics

1
by: Newbie | last post by:
Please Help, I have 2 <div's> named "DETdetails" & "MEMOdetails" in my ASP page that loads an external css file for these 2 <div's> I want both <div's> to be static when the page scrolls...
1
by: Luis | last post by:
When I run the following script it displays a form with a dropdown list and four text boxes. If I select "No" from the dropdown list all the text boxes are disabled. If I select "Yes" from the...
2
by: codesmithsf | last post by:
I'm using PHP 4.2.2 and Apache 2.0.4.0. A script running on a virtual host had an endless loop in it that brought Apache to its knees. I have max_execution_time=90 and memory_limit=32M to...
14
by: Java and Swing | last post by:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) { // this will store the result in a Python object PyObject *finalResult; // get arguments from Python char *result = 0; char *in=...
1
by: mydejamail | last post by:
My PHP setup is not updating the error_log, I have checked all the error logging related settings and they have all been set. The script is also crashing inexplicably. Whenever I call a specific...
2
by: yangsuli | last post by:
It works perfectly well before but today my browser cannot get this php script i tried to run it in the localhost and it reported a seg fault :( i donot konw what to do.....:( restarting the...
1
by: dragze | last post by:
Hi, On one of the pages of my site i use two javascripts, one makes transparency of png's work in IE, and the other embeds a flash player. Now use one of the scripts it works fine, use both and...
2
by: =?Utf-8?B?QW5uZXh4eHh4eHg=?= | last post by:
My computer keeps crashing. The files created when it does this are: WERdc15.dir00\Mini090708-03.dmp WERdc15.dir00\sysdata.xml has anybody any idea of what these files are and the solution to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.