Gifs created by ROOT do not replay on libreoffice impress

Run this macro:

//root -l -b -q test_gifs.cpp+

#include "TCanvas.h"
#include "TPaveText.h"
#include "TSystem.h"

void test_gifs()
{
	
	const TString kGifName = "test_gifs.gif";
	const TString kGifSleep = "50";//centiseconds
	gSystem->Unlink(kGifName.Data());//delete existing file
	
	TCanvas* c = new TCanvas();
	TPaveText* t = new TPaveText(0.55,0.65,0.8,0.85,"brNDC");
	
	t->AddText("1");
	t->Draw();
	c->Print(kGifName+"+"+kGifSleep);
	
	t->AddText("2");
	t->Draw();
	c->Print(kGifName+"+"+kGifSleep);
	
	t->AddText("3");
	t->Draw();
	c->Print(kGifName+"+"+kGifSleep);
	
	t->AddText("4");
	t->Draw();
	c->Print(kGifName+"++"+kGifSleep);//Two ++ makes an infinite loop (replay gif)
}

Then insert the generated file test_gifs.gif in a LibreOffice Impress slide. There, you will see that the gif file only loops once instead of infinitely.

This is due to the fact that the .gif file generated by ROOT fixes the number of loop iterations (the Netscape 2.0 block) at a later point than expected by the standard. Thus, Libreoffice sets the number of loops to the default value (1).

On What's In A GIF - Bits and Bytes, it says:

The Netscape 2.0 looping block must appear immediately after the global color table of the logical screen descriptor.

2 Likes