473,890 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting at the binary data in an Image object

I've search far and wide for an answer, so forgive me if this is a
stupid question. (Well, it probably is.)

Consider the following javascript:

var foo = new Image();
foo.src = "http://some.server.com/some_filename.g if";

Now, the browser will retrieve 'some_filename. gif' from some.server.com
and put it into the object foo. What I want to do is then subsequently
analyze the actual binary data contained inside some_filename.g if.
(Specifically, I just need to look at the first few bytes.) Is there
any way to do this in just JavaScript?

Thanks in advance for any assistance.

Dec 8 '05 #1
4 8333
"dirtside" <ma**@waggoner. com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com...
I've search far and wide for an answer, so forgive me if this is a
stupid question. (Well, it probably is.)

Consider the following javascript:

var foo = new Image();
foo.src = "http://some.server.com/some_filename.g if";

Now, the browser will retrieve 'some_filename. gif' from some.server.com
and put it into the object foo. What I want to do is then subsequently
analyze the actual binary data contained inside some_filename.g if.
(Specifically, I just need to look at the first few bytes.) Is there
any way to do this in just JavaScript?

Thanks in advance for any assistance.


Will this help?

function XML() {
var sURL = "http://some.server.com/some_filename.g if";
var oXML = new ActiveXObject(" Msxml2.XMLHTTP. 3.0");
oXML.open("GET" ,sURL,false);
oXML.send();
return oXML.responseBo dy;
}

alert( XML() );
You'll see a bunch of question marks but that's the binary data.
Substituting .responseText will show you some readable text ...
You can test with:
var sURL = "http://www.google.com/intl/en/images/logo.gif";

You might have to use one of these instead:
var oXML = new ActiveXObject(" Msxml2.XMLHTTP" );
var oXML = new ActiveXObject(" Microsoft.XMLHT TP");
Dec 8 '05 #2
On 7 Dec 2005 17:10:37 -0800, in comp.lang.javas cript "dirtside"
<ma**@waggoner. com> wrote:
| I've search far and wide for an answer, so forgive me if this is a
| stupid question. (Well, it probably is.)
|
| Consider the following javascript:
|
| var foo = new Image();
| foo.src = "http://some.server.com/some_filename.g if";
|
| Now, the browser will retrieve 'some_filename. gif' from some.server.com
| and put it into the object foo. What I want to do is then subsequently
| analyze the actual binary data contained inside some_filename.g if.
| (Specifically, I just need to look at the first few bytes.) Is there
| any way to do this in just JavaScript?
|
| Thanks in advance for any assistance.


This is server-side code but you might be able to convert it to
client-side.
http://4guysfromrolla.com/webtech/050300-1.shtml
---------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Dec 8 '05 #3
That looks like IE-specific code... whatever I do has to be
cross-platform. (I tried the above code in Mozilla, and was unsurprised
when the JavaScript debugger said it didn't know what 'ActiveXObject'
was ;)).

Dec 8 '05 #4
"dirtside" <ma**@waggoner. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
That looks like IE-specific code... whatever I do has to be
cross-platform. (I tried the above code in Mozilla, and was unsurprised
when the JavaScript debugger said it didn't know what 'ActiveXObject'
was ;)).


Try this.
function getRequestObj() {
var ret = null;
var xml = [
"MSXML2.XMLHTTP .5.0",
"MSXML2.XMLHTTP .4.0",
"MSXML2.XMLHTTP .3.0",
"MSXML2.XMLHTTP ",
"Microsoft.XMLH TTP"];
if (window.ActiveX Object) {
for (var i=0; i<xml.length; i++) {
try {
ret = new ActiveXObject(x ml[i]);
break;
} catch(e) {}
}
} else if(window.XMLHt tpRequest) {
try {
ret = new XMLHttpRequest( );
} catch(e) {}
}
return ret;
}

var sURL = "http://some.server.com/some_filename.g if";
var oXML = getRequestObj() ;
oXML.open("GET" ,sURL,false);
oXML.send();

// if you want the "GIF89" content prefix
alert(oXML.resp onseText);

// if you want the binary data stream
alert(oXML.resp onseBody);
Dec 8 '05 #5

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

Similar topics

5
5049
by: Blaktyger | last post by:
How can this be done? Images are stored in a LONGBLOB field. When I try to display them, it prints out the binary data as it is... Thank you
4
2419
by: projecktzero | last post by:
Well, I've managed to get an image into a postgre database, but now I'm having trouble getting it out. #! /usr/bin/env python from pyPgSQL import PgSQL def main(): connectdb = PgSQL.connect('server:port:database:username:password') cur = connectdb.cursor()
9
9727
by: Maurizio Penna | last post by:
I, guys. I've embeded an image into a xml file, something like that: <display type="picture" mime="image/png" name = "mosaico6.png"> <!]> </display> Now, I want to display it with a XSL Transformation, but my code don't work: <display>
8
25424
by: Jerry | last post by:
I have an off-the-shelf app that uses an Access database as its backend. One of the tables contains a field with an "OLE Object" datatype. I'm writing some reports against this database, and I believe this field contains data I need. When I view the table in datasheet view, all I can see in this field is the string "Long binary data". So, I've got the problem of needing to extract data from this field, but I don't know what format...
3
2105
by: Josema | last post by:
Hi to all, I have stored in a database some binary files (pdfs, and gif images), i would like to know how could i show it, in internet explorer when a person enters for instance in a textbox the id of the file that want to view.... This is my Sql table... ID int File binary
26
4344
by: Patient Guy | last post by:
Has anyone written code that successfully manipulates binary file data using Javascript? It might---and in the case of doing I/O, will---make use of browser- specific functions (ActiveX/COM with Internet Explorer, XPCOM/XPConnect with Mozilla/Firefox). I am writing client-side code that will generate binary data for producing a GIF file through an OBJECT element. (The GIF is an image of a line and points on a two-axis plot.)
6
2740
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios, every now and then the client would timeout and have to re-initiate the request... TIA!
2
1208
by: Areric | last post by:
Hey all, Another question for you. I have a script that reads in a row from my db into an image object which i defined. It then takes that image and generates a thumbnail by using an output buffer and writes the thumbnail to a new entry in the database. Finally it prints the new image to the screen via this method:
6
4357
by: aznimah | last post by:
hi, i'm work on image comparison. i'm using the similarity measurement which i need to: 1) convert the image into the binary form since the algorithm that i've use works with binary data for the computation 2) compare the string binary data to get the similarity or dissimilarity result. The problem is, i already done with the image (jpg) conversion to binary and also try the algorithm structure in C# language, but i having a problem to...
0
9976
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
9815
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
11215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10802
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
10908
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
5835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6035
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4259
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3267
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.