Jump to content
You must now use your email address to sign in [click for more info] ×

whatFileType - Detects file signatures and tells what sort of file it is (also if it's an Affinity file)


v_kyr

Recommended Posts

Here's another Python3 script whatFileType.py which can be helpful in situations, where some files don't have file extensions, or where you maybe can't trust a files initial shown file extension (...like an binary image file download without extension etc.).

So this little whatFileType.py Python 3 script does basically here what the Unix file cmd, or some services like what file is do, it tells you what sort of file it is. BTW this script can also tell if some binary file is an Affinity file.

The actual supported and recognized file signatures are: 

  • BMP, JPG, GIF, PNG, TIFF, PSD, PDF, WEBP, AFFINITY, EPS, RTF, HDR, EXR

... which are mostly those file formats Affinity apps export or save to.

The whatFileType.py script can be called either by passing over some file as an argument directly ...

Quote

> python3 whatFileType.py filename

... or in an interacting mode just like this ...

Quote

> python3 whatFileType.py                                                                                                                                                                 
Enter a filename to identify or press ENTER to skip: test                                                                                                                                 
Selecting file... test                                                                                                                                                                    
Opening file: test                                                                                                                                                                        
File size: 1001678 Bytes                                                                                                                                                                  
                                                                                                                                                                                          
Trying to identify file signature: AFFINITY

In cases where some file type is unrecognized (thus not supported yet) the script tells you ...

Quote

> python3 whatFileType.py unknown_check.txt                                                                                                                                                 
Selecting file...unknown_check.txt                                                                                                                                                          
Opening file: unknown_check.txt                                                                                                                                                             
File size: 451 Bytes                                                                                                                                                                      
                                                                                                                                                                                          
Trying to identify file signature: unrecognized file signature!

Here's the whatFileType.py Python3 script for download:

Have fun!

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Nice!, now just need to detect whether Affinity V1 or V2 for this chap?
 

 

 

My dad always told me, a bad workman always blames their tools….

Just waiting for Ronny Pickering…..

Affinity Photo, Designer, Publisher 1.10 and 2.2 beta on macOS Sonoma 14.0 Beta on M1 Mac Mini 16GB 1TB
Affinity Photo, Designer, Publisher 1.10 and 2.2 beta  on Windows 10 Pro.
Affinity Photo, Designer, Publisher 2.2 beta on M1 iPad Pro 11” on iPadOS 17.0 beta 
 

https://www.facebook.com/groups/AffinityForiPad

https://www.facebook.com/groups/AffinityPhoto/

The hardest link to find https://affinity.help

Link to comment
Share on other sites

It's unclear from the current description what "Affinity file" means. There are the obvious 3 main native types for Publisher, Designer, and Photo, of course. But what about afbrush, afassets, etc. files? 

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.3, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.3.1

Link to comment
Share on other sites

5 hours ago, Paul Mudditt said:

...now just need to detect whether Affinity V1 or V2 for this chap?

Well, sure that would be useful to detect, but I don't know yet if and where that information is hidden (...binary hex position wise) inside the Affinity format binary files. I also don't have any equal V2 to V1 files here in order to hunt after that via hex editor file compares. - So all in all it's probably not that easy to find out by such an proprietary completely undocumented file format.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

25 minutes ago, walt.farrell said:

It's unclear from the current description what "Affinity file" means. There are the obvious 3 main native types for Publisher, Designer, and Photo, of course. But what about afbrush, afassets, etc. files? 

Hi Walt, there are not 3 main native types, there is only one file format for V1 and one file format for V2, there is zero difference in contents for a .afdesign, .afphoto, .afpub file other than the text used in the file extension.   The file extension is a mere visual reminder where you saved it from and does not signify any different contents. For example, this why .afpub files can be opened in Photo or Designer as a native file import. Photo would not even know that it opened a file created in .afpub.

 

 

My dad always told me, a bad workman always blames their tools….

Just waiting for Ronny Pickering…..

Affinity Photo, Designer, Publisher 1.10 and 2.2 beta on macOS Sonoma 14.0 Beta on M1 Mac Mini 16GB 1TB
Affinity Photo, Designer, Publisher 1.10 and 2.2 beta  on Windows 10 Pro.
Affinity Photo, Designer, Publisher 2.2 beta on M1 iPad Pro 11” on iPadOS 17.0 beta 
 

https://www.facebook.com/groups/AffinityForiPad

https://www.facebook.com/groups/AffinityPhoto/

The hardest link to find https://affinity.help

Link to comment
Share on other sites

17 minutes ago, Paul Mudditt said:

there are not 3 main native types,

That's of course true, Paul, and I must apologize for my imprecise wording.

My main point was that there are many types of "Affinity files" (some with subtypes): afassets, afstyles, afbrushes (raster and vector), affont, afshortcut, afselection (if I remember correctly), and probably several I'm not remembering at the moment.

Thus, "Affinity" is not an ideal descriptor for a file type, and it's not clear (without reading the Python code, which I have not done yet, and looking at the hex for these files), what "Affinity" means in this context.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.3, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.3.1

Link to comment
Share on other sites

19 minutes ago, walt.farrell said:

That's of course true, Paul, and I must apologize for my imprecise wording.

My main point was that there are many types of "Affinity files" (some with subtypes): afassets, afstyles, afbrushes (raster and vector), affont, afshortcut, afselection (if I remember correctly), and probably several I'm not remembering at the moment.

Thus, "Affinity" is not an ideal descriptor for a file type, and it's not clear (without reading the Python code, which I have not done yet, and looking at the hex for these files), what "Affinity" means in this context.

Ah gotcha Walt, now I follow you. Apologies.

 

My dad always told me, a bad workman always blames their tools….

Just waiting for Ronny Pickering…..

Affinity Photo, Designer, Publisher 1.10 and 2.2 beta on macOS Sonoma 14.0 Beta on M1 Mac Mini 16GB 1TB
Affinity Photo, Designer, Publisher 1.10 and 2.2 beta  on Windows 10 Pro.
Affinity Photo, Designer, Publisher 2.2 beta on M1 iPad Pro 11” on iPadOS 17.0 beta 
 

https://www.facebook.com/groups/AffinityForiPad

https://www.facebook.com/groups/AffinityPhoto/

The hardest link to find https://affinity.help

Link to comment
Share on other sites

45 minutes ago, walt.farrell said:

My main point was that there are many types of "Affinity files" (some with subtypes): afassets, afstyles, afbrushes (raster and vector), affont, afshortcut, afselection (if I remember correctly), and probably several I'm not remembering at the moment.

They do mostly all start with the same signature (BOM) here, and as we always already often said in the forum, the Affinity file format(s) are sadly proprietary and undocumented, thus it's difficult to tell if there are maybe overall some deeply internal hidden differences here between the file formats the Affinity apps do write out (aka afphoto, afdesign, afpublish, afassets, afbrushes ... etc.), in order to differntiate between them.

And to make it clear here ALL these Affinity related files do always start with the same signature (BOM), thus this script so far can just tell that it is an (some kind of) "AFFINITY" file! - If you encounter more informations about possible by Affinity generated file format differences and how to differntiate between them, I will happily take those into account here for this script!

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Thanks, @v_kyr.

Meanwhile, if it helps with the V1 vs V2 detection request, here are empty V1 and V2 files, both based on the Letter Preset:

empty-v2.afdesignempty-v1.afdesign

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.3, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.3.1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.