Link to home
Start Free TrialLog in
Avatar of sleepybear
sleepybear

asked on

Any way to get background color info using JavaScript?

I know you can get a GIF's height and width, but I'm
wondering if there's anyway to retrieve its background
color. From what I understand, it's stored in the GIF
header right along with the height & width information,
so I'm curious if it's possible.

Failing that, is there anyway to dynamically rename a
GIF to a different file. In other words, can you change
the name of "image.gif" to "image.txt" somehow? If
so, you could just pull in the text file and read the
background color info. But I can't figure out how to do
that either!

Any suggestions are welcome
Avatar of sleepybear
sleepybear

ASKER

Oops. I suppose I should have mentioned that I meant to
add... "any way to do this in JavaScript?"

Hopefully, since this IS in the JavasScript section you guys
figured that out.
ASKER CERTIFIED SOLUTION
Avatar of GwynforWeb
GwynforWeb
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
     You have access to 4 bytes of info in the header (ie height and width) this is 32 bits. By limiting your chars to alpha-numeric and a just a few special chars with  compression you can get it down to between 4 and 5 bits per char (if you are really smart with the compression depending on the message type you could even get this down lower). Bascially you are looking at about 6 or 7 chars per header, this is not a lot and you would require about  40 images for 256 chars.

   
the width and height in the header can be edited with a hex editor on say with a 3 by 3 .bmp to be 63000 by 45987 and the file will still be tiny, the file can be loaded and not displayed with the data extracted, I tried it.  But still not much data per image.