DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

PicExport speed

Hi,

 

I recently updated a script that uses PicExport to export report pictures in PNG format instead of WMF. This was done to reduce the file size of each image as there doesn't seem to be a way of controlling the image size of vector graphics.

 

The file sizes are now greatly reduced and are of acceptable quality. However, the script speed has plummeted from a brief blip to a painful crawl.

 

Is it possible to have the best of both worlds - file size control and script speed?

 

I also noticed that the PowerPoint export is slow and this appears to use raster images. However, the PDF export is quite quick and seems to use vector graphics, but produces a file size that is way way smaller than the number of pages multiplied by the file size I get when I use PicExport with a vector file type. For example, one report page exported in EMF format is 1.14 MB and is 7680*5376 pixels when opened in a reviewer such as MS Picture Manager. However, the PDF document containing 17 such images is only 994 KB in total!!

 

Can I have individual image export, in good quality, and with a fast export speed??

 

Thanks, Simon.

0 Kudos
Message 1 of 7
(2,600 Views)

Hello Simon!

 

It sounds to me like PDF export is almost the right thing for you (fast, small file size, and perfect quality due to vector graphics), except that it gives you one pdf instead of separate ones. I'd solve this with post-processing. I know PDFtk Server (the command line tool) and Ghostscript (respectively GhostPDF which is built on top of ghostscript) that will to the trick. It's a one-line command on the command line each, should be easy to implement into your toolchain.

 

Test PDFtk first, as ghostscript converts pdfs to gs and back, which could lead to issues with your images.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 2 of 7
(2,572 Views)

Hi,

 

I'm not sure I would be any better off. I create image files so that they can be inserted into Word documents. Having a series of PDF documents in place of the images would give me much more work when trying to use them in reports.

 

Regards.

0 Kudos
Message 3 of 7
(2,570 Views)

Oh, I see. I'd still do it with tools originating from Linux, as this gives you detailed control over the result, and you can script it to do everything automatically. Ghostscript can do the trick for you, converting each page of your pdf into an individual png/jpg/[...]. Or you use "convert" from the ImageMagick package, which is easier to use. See e.g. How do you convert PDFs to PNGs with ghostscript? (first answer is about ghostscript and convert.).

 

In case you want to stick to DIAdem's own functionality: From your first post I get that your exported raster images are almost 8k x 5k pixels huge. That's 41MP, and the same amount of data to generate, compress (for the png), and write away. That is a reasonable amount of data, however I wonder how slow the "painful crawl" of your script actually is. How long does it take to create and write these 17 images? This would give us a better impression of what we are talking about.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 4 of 7
(2,564 Views)

Hi,

 

Thanks for the info. I don't think I'll go down that route as it will make the task significantly larger than intended. I've never used Linux products and have not even heard of the ones you mention. The investment in learning is likely to exceed the loss from the reduced script speed.

 

However, to answer your question about script speed, I ran a few tests. Firstly, the 8k x 5k doesn't apply to the raster export. That image size applies to the vector images once they are imported into some sort of viewing software. There is little that makes sense with image file sizes as I've seen files vary wildly in size on different user's machines and then vary again when inserting into Word documents. Once it stopped making sense, I stopped pursuing the problem.

 

The export of 17 vector images took 2 seconds. For raster images of 4096 x 3072, it increased to 25 seconds. Raster images of 2194 x 1536 took 7 seconds. The latter time is just about acceptable, but the file quality isn't that great. I'm inclined to stick to producing vector images and accepting the file size.

 

Regards.

 

 

0 Kudos
Message 5 of 7
(2,560 Views)

Exporting 17 EMF/WMF files in 2 seconds sounds good, 17 pngs of ~3MB(?) each within 7 seconds sounds okay. Are you writing these files locally or to a network drive?

 

This was done to reduce the file size of each image as there doesn't seem to be a way of controlling the image size of vector graphics.

For clarification: By "size", you mean "amount of bytes", right? This you can't control, as inside a vector image, all elements (lines, circles, fillings, etc) are described with mathematical functions. The more elements in the graph, the more disk space it needs. Or do you refer to dimensions? For all vector formats, this is just a stored, artificial number. Think of the content of a emf/wmf/pdf file that shows a black circle like this: "circle, center=middle of image area, black". Using this recipe, you can draw this image to any dimensions you want, it will always show a black circle. No matter if you use a sharpie, drawing a small circle with a diameter of 1mm, or if you draw it on the moon, 3000km diameter. The caveats come when converting this to an raster image:

For example, one report page exported in EMF format is 1.14 MB and is 7680*5376 pixels when opened in a reviewer such as MS Picture Manager.

So how does the MS Picture Manager how many pixels it shall create for your image? Either there is an artificial description inside the EMF file that DIAdem exports (like: "circle, center=middle of image area, black; image area=30cm x 20cm; use 260 pixels per cm". Or there is none and MS Picture Manager just uses a kind of random value. You can check the given dimensions by opening the EMF file in any text editor. If there is a definition stored by DIAdem, it's close to the beginning. That is still no guarantee that MS Picture Manager actually uses it for converting, as these artificial values are often simply ignored.

 

Another issue with vector format import lies within Word / MS Office. With version 2013 the emf/wmf importer to convert vector images to bitmaps depending on an unknown set of rules. Maybe you can find a format (emf/wmf/eps) and/or setting in DIAdem that Word imports as actual vector file and does not convert into a bitmap?


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 6 of 7
(2,556 Views)

Hi,

 

The PNGs are smaller than the vector images - that was the original reason for switching to them. The vector images are 1.2-1.4 MB, whilst the PNGs are 90-120 KB when at 2194 x 1536 and 160-300 KB when at 4388 x 3072. Thus the PNGs are way slower to produce. I'm writing to a network drive.

 

I'll stick to EMFs for now and check that they behave well on everyone's machine and when importing to Word.

 

Regards.

 

 

0 Kudos
Message 7 of 7
(2,552 Views)