2

I have noticed that changing the file extension from one to another and back to the old one will make the file unusable. Why is it so ? Does changing the extension change the file contents ?

Also, this can be noticed as changing the extension of .png file to .jpg works but it shouldn't since we are changing the extension. The binary data for .png should be meaningless as .jpg and vice versa.

Does Windows automatically try to change the file contents when the file extension is changed ?

1
  1. Does Windows automatically try to change the file contents when the file extension is changed ?

    No. It's just a part of filename, that indicates what content to expect inside and what program to launch to process that file.

  2. ...changing the extension of .png file to .jpg works but it shouldn't since we are changing the extension. The binary data for .png should be meaningless as .jpg and vice versa.

    The image viewing software is able to guess binary data format by signatures.

  3. I have noticed that changing the file extension from one to another and back to the old one will make the file unusable.

    No, it's not. Probably it was very specific situation caused by some background file processing with third-party software. Could you give an example?

  • I just tested multiple files and yes, it was a mistake on my part. I had saved an .svg file from the internet and changed the extension to .jpg and back to .svg and it wasnt working. But I checked now and .svg files themselves are not working with Windows Photo Viewer. Thanks for the answer. – Talha Sayed Mar 2 '15 at 11:02
  • You're welcome, we all live and learn. – beatcracker Mar 2 '15 at 14:14
1

Many image applications auto-detect the image format if the file doesn't match its extension. Some even ignore the extension entirely and just auto-detect the image format.

Windows does not change a file's contents when the file extension is changed, but it's possible you have some kind of indexing or thumbnail generating extension that "repairs" damaged files based on its extension. That might explain the behavior you describe in your first paragraph.

  • "Windows does not change a file's contents when the file extension is changed" .. How does this explain the corrupted file after changing the extension and back again ? – Talha Sayed Mar 2 '15 at 10:58
  • Never mind. I had made a mistake. You can see my comment on the other answer. Thanks anyway though. – Talha Sayed Mar 2 '15 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.