chore: added a way to find visually similar images

This commit is contained in:
Michele Cereda
2023-07-09 14:49:46 +02:00
parent 2079adda59
commit bd0eb609e7
3 changed files with 55 additions and 15 deletions

View File

@@ -2,36 +2,70 @@
Components:
- `compare`: diff tool
- `convert`: image conversion tool
## Table of contents <!-- omit in toc -->
1. [TL;DR](#tldr)
1. [Further readings](#further-readings)
1. [Sources](#sources)
## TL;DR
```sh
# scale an image to 50% its original size
convert IMG_20200117_135049.jpg -adaptive-resize 50% IMG_20200117_135049_resized.jpg
# Scale images to 50% its original size.
magick convert -adaptive-resize '50%' 'in.jpg' 'out.jpg'
# create a gif using images
magick *.jpg images.gif
# Create GIFs from single images.
magick *.jpg 'out.gif'
# convert n images to individual pdf pages
magick *.jpg +adjoin page-%d.pdf
# Convert N images into individual PDF documents.
magick *.jpg +adjoin 'page-%d.pdf'
# convert n images to a single pdf document
magick *.png out.pdf
# Convert N images into pages of a single PDF document.
magick *.png 'out.pdf'
# Calculate the percentage of *similarity* between 2 images.
# Avoid saving the diff.
magick compare -metric 'NCC' 'in_1.jpg' 'in_2.jpg' NULL:
# Output only the differences between 2 images.
magick compare -compose 'src' -fuzz '5%' 'in_1.jpg' 'in_2.jpg' 'diff.jpg'
```
## Further readings
- [Website]
- [cheat.sh/convert]
[cheat.sh/convert]: https://cheat.sh/convert
[website]: https://imagemagick.org
- [image similarity comparison]
## Sources
All the references in the [further readings] section, plus the following:
- [cheat.sh/convert]
- [cheat.sh/compare]
- [Converting Multiple Images into a PDF File]
- [How to Quickly Resize, Convert & Modify Images from the Linux Terminal]
- [Diff an image using ImageMagick]
- [ImageMagick compare without generating diff image]
<!--
references
-->
<!-- upstream -->
[image similarity comparison]: https://imagemagick.org/script/compare.php
[website]: https://imagemagick.org
<!-- article sections -->
[further readings]: #further-readings
<!-- knowledge base -->
<!-- others -->
[cheat.sh/compare]: https://cheat.sh/compare
[cheat.sh/convert]: https://cheat.sh/convert
[converting multiple images into a pdf file]: https://legacy.imagemagick.org/discourse-server/viewtopic.php?p=144157&sid=e7706233f81874af86ffbbf3e57b1e76#p144157
[diff an image using imagemagick]: https://stackoverflow.com/questions/5132749/diff-an-image-using-imagemagick
[how to quickly resize, convert & modify images from the linux terminal]: https://www.howtogeek.com/109369/how-to-quickly-resize-convert-modify-images-from-the-linux-terminal/
[imagemagick compare without generating diff image]: https://unix.stackexchange.com/questions/612067/imagemagick-compare-without-generating-diff-image