6 releases (3 breaking)
0.4.0 | Jun 25, 2022 |
---|---|
0.3.1 | Jun 25, 2022 |
0.2.0 | Jun 25, 2022 |
0.1.3 | Jun 25, 2022 |
#604 in #utility
57KB
189 lines
cliblur
A small and fast rust tool which can blur
images with cool features like:
- Scaling factor
- Resize down filter
- Resize up filter
- Grayscaling
- Blur only a specific area
Example
As you can see the default behaviour is to scale down
the image by 25%
,
for the scale down the Gaussian filter
will be applied.
After it was scaled down, it's scaling up
with the nearest filter
.
That behaviour make the text unreadable but the image itself crispy af! <3
And don't worry, you can change the scale down and up filter! :)
What is the benefit from using this tool?
When I lock my computer or laptop, I love it to take a screenshot of the current state, blur the image and set the blured image as lock screen. So that's it, just a small tool which blurs images. :)
How to blur and lock the screen
If you are using i3, you can install the cliblur
and create a small bash script
to create a screenshot, blur it and lock your screen. :)
#!/usr/bin/env bash
cd "$(dirname "$0")"
IMAGE=/tmp/lock.png
scrot -q 100 $IMAGE
cliblur $IMAGE
i3lock -i $IMAGE
rm $IMAGE
Why are you not using convert?
Because convert is very slow ... I mean really slow ... I love it take a
screenshot, blur it and set it as my locking screen, but convert is so damn so.
It takes 2 seconds on 16 cores (and yes, all of them are running...).
So I created this small tool, it's finishing the blur effect in just ~460ms
and takes one thread (instead of 16 threads with 100%). :)
The next reason is, the blur effect itself, as you can see on the example image,
the image is cripsy af, but blurred.
That's because I'm scaling down the image with Gaussian and scaling it up with
nearest.
So it's blurring a crispy image without exposing any text! Hurray! <3
Install
Just install it with crates, that's it! :)
cargo install cliblur
You can also install the compiled version or build it yourself. :)
See the chapter "Install (advanced)". :3
How to use it
It's working out of the box with default parameters. You just need to to run the command and specify the file:
cliblur /tmp/lock.png
Keep in mind, if you're just set the input file, the same file will be overwritten! You can avoid that by writing the destination file, as you can see here.
cliblur /tmp/lock.png /tmp/bluredlock.png
You can modify the settings for the blur effect.
There is a scale
which can be changed, so the blur will be increased/decreased.
And by the way, you can also change the scale down and scale up filter.
It's looking kinda 8-bit like if you use the gaussian
filter for scale down
and the nearest
for scaling up
.
If you just wanna blur the image, you can use the gaussian
filter for
scale down
and scale up
.
You can also say where the blur effect should start and end, see the documentation
for -x
, -y
, -width
and -height
for more information.
Just try a little bit around until you find something that's fits.
The documentation can be found in the --help
. :)
$ cliblur --help
cliblur 0.3.1
Daniél Kerkmann <daniel@kerkmann.dev>
A faster and more usefule image blur tool.
USAGE:
cliblur [OPTIONS] <INPUT_FILE> [OUTPUT_FILE]
ARGS:
<INPUT_FILE> Input file which will be used
<OUTPUT_FILE> Specify the output file, otherwise the input file will be overwritten
OPTIONS:
-d, --debug
Set logging level to debug
-g, --grayscale
Remove color from image
-h, --height <HEIGHT>
height of the blur effect, otherwise it will blur till the end
--help
Print help information
-l, --license
Print license information
-r, --resize-down-filter <RESIZE_DOWN_FILTER>
Will apply the filter on resize down [default: gaussian] [possible values: catmull-rom,
gaussian, lanczos3, nearest, triangle]
-R, --resize-up-filter <RESIZE_UP_FILTER>
Will apply the filter on resize up [default: nearest] [possible values: catmull-rom,
gaussian, lanczos3, nearest, triangle]
-s, --resize-scale <RESIZE_SCALE>
Set the resize scale ratio from resizing it down and up [default: 25]
-V, --version
Print version information
-w, --width <WIDTH>
width of the blur effect, otherwise it will blur till the end
-x, --x <X>
x coordinate where the blur should start [default: 0]
-y, --y <Y>
y coordinate where the blur should start [default: 0]
Install (advanced)
Install compiled version (gitlab)
It's really easy! For real, trust me. :3
# download the binary file
curl -L https://gitlab.com/kerkmann/cliblur/-/jobs/artifacts/main/raw/cliblur\?job\=release --output cliblur
# make file executable
chmod +x cliblur
# just copy the binary file to `/usr/local/bin/cliblur`
sudo cp cliblur /usr/local/bin/cliblur
Build it yourself (from source)
You are not trusting the pre built binary? Thankfully, you can build it yourself! :3
# clone the project
git clone https://gitlab.com/kerkmann/cliblur
# change into the directory
cd cliblur
# compile it yourself
cargo build --release
# (optional) make the binary smaller
upx --best --lzma target/release/cliblur
# make file executable
chmod +x target/release/cliblur
# just copy the binary file to `/usr/local/bin/cliblur`
sudo cp target/release/cliblur /usr/local/bin/cliblur
Things to do
- Better error handling instead of panicing
- Tests
Dependencies
~7.5MB
~109K SLoC