Staredit Network > Forums > Staredit Network > Topic: SQL Error on Use of [img] Tag
SQL Error on Use of [img] Tag
Sep 10 2010, 8:30 pm
By: DT_Battlekruser  

Sep 13 2010, 8:36 pm DavidJCobb Post #21



Quote from DT_Battlekruser
The slow function is getimagesize. It's a PHP library function and it can take as long as 15 seconds to return for the large image that's causing problems. Most images parse faster, but the call was probably always there. I suspect one of two things happened:

1) The timeout on the SQL database was lessened (15s seems a little short)
2) Something about this image is abnormal as far as being parsed by getimagesize. The delays are additive, so will likely encounter a similar error by including lots of images in your post (an average-size image takes a little less than 1s to parse)
Well, a browser knows an image's size even before it's downloaded the whole image, right? I figured that there had to be some way for PHP to do the same, and when going through the comments on PHP.net's getimagesize documentation, I found a possible solution for JPEGs. It does what I assume most browsers do: it goes through a JPEG's data until it finds the header bytes that specify its resolution.

If anyone here knows PHP and also knows how other image formats (BMP, PNG, GIF) are structured, then they can write similar functions, effectively removing the need for getimagesize.



None.

Sep 13 2010, 8:46 pm Aristocrat Post #22



I think these are correct:

Bitmap dimensions:
- offset 12: width
- offset 16: height

GIF dimensions:
- offset 06: width
- offset 08: height

(Those are hex values.)



None.

Sep 14 2010, 2:00 am O)FaRTy1billion[MM] Post #23

👻 👾 👽 💪

Quote from DavidJCobb
If anyone here knows PHP and also knows how other image formats (BMP, PNG, GIF) are structured, then they can write similar functions, effectively removing the need for getimagesize.
I could if necessary.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Sep 14 2010, 2:37 am shmeeps Post #24



Quote from DavidJCobb
Quote from DT_Battlekruser
The slow function is getimagesize. It's a PHP library function and it can take as long as 15 seconds to return for the large image that's causing problems. Most images parse faster, but the call was probably always there. I suspect one of two things happened:

1) The timeout on the SQL database was lessened (15s seems a little short)
2) Something about this image is abnormal as far as being parsed by getimagesize. The delays are additive, so will likely encounter a similar error by including lots of images in your post (an average-size image takes a little less than 1s to parse)
Well, a browser knows an image's size even before it's downloaded the whole image, right? I figured that there had to be some way for PHP to do the same, and when going through the comments on PHP.net's getimagesize documentation, I found a possible solution for JPEGs. It does what I assume most browsers do: it goes through a JPEG's data until it finds the header bytes that specify its resolution.

If anyone here knows PHP and also knows how other image formats (BMP, PNG, GIF) are structured, then they can write similar functions, effectively removing the need for getimagesize.
I believe almost all image formats have resolution data inside of the file, usually very close to the top. That code should be easily modifiable, especially on well know formats like BMP and GIF, which you can find large amounts of documentation about online. Same probably goes for PNG and just about any other format you could think of. I'll see if I can look into it a bit tommorrow.



None.

Sep 14 2010, 5:37 am O)FaRTy1billion[MM] Post #25

👻 👾 👽 💪

PNG should be well-known...



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Sep 15 2010, 3:16 am DT_Battlekruser Post #26



An interesting update on this. The files which take forever to be parsed by getimagesize on SEN run just fine (exact same code, exact same image) on my computer. Most images run in similar times on both, but with the so-called "problematic" images the difference is usually ~1000 ms on my computer versus ~20s on SEN.

Size sensing via direct streaming seems to still be dramatically faster on SEN though, so I will be switching that code over once I write a case for every file type.




None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:02 pm]
Zoan -- of course it isn't full understanding. You could ask "is the mechanism by which this counterexample blows up the ONLY mechanism possible for an initial configuration to blow up?"
[05:48 pm]
Zoan -- ppl do it all the time in PDEs
[05:47 pm]
Zoan -- Heinermann
Heinermann shouted: it also didn't solve that problem but hey as long as the investors are pleased
Constructing a counterexample is answering the question: "Is Navier Stokes well posed?" in the negative
[05:44 pm]
NudeRaider -- I only heard about it, didn't any news article, so what did it do then?
[05:43 pm]
Heinermann -- it also didn't solve that problem but hey as long as the investors are pleased
[05:39 pm]
NudeRaider -- I have no idea tbh. All I know no human was ever able to solve it, but there's at least a few that beat portal ;)
[05:32 pm]
Zoan -- Navier Stokes is not that esoteric I thought
[04:32 pm]
NudeRaider -- Zoan
Zoan shouted: I find it kind of sad that on the same day it was announced AI solved Navier Stokes, it was also announced AI beat Portal, and there's a good deal of people who don't know which is more impressive
you find it sad not everyone is a math nerd?
[03:25 pm]
NudeRaider -- (and yes, I capitalized that correctly :ego:)
[03:24 pm]
NudeRaider -- Symmetry
Symmetry shouted: Hi not I'm dad
Hi dad, I'm nude
Please log in to shout.


Members Online: Excalibur, Rawflesh0615, Ultraviolet