I have a bunch of files that have .png extension. However, some of them are actually gif files. Any of the files, I can open them w/ gimp or view them in firefox, but when I try to open them with the Eye of Gnome viewer, it gives an error "Could not load image: Fatal error reading PNG image file: Not a PNG file"

Is there:

  1. Another image viewer that can open files with incorrect extensions that I could use as default? It would need to have the ability to zoom in and out on images, and scroll through all the images in a folder via arrow keys.
  2. An automated way to rename the files that are actually gif files to the correct extensions?

Choice 2 is preferred, but I don't now how to tell what type they are. I would be able to put together a bash script to do the renaming if there is a command that could tell me what type they are.


If you use (from command line or within a script... if you need the script just ask ;) ) the command file thisimage.png, it will tell you what image format you actually have.... Then you can rename accordingly...

This is a sample of what I get with a file with incorrect file extension .png which is really a jpg file:

user@computer:$ file logo.png
logo.png: JPEG image data, JFIF standard 1.01 

Edit: Oh, ok, I was lazy before... Here's an script that will rename actual gif files that are named with .png extension to their correct extension .gif:

for NAME in $(ls *.png); do

if [ "$(file $NAME|grep GIF)" ]; then

echo "Renaming ${NAME} to ${NAME%.*}.gif"
mv ${NAME} ${NAME%.*}.gif


  • 1
    I know that this can probably be accomplished quite more easily with a single line using ´find´ with ´exec´ and such, but I'm not a 'scripter' at all, so anyone should feel free to edit my answer and add a shorter command, if you wish. – luri Mar 4 '11 at 21:55
  • This answer was of great help when debugging a javascript driven image download script. Thanks!! :) – yochannah Sep 10 '15 at 10:24

1.- Remove the file extension, and eye of gnome will be able to view your images as in the next example, the image file is having no extension.

enter image description here

This, however may be not useful for you if you wish the files to have the correct extension.

2.- Then you may be interested in Phatch, which will allow you to perform batch process for renaming and several other tasks.

enter image description here enter image description here

Additionally you may be interested in the Nautilus Scripts Pack which makes the image conversion as easy as a single click.

In the next image I have chosen a bunch of images which, no matters of its original extension or file type, they can be converted to any image format with a single click. Copies are dropped beside the original images.

enter image description here

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.