Improvement suggestion: trimming white space around the TCanvas?

Dear experts,

Is it possible to trim the white space around a plot on the creation?
I want to keep all the titles and labels as they are, so setting margins to 0 is not what I am after.

Here is the initial plot (left) and what I want to achieve (right).

It is possible with ImageMagick by doing this: convert input.png -trim output.png.

It would be very nice to have such an option when using c->Print() or c->SaveAs(), and so on.

I often find the white spaces to be the remnants of the manually set margins picked arbitrarily to not strip any titles/labels.
When used in latex, such white spaces create extremely large spaces around the images.
And tripping is a must.
Using purely ROOT it is doable by adjusting margins perfectly in advance, which is not easy for a regular user.

Dear @FoxWise ,

Thanks for reaching out to the forum!

AFAIK the only this is the only way to achieve what you are looking for, i.e. via SetMargins or other similar functions. Yes, it must be done on a per-canvas basis manually in this case.

It would be very nice to have such an option when using c->Print() or c->SaveAs() , and so on.

I am not aware of the existence of such an option, but I very much agree with you that it would be very nice to have! Maybe let’s hear @couet 's opinion on this.

Cheers,
Vincenzo

Such option does not exist in ROOT. There is TASIMage::Crop but that not the same functionality. You can always make a special ROOT script spawning the convert command.