Source language: Translate to:

VBScript and converting PPM image to BMP and back

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

VBScript and converting PPM image to BMP and back

Postby Enigman » Wed Apr 04, 2012 11:12 pm

Does anyone know where I can find some VBScript for a NB function to convert a PPM image file to BMP image format and back again?

The requirement is to take PPM data from a variable and write a BMP file to disk. It must also load a BMP file from disk and convert it to PPM data in a variable. Only BMP will be written or read. The PPM will always be only in memory.

It could also be PPM to TIF and back. Any uncompressed output image format will do, or a lossless compressed format. But it is essential that NO data is lost in the image file on disk. Every pixel must survive intact.

In case you haven't seen one, a PPM image file is a very simple ascii encoded bitmap file. You can find a specification here:

http://netpbm.sourceforge.net/doc/ppm.html

Scroll down to the P3 version of PPM.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Postby HPW » Wed Apr 04, 2012 11:57 pm

The PPM format is not very popular and very effectiv.
So what is the reason you want to use it?

Do you want to script images into a variable with this?
Then scriptable image-plugins could be a option.

By the way: IrfanView seem to support it.
Hans-Peter
User avatar
HPW
 
Posts: 2518
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: VBScript and converting PPM image to BMP and back

Postby dpayer » Thu Apr 05, 2012 7:30 am

Enigman wrote:Does anyone know where I can find some VBScript for a NB function to convert a PPM image file to BMP image format and back again?
http://netpbm.sourceforge.net/doc/ppm.html

Scroll down to the P3 version of PPM.


Your link led to another that has a download for a PHP class to maniuplate the files:

http://sourceforge.net/projects/phpnetpbm/?_test=b

You can call PHP scripts from a PHP plugin in NB or you could install the command line version of PHP onto your system to see if you could use this to do a batch style conversion.

David P.
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Enigman » Thu Apr 05, 2012 8:18 am

dpayer,

Thanks for your reply.

I can't really use a batch conversion, or external file. We have spoken about this app before in other posts. This is for the encryption app where I am restricting the use of even plug-ins.

If I can find some VBScript for this to use in a function, or if NeoBook wants to offer it as a plugin then I could add this function to my app. Either way, it would have to be a part of the app as if I wrote the file save and file open routines in native NB.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Postby Enigman » Thu Apr 05, 2012 8:46 am

HPW,

The PPM format is not very popular and very effectiv.
So what is the reason you want to use it?

Yes, it is a very old intermediate image file format normally used to translate between platforms. But it can be easily generated by NB code.

This is something I would offer for my encryption app as a "post-processing" format, where the encrypted data would be reprocessed into PPM format which is an all ascii format. I would need the file save and open routines to save the PPM format to BMP or TIF format so that the encrypted data could then "hide in plain sight" so to speak, as a valid and functional image file. It could be e-mailed as an image and would even display, looking like some kind of texture image. If I wanted to get fancy I could even interlace real image data in the output file.

If I can't readily get the save and open routines I can still offer the post processing format and save it as PPM, but that would be less effective at hiding than BMP since the arcane nature of the PPM format could increase attention.

Do you want to script images into a variable with this?
Then scriptable image-plugins could be a option.

If I understand the question, I want to do both but in the reverse order. I will convert text data into an image and later convert the image back into text data. Plug-in use would be limited to one from NeoBook. We have discussed previously why on this app.

By the way: IrfanView seem to support it.

I'm not sure what that is?

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Postby dpayer » Thu Apr 05, 2012 9:10 am

Enigman wrote:dpayer,

Thanks for your reply.

I can't really use a batch conversion, or external file. We have spoken about this app before in other posts. This is for the encryption app where I am restricting the use of even plug-ins.

If I can find some VBScript for this to use in a function, or if NeoBook wants to offer it as a plugin then I could add this function to my app. Either way, it would have to be a part of the app as if I wrote the file save and file open routines in native NB.

Thanks.


Understood, I thought you were free to use documentable software (like PHP).

If not... let me ask a question. Will the image be displayed at any time on the screen? If so, there may be a way to capture it and convert via script.

I found a few sample PPM files but they will not open natively in IE.

The closest I found was some C language code for converting ascii PPM files to BMP and viceversa.
http://orion.math.iastate.edu/burkardt/g_src/g_src.html
and a bmp format description that would be helpful if you had to work from scratch:
http://en.wikipedia.org/wiki/BMP_file_format

Good luck with this one!

David P.
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Enigman » Thu Apr 05, 2012 10:16 am

dpayer,

Understood, I thought you were free to use documentable software (like PHP).

If not... let me ask a question. Will the image be displayed at any time on the screen? If so, there may be a way to capture it and convert via script.

Well, ... not in the sense that you mean. If I am able to display the image on screen by any means, then it means I have already provided the conversion between PPM and BMP or TIF and I am done. Once I have that I can always bring up the saved image for viewing after the fact.

But normally, the process would go something like this:

USER 1:

Load plain text; encrypt the text; process to PPM; save as a BMP; transmit the BMP to User 2.

USER 2:

Load the BMP; process to encrypted text; decrypt to plain text.

This function is also meant to enable a user to store encryptions on disk as BMP files. If the laptop or PC was stolen or confuscated, a search of the hard drive would only show normal files, some of which would be plain old image files. There would be nothing to call attention to them.

I can still do this with PPM, but the arcane nature of the format might raise a tiny flag to the most savy of scavengers. Even then, the thief would have to brute force hack their way through several layers of encryption unique to each file, none of which would give them any feedback that they were making any headway at breaking the code.

I found a few sample PPM files but they will not open natively in IE.

No, they wouldn't support that. I can open and convert and manipulate them in my photo editor since editors are designed to be able to import intermediate files as well as normal formats. I could use that to convert files for my own use, but I would not be able to promote that for other users since most likely the first thing they would do is save it as a JPG and that would be the end of the encryption.

My original idea for the encryption program was to go from text directly to image format and back. But once the development started, the first and easiest step was text to encrypted text, and that's where I am now.

The closest I found was some C language code for converting ascii PPM files to BMP and viceversa.
http://orion.math.iastate.edu/burkardt/g_src/g_src.html
and a bmp format description that would be helpful if you had to work from scratch:
http://en.wikipedia.org/wiki/BMP_file_format

Thanks for the link. I tried searching for VBScript code in the same way. If push comes to shove I can try and convert the C into VBScript for a NB function. I was hoping someone had already done something similar.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Postby HPW » Thu Apr 05, 2012 10:17 am

I understand your restrictions.
But to have a BMP-save from neobooks memory you need native or plugin support.

I'm not sure what that is?


The popular image viewer and converter:

http://www.irfanview.com/

But also not usable by your restrictions.
Hans-Peter
User avatar
HPW
 
Posts: 2518
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby Enigman » Thu Apr 05, 2012 11:19 am

HPW,

But to have a BMP-save from neobooks memory you need native or plugin support.

Right ... that's what I am going for. A NB function using VBScript to read/write the BMP file, or a plug-in from NeoBook.

Thanks again.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Postby dpayer » Thu Apr 05, 2012 12:15 pm

Enigman wrote:HPW,

Right ... that's what I am going for. A NB function using VBScript to read/write the BMP file, or a plug-in from NeoBook.

Thanks again.


By chance, is the purpose of this conversion to show the representation of another code (such as Morse) visually?? If so, you could prepare multiple picture tokens that could be stringed together and then displayed. The combined display could then be saved as a BMP.

David P.
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Enigman » Thu Apr 05, 2012 12:47 pm

dpayer,

By chance, is the purpose of this conversion to show the representation of another code (such as Morse) visually?? If so, you could prepare multiple picture tokens that could be stringed together and then displayed. The combined display could then be saved as a BMP.

No. I already have a post processing option to convert to Morse Code, as well as one to go to NATO phonetic. Those are both handled as ascii output.

The image output is really all about the file format and not the image it creates. The image itself would actually end up looking like a slightly dark texture map. It would be nothing discernible. The whole point is to have a valid image file format, even if the image doesn't visually convey any information.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest