1

For example I have picture1.JPG then another user of my computer change the extension from picture1.JPG to picture1.PNG, I am sure that in most cases it will work. My question is this, is there a way to detect if a files extension has been modified?

2

2 Answers 2

2

The file program examines the contents of files, showing their actual type (with occasional misses). If you are using a Unix-like system, you probably already have it installed (there is a POSIX description of it, for instance). For Windows, there is a port in GnuWin32 (a little old, but better than nothing).

The program lists each filename, along with the types. All you have to do (with a script would be nice) is to look for mismatches between the two (filename versus description of its type).

Here is some sample output to illustrate:

escher03.jpg: JPEG image data, JFIF standard 1.02
snakes.jpg:   JPEG image data, JFIF standard 1.01
sphere.gif:   GIF image data, version 87a, 1120 x 832
spirals.jpg:  JPEG image data, JFIF standard 1.00, comment: "U-Lead Systems, Inc."
square_l.gif: GIF image data, version 87a, 634 x 668
st_peter.gif: GIF image data, version 87a, 640 x 480
2

Just to give you another alternative if you need to work only with images. You can use the command identify, which belongs to ImageMagick:

$ identify stellarium-000.png
stellarium-000.png PNG 1364x728 1364x728+0+0 8-bit sRGB 248KB 0.000u 0:00.000

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .