npm.io
0.0.3 • Published 7 years ago

imgscan

Licence
MIT
Version
0.0.3
Deps
0
Size
120 kB
Vulns
0
Weekly
0

imgscan

Read images (currently JPEG and PNG) from directory and save thumbnail atlas as a JPEG file and JSON array of thumbnail boundaries.

I needed pure javascript and zero-dependency NodeJS module for reading images (JPEG and PNG) from a directory and generating new JPEG image that shows thumbnails of the images inside the directory. This is not recursing into subfolders! Module packs output image to a square size with specified thumbnail size (maintaining image aspect ratio). Resizing to thumbnail is done with bilinear interpolation.

Example

var imgscan = require('imgscan')

imgscan('/path/to/test', {
  size: 128,
  output: 'output.jpg'
})

Output sample

Output

Module also outputs by default boxcache.json file, which is JSON data of where the images are and what files they represent. Order of the images in the atlas is not guaranteed.

[
  {
    "x": 0,
    "y": 128,
    "width": 128,
    "height": 85,
    "filename": "images\\bird.jpg"
  },
  {
    "x": 0,
    "y": 213,
    "width": 128,
    "height": 82,
    "filename": "images\\Blue-Lagoon-1.jpg"
  },
  etc ...
]

Keywords