Allow specifying image PPI when writing PNG/JPEG files

It would be useful to be able to specify the pixel density when writing images with PNGImageFormat and JPEGImageFormat.

Currently, as far as I can tell, there is no public API to control this metadata without modifying JUCE’s source code.

My proposed API is simply:

void PNGImageFormat::setDensity (const juce::uint32 x, const juce::uint32 y);
void JPEGImageFormat::setDensity (const juce::uint16 x, const juce::uint16 y);

This is particularly useful when JUCE is used to generate image files, where the physical resolution (DPI) can be just as important as the pixel dimensions.

I have implemented and tested this approach in production on macOS, Windows, and Linux. The required changes are relatively small.

I’m happy to submit a PR if this feature would be considered appropriate for JUCE.

here is the PR: Allow specifying image PPI when writing PNG/JPEG files by pierreguillot · Pull Request #1766 · juce-framework/JUCE · GitHub