So i have a folder that has a lot of images. I use imagemagick to optimize all the images inside the folder. I aborted the command to "optimize" the images. Now. Some images have been optimized but not all. So I must run the command again. Is there a way that imagemagick skip the images that have already been optimized?
This is what i usually do to optimze all the images:
for i in *.jpg; do mogrify -quality 85 "$i"; done
If you have tens of thousands of images to process, and a decent fairly modern machine (i.e. multi-core CPU and decent RAM and disks), you could consider GNU Parallel.
Basically, you need to pipe the filenames into GNU Parallel if there are more than your system's ARGMAX limit. It is best to use null-terminated names so that filenames including spaces continue to work, so you'd want:
If that looks correct, you can remove the
--dry-runand run it again for real. As it is, that will keep 4 copies ofmogrifyrunning in parallel if your CPU has 4 cores - i.e. it will keep them all busy and should process your images miles faster, However, it is not most efficient because it starts a whole newmogrifyprocess for every image, it is better to add-Xto GNU Parallel and then it will startmogrifywith as many filenames as your OS can handle and the cost of starting the one process will be amortised over a large number of images. That would be:Make your experiences with any new software on a copy of your data - GNU Parallel can do lots of stuff very fast - good stuff and bad!