Reputation: 260
On a linux machine, you can change file name from "abc.jpeg" to "abc.png" by just doing rename. I am still able to open my pic in image viewer.
I wanted to know if the compression technique also changes when we change the name, or just the name changes and the image viewer itself opens it the way it likes?
Upvotes: 0
Views: 830
Reputation: 260
As pointed out by yacc in comments, renaming that file won't change the compression method, if we want a true png we will have to convert it.
The hex signature of image/file is checked before opening it in the image viewer. Changing name does not change this signature and hence, even though your file name is .png, it is actually a jpeg and your viewer knows it by the hex signature.
https://en.wikipedia.org/wiki/List_of_file_signatures
Upvotes: 0
Reputation: 21617
The file name has nothing whatsoever to do with the contents of a file stream. Every decoder I have ever encountered will decode the stream based upon its contents; and not the file name. Some decodes will warn if the file name does not correspond with the stream type.
To your question, renaming does not change the contents of the file on any system I have ever seen.
Upvotes: 1