# SetBatch causes different graphics output for pngs

**URL:** <https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682>\
**Category:** ROOT\
**Created:** [August 12, 2015, 7:44pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682 "2015-08-12T19:44:25Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 13, 2015, 1:51pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/8 "2015-08-13T13:51:36Z")

</div>

I’m afraid [TCanvas::SetWindowSize](https://root.cern.ch/root/html534/TCanvas.html#TCanvas:SetWindowSize) is completely unreliable (it can misbehave even in interactive mode).  
When I try (ROOT 5.34 and 6.04.02):

```cpp
{
  Int_t w = 800;
  Int_t h = 600;
  TCanvas *c;
  gROOT->SetBatch(kFALSE);
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  delete c;
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetCanvasSize(w, h);
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  delete c;
  gROOT->SetBatch(kTRUE);
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  delete c;
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetCanvasSize(w, h);
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
}

```

I sometimes get:

```nohighlight
798 573
800 600 SetWindowSize WORKS in interactive mode
798 573
800 600 SetCanvasSize WORKS in interactive mode
796 572
796 572 !!! SetWindowSize FAILS in batch mode !!!
796 572
800 600 SetCanvasSize WORKS in batch mode

```

and sometimes:

```nohighlight
798 573
798 573 !!! SetWindowSize FAILS in interactive mode !!!
798 573
800 600 SetCanvasSize WORKS in interactive mode
796 572
796 572 !!! SetWindowSize FAILS in batch mode !!!
796 572
800 600 SetCanvasSize WORKS in batch mode

```

BTW. I can switch from interactive to batch mode, but not the other way (I get “Warning in TCanvas::ResizePad: c width changed from 0 to 10” if I try it).

JIRA: [sft.its.cern.ch/jira/browse/ROOT-7552](https://sft.its.cern.ch/jira/browse/ROOT-7552)

---

_[View the full topic](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682)._
