Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 9450  / 3 Years ago, wed, november 17, 2021, 7:51:50

I want to batch process images but I have a very specific task that I want to do




  1. I do not want to change image type

  2. I want to make them black and white

  3. 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



http://ubuntuforums.org/showthread.php?t=2143992


More From » 13.04

 Answers
0

We can use convert command to convert images to black & white:



convert -colorspace GRAY image.png b-w_image.png


Where 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]'; done


It 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.


[#31266] Friday, November 19, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eryeath

Total Points: 122
Total Questions: 121
Total Answers: 112

Location: Saint Helena
Member since Fri, Aug 26, 2022
2 Years ago
;