Get binary data from image

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Locked
User avatar
stu
Posts: 322
Joined: Wed Aug 07, 2013 11:37 am

Get binary data from image

Post by stu »

Having this VBScript function:

[syntax=vb]Const adTypeBinary = 1
Dim oStream, bData
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = adTypeBinary
oStream.Open
oStream.LoadFromFile "D:\temp.jpg"
bData = oStream.Read[/syntax]

How can I get the binary data on a Neobook variable?

Regards
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Get binary data from image

Post by Gaev »

Stu:

How about doing a "base64 encoding" of the binary data ... and then reading/storing the resulting "text string" in a NeoBook variable ?
User avatar
stu
Posts: 322
Joined: Wed Aug 07, 2013 11:37 am

Re: Get binary data from image

Post by stu »

Gaev wrote:Stu:

How about doing a "base64 encoding" of the binary data ... and then reading/storing the resulting "text string" in a NeoBook variable ?
Might just do the trick... Need a plugin for that?

That method is not working for me btw (the op one)... It gives a crappyfied string thats no use to me... I'm looking for this sort of result:

0x443A5C46455C437573746F647944617461626173655C74656D702E6A7067
User avatar
HPW
Posts: 2571
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany
Contact:

Re: Get binary data from image

Post by HPW »

Not sure what you want to do with the data, but maybe this might help:

Action: hpwImageSaveToMimeStream - Save a image to MimeStream (BMP/JPG/PNG/CAR).

First you have to load it to the image of course.

Regards
Hans-Peter
User avatar
stu
Posts: 322
Joined: Wed Aug 07, 2013 11:37 am

Re: Get binary data from image

Post by stu »

I dont store images in databases but as a requirement I need to store some small > 10 Kb jpg's on an SQL database (MS SQL 2005), so I'm trying to do this:

[syntax=sql]INSERT INTO Files (FileId, FileData) VALUES (1, 0x010203040506)[/syntax]

since thats the format images get stored on the SQL database field IMAGE, I dont know how can I turn an image into that sort of binary string, really... thats the issue.

-----

And, actually, this approach suits me:

[syntax=sql]UPDATE tblRights SET Sig1 = (SELECT * FROM OPENROWSET(BULK N'D:\Temp\temp.jpg', SINGLE_BLOB) AS x) WHERE RightsID = 9[/syntax]

Except that for some reason I keep getting "data set closed" sort of error from Neobook, maybe I should keep trying, but thought it might be possible to go the other way...
Locked