Flatten image with external build script trick