Page 1 of 1

Linux and saving big nice PNG diagrams workflow

Posted: 03 Sep 2019 21:41
by piotao
Hello again,

I would like to share my workflow in order to save some experience and knowledge for others. This workflow is good for me, but maybe somebody else will find this useful.

Setup: Linux workstation with 64GiB of ram, windoze7 in VirtualBox with Historian installed.
Family tree has nearly 400 people and 8 generations, so it is very wide and pretty flat. Typical diagram of descendants has a proportion 5:1, so the whole diagram could easily take 5m x 1m paper when printed. For this reason I had to manually change branches and after tuning I got the tree with more vertical look, bottom-up direction with generations in branches spread more vertically. It's not important, but the current shape has proportions of 2:1 approximately. Historian is unable to save this diagram in 100% size due to 32-bit memory limitation. PDF save if of poor quality. So I decided to save it in XPS format (via print to XPS driver) and convert.

This workflow requires to have some additional applications installed. For my system, which is Linux Mint, you will have to install packages: libgxps2 and imagemagick. For windoze in a box, I had to install also VirtualBox and prepare virtual machine, inside which I've installed windoze7.


0. Prepare VirtualBox windoze installation, and Family Historian installation where you can build the whole tree and create a complicated diagram.

1. In Historian, setup the page to A2 landscape format (the bigger, the better), and set all margins to 0.

2. Print the whole diagram to XPS. This is like regular printing, only select XPS instead of a printer. You will save the output as a file, for example ready.xps.

3. Return to Linux and enjoy the freedom! Install libgxps2, and in terminal type:

Code: Select all

xpstopng ready.xps
This will convert XPS document with lots of pages to lots of PNG files. They will be saved as page-###.png files, for example page-001.png, page-002.png, etc.

4. If you notice that your pages have some margins (if you forgot to set them to 0 in step 1), you can run this command instead:

Code: Select all

xpstopng -x 0 -y 0 -w 3508 -h 2480 ready.xps
These options will crop every page to specified dimension, so you can remove margins. X and Y specify top-left corner, and W and H specify the dimension of new page after crop. Watch carefully your pages - margins sometimes may be as small as 1 pixel, and having them will create artifacts later.

5. Watch your pages again (using Print Preview in Historian) to determine how many of them is used in a single horizontal row. For my case it was 13 A2 pages horizontally, and 10 rows in total. So, all my pages have to be merged in 13x10 mosaic to create a single huge poster. If you know how many pages you have in horizontal and vertical direction, use montage from imagemagick, and join all of them into one huge page:

Code: Select all

montage page-* -mode Concatenate -tile 13x10 full.png
This command WILL require a lot of RAM. If you got the warnings like this:

Code: Select all

montage-im6.q16: cache resources exhausted `page-078.png' @ error/cache.c/OpenPixelCache/3984.
then go to /etc/ImageMagick-6/policy.xml file, and enlarge memory limits, editing the line with name="memory" value="....". I've put there 32GiB and everything worked.

6. The picture generated in step 5 is so huge, that on my system it cannot be displayed using xviewer or other 'image browsers'. However, if you open it with GIMP, typing in the console:

Code: Select all

gimp full.png
then it should open, and you may even be able to manipulate such a big picture. In my case the size of the picture was 44MB png with dimensions 45604 x 24800 pixels.

This was my workflow of creating a huge images with high-quality diagrams. Family Historian is unfortunately unable to save them directly via Diagram->SaveAs->PNG file, which is a problem, solved above. I hope you find this workflow useful and if some of this was already posted then sorry. Have fun, let's hope next Historian version will support 64bit and huge files saving! Also, it will be nice to have your feedback. 8-)

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 09:37
by tatewise
The FH 64bit issue was discussed at length in New Version or update for modern Windows (16826) and I don't believe FH being a 32bit application has any significant impact.

I have experimented (on Windows 10) with Diagram > Save Diagram As > PDF File (.pdf) using the single page option.
My diagram is 356 boxes with 11 generations. At 100% Scale is nearly 9m x 1m so too big for one PDF page.
By reducing to 30% Scale it fits one PDF page as shown below at 25% Zoom.

DiagramSaveAsPDF.png (59.55 KiB) Viewed 1281 times

The resolution is superb as shown at 400% Zoom below, and is still superb even at 6400% Zoom.

DiagramSavedPDFZoom.png (34.1 KiB) Viewed 1281 times

So what is different on Linux that prevents such high resolution PDF?
When using Diagram > Save Diagram As > PDF File (.pdf) what is the Printer Name?
It should be Name: Family Historian PDF Type: novaPDF 7 Printer Driver but is it that on Linux?

DaigramSaveAsPDFPrinter.png (12.66 KiB) Viewed 1279 times

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 10:36
by piotao
In fact, I realized that I didn't try that method. I've never 'printed' to PDF (only to XPS). But there is a menu option in Historian, in Diagram, Save As, PDF - which I've used. It seems to be different though. I was able to save PDF with maybe 30-40% zoom (bigger sizes didn't work), and the resulting pages and pictures were of poor quality. For example, some of the letters were spread too wide, and some of the letter stems were not visible. Examples below.

Here is a problem when I tried to save as some bitmap with 30-40% scale (larger ratios did not work):

Some letters are garbled. Maybe because of the scale.

Another problem occurred numerous times with fonts. When producing PDF - some fonts are rendered incorrectly and I did not test whether this was Historian fault or some fonts problem in my system, or windoze PDF vs Linux TTF or OTF conversion. Here is how this look from one of my previous trials:

So, maybe you're lucky to work only in one system or have a good fonts combo. My workflow shown above just gave me a proper results I desired. Also, please note that your kerning isn't perfect and in my case this was also one of the problems. I needed bit picture for further processing. Importing PDF to another application (GIMP 2.10) also lead to its own conversion problems in my case. Anyway, thank you for the insight!

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 11:12
by tatewise
In your original posting you said: "PDF save is of poor quality."
How did you save to PDF in that case?

In my experience all the Diagram > Save Diagram As > ... File (...) options, except PDF File (.pdf), produce poor resolution.
If your bitmap screenshot used the Bitmap File (.bmp) option then I am not surprised.

The Diagram > Save Diagram As > PDF File (.pdf) uses the Family Historian PDF printer driver installed with FH and that should work in VirtualBox. Do you get the dialogue I posted earlier showing the Family Historian PDF printer?

Does the Diagram > Save Diagram As > PDF File (.pdf) option produce a PDF file for your 400 people and 8 generation tree?

To improve the text problem you illustrated, try adjusting some of the Diagram Options > Dimensions tab settings.
The problem is that your boxes are too narrow to allow long words, so let them be wider and the text should be OK.
Increase Maximum box width and Standard box width to allow boxes to be wider.

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 11:51
by piotao
Hi Mike, my problem is solved already. Thank you anyway.
I've noticed that only some special fonts have kerning problems, like Sinkin Sans - nice, wide, big and readable font which I've used. For me, XPS is working nicely, so I could drop PDFs for now.
One way or another, all this PDF/XPS step is required only to get the big picture in 100% scale, which has several meters in diameter. If FH is able to save png/jpg files with no problem in any scale, these steps will be no longer required.
Previously I had to catch screen dump for every part of the tree in 100% size and then manually merging all parts into a big picture. Now this workflow is semi-automated and could work for any numer of even small pages. It may even work for PDFs too. That was the reason I posted it here.

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 13:00
by tatewise
As I said, all the FH Diagram Save As options produce poor quality, especially with a reduced Scale such as 30%.
The one exception is PDF File that even with a Scale as low as 30% as shown in my screenshot earlier, the PDF quality is excellent, and usually can fit the whole diagram automatically into one large PDF page. No need to go via XPS.

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 13:11
by piotao
Hm, OK, let me test that, thank you!

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 14:37
by Jane
Another thing to check is that you have set the PDF writer to embed the fonts you have used otherwise the proportions could be out. It's also worth setting the Printer to the Family historian PDF printer before you save the diagram.

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 14:58
by piotao
I've checked that and printing as PDF works as well. The only limitation is that it do not prints into one huge page, but instead I was able to set A0 format, which decreased number of 'pages' to about 34 for 'flat' tree I've tested. Then, the conversion to bitmap can be done by using pdftoppm which has even more options (like antialiasing etc.), and merged with montage as before. This time again I had to enlarge limits in the system because for flat tree the pixel size was about 119340 x 9932.

I've noticed that PDF printing allows for far more options, with the possibility to define my own paper sized. However when I tried to define a custom paper size of 20000 x 200mm, HF hung and I probably lost my carefully positioned diagram. ARGH!!!

Re: Linux and saving big nice PNG diagrams workflow

Posted: 04 Sep 2019 15:27
by tatewise
Always use Diagram > Save Diagram As > Family Historian Chart to avoid losing a carefully positioned diagram!

When using Diagram > Save Diagram As > PDF File (.pdf) did you accept the default Adjust PDF File Page Size so that Diagram fits into One Page option? You don't need to specify paper size for that to work.
Do not use the File > Print command, or any other Print commands.
However, with a large diagram like yours (larger than about 3.2m x 3.2m), it won't fit into one page automatically.
Use the Diagram > Diagram Statistics command to find the Diagram Size of your diagram.
Adjust the Scale down to a small percentage such as 50% or 30% or even smaller, then check the Diagram > Diagram Statistics again to see if it is less than 3.2m x 3.2m.
Beware Scale and Zoom are two different settings ~ Scale affects print size and screen display, whereas Zoom only affects screen display.

See Knowledge Base > Single Page PDF of a Diagram that has advice about the adjustments that will help fit it all into one page.