Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/esimov/triangle
Browse files Browse the repository at this point in the history
  • Loading branch information
esimov committed May 6, 2021
2 parents cafd57f + b8e2842 commit 9519877
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[![Build Status](https://travis-ci.org/esimov/triangle.svg?branch=master)](https://travis-ci.org/esimov/triangle)
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/esimov/triangle)
[![license](https://img.shields.io/github/license/esimov/triangle)](./LICENSE)
[![release](https://img.shields.io/badge/release-v1.2.1-blue.svg)](https://github.com/esimov/triangle/releases/tag/v1.2.1)
![homebrew](https://img.shields.io/badge/homebrew-v1.2.1-orange.svg)
[![release](https://img.shields.io/badge/release-v1.2.2-blue.svg)](https://github.com/esimov/triangle/releases/tag/v1.2.2)
![homebrew](https://img.shields.io/badge/homebrew-v1.2.2-orange.svg)

**▲ Triangle** is a tool to generate triangulated image using [delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation). It takes a source image and converts it to an abstract image composed of tiles of triangles.

Expand All @@ -26,33 +26,34 @@ points = tri.GetEdgePoints(sobel, *pointsThreshold, *maxPoints)
triangles = delaunay.Init(width, height).Insert(points).GetTriangles()
```

## Features
### Features

#### Features implemented
- [x] Can process recursively whole directories and subdirectories concurrently.
- [x] Supports various image types.
- [x] There is no need to specify the file type, the CLI tool can recognize automatically the input and output file type.
- [x] Can accept image URL as parameter for the `-in` flag.
- [x] Possibility to save the generated image as an **SGV** file.
- [x] The generated SVG file can be accessed from the Web browser directly.
- [x] Clean and intuitive API. The core method responsible with the image triangulation not only that accepts image files but can also work with image data. This means that the `Draw` method can be invoked even on data streams. Check this [demo](https://github.com/esimov/pigo-wasm-demos#face-triangulator) for reference.

#### Features to be implemented
- [ ] Pipe commands
- [x] Clean and intuitive API. The API not only that accepts image files but can also work with image data. This means that the [`Draw`](https://github.com/esimov/triangle/blob/65672f53a60a6a35f5e85bed69e46e97fe2d2def/process.go#L82) method can be invoked even on data streams. Check this [demo](https://github.com/esimov/pigo-wasm-demos#face-triangulator) for reference.
- [x] Support for pipe commands (possibility to pipe in and pipe out the source and destination image).

Head over to this [subtopic](#key-features) to get a better understanding of the supported features.

## Installation and usage
```bash
$ go get -u -f github.com/esimov/triangle/cmd/triangle
$ go install
```
You can also download the binary file from the [releases](https://github.com/esimov/triangle/releases) folder.

## MacOS (Brew) install
The library can be installed via Homebrew too or by downloading the binary file from the [releases](https://github.com/esimov/triangle/releases) folder.
The library can be installed via Homebrew too.

```bash
$ brew install triangle
```

### Supported commands
## Supported commands

```bash
$ triangle --help
Expand All @@ -76,6 +77,27 @@ The following flags are supported:
| `bg` | ' ' | Background color (specified as hex value) |
| `c` | system spec. | Number of files to process concurrently (workers)

## Key features

#### Process multiple images from a directory concurrently
The CLI tool also let you process multiple images from a directory **concurrently**. You only need to provide the source and the destination folder by using the `-in` and `-out` flags.

```bash
$ triangle -in <input_folder> -out <output-folder>
```

#### Pipe commands
The CLI tool accepts also pipe commands, which means you can use `stdin` and `stdout` without providing a value for the `-in` and `-out` flag directly since these defaults to `-`. For this reason is possible to use `curl` for example to get an image from the net and invoke the triangulation process over it directly without the need to download the image first and call **▲ Triangle** afterwards.

Here are some examples using pipe names:
```bash
$ curl <image_url> | triangle > out.jpg
$ cat input/source.jpg | triangle > out.jpg
$ triangle -in input/source.jpg > out.jpg
$ cat input/source.jpg | triangle -out out.jpg
$ triangle -out out.jpg < input/source.jpg
```

#### Background color
You can specify a background color in case of transparent background images (`.png`) by using the `-bg` flag. This flag accepts a hexadecimal string value. For example setting the flag to `-bg=#ffffff00` will set the alpha channel of the resulted image transparent.

Expand All @@ -88,20 +110,13 @@ $ triangle -in samples/input.jpg -out output.svg

Using with `-web` flag you can access the generated svg file directly on the web browser.


```bash
$ triangle -in samples/input.jpg -out output.svg -web=true
```

#### Supported output types
The following output types are supported: `.jpg`, `.jpeg`, `.png`, `.svg`.
The following output file types are supported: `.jpg`, `.jpeg`, `.png`, `.bmp`, `.svg`.

### Process multiple images from a directory concurrently
The CLI tool also let you process multiple images from a directory **concurrently**. You only need to provide the source and the destination folder by using the `-in` and `-out` flags.

```bash
$ triangle -in <input_folder> -out <output-folder>
```
### Tweaks
Setting a lower points threshold, the resulted image will be more like a cubic painting. You can even add a noise factor, generating a more artistic, grainy image.

Expand All @@ -111,7 +126,7 @@ $ triangle -in samples/input.jpg -out output.png -wf=0 -pts=3500 -stroke=2 -blur
$ triangle -in samples/input.jpg -out output.png -wf=2 -pts=5500 -stroke=1 -blur=10
```

### Examples
## Examples

<a href="https://github.com/esimov/triangle/blob/master/output/sample_3.png"><img src="https://github.com/esimov/triangle/blob/master/output/sample_3.png" width=410/></a>
<a href="https://github.com/esimov/triangle/blob/master/output/sample_4.png"><img src="https://github.com/esimov/triangle/blob/master/output/sample_4.png" width=410/></a>
Expand Down

0 comments on commit 9519877

Please sign in to comment.