imgscan

0.0.3 • Public • Published

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 ...
]

Package Sidebar

Install

npm i imgscan

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

123 kB

Total Files

5

Last publish

Collaborators

  • nowakcasimir