Skip to content

Instantly share code, notes, and snippets.

@josnidhin
Last active December 24, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josnidhin/6758546 to your computer and use it in GitHub Desktop.
Save josnidhin/6758546 to your computer and use it in GitHub Desktop.
Parses the filename and adds it as a text to the image using imagemagick tool
#! /bin/bash
#
# This script parses filenames of the following format "s1_c-sq-0x_1_1369921304_1.PNG" and add
# certain info to the image
#
FILES=*.PNG
for file in $FILES; do
while IFS='_' read -ra filename; do
USER="${filename[0]}"
VIEW="${filename[4]}"
while IFS='-' read -ra type; do
if [[ ${type[0]} == "c" ]];
then
TYPE="Direct"
ORIENT="${type[2]}"
else
TYPE="${type[0]}"
ORIENT="${type[3]}"
fi
done <<< "${filename[1]}"
done <<< "$file"
convert $file -background White -weight bold -pointsize 40 label:"$USER $TYPE $ORIENT" -gravity Center -append "output/$USER $TYPE $ORIENT $VIEW"
done
#! /bin/bash
#
# # This script parses filenames of the following format "S4 DIRECT 0X.jpg" and add
# certain info to the image
#
FILES=*.jpg
for file in $FILES; do
while IFS='.' read -ra filename; do
NAME="${filename[0]}"
done <<< "$file"
convert "$file" -background White -weight bold -pointsize 40 label:"${NAME} IMFs" -gravity Center -append "output/${NAME}_%d.jpg"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment