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:18 am]
Sylph-Of-Space -- No complaints here, i'm just curious!
[11:05 pm]
Ultraviolet -- :wob:
[03:55 pm]
Zoan -- :wob:
[10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[2024-5-18. : 3:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
[2024-5-17. : 4:35 am]
Ultraviolet -- mud, meet my friend, the stick
[2024-5-16. : 10:07 pm]
lil-Inferno -- nah
Please log in to shout.


Members Online: Roy