Converting ROOT generated EPS to JPG or GIF

or anything actually useful. (I don’t care … even bmp or tiff is better for me than postscript … PNG, PNM … anything.)

Brand new ROOT user. Love it. One of the coolest things I’ve ever seen. (Okay, I don’t get out much.) A few problems, though.

Running:
W2K w/ SP3
Cygwin_NT-5.0
Root 4.02 17 Dec 2004

I’m using a trivial variant of the tutorial script surfaces.C.

Problem 1:
I’m unable to save a canvas as anything other than eps - either through through scripting with the SaveAs() method or through the GUI.

When I attempt to save the canvas using:

I get the following error:

Error in : fatal X11 error (connection to server lost?!)

Problem 2:
I can create an EPS file just fine and I can read this eps file with ghostscript; however, for some reason ghostscript chokes when I try to convert this eps to jpeg. (No problem converting eps file which I generate with my own homegrown stuff, but they’re a lot simpler.)

I don’t know that this is a problem with ROOT, per se, but it is a problem for me. In the past, I have generated postscript files from my code, because they are easy for me to understand. I never use the files directly, but convert them immediately to jpeg using gs. They are useless to me as postscript, because for me ps has always been merely an intermediary.

Question:
Is there some other program besides ghostscript that you guys use to view and manipulate the postscript files you generate from ROOT?

Thanks in advance for any assistance,
k

For reference, below is the code I’m using:

[code]
{
//
gROOT->Reset();
c1 = new TCanvas(“c1”,“Magnum Opus”,200,10,900,900);
c1.Divide(3, 3);
c1->SetFillColor(33);
gStyle->SetFrameFillColor(42);

//
// 2D func
TF2 f2 = new TF2(“f2”,"x2 + y2 - x**3 -8x*y**4",-1,1.2,-1.5,1.5);
f2->SetContour(48);
f2->SetFillColor(45);

//
// Fill 9 pads with graph of func increasing in rotation.
for (int i=1; i<=9; i++) {
TPad pad = c1->cd(i);
pad->SetPhi(-100 + i
10);
pad->SetLogz();
f2.Draw(“surf4”);
}

c1->SaveAs(“test.gif”);
}[/code]

Hi J,
I’m also running on cygwin. A couple of hints:

  1. Try:
    root> c1->Print(“bla.jpg”)
    instead of c1->SaveAs
    to get a jpg file

  2. gif files (in my opinion) work better for plots than jpgs

  3. What I usually do is save eps files and then convert them (I use a script I found on the web called ps2gif.sh; I looked and couldn’t find it again). If you install the ImageMagick package in cygwin, you’ll get something called ‘convert.exe’ that should work for you.

Good luck,
Charles

I have tried your example on cygwin with the latest root and I can generate both gif and jpg files. It works fine. No problems.

[quote=“cplager”]Hi J,

  1. Try:
    root> c1->Print(“bla.jpg”)
    instead of c1->SaveAs
    to get a jpg file
    [/quote]

No luck on this one.

Noted.

[quote=“cplager”]
3) What I usually do is save eps files and then convert them (I use a script I found on the web called ps2gif.sh; I looked and couldn’t find it again). If you install the ImageMagick package in cygwin, you’ll get something called ‘convert.exe’ that should work for you.

Good luck,
Charles[/quote]

Previously I had to remove and replace my cygwin with the latest version, as ROOT did not like the old one. In any case, the new version already has this installed and it worked perfectly first time! I feel like I just won the lottery.

Thanks,
k

That’s good to know. I suspect I must have some problem with my cygwin configuration.

Thanks for the response,
k

About GIFs/JPGs/PNGs, the last format seems to be the best. GIFs tend to become big, and its proprietary file format, whereas PNG is open. Secondly, JPGs may get very pixelized around edges.

If you get a graphic, try going to the menu on top of its window and select ‘File’, ‘Save as’, ‘PNG format’ (or other of your choice) and the file name. Try out with different formats.

On occasions I’m able to save the image with the shell, and in other occasions I’ve to use the menu. (BTW, I’m using Linux … so Results May Vary). If c1 is the TCanvas where’s the graph, usually a c1->Print(“graphic.eps”) would suffice, but since it doesn’t for you, I hope the suggestion above works out.

Check

root.bnl.gov/QtRoot/QtRoot.html#gifbatch

it may help also