0xC0000054 / pdn-heicfiletype-plus

A Paint.NET filetype plugin that allows HEIC images to be loaded and saved with transparency.
https://forums.getpaint.net/topic/116873-heic-filetype-plus/
GNU General Public License v3.0
38 stars 1 forks source link

Add format detection for files with the wrong extension #4

Closed 0xC0000054 closed 2 years ago

0xC0000054 commented 2 years ago

It appears to be fairly common for JPEG files (and possibly other formats?) to be misidentified with a HEIC file extension. See issue #1 and #3 for examples of JPEG images with a HEIC file extension.

The format detection can be run on the error code path, when libheif returns heif_error_Invalid_input with heif_suberror_No_ftyp_box. It would consist of checking the first few bytes of the file for the magic number signature of different image formats. If the image format is supported by GDI+, it will be loaded using Document.FromGdipImage.

All JPEG files start with the signature FFD8, the 'Start of Image' marker.