texture-compressor
Advanced tools
Comparing version 0.3.9 to 1.0.0
#!/usr/bin/env node | ||
require('../lib/index.js'); | ||
require('../dist/cli/lib/index.js').pack(); |
{ | ||
"name": "texture-compressor", | ||
"version": "0.3.9", | ||
"version": "1.0.0", | ||
"description": "CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container.", | ||
"main": "index.js", | ||
"main": "dist/cli/lib/index.js", | ||
"scripts": { | ||
"generate-default": "./docs/generate_default.sh", | ||
"generate-flipped-y": "./docs/generate_flipped_y.sh", | ||
"generate-flipped-y-mipmaps": "./docs/generate_flipped_y_mipmaps.sh", | ||
"start": "http-server --cors -s -o", | ||
"lint": "eslint lib/**/*.js", | ||
"deploy": "npm version patch && npm publish && git push origin" | ||
"start": "tsc -w", | ||
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc" | ||
}, | ||
@@ -21,20 +19,19 @@ "bin": { | ||
"argparse": "^1.0.10", | ||
"image-size": "^0.6.3" | ||
"image-size": "^0.7.4" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.9.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"http-server": "^0.11.1", | ||
"prettier": "^1.15.3", | ||
"prettier-eslint": "^8.8.2" | ||
"@types/argparse": "^1.0.36", | ||
"@types/node": "^12.0.2", | ||
"prettier": "^1.17.1", | ||
"rimraf": "^2.6.3", | ||
"tslint": "^5.16.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/TimvanScherpenzeel/texture-compressor.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/TimvanScherpenzeel/texture-compressor/issues" | ||
}, | ||
"homepage": "https://github.com/TimvanScherpenzeel/texture-compressor#readme" | ||
"prettier": { | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"printWidth": 100 | ||
} | ||
} |
159
README.md
@@ -1,70 +0,24 @@ | ||
# Texture compressor | ||
# Texture Compressor | ||
[![npm version](https://badge.fury.io/js/texture-compressor.svg)](https://www.npmjs.com/package/texture-compressor) | ||
[![dependencies](https://david-dm.org/timvanscherpenzeel/texture-compressor.svg)](https://david-dm.org/timvanscherpenzeel/texture-compressor) | ||
[![devDependencies](https://david-dm.org/timvanscherpenzeel/texture-compressor/dev-status.svg)](https://david-dm.org/timvanscherpenzeel/texture-compressor#info=devDependencies) | ||
[![npm version](https://badge.fury.io/js/texture-compressor.svg)](https://badge.fury.io/js/texture-compressor) | ||
CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container. | ||
Easily compress for all hardware using sensible defaults but with the option to pass any custom flag directly to the tool. | ||
## Installation | ||
Make sure you have [Node.js](http://nodejs.org/) installed. | ||
```sh | ||
$ npm install -g --save texture-compressor | ||
$ npm install texture-compressor | ||
``` | ||
## Live demo | ||
## Documentation | ||
[Live demo](https://timvanscherpenzeel.github.io/texture-compressor/) and [Live demo (mipmaps)](https://timvanscherpenzeel.github.io/texture-compressor/mipmap.html) using [KTXLoader](https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/KTXLoader.js) from [Three.js](https://github.com/mrdoob/three.js/). | ||
[Supported devices table](docs/SUPPORTED_DEVICES_TABLE.md) | ||
## Support table | ||
[Supported parameters](docs/SUPPORTED_PARAMETERS.md) | ||
| Device | OS | OS version | Browser | Browser version | ASTC | ETC | ETC1 | S3TC | PVRTC | | ||
| ----------------------- | ------- | ---------- | ------------- | --------------- | ---- | --- | ---- | ---- | ----- | | ||
| Apple iPad 5th | iOS | 11.0.3 | Mobile Safari | 11.0 | | | | | X | | ||
| Apple iPad Air 2 | iOS | 8.4 | Mobile Safari | 8.0 | | | | | X | | ||
| Apple iPad Mini 3 | iOS | 8.1.2 | Mobile Safari | 8.0 | | | | | X | | ||
| Apple iPad Pro | iOS | 11.2.1 | Mobile Safari | 11.0 | | | | | X | | ||
| Apple iPhone 5S | iOS | 8.1.3 | Mobile Safari | 8.0 | | | | | X | | ||
| Apple iPhone 6 Plus | iOS | 8.1 | Mobile Safari | 8.0 | | | | | X | | ||
| Apple iPhone 6 | iOS | 8.1.3 | Mobile Safari | 8.0 | | | | | X | | ||
| Apple iPhone 6S Plus | iOS | 9.0.1 | Mobile Safari | 9.0 | | | | | X | | ||
| Apple iPhone 6S | iOS | 9.1 | Mobile Safari | 9.0 | | | | | X | | ||
| Apple iPhone 7 | iOS | 10.3.1 | Mobile Safari | 10.0 | | | | | X | | ||
| Apple iPhone 8 | iOS | 11.0 | Mobile Safari | 11.0 | | | | | X | | ||
| Apple iPhone 8 | iOS | 11.0 | Mobile Safari | 11.0 | | | | | X | | ||
| Apple iPhone SE | iOS | 11.2.1 | Mobile Safari | 11.0 | | | | | X | | ||
| Apple iPhone X | iOS | 11.2 | Mobile Safari | 11.0 | | | | | X | | ||
| Google Nexus 5X | Android | 7.0 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Google Nexus 6P | Android | 7.0 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Google Pixel 2 | Android | 8.0.0 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Google Pixel 2 | Android | 8.0.0 | Firefox | 51.0 | | X | X | | | | ||
| Google Pixel | Android | 7.1 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Google Pixel | Android | 8.0.0 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Google Pixel | Android | 8.0.0 | Firefox | 51.0 | | X | X | | | | ||
| LG G5 | Android | 6.0.1 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| MacOS High Sierra | Mac OS | 10.13.3 | Chrome | 65.0.3325.181 | | | | X | | | ||
| MacOS High Sierra | Mac OS | 10.13 | Firefox | 59.0 | | | | X | | | ||
| MacOS High Sierra | Mac OS | 10.13.3 | Safari | 11.0.3 | | | | X | | | ||
| Motorola Moto X 2nd Gen | Android | 6.0 | Chrome | 63.0.3239.111 | | | X | | | | ||
| Oculus Go | Android | 7.1.2 | Oculus | 4.5.1.108860099 | X | X | X | | | | ||
| Samsung S6 | Android | 5.0.2 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Samsung S7 | Android | 6.0.1 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Samsung S7 | Android | 6.0.1 | Firefox | 51.0 | | X | X | | | | ||
| Samsung S8 | Android | 7.0 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Samsung S8 | Android | 7.0 | Firefox | 51.0 | | X | X | | | | ||
| Samsung S8+ | Android | 7.0 | Chrome | 63.0.3239.111 | X | | X | | | | ||
| Samsung S8+ | Android | 7.0 | Firefox | 51.0 | | X | X | | | | ||
| Windows 10 | Windows | 10 | Chrome | 65.0.3325.146 | | | X | X | | | ||
| Windows 10 | Windows | 10 | Edge | 14.14393 | | | | X | | | ||
| Windows 10 | Windows | 10 | Edge | 15.15063 | | | | X | | | ||
| Windows 10 | Windows | 10 | Edge | 16.16299 | | | | X | | | ||
| Windows 10 | Windows | 10 | Firefox | 59.0 | | | | X | | | ||
| Windows 10 | Windows | 10 | IE | 11.0 | | | | X | | | ||
| Windows 7 | Windows | 7 | IE | 10.0 | | | | | | | ||
| Windows 7 | Windows | 7 | IE | 11.0 | | | | X | | | ||
| Windows 8 | Windows | 8 | IE | 10.0 | | | | | | | ||
[Recommended parameters](docs/RECOMMENDED_PARAMETERS.md) | ||
## Usage | ||
## CLI Usage | ||
@@ -74,11 +28,3 @@ ### ASTC | ||
```sh | ||
# PVRTexTool - https://community.imgtec.com/developers/powervr/tools/pvrtextool/ | ||
# Astcenc - https://github.com/ARM-software/astc-encoder | ||
# Extension - https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_astc/ | ||
# example-astc-4x4 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-astc-4x4.ktx -t astc -c astc -b 4x4 | ||
# example-astc-8x8 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-astc-8x8.ktx -t astc -c astc -b 8x8 | ||
$ node ./bin/texture-compressor -i input/example.png -t astc -c ASTC_4x4 -q astcmedium -o output/example-astc.ktx -y -m -vb | ||
``` | ||
@@ -89,32 +35,9 @@ | ||
```sh | ||
# PVRTexTool - https://community.imgtec.com/developers/powervr/tools/pvrtextool/ | ||
# Extension - https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc/ | ||
# example-etc1 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-etc1.ktx -t etc -c etc1 | ||
# example-etc2 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-etc2.ktx -t etc -c etc2 | ||
# example-etc2A | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-etc2A.ktx -t etc -c etc2 -a | ||
$ node ./bin/texture-compressor -i input/example.png -t etc -c ETC2_RGB -q etcfast -o output/example-etc.ktx -y -m -vb | ||
``` | ||
### PVR | ||
### PVRTC | ||
```sh | ||
# PVRTexTool - https://community.imgtec.com/developers/powervr/tools/pvrtextool/ | ||
# Extension - http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/ | ||
# example-pvrtc2BPP | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-pvrtc2BPP.ktx -t pvr -c pvrtc1 | ||
# example-pvrtc2BPPA | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-pvrtc2BPPA.ktx -t pvr -c pvrtc1 -a | ||
# example-pvrtc4BPP | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-pvrtc4BPP.ktx -t pvr -c pvrtc1 -b 4 | ||
# example-pvrtc4BPPA | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-pvrtc4BPPA.ktx -t pvr -c pvrtc1 -b 4 -a | ||
$ node ./bin/texture-compressor -i input/example.png -t pvrtc -c PVRTC1_2 -q pvrtcnormal -o output/example-pvrtc.ktx -y -m -vb | ||
``` | ||
@@ -125,20 +48,20 @@ | ||
```sh | ||
# Crunch - https://code.google.com/archive/p/crunch/ | ||
# Extension - http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/ | ||
$ node ./bin/texture-compressor -i input/example.png -t s3tc -c DXT1 -q normal -o output/example-s3tc.ktx -y -m -vb | ||
``` | ||
# example-dxt1 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-dxt1.ktx -t s3tc -c dxt1 | ||
## Module usage | ||
# example-dxt1A | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-dxt1A.ktx -t s3tc -c dxt1 -a | ||
```js | ||
const { pack } = require('./dist/cli/lib/index'); | ||
# example-dxt3 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-dxt3.ktx -t s3tc -c dxt3 | ||
# example-dxt5 | ||
$ node ./bin/texture-compressor -i ./docs/example/example.png -o ./docs/example/example-dxt5.ktx -t s3tc -c dxt5 | ||
pack({ | ||
type: 'astc', | ||
input: 'input/example.png', | ||
output: 'output/example-astc.ktx', | ||
compression: 'ASTC_4x4', | ||
quality: 'astcmedium', | ||
verbose: true, | ||
}).then(() => console.log('done!')); | ||
``` | ||
In [docs/generate_default.sh](docs/generate_default.sh), [docs/generate_flipped_y.sh](docs/generate_flipped_y.sh) and [docs/generate_flipped_y_mipmaps.sh](docs/generate_flipped_y_mipmaps.sh) one can find batch scripts for automatically generating all the filetypes mentioned above. | ||
## Flags | ||
@@ -148,16 +71,12 @@ | ||
-c, --compression ['astc', 'etc1', 'etc2', 'pvrtc1', 'dxt1', 'dxt3', 'dxt5'] [required] | ||
-i, --input [example: ./docs/example/example.png] [required] | ||
-o, --output [example: ./docs/example/example.ktx] [required] | ||
-t, --type ['astc', 'etc', 'pvr', 's3tc'] [required] | ||
-i, --input [example: ./input/example.png] [required] | ||
-o, --output [example: ./output/example.ktx] [required] | ||
-t, --type [example: astc, etc, pvrtc, s3tc] [required] | ||
-c, --compression [example: ASTC_4x4, ETC2_RGB, PVRTC1_2, DXT1] [required] | ||
-q, --quality [example: astcmedium, etcfast, pvrtcnormal, normal] [required] | ||
### Optional | ||
-b, --bitrate [2.0 - 4.0, default: 2.0 = 8x8 blocksize] [not required] | ||
-vb, --verbose [true / false, default: false] [not required] | ||
Or if using ASTC you can optionally change the bitrate for one of the following blocksizes: | ||
[4x4, 5x4, 5x5, 6x5, 6x6, 8x5, 8x6, 8x8, 10x5, 10x6, 10x8, 10x10, 12x10, 12x12] [not required] | ||
-q, --quality [0 - 10, default: 5] [not required] | ||
-a, --alpha [true / false, default: false] [not required] | ||
-m, --mipmap [true / false, default: false] [not required] | ||
@@ -178,14 +97,6 @@ -y, --flipY [tue / false, default: false] [not required] | ||
## Mipmaps | ||
## License | ||
One important thing to note is that compressed mipmapped textures in WebGL should always have a complete mipchain going to `1x1` pixel (`512x512`, `256x256`, `128x128`, `64x64`, `32x32`, `16x16`, `8x8`, `4x4`, `2x2`, `1x1`). | ||
My work is released under the [MIT license](https://raw.githubusercontent.com/TimvanScherpenzeel/texture-compressor/master/LICENSE). | ||
Previously I had an option `-l` to pass in a custom amount of mip levels but to avoid confusion I've decided to automatically detect the power of two's down to `1x1` necessary to create the correct amount of mip levels. | ||
## Licence | ||
My work is released under the [MIT licence](https://raw.githubusercontent.com/TimvanScherpenzeel/texture-compressor/master/LICENSE). | ||
Much has been based on the automated texture compression tool baked into [gltf-pipeline](https://raw.githubusercontent.com/AnalyticalGraphicsInc/gltf-pipeline/master/LICENSE.md). | ||
This repository distributes multiple binary tools for Windows, Mac and Linux. | ||
@@ -192,0 +103,0 @@ This product includes components of the PowerVR™ SDK from Imagination Technologies Limited. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 12 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33505607
78
1394
7
3
80
2
103
2
23
+ Addedimage-size@0.7.5(transitive)
- Removedimage-size@0.6.3(transitive)
Updatedimage-size@^0.7.4