0.1.1 • Published 6 years ago

scanahedron v0.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

Scanahedron

About

Easy image scanning module for node.

Scanahedron scans images with minimal effort, but still allows for a flexible configuration.

Usage

Scan to file with the default scanner:

const scanahedron = require("path-to/libscanahedron.node")
scanahedron.scanToFile(null, "test.png");

Scan to buffer with a specific scanner:

const scanahedron = require("path-to/libscanahedron.node")
const scanners = scanahedron->getScanners();
const myScanner = filterScanner(scanners);
const buffer = scanahedron.scanToBuffer(myScanner, myScanner);

console.log(buffer.width);
console.log(buffer.height);
console.log(buffer.bytesPerPixel);
console.log(buffer.pixels);

Scan only the first 5 cm:

const scanahedron = require("path-to/libscanahedron.node")
const scanners = scanahedron.getScanners();
let configuration = scanahedron.getConfiguration(scanners[0]);
configuration.toY = 50;
scanahedron.setConfiguration(scanners[0], configuration);

scanahedron.scanToFile(scanners[0], "output.png");

Dump the scanner's capabilities:

const scanahedron = require("path-to/libscanahedron.node")
const scanners = scanahedron.getScanners();
let capabilities = scanahedron.getCapabilities(scanners[0]);
console.log(capabilities);

Development Notes

The project is cmake based and uses cmake-js to configure/build the node module.

Dependencies

  • libsane-dev
  • libpng-dev
  • libpng++-dev

Building

Required cmake-js:

npm install nan --save
npm install cmake-js --save #(or install globaly with -g option)

Then to build in release mode just call:

cmake-js

To build in debug:

cmake-js -D

Testing

GTest & Gmock are required for the unit tests. Hence install the following package (apt install):

  • libgtest-dev

To build with tests enabled run:

cmake-js --CDBUILD_TESTS=On

Run the test the by simply executing the build/tests file.

Notes

If GTest library cannot be found you have to build it:

cd /usr/src/gtest # (or /usr/src/googletest/googletest/)
sudo cmake CMakeLists.txt
sudo make

#copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
sudo cp *.a /usr/lib

Same for GMock:

cd /usr/src/gmock # (or /usr/src/googletest/googlemock/)
sudo cmake CMakeLists.txt
sudo make

#copy or symlink libgmock.a and libgmock_main.a to your /usr/lib folder
sudo cp *.a /usr/lib

Credits

The project uses the FindSane.cmake file from here.

Licensing