One of the things that is very broken in Megapixels 2.0 is actually saving pictures, so here I will embark on a side-quest to make a new DNG exporting library that moves the code out of Megapixels.
It seems overkill to make a whole seperate library dedicated to replacing 177 lines of code in Megapixels that touches libtiff, but this small section of code causes significant issues for distribution packaging and compatability with external photo editing software. Most importantly the adjusted version in Millipixels for the Librem 5 does not output DNG files that are close enough to the Adobe specifications to be loaded into the calibration software.
Making this a seperate library would make it easier to test. In the Adobe DNG SDK there is a test utility that can verify if a TIFF file is up to DNG spec and it can (with a lot of complications) be build for Linux.
The first thing after copying over the code block from Megapixels to a seperate project is reading the Adobe DNG specification.