Source language: Translate to:

Get binary data from image

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Get binary data from image

Postby stu » Fri Jan 08, 2016 7:30 am

Having this VBScript function:

Syntax: [ Download ] [ Hide ]
Using Visual Basic Syntax Highlighting
Const adTypeBinary = 1
Dim oStream, bData
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = adTypeBinary
oStream.Open
oStream.LoadFromFile "D:\temp.jpg"
bData = oStream.Read
Parsed in 0.003 seconds, using GeSHi 1.0.8.10


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

Regards
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Get binary data from image

Postby Gaev » Fri Jan 08, 2016 7:50 am

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
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Get binary data from image

Postby stu » Fri Jan 08, 2016 7:57 am

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
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Get binary data from image

Postby HPW » Fri Jan 08, 2016 8:11 am

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
HPW
 
Posts: 2516
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Get binary data from image

Postby stu » Fri Jan 08, 2016 9:04 am

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: [ Download ] [ Hide ]
Using SQL Syntax Highlighting
INSERT INTO Files (FileId, FileData) VALUES (1, 0x010203040506)
Parsed in 0.005 seconds, using GeSHi 1.0.8.10


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: [ Download ] [ Hide ]
Using SQL Syntax Highlighting
UPDATE tblRights SET Sig1 = (SELECT * FROM OPENROWSET(BULK N'D:\Temp\temp.jpg', SINGLE_BLOB) AS x) WHERE RightsID = 9
Parsed in 0.005 seconds, using GeSHi 1.0.8.10


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...
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests