473,785 Members | 2,275 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 8323
"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
5047
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
2414
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
9721
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
25406
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
2098
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
4320
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
2732
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
1201
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
4344
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
10357
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...
1
10101
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
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
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...
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
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.