<commit_before>autocrop
========

Image auto-cropper. This is [how it works][how].

[how]: http://nbviewer.ipython.org/github/tinkerx3/autocrop/doc/autoctrop.ipynb

Dependencies
------------

* scipy
* numpy
* scikit-image
* Pillow


Algorithm for content aware cropping
------------------------------------

1. Calculate entropy of input image.
2. Based on tresholds check if the entropy gives satisfying results. If
   not. Blur the input image, calculate entropy and continue using this
   entropy.
3. Calculate the convolution with summation kernel of fixed size.
4. Find the pixel with max value.
5. Put the pixel in the center and calculate rect with output size.
6. Readjust the rect if the original rect goes outside the boundary of
   the image.
7. Crop and save image.

Installation
------------

```
pip install git+https://github.com/tinkerX3/autocrop
```

Usage
-----

```
usage: autocrop [-h] [-s W,H] [-f X1,Y1,X2,Y2] [-i FILE] [-o FILE]

Image cropper

optional arguments:
  -h, --help            show this help message and exit
  -s W,H, --size W,H    ouput image size
  -f X1,Y1,X2,Y2, --featured X1,Y1,X2,Y2
                        coordinates of the important part of the image;X1 <
                        X2, Y1 < Y2; (0,0) = top-left corner
  -i FILE, --input FILE
                        path/to/the/input/image
  -o FILE, --output FILE
                        path/to/the/output/image
```

Examples
--------

Crop image to provided size ensuring featured rectangle is included:
```bash
$ ./autocrop --size 500x500 \
             --featured 250x100x650x500 \
             --input path/to/image.png \
             --output path/to/output.png
```

Crop image to provided size by automatically determining the most
important features.
```bash
$ ./autocrop --size 500x500 \
             --input path/to/image.png \
             --output path/to/output.png
```

Also determine the size of important part automatically.
```bash
$ ./autocrop --input path/to/image.png \
             --output path/to/output.png
```

<commit_msg>Update README.md with correct nbviewer URL<commit_after>autocrop
========

Image auto-cropper. This is [how it works][how].

[how]: http://nbviewer.ipython.org/github/tinkerX3/autocrop/blob/master/doc/autocrop.ipynb

Dependencies
------------

* scipy
* numpy
* scikit-image
* Pillow


Algorithm for content aware cropping
------------------------------------

1. Calculate entropy of input image.
2. Based on tresholds check if the entropy gives satisfying results. If
   not. Blur the input image, calculate entropy and continue using this
   entropy.
3. Calculate the convolution with summation kernel of fixed size.
4. Find the pixel with max value.
5. Put the pixel in the center and calculate rect with output size.
6. Readjust the rect if the original rect goes outside the boundary of
   the image.
7. Crop and save image.

Installation
------------

```
pip install git+https://github.com/tinkerX3/autocrop
```

Usage
-----

```
usage: autocrop [-h] [-s W,H] [-f X1,Y1,X2,Y2] [-i FILE] [-o FILE]

Image cropper

optional arguments:
  -h, --help            show this help message and exit
  -s W,H, --size W,H    ouput image size
  -f X1,Y1,X2,Y2, --featured X1,Y1,X2,Y2
                        coordinates of the important part of the image;X1 <
                        X2, Y1 < Y2; (0,0) = top-left corner
  -i FILE, --input FILE
                        path/to/the/input/image
  -o FILE, --output FILE
                        path/to/the/output/image
```

Examples
--------

Crop image to provided size ensuring featured rectangle is included:
```bash
$ ./autocrop --size 500x500 \
             --featured 250x100x650x500 \
             --input path/to/image.png \
             --output path/to/output.png
```

Crop image to provided size by automatically determining the most
important features.
```bash
$ ./autocrop --size 500x500 \
             --input path/to/image.png \
             --output path/to/output.png
```

Also determine the size of important part automatically.
```bash
$ ./autocrop --input path/to/image.png \
             --output path/to/output.png
```


{'fraction_non_alphanumeric': 0.1387409200968523, 'fraction_numerical': 0.024697336561743343, 'mean_word_length': 2.113036925395629, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7496188', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1246, 'n_words': 441}