I want to batch process images but I have a very specific task that I want to do
- I do not want to change image type
- I want to make them black and white
- I want it to create/preserve images and sub folder structure
I did this in Photoshop but it did not preserve folders and sub folder content it just threw every converted file in one directory.
My only hope is Linux :D
Thank you in advance!
You can see different discussion about this here but Basharat Sial worked for me
42 Answers
We can use convert command to convert images to black & white:
convert -colorspace GRAY image.png b-w_image.pngWhere image.png is the input image and b-w_image.png is output imgage.
Combining this command with find we can create a bash one liner to convert all the images found under parent directory.
How-to:
Open terminal by hitting Ctrl+Alt+T, cd to parent/main directory and run the following command:
for img in $(find . -iname '*.png'); do echo -n "Converting $img"; convert -colorspace GRAY $img $img && echo ' [Done]'; doneIt will convert and overwrite all the images under parent directory. I will suggest to test it on some temporary images and if you're satisfied with the results than run it on actual images.
1-monochrome is an option if you want binary black and white (1bit per pixel).
It uses some smart dithering and generates very visible output:
convert -monochrome in.png out.pngAfter:
To maintain directory structure, you will have to script it up as mentioned by Basharat.