#! /bin/bash

####################################################################################################
# 
# PyDvi - A Python Library to Process DVI Stream
# Copyright (C) 2014 Fabrice Salvaire
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
# 
####################################################################################################

####################################################################################################

root_dir=`realpath $0`
root_dir=`dirname ${root_dir}`
root_dir=`dirname ${root_dir}`

dvi_file=`realpath $1`
dpi=600

tmp_dir=`mktemp -d`
pushd ${tmp_dir}

dvipng --truecolor -D ${dpi} -T tight ${dvi_file} -o out-ref.png
${root_dir}/bin/dvi-to-png --tight --dpi=${dpi} ${dvi_file} out.png
${root_dir}/bin/diff-image out-ref.png out.png diff.png

geeqie diff.png

rm -rf *.png
popd
rmdir ${tmp_dir}

####################################################################################################
#
# End
#
####################################################################################################
