| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function render_convertGplToHex { |
| |
| local COLOR='' |
| local COUNT=0 |
| local -a FILES |
| |
| |
| |
| local PALETTE_GPL="$1" |
| |
| |
| |
| local PALETTE_HEX="$2" |
| |
| |
| local COLOR_NUMBER="$3" |
| |
| |
| |
| |
| if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then |
| cli_printMessage "`eval_gettext "Reducing image to \\\"\\\$COLOR_NUMBER\\\" colors is not supported."`" --as-error-line |
| fi |
| |
| # Define list of colors from GPL palette. |
| local COLORS=$(render_getColors "$PALETTE_GPL") |
| |
| # Verify number of colors returned in the list. |
| if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then |
| cli_printMessage "`gettext "The palette do not have the correct number of colors."`" --as-error-line |
| fi |
| |
| # Verify format of colors inside the list. |
| for COLOR in $COLORS;do |
| if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then |
| cli_printMessage "`eval_gettext "The \\\"\\\$COLOR\\\" string is not a valid color code."`" --as-error-line |
| fi |
| done |
| |
| # Create list of colors to be process by pnmtolss16 |
| echo "$COLORS" | nl | awk '{ printf " |
| > $PALETTE_HEX |
| |
| |
| cli_checkFiles "$PALETTE_PPM" --regular-file |
| |
| } |