@drolon I have modified FreeImage to use automatic memory management (scope exit release)
https://github.com/mnaydenov/FreeImage-Adv/tree/RAII
Look at the end of Utilities.h to get an idea.
Please, consider adding this to the main repo! This is one of those things that greatly increase code simplicity and maintainability. I am willing to create formal patches (modified files)
Anonymous