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?
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.