Hello,
I use the following code to create GIF files from PNG files
#include "TPad.h"
#include "TImage.h"
#include "TSystem.h"
#include "TString.h"
void testGIF(TString filename = "colour") {
//Replace "colour" by "blackWhite" to see that it ROOT manage to create the gif file
gSystem->Unlink(Form("%s.gif",filename.Data()));
TImage *img = TImage::Open(Form("%s.png",filename.Data()));
img->Draw();
gPad->SaveAs(Form("%s.gif",filename.Data()));
}
Here is what I get in the terminal
$ root
------------------------------------------------------------
| Welcome to ROOT 6.14/04 http://root.cern.ch |
| (c) 1995-2018, The ROOT Team |
| Built for linuxx8664gcc |
| From tags/v6-14-04@v6-14-04, Aug 23 2018, 17:00:44 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0] .x testGIF.C++("colour")
Info in <TUnixSystem::ACLiC>: creating shared library /home/pamputt/test/./testGIF_C.so
root [1] .x testGIF.C++("blackWhite")
Info in <ACLiC>: unmodified script has already been compiled and loaded
Info in <ACLiC>: it will be regenerated and reloaded!
Info in <TUnixSystem::ACLiC>: creating shared library /home/pamputt/test/./testGIF_C.so
Info in <TCanvas::Print>: file blackWhite.gif has been created
My guess is ROOT is not able to convert GIF to PNG if there is too many colours in the PNG file. However using the “convert” command from ImageMagick, the GIF file is created.
The Info messages you get are not related to the gif creation. They just warn that you are compiling the same macro twice and the 2nd time it will be recompiled and reloaded. But the gif file should be created.
I agree, the Info messages only says that blackWhite.gif has been created (and it is). Yet, no message is displayed for “colour.gif” (and indeed it is not created). I wonder why ROOT does not manage to create colour.png?
I just tried. I did a siren capture of may Mac backcourt which is quite colourful. I named it “colour.png” . And I executed your macro:
$ root
------------------------------------------------------------
| Welcome to ROOT 6.15/01 https://root.cern |
| (c) 1995-2018, The ROOT Team |
| Built for macosx64 on Oct 23 2018, 14:04:30 |
| From heads/master@v6-13-04-1856-gc5860b2c5f |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0] .x testGIF.C("colour")
Info in <TCanvas::Print>: file colour.gif has been created
root [1] .q
Hmmm, weird. here it does not work. Maybe it is because this is jpg file in the message above (I uploaded png files but they have been automatically converted to jpg files). Could you try with the png files available here: ftp://ftp.cea.fr/incoming/y2k01/ROOT ?
Ah ok … gif files production takes a different path depending if ROOT runs in batch mode or not. In batch mode it uses LibAfterImage and in interactive mode it is a screen copy of what is on screen. I would recommend you to run in batch. May be you can turn batch mode in the macro before executing your conversion procedure and turn it back to interactive when finished. In any case it seems good to run such conversation tool in batch.
Converting the png file in batch mode is a solution. However, would it be possible to know why it does not work in graphic mode? The best would be to fix the issue or at least to add an Info message that says why the conversion is not done. I ask that because I was looking for the origin of this issue and a workaround without any success and I guess it may happen to other users.