Image standardization as PNG


SUBMITTED BY: GaivsIvlivs

DATE: March 22, 2021, 5:39 a.m.

FORMAT: Text only

SIZE: 2.2 kB

HITS: 427

  1. ## Put into a .sh file, or your .bashrc file
  2. ## Assumes you have ImageMagick and OptiPNG installed
  3. ## Great for standardizing files as 1200x1200 PNGs for album covers, remove the
  4. ## 'adaptive-resize 1200x1200! if you aren't changing the size
  5. function album () {
  6. find . -type f -name "*.png" -print0 | while IFS= read -r -d '' f ; do
  7. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "$f" && optipng -o7 "$f" ; done
  8. find . -type f -name "*.bmp" -print0 | while IFS= read -r -d '' f ; do
  9. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.bmp}.png" && optipng -o7 "${f%.bmp}.png" && rm "$f" ; done
  10. find . -type f -name "*.gif" -print0 | while IFS= read -r -d '' f ; do
  11. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.gif}.png" && optipng -o7 "${f%.gif}.png" && rm "$f" ; done
  12. find . -type f -name "*.jpg" -print0 | while IFS= read -r -d '' f ; do
  13. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.jpg}.png" && optipng -o7 "${f%.jpg}.png" && rm "$f" ; done
  14. find . -type f -name "*.jpeg" -print0 | while IFS= read -r -d '' f ; do
  15. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.jpeg}.png" && optipng -o7 "${f%.jpeg}.png" && rm "$f" ; done
  16. find . -type f -name "*.tif" -print0 | while IFS= read -r -d '' f ; do
  17. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.tif}.png" && optipng -o7 "${f%.tif}.png" && rm "$f" ; done
  18. find . -type f -name "*.tiff" -print0 | while IFS= read -r -d '' f ; do
  19. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.tiff}.png" && optipng -o7 "${f%.tiff}.png" && rm "$f" ; done
  20. find . -type f -name "*.webp" -print0 | while IFS= read -r -d '' f ; do
  21. magick "$f" -type TrueColor -quality 100 -strip -despeckle -enhance -ping -adaptive-resize 1200x1200! "${f%.webp}.png" && optipng -o7 "${f%.webp}.png" && rm "$f" ; done
  22. }

comments powered by Disqus