TCanvas::Print PNG outputs fraction of figure when canvas size is declared

This problem is now fixed in the ROOT master. It was in TASimage::FromPad.

Excellent, thanks for not giving up on this. I’ll be able to check it on my system next week.

Please let me know if the fix I did for the old post Wile reminded me, also fixes the issue you mentioned at the beginning of this thread. And thanks to Wile to have reminded me this old issue.

Unfortunately, this did not resolve my issue. I tested it with the master branch pulled today (commit 9e3f9c85136b26708c6813aa0fc96600b0130d21).

In you environment, does it fix the example if posted before ? i.e.:

void png_double_x_axis_title(){
   TCanvas *c1 = new TCanvas("c1","c1",0,0,1000,2000);
   c1->DrawFrame(0.,0.,10.,10.);
   c1->Print("test1.gif");
   c1->Print("test1.png");
   c1->Print("test1.pdf");
}

Nope:
gif:


png:

pdf:

I’m afraid that, in all cases, I get the whole non-truncated pictures but I also see some problems with the current “v5-34-00-patches” (see the reported widths and heights of GIF and PNG images and note the PDF “page rotation”):

[...] $ root -n -l -q png_double_x_axis_title.cxx
(...)
[...] $ identify test1.gif
test1.gif GIF 998x1973 998x1973+0+0 8-bit PseudoClass 8c 10.8KB 0.000u 0:00.000
[...] $ identify test1.png
test1.png PNG 998x961 998x961+0+0 8-bit DirectClass 11KB 0.000u 0:00.000
[...] $ identify test1.pdf
test1.pdf PDF 842x595 842x595+0+0 16-bit Bilevel DirectClass 63.1KB 0.000u 0:00.019
[...] $ root -b -n -l -q png_double_x_axis_title.cxx
(...)
[...] $ identify test1.gif
test1.gif GIF 996x1972 996x1972+0+0 8-bit PseudoClass 8c 10.9KB 0.000u 0:00.000
[...] $ identify test1.png
test1.png PNG 996x1972 996x1972+0+0 8-bit DirectClass 16.8KB 0.000u 0:00.010
[...] $ identify test1.pdf
test1.pdf PDF 595x842 595x842+0+0 16-bit Bilevel DirectClass 63.2KB 0.000u 0:00.000

I get non truncated pictures (gif, png, pdf) with both 5.34 and 6.11
See the two attached screen shots I just did:

Try to run “identify” on all three files (I think I can clearly see that your GIF has another “proportions” than your PNG and PDF).

Note also that in my case, my screen is 1680x1050 so, requesting a canvas 1000x2000 will trigger its “shrinking” in interactive mode (and that happens for the second PNG but not for the first GIF and then the third PDF “aspect ratio” is wrong -> in batch mode there is no need for “shrinking” so GIF and PNG sizes seem to be o.k. but the PDF “aspect ratio” is again wrong, but different from the one in the interactive mode).

Hi @Wile_E_Coyote, I am trying to first solve the @ksmith issue: which is the truncated output for the png and gif files. None of the ROOT versions I am suing produce such truncated output after the fix I did. I do not understand why he gets this truncation with the small macro example I posted. Then I will look at your suggestion in this post . If you think there is an other issue wihen running “identify” it might better to make an other post or a Jira report. Right now I am debugging an other issue not related to this topic.

Note that I am also talking about your small macro example. Like you, I also get non-truncated output, but I can clearly see that their sizes, reported by “identify”, are wrong.

Why are the figures so much taller than mine? Mine look rather square by eye. In addition, have you scaled the resolution down, if you are using a mac? I don’t see the issue at the nominal resolution.

No idea.

I am using an iMac 27 inches with the X11 backend. I did nothing special. Just ran the normal ROOT. I had the truncated output before I did the fix. Now with the fix it is fine,

So what do you suggest I tried on my Mac ?

I did another test … I swapped the lines which produce GIF and PNG and I got another numbers (note that this time, GIF and PNG sizes are equal in interactive mode, but PDF is still wrong and it’s “rotated”):

[...] $ root -l -q png_double_x_axis_title.cxx
(...)
[...] $ identify test1.gif
test1.gif GIF 998x961 998x961+0+0 8-bit PseudoClass 8c 6.67KB 0.000u 0:00.010
[...] $ identify test1.png
test1.png PNG 998x961 998x961+0+0 8-bit DirectClass 11KB 0.000u 0:00.000
[...] $ identify test1.pdf
test1.pdf PDF 842x595 842x595+0+0 16-bit Bilevel DirectClass 63.1KB 0.000u 0:00.000
[...] $ root -b -l -q png_double_x_axis_title.cxx
(...)
[...] $ identify test1.gif
test1.gif GIF 996x1972 996x1972+0+0 8-bit PseudoClass 8c 10.9KB 0.000u 0:00.000
[...] $ identify test1.png
test1.png PNG 996x1972 996x1972+0+0 8-bit DirectClass 16.8KB 0.000u 0:00.000
[...] $ identify test1.pdf
test1.pdf PDF 595x842 595x842+0+0 16-bit Bilevel DirectClass 63.2KB 0.000u 0:00.000

So I did yet another test … I made the PDF creation the first, then PNG, then GIF (note that PDF is not “rotated” in interactive mode any more):

[...] $ root -l -q png_double_x_axis_title.cxx
(...)
[...] $ identify test1.gif
test1.gif GIF 998x961 998x961+0+0 8-bit PseudoClass 8c 6.67KB 0.000u 0:00.010
[...] $ identify test1.png
test1.png PNG 998x961 998x961+0+0 8-bit DirectClass 11KB 0.000u 0:00.000
[...] $ identify test1.pdf
test1.pdf PDF 595x842 595x842+0+0 16-bit Bilevel DirectClass 63.2KB 0.000u 0:00.000
[...] $ root -b -l -q png_double_x_axis_title.cxx
(...)
[...] $ identify test1.gif
test1.gif GIF 996x1972 996x1972+0+0 8-bit PseudoClass 8c 10.9KB 0.000u 0:00.000
[...] $ identify test1.png
test1.png PNG 996x1972 996x1972+0+0 8-bit DirectClass 16.8KB 0.000u 0:00.000
[...] $ identify test1.pdf
test1.pdf PDF 595x842 595x842+0+0 16-bit Bilevel DirectClass 63.2KB 0.000u 0:00.000

And if, in interactive mode, I first try PDF then GIF and finally PNG, then I again get much “higher” GIF (998x1973) but PDF is not “rotated” (PNG remains as it was).

In all cases, pictures are not truncated.

@ksmith maybe you could do such tests, too (and report the outcome here).

Can you try and scale the resolution in Displays as I have done here:


I will do more tests with my Mac to see what the simplest arrangement of monitors is that reproduces the issue. It seems to vanish when I just use a single monitor.

I’ve modified the scripts a bit to make this easier:

void png_double_x_axis_title(std::vector<std::string> extensions={"gif","png","pdf"}){
   TCanvas *c1 = new TCanvas("c1","c1",1000,2000);
   c1->DrawFrame(0.,0.,10.,10.);
   for (auto ext : extensions) {
      c1->Print(("test1."+ext).c_str());
      gSystem->Exec(("identify test1."+ext).c_str());
   }
}

And a script to test all combinations:

{  
   gROOT->ProcessLine(".L png_double_x_axis_title.C");
   std::cout << "gif, png, pdf\n";
   png_double_x_axis_title({"gif", "png", "pdf"});
   std::cout << "gif, pdf, png\n";
   png_double_x_axis_title({"gif", "pdf", "png"});
   std::cout << "png, gif, pdf\n";
   png_double_x_axis_title({"png", "gif", "pdf"});
   std::cout << "png, pdf, gif\n";
   png_double_x_axis_title({"png", "pdf", "gif"});
   std::cout << "pdf, gif, png\n";
   png_double_x_axis_title({"pdf", "gif", "png"});
   std::cout << "pdf, png, gif\n";
   png_double_x_axis_title({"pdf", "png", "gif"});
}

The output:

$ root -q all_choices.C 

Processing all_choices.C...
gif, png, pdf
Info in <TCanvas::Print>: GIF file test1.gif has been created
test1.gif GIF 998x1820 998x1820+0+0 8-bit sRGB 256c 17259B 0.000u 0:00.019
Info in <TCanvas::Print>: file test1.png has been created
test1.png PNG 998x1820 998x1820+0+0 8-bit sRGB 28848B 0.000u 0:00.009
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 9287B 0.000u 0:00.000
gif, pdf, png
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: GIF file test1.gif has been created
test1.gif GIF 998x1820 998x1820+0+0 8-bit sRGB 256c 17259B 0.000u 0:00.019
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 9287B 0.000u 0:00.000
Info in <TCanvas::Print>: file test1.png has been created
test1.png PNG 998x1820 998x1820+0+0 8-bit sRGB 28848B 0.000u 0:00.009
png, gif, pdf
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: file test1.png has been created
test1.png PNG 998x1820 998x1820+0+0 8-bit sRGB 28848B 0.000u 0:00.009
Info in <TCanvas::Print>: GIF file test1.gif has been created
test1.gif GIF 998x1820 998x1820+0+0 8-bit sRGB 256c 17259B 0.000u 0:00.000
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 9287B 0.000u 0:00.000
png, pdf, gif
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: file test1.png has been created
test1.png PNG 998x1820 998x1820+0+0 8-bit sRGB 28848B 0.000u 0:00.009
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 9287B 0.000u 0:00.000
Info in <TCanvas::Print>: GIF file test1.gif has been created
test1.gif GIF 998x1820 998x1820+0+0 8-bit sRGB 256c 17259B 0.000u 0:00.000
pdf, gif, png
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 9287B 0.000u 0:00.000
Info in <TCanvas::Print>: GIF file test1.gif has been created
test1.gif GIF 998x1820 998x1820+0+0 8-bit sRGB 256c 17259B 0.000u 0:00.009
Info in <TCanvas::Print>: file test1.png has been created
test1.png PNG 998x1820 998x1820+0+0 8-bit sRGB 28848B 0.000u 0:00.009
pdf, png, gif
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 9287B 0.000u 0:00.000
Info in <TCanvas::Print>: file test1.png has been created
test1.png PNG 998x1820 998x1820+0+0 8-bit sRGB 28848B 0.000u 0:00.019
Info in <TCanvas::Print>: GIF file test1.gif has been created
test1.gif GIF 998x1820 998x1820+0+0 8-bit sRGB 256c 17259B 0.000u 0:00.009
$ root -b -q all_choices.C 

Processing all_choices.C...
gif, png, pdf
Info in <TCanvas::Print>: gif file test1.gif has been created
test1.gif GIF 996x1972 996x1972+0+0 8-bit sRGB 8c 10707B 0.000u 0:00.000
Info in <TCanvas::Print>: png file test1.png has been created
test1.png PNG 996x1972 996x1972+0+0 8-bit sRGB 16420B 0.000u 0:00.000
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 8877B 0.000u 0:00.000
gif, pdf, png
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: gif file test1.gif has been created
test1.gif GIF 996x1972 996x1972+0+0 8-bit sRGB 8c 10707B 0.000u 0:00.000
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 8877B 0.000u 0:00.000
Info in <TCanvas::Print>: png file test1.png has been created
test1.png PNG 996x1972 996x1972+0+0 8-bit sRGB 16420B 0.000u 0:00.009
png, gif, pdf
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: png file test1.png has been created
test1.png PNG 996x1972 996x1972+0+0 8-bit sRGB 16420B 0.000u 0:00.009
Info in <TCanvas::Print>: gif file test1.gif has been created
test1.gif GIF 996x1972 996x1972+0+0 8-bit sRGB 8c 10707B 0.000u 0:00.000
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 8877B 0.000u 0:00.000
png, pdf, gif
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: png file test1.png has been created
test1.png PNG 996x1972 996x1972+0+0 8-bit sRGB 16420B 0.000u 0:00.000
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 8877B 0.000u 0:00.000
Info in <TCanvas::Print>: gif file test1.gif has been created
test1.gif GIF 996x1972 996x1972+0+0 8-bit sRGB 8c 10707B 0.000u 0:00.009
pdf, gif, png
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 8877B 0.000u 0:00.000
Info in <TCanvas::Print>: gif file test1.gif has been created
test1.gif GIF 996x1972 996x1972+0+0 8-bit sRGB 8c 10707B 0.000u 0:00.000
Info in <TCanvas::Print>: png file test1.png has been created
test1.png PNG 996x1972 996x1972+0+0 8-bit sRGB 16420B 0.000u 0:00.009
pdf, png, gif
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c1
Info in <TCanvas::Print>: pdf file test1.pdf has been created
test1.pdf PDF 595x842 595x842+0+0 16-bit sRGB 8877B 0.000u 0:00.000
Info in <TCanvas::Print>: png file test1.png has been created
test1.png PNG 996x1972 996x1972+0+0 8-bit sRGB 16420B 0.000u 0:00.009
Info in <TCanvas::Print>: gif file test1.gif has been created
test1.gif GIF 996x1972 996x1972+0+0 8-bit sRGB 8c 10707B 0.000u 0:00.000

How do I find out what back end I am using?

When you stat ROOT if the X11 icon appears in the dock then you are using the X11 backend.
32

Exit it to make sure it restarts.

Note that with the cocoa backend the image were never truncated.
I will check now if, with the changes of resolution you suggested, I get the truncation…

I have set up the resolution as you suggested. I ran the macro:

void png_double_x_axis_title(){
   TCanvas *c1 = new TCanvas("c1","c1",0,0,1000,2000);
   c1->DrawFrame(0.,0.,10.,10.);
   c1->Print("test1.gif");
   c1->Print("test1.png");
   c1->Print("test1.pdf");
}

With ROOT 6.11/01 using the X11 and Cocoa backends both in interactive and batch modes. In all cases the gif and png files generated try this macro are not truncated.

I must be using the Cocoa back end then.

After further troubleshooting I can simplify my monitor setup and still reproduce the error. If I use the following setup I have the issue:

Monitor DimensionRotation
1 3360 x 1890 (scaled down from 3840x1920)0
3 1920 x 1080270

The error only occurred when the canvas was created on Monitor 1. If I removed the scaling of monitor 1 the issue goes away, if I remove the rotation of monitor 3 (I kept the same numbers as above) the issue goes away. If I try an alternate rotated monitor (swap 3 for 4 not the same resolution) I don’t have the issue.

It seems I have stumbled into a very unique setup that causes problem and thus is hard to reproduce. Meanwhile @Wile_E_Coyote also reports the issue, but on a single monitor setup and on the X11 backend (if I understood correctly):

I’m not sure where to go from here except to have you come for a visit and check it out (too bad I’m so far away). Or have you find monitors of the same dimensions and see if you can reproduce the issue there.

So it seems we are looking at completely different problems. I saw, on a single monitor, an issue with the X11 version of ROOT. This version had a syncing problem when generated the png image. This is what I fixed for a single monitor. The cocoa version did not have any problem for me. So it is normal you do not see any improvement with the fix I did because it affected the X11 version only.

Yes it is hard to debug for me as I have only one monitor. …