cropBmp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. # Copyright 2021 Batuhan Başerdem
  3. # <baserdem.batuhan@gmail.com> @bbaserdem
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. # Goes through all the files and turns them into strips in their respective folder
  18. if [ -z "${1}" ] ; then
  19. echo 'No argument; defaulting to script directory.'
  20. target_dir="$(dirname "${0}")"
  21. elif [ -d "${1}" ] ; then
  22. echo "Targeting files in '${1}'."
  23. target_dir="${1}"
  24. else
  25. echo 'Argument is not directory.'
  26. exit 1
  27. fi
  28. output_dir="${target_dir}/splitImages"
  29. mkdir -p "${output_dir}"
  30. for this_image in "${target_dir}/"*.bmp ; do
  31. echo "Found '${this_image}'."
  32. this_name="$(basename "${this_image%%.bmp}")"
  33. convert "${this_image}" -crop 'x8' "${output_dir}/${this_name}"_%d.bmp
  34. done