Home

Awesome

npm travis deps

WIP.

Install

npm i -S itc

Usage

import path from 'path';
import fs from 'fs';
import ITC from 'itc';

const itcFilePath = path.resolve('./test.itc');
const itc = new ITC(itcFilePath);

itc.extractImages().then(images => {
    console.log(images);
    /*
    [
        {
            info: {
                filename: './test.itc',
                type: 'png',
                itemSize: 65732,
                width: 128,
                height: 128,
                start: 480,
                size: 65536
            },
            raw: <Buffer>
        },
        {
            info: {
                type: 'png',
                itemSize: 262340,
                width: 256,
                height: 256,
                start: 66212,
                size: 262144
            },
            raw: <Buffer>
        },
        {
            info: {
                type: 'png',
                itemSize: 640196,
                width: 400,
                height: 400,
                start: 328552,
                size: 640000 },
                raw: <Buffer>
            },
            raw: <Buffer>
        }
    ]
    */

    images.forEach(image => {
        fs.writeFile(
            `${image.info.width}-test.${image.info.type}`,
            image.raw
        );
        /*
        .
        ├── test.itc
        ├── 128-test.png
        ├── 256-test.png
        └── 400-test.png
        */
    });
});

API

getImageOffset(itemOffset = 0)

itc.getImageOffset().then(imageOffset => console.log(imageOffset));
// <Number>

getImageType(itemOffset = 0)

itc.getImageType().then(imageType => console.log(imageType));
// <String>: 'png' || 'argb' || 'jpg'

getItemSize(itemOffset = 0)

itc.getItemSize().then(itemSize => console.log(itemSize));
// <Number>

getImageStart(itemOffset = 0)

itc.getImageStart().then(imageStart => console.log(imageStart));
// <Number>

getImageSize(itemOffset = 0)

itc.getImageSize().then(imageSize => console.log(imageSize));
// <Number>

getImageWidth(itemOffset = 0)

itc.getImageWidth().then(imageWidth => console.log(imageWidth));
// <Number>

getImageHeight(itemOffset = 0)

itc.getImageHeight().then(imageHeight => console.log(imageHeight));
// <Number>

getImageInfo(itemOffset = 0)

itc.getImageInfo().then(imageInfo => console.log(imageInfo));
/*
{
    filename: <String>,
    type: <String>,
    itemSize: <Number>,
    width: <Number>,
    height: <Number>,
    start: <Number>,
    size: <Number>
}
*/

getImagesInfo()

itc.getImagesInfo().then(imagesInfo => console.log(imagesInfo));
/*
[
    {
        filename: <String>,
        type: <String>,
        itemSize: <Number>,
        width: <Number>,
        height: <Number>,
        start: <Number>,
        size: <Number>
    },
    ...
]
*/

extractImage(imageInfo)

itc.extractImage({ ... }).then(image => console.log(image));
/*
{
    info: {
        filename: <String>,
        type: <String>,
        itemSize: <Number>,
        width: <Number>,
        height: <Number>,
        start: <Number>,
        size: <Number>
    },
    raw: <Buffer>
}
*/

extractImages()

itc.extractImages().then(images => console.log(images));
/*
[
    {
        info: {
            filename: <String>,
            type: <String>,
            itemSize: <Number>,
            width: <Number>,
            height: <Number>,
            start: <Number>,
            size: <Number>
        },
        raw: <Buffer>
    },
    ...
]
*/

References