In theory, no, it shouldn't result in corrupted images. From memory, I think imagemagick works with temporary files, which are renamed to the chosen destination file once processing is done.
BTW converting images the way you did is a one-way operation, I guess you've noticed that, hence your question, I guess.
To find which image was converted last, list files in chronological order, newer files first. If there's a noticeable difference in file size you'll know easily where to start from next time. Otherwise you'll have to retrieve image dimensions using imagemagick's identify.
Also note that for one million images, if each image is processed in one second that would still require about 280 hours to complete! I hope you have a fast, powerful machine...
EDIT: If you want to show some progress, here's what I can think of, based on Martin's answer:
mkdir -p thumbs; \
COUNT=$(find -name "*.JPEG" | wc -l); \
find -name "*.JPEG" | while read IMG; do \
printf "\n$(( ++i )) / $COUNT\n" && \
[ -s "thumbs/${IMG%.JPEG}-small.jpg" ] || \
convert "$IMG" -resize "256^>" "thumbs/${IMG%.JPEG}-small.jpg"; \
done
What this does:
- create the thumbnail directory...
- count the total number of
.JPEG images...
- for each image...
- print the current image file index vs total...
- if the image has not yet been converted...
- make a thumbnail of it.
Assuming all the images to resize are in the same directory, I've used a subdirectory to save the thumbnail images to avoid cluttering the main directory with the corresponding thumbnails. Otherwise you can remove the first line and the thumbs/ subdirectory from the 5th and 6th lines.
If images are spread into subdirectories:
COUNT=$(find -name "*.JPEG" | wc -l); \
find -name "*.JPEG" | while read IMG; do \
printf "\n$(( ++i )) / $COUNT\n" && \
[ -s "${IMG%.JPEG}-small.jpg" ] || \
convert "$IMG" -resize "256^>" "${IMG%.JPEG}-small.jpg"; \
done
Note that this script accounts for spaces in file names as read stops at a new line character.
mogrifyinstead ofconvert. – Yay295 4 hours ago