Png image not saved (with gentoo)

Hi all!

I get an error Error in <TASImage::WriteImage>: no image loaded whenever I try saving a TCanvas as a .png image (.pdf works fine). Example with a super simple macro:

  void plot(){
    TCanvas *c = new TCanvas("","",800,800);
    c->SaveAs("newplot.png");
    c->SaveAs("newplot.pdf");
  }

I get the following output:

root [1] .L plot.C
root [2] plot()
Error in <TASImage::WriteImage>: no image loaded
Info in <TCanvas::Print>: pdf file newplot.pdf has been created

So the .pdf is saved, .png throws an error.
Here are my portage (gentoo package manager) USE flags for root:
sci-physics/root X davix examples fortran gdml gsl graphviz ldap minuit python python_single_target_python3_6 python_targets_python3_6 roofit ssl tbb threads tiff tmva unran xml -opengl -qt5

Any help would be greatly appreciated.


ROOT Version: 6.18/04
Platform: Gentoo, kernel: 5.1.6
Compiler: gcc 9.1.0
Python: 3.6.5


It works for me:

$ root -b
   ------------------------------------------------------------------
  | Welcome to ROOT 6.19/01                        https://root.cern |
  | (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Oct 29 2019, 09:17:06                      |
  | From heads/master@v6-19-01-1840-g5e8c56b0cc                      |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] .L plot.C
root [1] plot()
Info in <TCanvas::Print>: png file newplot.png has been created
Info in <TCanvas::Print>: pdf file newplot.pdf has been created
root [2] 

do you get the same if you try a jpg image ?

Hi,

I think this issue is related to the bug report ROOT-10228 fixed in master.

You have to name the canvas and then it should work. Could you give it a try?

Best
Stefan

1 Like

Oh yes, I did not noticed the canvas is not named. (thanks @swunsch ). Simply do:

TCanvas *c = new TCanvas("c","c",800,800)

and it will be fine with the version you are using.

1 Like

Adding ā€œcā€ in the name worked, thank you @swunsch and @couet! I guess the bug will be gone once v6.20 is added to gentoo repository.

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