Re: [Tutor] File extension against File content

2019-05-31 Thread Alan Gauld via Tutor
On 31/05/2019 11:03, Sunil Tech wrote: > Hi Tutor, > > Is there any way that I can actually programmatically compare the file > extension with its content? For images the standard library offers imghdr I'm not sure how reliable or accurate it is but it claims to identify a dozen or so of the mos

Re: [Tutor] File extension against File content

2019-05-31 Thread Cameron Simpson
On 31May2019 12:38, ingo wrote: Many file formats have "magic bytes" that you can use for that purpose. https://en.wikipedia.org/wiki/List_of_file_signatures Also, UNIX systems ship with a command called "file" which inspects a file's leading data for such magic numbers to identify their cont

Re: [Tutor] File extension against File content

2019-05-31 Thread ingo
Many file formats have "magic bytes" that you can use for that purpose. https://en.wikipedia.org/wiki/List_of_file_signatures Ingo On 31-5-2019 12:03, Sunil Tech wrote: > Hi Tutor, > > Is there any way that I can actually programmatically compare the file > extension with its content? > > This