How To Create Thumbnail Of Image In Linux With Bash?
We know that Linux is very capable for alot of different solutions. In this blog we will look how to create thumbnail from a ton of images. There will be a lot of images and by using simple loops and commands we will create thumnails.
Start From Easy and Simple
For now we will create thumbnail for single image.
convert -thumbnail 200x200 pnggrad8rgb.png thumb.png
This will create a thumbnail for 200×200 and save it with name thumb.png
Automate It With Script
Previous example is working but we need some automation. We will create a bash script to loop through png files in current directory and create thumbs from them
for f in *.png; \
do convert -thumbnail 200 $f thumb.$f ; done
- for f in *.png ensures that loop over png files and set their names to the f parameter
- do convert -thumbnail 200 $f thumb.$f ; done line simple convert the files as done previous step