Photo Classes - Rafostar/ink GitHub Wiki
Photo.Scanner
let scanner = new Photo.Scanner(options)
options
- an object containing configuration properties:
size_x
- horizontal size of scanned photo in pixels (default:-1
- same as input)size_y
- vertical size of scanned photo in pixels (default:-1
- same as input)keep_aspect
- whether to keep the aspect ratio of image (default:true
)
All of the above properties can be changed at runtime.Please use very low values for size_x
/size_y
if you plan to print the image in terminal with Ink
.
Scanned images (colors arrays) can be:
- printed with Ink.Printer
- painted with
printer.getPainted()
and then printed using standardprint()
function
Functions:
scanner.scan(filePath, isResource, cancellable)
Reads local image file at filePath
and returns its colors in an array.
filePath
- path to destination file (string).
isResource
- optional boolean. When set, file at filePath
is treated as resource file.
cancellable
- optional argument. A Gio.Cancellable
object or null
.
scanner.scanPixbuf(pixbuf)
Same as normal scan, but uses Gdk.Pixbuf
as input.
scanner.scanStreamAsync(stream, cancellable, callback)
An asynchronous version of scan. Uses Gio.FileInputStream
instead of file path as input.
scanner.scanStreamPromise(stream, cancellable)
Same as scanner.scanStreamAsync
, but returns a Promise
instead of using a callback
.