Error when saving animated GIF

Hi,

I try to save an animated gif, e.g. with the following example code

TH1F h("h","",100,-5,5); 
for (int i=0; i<10; ++i) {
  h.FillRandom("gaus",1000); 
  h.Draw(); 
  gPad->Update(); 
  gPad->Print("ani.gif+100");
}

but I constantly get the error message

Error in <TASImage::WriteImage>: error writing file ani.gif+100
Error in <TASImage::WriteImage>: error writing file ani.gif+100
...

Saving a file as GIF (e.g. c1->SaveAs("ani.gif")) seems to work properly. It does not make any difference using gPad or c1 or Print(..) or SaveAs(..).

Can somebody give me a hint what’s going wrong?

Best regards,
Klaus


ROOT Version: 6.36.000
Platform: Debian12
Compiler: Not Provided


Maybe @couet can take a look?

I’ll check

I ran your macro on Mac with ROOT master (that should not make any difference because this code has not changed for a. long time) and it works. I do not get any error message and it produces the following file.
ani
Is TASImage working correctly on your machine ? can you produce a simple jpeg or gif file ?

Thanks for checking! Saving single images with any type seems to be possible.

root [1] c1->SaveAs("test.jpg")
Info in <TCanvas::Print>: file test.jpg has been created
root [2] c1->SaveAs("test.png")
Info in <TCanvas::Print>: file test.png has been created
root [3] c1->SaveAs("test.gif")
Info in <TCanvas::Print>: GIF file test.gif has been created
root [4] c1->SaveAs("test.gif+1")
Error in <TASImage::WriteImage>: error writing file test.gif+1

Only the output to animated gif (with e.g. “+100”) fails.

Can you try c1->Print("test.gif+")

Same result.

root [0] TH1F h; h.Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [1] c1->Print("test.gif+")
Error in <TASImage::WriteImage>: error writing file test.gif+

Just to report: I also have a ROOT 6.34.00 version installed here, and using this version does not produce the error. Could something be wrong with the 6.36 installation?

I am using 6.39 so if the problem appeared in 6.36 it is gone in 6.39.
I will install 6.36 on my mac.

It works for me with 6.36:

% cat test.C
{
   TH1F h("h","",100,-5,5);
   for (int i=0; i<10; ++i) {
     h.FillRandom("gaus",1000);
     h.Draw();
     gPad->Update();
     gPad->Print("ani.gif+100");
   }
} 
   ------------------------------------------------------------------
  | Welcome to ROOT 6.36.05                        https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Nov 13 2025, 14:27:39                      |
  | From heads/v6-36-00-patches@v6-36-02-29-g40f86fe94f2             |
  | With Apple clang version 17.0.0 (clang-1700.4.4.1)               |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] .x test.C
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [1] 

Thanks for checking again. Then probably our 6.36 installation is flawed…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.