<commit_before># Pointr

A simple image service using Node.js, Express, GraphicsMagick, and OpenCV.

## What's it do?

- (Re)sizing, cropping
- Image formatting (JPG, PNG, ...)
- Reduce quality (for fast downloads)
- Filters (brightness, hue, contrast, blur, ...)

## Installation

1. Install Node.js
2. Install GraphicsMagick
3. Install OpenCV
4. `npm install`
5. Create a config YAML file based on the `config.example.yml`

## Running

`bin/pointr production_config.yml`

### Configuration

Pointr uses a config file to control all options. See `config.example.yml` as an example and for more details.

|Config Option||
|:---|:---|
|`port`|Optional. Defaults to `3000`. The port to run the service on.|
|`validHostnames`|Optional. A list of valid host names the service will respond to.|
|`instances.min`|Optional. Defaults to `16`. The minimum number of instances to start.|
|`instances.max`|Optional. Defaults to `128`. The maximum number of instances to start.|
|`ipHeader`|Recommended. The header to use for the end-client (browser) IP address.|
|`rateLimiter`|Recommended. A rate limiter to use. See `config.example.yml` for an example.|
|`clients`|Required. The set of clients that will be using the service. See `config.example.yml` for an example.|

#### Example Configuration

```yml
# Optional. Defaults to 3000. The port for the service to run on.
port: 3000

# Optional. A list of valid hostnames for the service.
# This is useful if you want to hide the origin hostname (e.g. s3cr3th0s1.example.com).
validHostnames:
  - localhost

# Optional. The number of pointr instances to run.
# This will default to the number of CPUs on the system bounded by the min and max.
instances:
  min: 16
  max: 64

# Recommended. The header to use for the end-client (browser) IP address.
# This is necessary if this service is an origin,
# fronted by a CDN that provides its own header for the client IP address.
# For example, Akamai provides a "True-Client-IP" header.
ipHeader: True-Client-IP

# Recommended. The rate limiter to use.
# The rate limiter should have a type (key) to a set of options.
rateLimiter:

  # Use a redis rate limiter.
  redis:
    # Required. The host where the redis instance lives.
    host: localhost
    # Required. The port the redis instance is running on.
    port: 6379
    # Optional. The redis password.
    # pass: <PASSWORD>

# The set of clients that will be using the service.
# Each client is a key to a set of options for that client.
clients:

  # A demo client. A unsafe, rate limited client for demo purposes.
  demo:
    # Allow requests without a signature.
    unsafe: true<commit_msg>Updated readme.<commit_after># Pointr

A simple image service using Node.js, Express, GraphicsMagick, and OpenCV.

## What's it do?

- (Re)sizing, cropping
- Image formatting (JPG, PNG, ...)
- Reduce quality (for fast downloads)
- Filters (brightness, hue, contrast, blur, ...)

## Installation

1. Install Node.js
2. Install GraphicsMagick
3. Install OpenCV
4. `npm install`
5. Create a config YAML file based on the `config.example.yml`

## Running

`bin/pointr production_config.yml`

### Configuration

Pointr uses a config file to control all options. See `config.example.yml` as an example and for more details.

|Config Option||
|:---|:---|
|`port`|Optional. Defaults to `3000`. The port to run the service on.|
|`validHostnames`|Optional. A list of valid host names the service will respond to.|
|`instances.min`|Optional. Defaults to `16`. The minimum number of instances to start.|
|`instances.max`|Optional. Defaults to `128`. The maximum number of instances to start.|
|`cacheSeconds`|Recommended. Defaults to `2592000`. What to set the `Cache-Control` header to.|
|`ipHeader`|Recommended. The header to use for the end-client (browser) IP address.|
|`rateLimiter`|Recommended. A rate limiter to use. See `config.example.yml` for an example.|
|`clients`|Required. The set of clients that will be using the service. See `config.example.yml` for an example.|

#### Example Configuration

# Optional. Defaults to 3000. The port for the service to run on.
port: 3000

# Optional. A list of valid hostnames for the service.
# This is useful if you want to hide the origin hostname (e.g. s3cr3th0s1.example.com).
validHostnames:
  - localhost

# Optional. The number of pointr instances to run.
# This will default to the number of CPUs on the system bounded by the min and max.
instances:
  min: 16
  max: 64

# Recommended. The header to use for the end-client (browser) IP address.
# This is necessary if this service is an origin,
# fronted by a CDN that provides its own header for the client IP address.
# For example, Akamai provides a "True-Client-IP" header.
ipHeader: True-Client-IP

# How long to cache images. This will set the cache control header for the CDN.
# Set for 30 days (2592000 seconds).
cacheSeconds: 2592000

# Recommended. The rate limiter to use.
# The rate limiter should have a type (key) to a set of options.
rateLimiter:

  # Use a redis rate limiter.
  redis:
    # Required. The host where the redis instance lives.
    host: localhost
    # Required. The port the redis instance is running on.
    port: 6379
    # Optional. The redis password.
    # pass: <PASSWORD>

# The set of clients that will be using the service.
# Each client is a key to a set of options for that client.
clients:

  # A demo client. A unsafe, rate limited client for demo purposes.
  demo:
    # Allow requests without a signature.
    unsafe: true
{'fraction_non_alphanumeric': 0.09289220141792401, 'fraction_numerical': 0.016542446827849482, 'mean_word_length': 3.6865417376490632, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4382236', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1627, 'n_words': 775}