#! /bin/bash # This script tests: giftopnm pamtogif # Also requires: ppmtopgm ppmtorgb3 rgb3toppm pbmmake alias giftopnm="${PBM_TESTPREFIX}giftopnm" alias pamtogif="${PBM_TESTPREFIX}pamtogif" alias pbmmake="${PBM_BINPREFIX}pbmmake" alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm" alias ppmtorgb3="${PBM_BINPREFIX}ppmtorgb3" alias rgb3toppm="${PBM_BINPREFIX}rgb3toppm" alias pnminvert="${PBM_BINPREFIX}pnminvert" shopt -s expand_aliases # Test 1. Should produce 2871603838 33838 # which is the result of ppmtopgm testimg.ppm | cksum # four times ppmtopgm testimg.ppm | tee ${tmpdir}/testimg.pgm | pamtogif | giftopnm | cksum pamtogif -interlace ${tmpdir}/testimg.pgm | giftopnm | cksum pamtogif -sort ${tmpdir}/testimg.pgm | tee ${tmpdir}/testimg.gif | \ giftopnm | cksum echo "junk" >> ${tmpdir}/testimg.gif && \ giftopnm -image=1 -quitearly ${tmpdir}/testimg.gif | cksum rm ${tmpdir}/testimg.pgm rm ${tmpdir}/testimg.gif # Test 2. Break up input image into three monochrome planes, # maxval 255. Transform each plane to gif and back to pgm. # Reassemble the planes. Result should be identical to input. # Should print 1926073387 101484 cp testimg.ppm ${tmpdir} && ppmtorgb3 ${tmpdir}/testimg.ppm && pamtogif ${tmpdir}/testimg.red | \ giftopnm > ${tmpdir}/out.red && pamtogif ${tmpdir}/testimg.grn | giftopnm > ${tmpdir}/out.grn && pamtogif ${tmpdir}/testimg.blu | \ giftopnm | \ rgb3toppm ${tmpdir}/testimg.red ${tmpdir}/testimg.grn - | \ cksum rm ${tmpdir}/testimg.{ppm,red,grn,blu} ${tmpdir}/out.{red,grn} # Test 3. Should produce 2425386270 41 five times. pamtogif testgrid.pbm | giftopnm | cksum pamtogif -nolzw testgrid.pbm | giftopnm | cksum pamtogif -transparent=black testgrid.pbm | giftopnm | cksum pamtogif -alpha=testgrid.pbm testgrid.pbm | giftopnm | cksum pamtogif -transparent=white testgrid.pbm | giftopnm -alpha=- | \ pnminvert | cksum # Test 4. # In this gif file the code length changes after the last image data. # Image data: 3 bits, end code 4 bits. # Should produce P1 4 1 0 1 0 1 pbmmake -g 4 1 | \ pamtogif | giftopnm -plain | \ tr '\n' ' '