Really simple image file support and SVG limits

Talk about Pixelmator Pro, share tips & tricks, tutorials, and other resources.
User avatar

2020-06-08 10:24:50

Hi all.

I'm working on a few data visualisation projects that involve outputting vector and bitmap images. Due to the unusual nature of the project I'm not going to be able to use any libraries so I'm going to have to write the export function myself.

Vector graphics are easy. I know a tiny amount about SVG files and it turns out that's all you need (for export, anyhow: parsing for import is way more complex). I can easily write a method that takes the data and spits out a .svg file.

Bitmap graphics are somewhat more complex. Does anyone have a feel for the absolute simplest image format that I can spit out (preferably 24-bit colour with transparency, but happy to compromise)(also preferably importable by Pixelmator Pro but again, happy to compromise).

My back-up plan (which I'll admit is a rather clunky) is to write out my bitmap file as a vector SVG with an SVG rectangle per pixel then loading that into Pixelmator Pro and exporting a bitmap from there. Other than mucking about with files that are much bigger than they need to be (and battling with conceptual ugliness), can anyone see a problem with this? Will I hit a limit with number of shapes (typical image will be 1000px × 1000 px so 1 million rectangles, but I can easily foresee going up to HD 1920×1080=2,073,600 rectangles).

Any help from either the Pixelmator team or the community at large greatly appreciated.

- Stef.
User avatar

2020-06-10 11:50:23

Pixelmator cannot handle SVG files beyond very basic ones. Try opening an SVG with 1000 layers (this is considered small) and you'll see. It probably converts every layer to bitmap and renders as a stack of bitmaps rather than a stack of shapes. You will never see the end of beachball if you try to open SVG with millions of rectangles using pixelmator.
User avatar

2020-06-10 14:16:32

Hey Stef, my colleague tells me BMP is about the simplest bitmap format you can spit out but, just to clarify, are these visualizations in a raster format already or in some other app, or in code format? As it's a raster-first app, Pixelmator Pro does render vector layers as pixels (although they are processed as vectors by the Pixelmator Pro editing engine). Doing this is quite resource-intensive so having millions of layers is, unfortunately, not feasible. But it would interesting to know in what format/medium are the original visualizations.
User avatar

2020-06-10 18:19:05

Hi Andrius and leonfabr.

Thanks for your replies. The bitmap images will be algorithmically generated from minimal data. They're not fractals but, if you were to think of generating a part of a Mandelbrot set, adding a few lines and some lettering you wouldn't be a million miles off.

I guess I've been looking for something like a bitmap version of SVG: a text-based bitmap graphics format that is really easy for a bit of simple code to spit out. That said, I looked up the file format for a .BMP and it doesn't look too horrible. I think I can do that if I can find my hex editor for debugging.

Thanks for the help.

- Stef.
User avatar

2020-06-11 13:46:17

Got it, let us know how it goes!