• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

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
0
sleepybear
Asked:
sleepybear
  • 3
1 Solution
 
sleepybearAuthor Commented:
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.
0
 
GwynforWebCommented:
not client side. The only things exposed off the header of an image file to JS are the heigth and width. see http://www.devguru.com/Technologies/ecmascript/quickref/image.html

You can not change the extension using JS programatically
0
 
GwynforWebCommented:
     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.

   
0
 
GwynforWebCommented:
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.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now