Skip to content

Commit 7ceafc0

Browse files
committed
README added
1 parent 9e80235 commit 7ceafc0

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ShrinkShot
2+
3+
A simple CLI tool to detect and cut out empty areas of an image (screenshot) in order to make them smaller without resizing their content.
4+
5+
## Features
6+
7+
The program simply scans for whole pixel columns and lines which are identical to their neigbours. These columns and lines can be cut out from the image, no information will be loss, but the image will be smaller and more compact.
8+
9+
This is not an out-of-box application: the program itself only a CLI tool, which tries to detect empty areas in a specified PNG image, then prints out a bunch of CLI arguments to be passed to ImageMagick's `convert` utility, which is doing the actual job.
10+
11+
You may assign a hotkey to yout script, which makes a screenshot from a window, passing through it on shrinkshot+convert, and saves it. Currently, I don't provide this kinda script, as I'm a newbie Mac user and I don't know how to do it.
12+
13+
## Usage
14+
15+
By calling `shrinkshot` with a PNG filename specified, it dumps out a bunch of parameters for `convert` (ImageMagick's CLI app):
16+
```
17+
$ shrinkshot image.png
18+
-chop 4x0+2+0 -chop 4x0+11+0 -chop 2x0+19+0 -chop 12x0+26+0 -chop 0x5+0+2 -chop 0x2+0+6 -chop 0x6+0+11
19+
```
20+
21+
To make it work, first, you should install ImageMagick:
22+
23+
- MacOS: `brew install imagemagick`
24+
- Debian/Ubuntu Linux: `sudo apt-get install imagemagick`
25+
- etc.
26+
27+
Then you may pass the parameters to `convert` utility>
28+
```
29+
convert image.png `shrinkshot image.png` result.png
30+
```
31+
32+
If any problem occurs, `shrinkshot` prints error messages to `stderr`.
33+
34+
## TODO
35+
36+
### Needs more test
37+
38+
- Only tested on sample images you can found in the `test/` directory.
39+
- Not tested on Linux distros yet.
40+
41+
### Known issues to be fixed
42+
43+
Rightmost and bottom areas will be not removed due to a missing check at the end of the processing. This will be fixed soon.
44+
45+
If you make a screenshot by marking the area by hand (sometimes called snipping tool), empty area detection may fail on background image. A simple solution is by just simply ignore 3-4 pixels on the borders, this hack will be applied soon.
46+
47+
### Enhance distribution
48+
49+
ShrinkShot is now a CLI tool for doing a half job. It should be turned to an easy-to-install solution for making shrinked screenshots with a hotkey.
50+
51+
I don't want to turn it to a boxed software with printed manual, but the distribution should be more user-friendly:
52+
- Linux: provide a shell script, which can be assigned to a hotkey. Probably release it as a `.deb` package.
53+
- MacOS: have no idea.
54+
55+
### Conceptional issues
56+
57+
The program now detects empty areas by checking whole pixel rows and columns. It works well, but there are some cases, when empty regions does not occupy the whole height/width of the image.
58+
59+
There's an example, which the current method couldn't handle:
60+
```
61+
------------- ----------
62+
| 111111 | => | 111111 |
63+
| 2222222 | | 2222222 |
64+
------------- ----------
65+
```
66+
67+
## Credits
68+
69+
The idea and some sample images come from a question issued by *Thomas* on the Software Recommendation (StackExchange) site.
70+
71+
The actual conversation is done by **ImageMagick*.
72+
73+
ShrinkShot is using **UPNG** library to load and parse PNG files. It's included in the repository as a GIT submodule.
74+
75+
## Copyright
76+
77+
Use it as you want. I'll be happy if you mention it in the credits.

0 commit comments

Comments
 (0)