#!/bin/bash

# -----------------------------------------------------------------------------
#
#   parse_subtitles
#   ===============
#   Python-Fu script to create subtitle images for DVDs from "SubRip" files
#   (*.srt).  Can be used in batch mode; just adapt the files 'gimprc' and
#   the Linux shell script 'run_parse_subtitles'.  Extension to support other
#   filetypes should be easy.
#
#   Copyright (c) 2006-2007 Martin Zuther (http://www.mzuther.de/)
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# -----------------------------------------------------------------------------

options=' --no-interface --no-data --console-messages --batch-interpreter=plug-in-script-fu-eval --gimprc=./gimprc'

input_file=test/subtitles.srt
input_file_format="SubRip"
path=$HOME/subtitles
filename_prefix="subtitle_"
image_format="NTSC"
text_color="'(255 255 0)"
shadow_color="'(0 0 0)"
shadow_size=2
safe_area=10
font_name="Sans"
font_size=20
antialias=1
display_images=0

echo
echo "Starting the GIMP..."

gimp $options --batch "(python-fu-parse-subtitles RUN-NONINTERACTIVE \"$input_file\" \"$input_file_format\" \"$path\" \"$filename_prefix\" \"$image_format\" $text_color $shadow_color $shadow_size $safe_area \"$font_name\" $font_size $antialias $display_images) (gimp-quit 1)"

echo "Finished."
echo
