Intro:
There are some unique commands that leaves us speechless and the imagemagick and gnu parallel are two of them. The imagemagick has a bunch of sub-commands for image manipulation, for example to create a image thumbnail of each image of your wallpapers folder you can run:
mkdir thumbs
mogrify -format jpg -path thumbs -thumbnail 200x200 *
Some convertion operations, depending on the amout of files can consume a lot of processing and memory, so we can use gnu parallel to improve this task:
[ -d thumbs ] || mkdir thumbs
fd -d1 -tf | parallel mogrify -format jpg -path thumbs -thumbnail 200x200 {}
If the thumbs foldes does not exist we create it [ -d thumbs ] || mkdir thumbs
, then the fd -d1 -tf
createds the list of files, the gnu parallel will get each one of the entries and will apply the mogrify
command.
The option -d1
ensures that fd
will only search in the current folder.
Creating a README.md with thumbnails:
To use image thumbnails in your repo README.md file you must use this notation:
[](anchor link)
fd -tf . thumbs | awk -F/ '{print "[]("$2")"}' > README.md
The trick here is to put awk literal strings between double quotes, just for the sake of test run this:
fd -tf . thumbs | awk -F/ '{print "field one="$1", field two="$2}'
fd -tf . thumbs | awk -F/ '{print $1" test "$2}'
My wallpapers:
Just to see how it will end up being visit my wallpapers:
Top comments (1)
Thanks for sharing.