Skip to content

Commit

Permalink
refactored into npm package and global cmd alias
Browse files Browse the repository at this point in the history
  • Loading branch information
cpietsch committed Aug 14, 2020
1 parent e79bb89 commit 0ccbb84
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 1,006 deletions.
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ The script in /images will generate textures and spritesheet assets which are ne

## Usage image script

Download or clone this repo, navigate to /images and install the required node packages:
Install the script as a command line tool without the need of cloning / downloading:

```sh
cd /images
npm i
```
npm install -g vikus-viewer-script
```

Alternativly you can download or clone this repo and install the required node packages:

```sh
git clone https://github.com/cpietsch/vikus-viewer-script
cd vikus-viewer-script
npm install
```
Note: You can run the script via `node bin/textures` instead of `vikus-viewer-script` if you have cloned it.


All your images should be in one folder (lets say "images") and named x.jpg where x is the id of the image corresponding to the id field in data.csv

To generate textures and sprites run the script like this:

```sh
node bin/textures.js "/path/to/your/images/*.jpg"
```
vikus-viewer-script "/path/to/your/images/*.jpg"
```

This will create a data folder for the textures (1024 and 4096) as well as a sprites folder for the spritesheets inside the current folder. You can also define an output folder via the output flag: `--output /path/to/output`

Expand All @@ -38,18 +47,17 @@ Copy the folder 1024, 4096 and sprites inside data into your /data folder of you

#### Create textures
```sh
node bin/textures.js "/path/to/your/images/*.jpg" # on jpg's
node bin/textures.js "/path/to/your/images/*.(jpg|jpeg|png)" # on multiple formats
node bin/textures.js "/path/to/your/images/**/*.jpg" # on all jpg's in subfolders
vikus-viewer-script "/path/to/your/images/*.jpg" # on jpg's
vikus-viewer-script "/path/to/your/images/*.(jpg|jpeg|png)" # on multiple formats
vikus-viewer-script "/path/to/your/images/**/*.jpg" # on all jpg's in subfolders
```

### CLI commands
```sh
node .\bin\textures.js
Usage: textures.js "/path/to/large/images/*.jpg" [options]
Usage: vikus-viewer-script "/path/to/large/images/*.jpg" [options]

Commands:
textures.js "/path/to/large/images/*.jpg" Glob to input images
vikus-viewer-script "/path/to/large/images/*.jpg" Glob to input images

Options:
--version Show version number [boolean]
Expand All @@ -59,12 +67,14 @@ Options:
--textureQuality Texture image quality (0-100) [default: 60]
--spriteSize Resolution of images for spritesheets [default: 256]
--spriteQuality Quality of jpg compression for spritesheets (0-100)
[default: 60]
[default: 70]
--spriteFormat spritesheets format (jpg or png) [default: "jpg"]
--largeSize resolution of full sized images [default: 4096]
--mediumSize resolution of images loaded on the fly [default: 1024]
-h, --help Show help [boolean]
Examples:
textures.js "/path/to/large/images/*.jpg" create VV textures from jpgs
vikus-viewer-script "/path/to/large/images/*.jpg" create VV textures from jpgs
```
## Usage t-SNE/UMAP script
Expand All @@ -74,6 +84,7 @@ As an alternative to the temporal view, you can create a t-SNE layout based on i
Download or clone this repo, navigate to /similarity and install the required node packages:
```sh
cd /similarity
npm i
```
Expand Down
39 changes: 39 additions & 0 deletions bin/textures
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

// https://github.com/cpietsch/vikus-viewer-script
// by Christopher Pietsch 2020
const textures = require("../src/textures.js");

const argv = require("yargs")
.usage("Usage: vikus-viewer-script \"/path/to/large/images/*.jpg\" [options]")
.command("\"/path/to/large/images/*.jpg\"", "Glob to input images")
.example("vikus-viewer-script \"/path/to/large/images/*.jpg\"", "create VV textures from jpgs")
.demandCommand(1)
.describe("output", "Path to output folder")
.default("output", "./data")
.describe("skip", "Don't regenerate existing textures")
.default("skip", true)
.describe("textureFormat", "Texture image format")
.default("textureFormat", "jpg")
.describe("textureQuality", "Texture image quality (0-100)")
.default("textureQuality", 60)
.describe("spriteSize", "Resolution of images for spritesheets")
.default("spriteSize", 256)
.describe("spriteQuality", "Quality of jpg compression for spritesheets (0-100)")
.default("spriteQuality", 70)
.describe("spriteFormat", "spritesheets format (jpg or png)")
.default("spriteFormat", "jpg")
.describe("largeSize", "resolution of full sized images")
.default("largeSize", 4096)
.describe("mediumSize", "resolution of images loaded on the fly")
.default("mediumSize", 1024)
.help("h")
.alias("h", "help").argv;

// console.log('starting with', argv);

const inputPath = argv._[0];

(async function main() {
await textures.run(inputPath, argv)
})();
97 changes: 0 additions & 97 deletions images/bin/textures.js

This file was deleted.

79 changes: 0 additions & 79 deletions images/textures.js

This file was deleted.

Loading

0 comments on commit 0ccbb84

Please sign in to comment.