473,883 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

imagecreatetrue color sometimes causes forced-download of index.php for some JPEG images

index.php:

[PHP]
// STUFF
// STEP 1: imagecreatetrue color ONLY IF GD 2.0+ SUPPORTED AND FOUND
if ($this->isSuccessful && !$hasMogrified && $image && !$newImage &&
function_exists ('imagecreatetr uecolor') && preg_match('/2\.0/i',
$this->gd_info_arra y[0])) {
$newImage = @imagecreatetru ecolor($configA rray['width'],
$configArray['height']);
if (!$newImage) {
$this->isSuccessful = false;
$this->setErrorArray( array('action' ='Could not seem to create
new image'));
}
}

[/PHP]

This block of code will sometimes, for reasons I just don't understand,
cause a forced-download of the entire index.php script! This is not
even a consistent issue inasmuch as this only happens to certain JPEG
images. I am completely unable to discern a pattern; it happens to
some JPEG images and not to others; furthermore, this behavior does not
occur in GIF or PNG images.

I am using PHP 4.3.9 with GD 2.0.1 in Linux RHEL 4.

Thanx
Phil

Aug 4 '06 #1
12 2855
On 4 Aug 2006 09:22:45 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
>index.php:

[PHP]
// STUFF
// STEP 1: imagecreatetrue color ONLY IF GD 2.0+ SUPPORTED AND FOUND
if ($this->isSuccessful && !$hasMogrified && $image && !$newImage &&
function_exist s('imagecreatet ruecolor') && preg_match('/2\.0/i',
$this->gd_info_arra y[0])) {
$newImage = @imagecreatetru ecolor($configA rray['width'],
$configArray['height']);
if (!$newImage) {
$this->isSuccessful = false;
$this->setErrorArray( array('action' ='Could not seem to create
new image'));
}
}

[/PHP]

This block of code will sometimes, for reasons I just don't understand,
cause a forced-download of the entire index.php script! This is not
even a consistent issue inasmuch as this only happens to certain JPEG
images. I am completely unable to discern a pattern; it happens to
some JPEG images and not to others; furthermore, this behavior does not
occur in GIF or PNG images.

I am using PHP 4.3.9 with GD 2.0.1 in Linux RHEL 4.
There was probably an error in the script, so what comes out isn't image data.
Your first thing to do is check the actual output. Either download the data
it's offering and look at it with an editor, or temporarily change the
Content-type.

You also mention that the symptoms occur with specific JPEG images; can you
find some common factor in these images that is not in the other images?

Given the considerably higher compression ratio in JPEG vs. PNG and GIF -
since it's lossy it can reduce much further than the other two lossless formats
- then you have to also bear in mind that JPEGs decompress in memory into far
bigger images. Are you running out of memory (or exceeding the PHP memory_limit
setting?)

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 4 '06 #2
Actually I was wrong and found out the problem isn't
imagecreatetrue color() but it happens to be imagecreatefrom jpeg(),
again, only with certain JPEG images. There is nothing I could find
that distinguished one JPEG from another; they're all roughly the same
size, compression, having the same permissions, group and onwership,
all the same amount of color, all from the same CD source.

I thought it was exceeding of memory_limit, however, using
memory_get_usag e() I am finding the memory allotted for use in the
script is far below memory_limit, however, it still "dies".

Phil

Andy Hassall wrote:
On 4 Aug 2006 09:22:45 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
index.php:

[PHP]
// STUFF
// STEP 1: imagecreatetrue color ONLY IF GD 2.0+ SUPPORTED AND FOUND
if ($this->isSuccessful && !$hasMogrified && $image && !$newImage &&
function_exists ('imagecreatetr uecolor') && preg_match('/2\.0/i',
$this->gd_info_arra y[0])) {
$newImage = @imagecreatetru ecolor($configA rray['width'],
$configArray['height']);
if (!$newImage) {
$this->isSuccessful = false;
$this->setErrorArray( array('action' ='Could not seem to create
new image'));
}
}

[/PHP]

This block of code will sometimes, for reasons I just don't understand,
cause a forced-download of the entire index.php script! This is not
even a consistent issue inasmuch as this only happens to certain JPEG
images. I am completely unable to discern a pattern; it happens to
some JPEG images and not to others; furthermore, this behavior does not
occur in GIF or PNG images.

I am using PHP 4.3.9 with GD 2.0.1 in Linux RHEL 4.

There was probably an error in the script, so what comes out isn't image data.
Your first thing to do is check the actual output. Either download the data
it's offering and look at it with an editor, or temporarily change the
Content-type.

You also mention that the symptoms occur with specific JPEG images; can you
find some common factor in these images that is not in the other images?

Given the considerably higher compression ratio in JPEG vs. PNG and GIF -
since it's lossy it can reduce much further than the other two lossless formats
- then you have to also bear in mind that JPEGs decompress in memory into far
bigger images. Are you running out of memory (or exceeding the PHP memory_limit
setting?)

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 4 '06 #3
Rik
comp.lang.php wrote:
Actually I was wrong and found out the problem isn't
imagecreatetrue color() but it happens to be imagecreatefrom jpeg(),
again, only with certain JPEG images. There is nothing I could find
that distinguished one JPEG from another; they're all roughly the same
size, compression, having the same permissions, group and onwership,
all the same amount of color, all from the same CD source.

I rather doubt it.
What if you halt the script directly after imagecreatefrom jpeg()?

Grtz,
--
Rik Wasmus
Aug 4 '06 #4
On 4 Aug 2006 14:44:18 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
>Actually I was wrong and found out the problem isn't
imagecreatetru ecolor() but it happens to be imagecreatefrom jpeg(),
again, only with certain JPEG images. There is nothing I could find
that distinguished one JPEG from another; they're all roughly the same
size, compression, having the same permissions, group and onwership,
all the same amount of color, all from the same CD source.

I thought it was exceeding of memory_limit, however, using
memory_get_usa ge() I am finding the memory allotted for use in the
script is far below memory_limit, however, it still "dies".
If imagecreatefrom jpeg() is exhausting the memory you're not going to be able
to see it from memory_get_usag e(); you'll be below the limit before the call,
and it'll die during the call - you won't be able to see it exceeding the limit
apart from the error message (you have turned error_reporting back up to E_ALL,
right?)

And next:

(1) What _is_ output by the script when it fails?

(2) Can you reduce it to a _minimal_ test script - sounds like it could go all
the way down to imagecreatefrom jpeg() followed by imagejpeg() ?

(3) If you still can't work it out from there can you make available to the
group examples of (a) an image that fails and (b) a similar one that doesn't
fail?

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 4 '06 #5

Rik wrote:
comp.lang.php wrote:
Actually I was wrong and found out the problem isn't
imagecreatetrue color() but it happens to be imagecreatefrom jpeg(),
again, only with certain JPEG images. There is nothing I could find
that distinguished one JPEG from another; they're all roughly the same
size, compression, having the same permissions, group and onwership,
all the same amount of color, all from the same CD source.


I rather doubt it.
What if you halt the script directly after imagecreatefrom jpeg()?
SImple. You get a prompt asking you to open and same "index.php" to
your browser.

Phil
>
Grtz,
--
Rik Wasmus
Aug 4 '06 #6

Andy Hassall wrote:
On 4 Aug 2006 14:44:18 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
Actually I was wrong and found out the problem isn't
imagecreatetrue color() but it happens to be imagecreatefrom jpeg(),
again, only with certain JPEG images. There is nothing I could find
that distinguished one JPEG from another; they're all roughly the same
size, compression, having the same permissions, group and onwership,
all the same amount of color, all from the same CD source.

I thought it was exceeding of memory_limit, however, using
memory_get_usag e() I am finding the memory allotted for use in the
script is far below memory_limit, however, it still "dies".

If imagecreatefrom jpeg() is exhausting the memory you're not going to be able
to see it from memory_get_usag e(); you'll be below the limit before the call,
and it'll die during the call - you won't be able to see it exceeding the limit
apart from the error message (you have turned error_reporting back up to E_ALL,
right?)
Yes, to no avail. It still forces you to download "index.php" . There
is no error, no warning, nothing. PHP doesn't register any kind of
message whatseover; in fact, it sounds more like a segfault, in short,
*there is no PHP anymore*
>
And next:

(1) What _is_ output by the script when it fails?
Nothing. You're forced to download index.php
(2) Can you reduce it to a _minimal_ test script - sounds like it could go all
the way down to imagecreatefrom jpeg() followed by imagejpeg() ?
It doesn't. It dies right at imagecreatefrom jpeg() every time. Never
gets any further than that.
(3) If you still can't work it out from there can you make available to the
group examples of (a) an image that fails and (b) a similar one that doesn't
fail?
I don't have an immediate way of producing them publically; they're on
a government-protected server that's not open to the general public; I
would have to attach them here, which I don't think Google Groups
allows to do.
--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 4 '06 #7
On 4 Aug 2006 15:12:05 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
>Yes, to no avail. It still forces you to download "index.php" . There
is no error, no warning, nothing. PHP doesn't register any kind of
message whatseover; in fact, it sounds more like a segfault, in short,
*there is no PHP anymore*
If there was a segfault there'd be a record of it in the Apache error log - is
there?
> (1) What _is_ output by the script when it fails?

Nothing. You're forced to download index.php
Then at least _something_ was output. Accept the download - how long is the
file you download? Is it zero-length or not?
> (2) Can you reduce it to a _minimal_ test script - sounds like it could go all
the way down to imagecreatefrom jpeg() followed by imagejpeg() ?

It doesn't. It dies right at imagecreatefrom jpeg() every time. Never
gets any further than that.
So you have reproduced the problem on a new minimal script containing only a
call to imagecreatefrom jpeg() and nothing else?

What is memory_limit set to?
What are the properties of the JPEG file?
> (3) If you still can't work it out from there can you make available to the
group examples of (a) an image that fails and (b) a similar one that doesn't
fail?

I don't have an immediate way of producing them publically; they're on
a government-protected server that's not open to the general public; I
would have to attach them here, which I don't think Google Groups
allows to do.
You don't have another website you can put it on? Failing that you could email
one to me if you wanted and I could have a look to see if there's anything
strange about the JPEG, unless you're not allowed to distribute it.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 4 '06 #8

Andy Hassall wrote:
On 4 Aug 2006 15:12:05 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
Yes, to no avail. It still forces you to download "index.php" . There
is no error, no warning, nothing. PHP doesn't register any kind of
message whatseover; in fact, it sounds more like a segfault, in short,
*there is no PHP anymore*

If there was a segfault there'd be a record of it in the Apache error log - is
there?
I will let you know; I was not given permission to view the Apache
error logs (yes of my own machine, it's the US government, nuff said)
>
(1) What _is_ output by the script when it fails?
Nothing. You're forced to download index.php

Then at least _something_ was output. Accept the download - how long is the
file you download? Is it zero-length or not?
It's the length of the original index.php that I wrote, script intact.
Not very safe.
(2) Can you reduce it to a _minimal_ test script - sounds like it could go all
the way down to imagecreatefrom jpeg() followed by imagejpeg() ?
It doesn't. It dies right at imagecreatefrom jpeg() every time. Never
gets any further than that.

So you have reproduced the problem on a new minimal script containing only a
call to imagecreatefrom jpeg() and nothing else?
Yes, and the download is the script I created with
imagecreatefrom jpeg() as well.
What is memory_limit set to?
What are the properties of the JPEG file?
memory_limit set to 8M (8mb)
Properites of the JPEG file are pretty standard AFAIK, I'm sending one
"good one" and one "bad one" to you
(3) If you still can't work it out from there can you make available to the
group examples of (a) an image that fails and (b) a similar one that doesn't
fail?
I don't have an immediate way of producing them publically; they're on
a government-protected server that's not open to the general public; I
would have to attach them here, which I don't think Google Groups
allows to do.

You don't have another website you can put it on? Failing that you could email
one to me if you wanted and I could have a look to see if there's anything
strange about the JPEG, unless you're not allowed to distribute it.
I emailed them to you; these are not private proprietary images they
are my own test images.
--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 4 '06 #9
On 4 Aug 2006 16:06:19 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
>Andy Hassall wrote:
>On 4 Aug 2006 15:12:05 -0700, "comp.lang. php" <ph************ **@gmail.com>
wrote:
>>> (1) What _is_ output by the script when it fails?

Nothing. You're forced to download index.php

Then at least _something_ was output. Accept the download - how long is the
file you download? Is it zero-length or not?

It's the length of the original index.php that I wrote, script intact.
Not very safe.
That's worrying; even in fairly catastrophic failures that's not supposed to
happen.
> So you have reproduced the problem on a new minimal script containing only a
call to imagecreatefrom jpeg() and nothing else?

Yes, and the download is the script I created with
imagecreatefro mjpeg() as well.
> What is memory_limit set to?
What are the properties of the JPEG file?

memory_limit set to 8M (8mb)
Properites of the JPEG file are pretty standard AFAIK, I'm sending one
"good one" and one "bad one" to you
The images you sent appear to confirm that memory limit is at least part of
the issue; the smaller (good) image is quite small, whereas the larger (bad)
image is well over the 8M limit when decompressed. I've just tried it on PHP
5.1.2 with memory_limit set to 32M, and memory_get_usag e() says that the memory
used immediately after imagecreatefrom jpeg() is:

Memory usage: 9490728

This is a bit higher than I'd expect - the image is 1770x1100 so the
uncompressed image data would be somewhere in the region of 46728000 bytes (24
bit colour), or 62304000 (24 bit plus transparency/alpha channel).

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 5 '06 #10

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

Similar topics

5
4762
by: Harry | last post by:
CSS Description: Table contains a column of td cells with links. Achieved: 1. Entire link cells highlight when hovered. 2. The entire area of these cells are clickable. Problem:
6
6990
by: VK | last post by:
I'm using window.open method in my script to open poup window. Recently Internet Explorer users reported that the script crashes on their machine with different runtime errors. See the bug: <http://support.microsoft.com/default.aspx?scid=kb;en-us;888021> The statement like myPopup = window.open(args); gives you runtime error and halts the script execution *if a 3rd party
5
3278
by: Frank van Vugt | last post by:
Hi, I noticed that when using the single commandline: drop database <name>; create database <name>; this sometimes fails due to a pg_autovacuum process running on the background. When this happens, the error returned is:
1
2724
by: Ben Harper | last post by:
In VC7, look at the following code: char* ok1 = "1234567890ABCD"; char* ok2 = "1234567890ABCDE"; char* bad1 = "1234567890ABCDEF"; char* bad2 = "1234567890ABCDEFG"; string take; take = ok1; take = ok2; take = bad1;
4
6431
by: Chamomile | last post by:
Does anyone know if its possible to set imagecreatetruecolor() to initialise with transparency rather than black? Maybe a cunning work-around?
0
1556
by: Chamomile | last post by:
Does anyone know if its possible to set imagecreatetruecolor() to initialise with transparency rather than black? (using png...) Maybe a cunning work-around?
3
2124
by: Danny J. Lesandrini | last post by:
-- previously posted on newsgroup :: <microsoft.public.access-- Has anyone else noticed this behavior? Focus jumping from current cell to upper left in embedded datasheet. If not, would you be willing to test your environment and report back? I posted this question back in May because a client using our application reported it. We could only reproduce it on our network if we modified the configuration. Now, however, it's happening...
5
2244
by: PooFlinger1 | last post by:
I am writing an application which will install a number of updates (silently) as well as installing Norton and Spysweeper silently. Problem is that after spysweeper installs, it performs a forced reboot of the PC. How would I abort the FORCED shutdown?
0
1661
jeffstl
by: jeffstl | last post by:
After enabling forced protocol encryption on SQL server there are a handful of crystal reports that have the following error when you try to run them Query Engine Error: '08S01:Communication link failure Turn the forced protocol encryption off on SQL Server and they work again just fine. I have tried re-choosing the data source of the .rpt files, and tried turning on Integrated Security before loading the reports with no luck Has anyone...
7
3453
by: fuchsia555 | last post by:
hi why is sometimes i get this message error during browsing my site ? but when i refresh it comes back , what causes this error ? Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. Apache/1.3.33 Server at www.example.com Port 80
0
9942
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10416
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7971
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3233
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.