/LoremImageCryptonator

js-package to insert or extract text into or from an image

Primary LanguageJavaScript

LoremImageCryptonator

General-Description:

A JavaScript-package to insert some text into an image (*.jpg, *.png, *.gif) and extract some text from an image (Crypto-image).

With help of this package an user can handle text that can be inserted in one of the fourth-pixel-channels (red, green, blue and alpha) within an image. Furthmore each signs of some text can be placed either on a LSB(least significant bit) of a channel or on a whole channel of a pixel itself. The packages enables an user to extract text from an image that some text has been inserted before. This option of extracting text out of an image can be done on an HTML-Image-Element or on an Image-Object.

Supported Options:

The options below are
  • Necessary Options
    • text: String that should be inserted into a image.
  • Optional Options:
    • mode: 'fast' and 'slow'. When mode 'fast' is selected each sign is put into a whole pixel. It's faster than 'slow' because 'slow' puts each bit of each sign into the LSB (least significant bit) of each pixel successively. When 'slow'-mode is selected each signs takes put eight pixel of the image partly but it has got a very low effect on the image. So 'fast'-mode is faster and has to alter less pixels of the image but depending on the text-size there is a chance that a user might see that some image-sections look different in comparison with other sections. Furthermore when using 'fast'-mode there can be saved more signs into an image than using 'slow'-mode.(Standard: 'slow')

    • Advantages of 'fast'-mode:
      • Faster while inserting each sign of some text
      • Greater Number of signs can be stored in an image
      • Alters less pixels of an image

      Advantages of 'slow'-mode:
      • Very low effect on each pixel of an image.
      • Cryptography is better, LSB of each pixels is altered and not whole pixel as it is the case with 'fast'-mode.

    • channel: 'red', 'green', 'blue' and 'alpha'. Text-signs can be put into red-, green-, blue- or alpha-channel of each pixel. It is recommended to use the alpha-channel because it's not likely that you see any visual-difference before and after some text has been inserted. (Standard: 'alpha')

Useful Tips:

For those who want to store large quantities of text always keep in mind that the bigger the image is the more signs can be stored into and in this case the 'fast'-mode is recommended.

Szenario-Example when an image-Size of 480x320 size is used:

  • 'fast'-mode:
    • max. Number of signs: 153600 (480x320)
  • 'slow'-mode:
    • max. Number of signs: 19200 ((480x320)/8)

For those who want to mask text in an image the 'slow'-mode plus the channel alpha is recommended as these options are selected by default.

Methods:

The package offers following methods:

setImage is used for overloading an image that get used for being inserted some text into.

@param img must be an Image-Object

@return undefined

setImage( in img:Image ) : undefined

getCryptoImage is used for inserting some text into an image.

@param opt must be a JSON-Object and contains the options (text, mode and channel)

@param callback must be a Function-Object that gets called when Crypto-image is ready to be viewed or inserted into HTML-Elements. The callback-function must define one param that represents the Crypto-Image after a successful text-insertion.

@return undefined

getCryptoImage( in opt:Object, in callback:Function ) : undefined

getTextFromCryptoImage is used for extracting some text that has been inserted into an image.

@param opt (optional) must be a JSON-Object but can be omitted when standard options have been used to insert text into image.

@param cimg must be an Image-Object that some text has been inserted into before.

@return String that represents the inserted Text

getTextFromCryptoImage( in opt:Object, in cimg:Image ) : String

Supported Browsers:

  • IE9+
  • Mozilla Firefox
  • Google Chrome
  • Safari
  • Opera

License:

GNU: This software can be used and modified freely and without any restrictions.