start of image format & extraction logic