Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7072

How to bulk convert images from TIF to png using ImageMagick?

$
0
0

I have plenty of images in TIFF format that are saved in the following folder structure and that I'd like to convert to PNG format.

This is the folder structure:

FOLDER0001  ---- FOLDER0001-IMAGE0001.TIF  ---- FOLDER0001-IMAGE0002.TIF  ---- FOLDER0001-IMAGE0003.TIF  ---- etc.FOLDER0002  ---- FOLDER0002-IMAGE0001.TIF  ---- FOLDER0002-IMAGE0002.TIF  ---- FOLDER0002-IMAGE0003.TIF  ---- etc.  FOLDER9999  ---- FOLDER9999-IMAGE0001.TIF, etc.  

See that the name of the image contains the name of the folder too. (i.e. FOLDER000X-IMAGE000X.TIF)

To convert the images I'm using ImageMagick on Ubuntu 20.04. So, using

convert '*.TIF[224x224]' thumbnail%05.png

I'm able to convert all images inside one folder to, for example, thumbnail00000.png, although this is not the name I wish, as I'd like to keep the original name and changing only the format-suffix of the file from TIF to png.

In folder FOLDER0001 we'd have:

FOLDER0001-IMAGE0001.png  FOLDER0001-IMAGE0002.png, etc  

I could even do something like

convert *.TIF FOLDER00001-IMAGE%05.png

but then I had to do this 9,999 times, one for each folder with images I have.

As the name of the file has the name of the folder, I think the abstract form of the name would be:

convert *.TIF {NAME-OF-FOLDER}-{NAME-OF-FILE}-{NUMBER-OF-FILE}.png

Or better and simpler:

convert *.TIF {ORIGINAL-NAME-OF-FILE}.png  

How to accomplish that programatically using ImageMagick in the terminal from the top folder level?


Viewing all articles
Browse latest Browse all 7072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>