mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
chore: added a way to find visually similar images
This commit is contained in:
@@ -2,36 +2,70 @@
|
|||||||
|
|
||||||
Components:
|
Components:
|
||||||
|
|
||||||
|
- `compare`: diff tool
|
||||||
- `convert`: image conversion 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
|
## TL;DR
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# scale an image to 50% its original size
|
# Scale images to 50% its original size.
|
||||||
convert IMG_20200117_135049.jpg -adaptive-resize 50% IMG_20200117_135049_resized.jpg
|
magick convert -adaptive-resize '50%' 'in.jpg' 'out.jpg'
|
||||||
|
|
||||||
# create a gif using images
|
# Create GIFs from single images.
|
||||||
magick *.jpg images.gif
|
magick *.jpg 'out.gif'
|
||||||
|
|
||||||
# convert n images to individual pdf pages
|
# Convert N images into individual PDF documents.
|
||||||
magick *.jpg +adjoin page-%d.pdf
|
magick *.jpg +adjoin 'page-%d.pdf'
|
||||||
|
|
||||||
# convert n images to a single pdf document
|
# Convert N images into pages of a single PDF document.
|
||||||
magick *.png out.pdf
|
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
|
## Further readings
|
||||||
|
|
||||||
- [Website]
|
- [Website]
|
||||||
- [cheat.sh/convert]
|
- [image similarity comparison]
|
||||||
|
|
||||||
[cheat.sh/convert]: https://cheat.sh/convert
|
|
||||||
[website]: https://imagemagick.org
|
|
||||||
|
|
||||||
## Sources
|
## 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]
|
- [Converting Multiple Images into a PDF File]
|
||||||
- [How to Quickly Resize, Convert & Modify Images from the Linux Terminal]
|
- [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
|
[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/
|
[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
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ parallel --group --jobs 100% --tag \
|
|||||||
| jq -r '.items[] | .metadata.name + \"\t\" + .spec.nodeName' -" \
|
| jq -r '.items[] | .metadata.name + \"\t\" + .spec.nodeName' -" \
|
||||||
::: "${NAMESPACES}" \
|
::: "${NAMESPACES}" \
|
||||||
| column -t
|
| column -t
|
||||||
|
|
||||||
|
# Given a collection of images in the same working directory, find all those
|
||||||
|
# that are at least 90% similar, but not equal, to another.
|
||||||
|
parallel --tag "magick compare -metric NCC -quiet {} NULL: 2>&1; echo" \
|
||||||
|
::: *.jpg *.jpeg *.png *.webp ::: *.jpg *.jpeg *.png *.webp \
|
||||||
|
| grep '0\.9'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Further readings
|
## Further readings
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Resize images using the CLI
|
# Resize images using the CLI
|
||||||
|
|
||||||
Leverages `convert` from `imagemagick`.
|
Leverage `convert` from `imagemagick`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
convert input.jpg -adaptive-resize 50% output.jpg
|
magick convert -adaptive-resize '50%' 'in.jpg' 'out.jpg'
|
||||||
|
|
||||||
# Scale down all images in a folder.
|
# Scale down all images in a folder.
|
||||||
ls -1 | xargs -I{} convert {} -adaptive-resize 50% {}_scaled.jpg
|
ls -1 | xargs -I{} magick convert -adaptive-resize '50%' {} {}_scaled.jpg
|
||||||
```
|
```
|
||||||
|
|
||||||
Further readings
|
Further readings
|
||||||
|
|||||||
Reference in New Issue
Block a user