Still need to figure out the memory issues
Consolidates image conversion logic into a dedicated method.
This change streamlines the conversion process by centralizing the
setting of converted image data, extension, and size. It also
introduces a flag to track whether an image has been converted.
The old resource cleanup has been removed since it is not needed anymore.