Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azerion/h5-texture-unpacker

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azerion/h5-texture-unpacker - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

10

CHANGELOG.md
# Changelog
## [0.0.2] - 2019-11-04
### Added
- Winston logging with a verbose check
- check to see if img exists
- Can now read img file from json config
### Fixed
- error reporting image size equals zero is nog caught
- cleaned up dist folder
## [0.0.1] - 2019-11-01
### Added
- Initial setup and release

52

dist/h5-texture-unpacker.js
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Sharp = require('sharp');
var path = require('path');
var fs = require('fs');
var yargs = require('yargs');
var basePath = path.join(__dirname, '../');
var argv = yargs
.usage('Usage: $0 [imageFile] [jsonFile] [outputDir]')
.option('imageFile', {
alias: 'i',
demandOption: true,
describe: 'The input texture image',
type: 'string'
})
.option('jsonFile', {
alias: 'j',
demandOption: true,
describe: 'The input JSON configuration',
type: 'string'
})
.option('outputDir', {
alias: 'o',
demandOption: true,
describe: 'The output folder',
type: 'string'
})
.help('h')
.alias('h', 'help')
.epilog('copyright Azerion 2019')
.argv;
var imgUrl = path.join(argv.i);
var jsonUrl = path.join(argv.j);
var outputDir = path.join(argv.o, '/');
var json = JSON.parse(fs.readFileSync(jsonUrl));
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
json.frames.forEach(function (source) {
Sharp(imgUrl).extract({
width: source.frame.w,
height: source.frame.h,
left: source.frame.x,
top: source.frame.y
}).toFile(path.join(outputDir, '/', source.filename + '.png')).then(function (fileInfo) {
console.log('File: ', source.filename, ' written');
}).catch(function (err) {
console.log('Unable to write file ', source.filename, ':', err);
});
});
var e=require("sharp"),i=require("path"),t=require("fs"),r=require("yargs"),n=require("winston"),o=(new Date).toISOString(),a=n.format.printf((function(e){return o+"-"+e.level+": "+JSON.stringify(e.message,null,4)+"\n"})),s=n.createLogger({transports:[new n.transports.Console({format:n.format.combine(n.format.colorize(),a)})]}),l=(i.join(__dirname,"../"),r.usage("Usage: $0 -j [jsonFile] -o [outputDir]").option("imageFile",{alias:"i",demandOption:!1,default:"",describe:"The input texture image",type:"string"}).option("jsonFile",{alias:"j",demandOption:!0,describe:"The input JSON configuration",type:"string"}).option("outputDir",{alias:"o",demandOption:!0,describe:"The output folder",type:"string"}).option("verbose",{alias:"v",default:!1,describe:"Show log messages",type:"boolean"}).help("h").alias("h","help").epilog("copyright Azerion 2019").argv),f=i.join(l.i),p=i.join(l.j),m=i.join(l.o,"/"),u=JSON.parse(t.readFileSync(p));s.level=!0===l.verbose?"info":"warn",""===l.i&&(f=i.join(i.parse(p).dir,u.meta.image)),t.existsSync(f)||(s.error("Could not find image at specified path!"),process.exit(1)),t.existsSync(m)||t.mkdirSync(m),u.frames.forEach((function(t){0!==t.frame.w&&0!==t.frame.h?e(f).extract({width:t.frame.w,height:t.frame.h,left:t.frame.x,top:t.frame.y}).toFile(i.join(m,"/",t.filename+".png")).then((function(e){s.info("File: "+t.filename+" written")})).catch((function(e){s.info("Unable to write file , "+t.filename+":, "+e)})):s.warn("Unable to write file , "+t.filename+": Source width/height is 0")}));
{
"name": "@azerion/h5-texture-unpacker",
"author": "Azerion",
"version": "0.0.1",
"version": "0.0.2",
"description": "Simple CLI tool that allows you to unpack your existing Texture atlasses provided that you have the JSON file available",

@@ -30,3 +30,3 @@ "contributors": [

"prebuild": "rimraf dist",
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"build": "rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"start": "rollup -c rollup.config.ts -w",

@@ -90,3 +90,4 @@ "test": "jest --coverage",

"@types/jest": "^23.3.2",
"@types/node": "^10.17.2",
"@types/node": "^10.17.3",
"@types/sharp": "^0.23.0",
"@types/yargs": "^13.0.3",

@@ -108,2 +109,3 @@ "colors": "^1.4.0",

"rollup": "^0.67.0",
"rollup-plugin-add-shebang": "^0.3.1",
"rollup-plugin-commonjs": "^9.3.4",

@@ -125,6 +127,6 @@ "rollup-plugin-node-resolve": "^3.4.0",

"dependencies": {
"@types/sharp": "^0.23.0",
"sharp": "^0.23.2",
"winston": "^3.2.1",
"yargs": "^14.2.0"
}
}

@@ -15,3 +15,3 @@ [![npm version](https://badge.fury.io/js/%40azerion%2Fh5-texture-unpacker.svg)](https://badge.fury.io/js/%40azerion%2Fh5-texture-unpacker)

ale@computer:~$ unpack
Usage: unpack [imageFile] [jsonFile] [outputDir]
Usage: unpack -j [jsonFile] -o [outputDir]
```

@@ -22,14 +22,14 @@

```
ale@NL0NTB032:/media/ale/dev/tools/h5-texture-unpacker$ unpack
Usage: unpack [imageFile] [jsonFile] [outputDir]
ale@computer:~$ unpack
Usage: unpack -j [jsonFile] -o [outputDir]
Options:
--version Show version number [boolean]
--imageFile, -i The input texture image [string] [required]
--imageFile, -i The input texture image [string] [default: ""]
--jsonFile, -j The input JSON configuration [string] [required]
--outputDir, -o The output folder [string] [required]
--verbose, -v Show log messages [boolean] [default: false]
-h, --help Show help [boolean]
copyright Azerion 2019
```

@@ -36,0 +36,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc