Why am I getting the error: "Not a JPEG file: starts with 0x89 0x50"

103,082

Solution 1

The file is actually a PNG with the wrong file extension. "0x89 0x50" is how a PNG file starts.

Solution 2

Your file is not a JPEG file, it's just been renamed from a PNG to a JPEG somewhere along the way. Some programs will open this as a recognised file extension and infer the type from the prefix, but obviously not the one you're using.

Solution 3

Your 'JPEG' file has wrong filename extension 'jpg' or 'jpeg', it's real type is most probably a PNG file.

Just try to rename file name from 'xxx.jpg' or 'xxx.jpeg' to 'xxx.png'.

Under most circumstances, programs distinguish file type with filename extension for convenience, however, if we specify a wrong filename extension(like 'jpg') to a file in other format(like a PNG file), the program will still try to load the PNG file with JPG library, an error will certainly be thrown to user.

Actually, different type of files always have different file header (first 1024 byte)

Here's a quick pass to check real type of the file on Unix-like platform:

using the "file" command, like:

file e3f8794a5c226d4.jpg 

and output is

e3f8794a5c226d4.jpg: PNG image data, 3768 x 2640, 8-bit/color RGBA, non-interlaced

which will print file information details, and we can also check if the specified file has been destructed.

Solution 4

simply rename *.jpg to *.png. Or open this file in browser

Solution 5

This is the error response when you try to open a PNG file using a JPEG file viewer which uses libjpeg to open jpeg files. Your file is renamed from png to JPEG as mentioned in earlier answers.

Share:
103,082

Related videos on Youtube

matt burns
Author by

matt burns

Programming photographer. Creator of StolenCameraFinder, OddPrints and AwesomeTimer.

Updated on May 23, 2021

Comments

  • matt burns
    matt burns over 1 year

    Why am I getting the message "Not a JPEG file: starts with 0x89 0x50" when I try to open my jpg file?

  • zigzag over 5 years
    If you'd like to find those files, you can use this StackOverflow link: stackoverflow.com/questions/30684796/…
  • Ashwin
    Ashwin over 4 years
    Adding on to Different55's answer. The script works only for Python version 3.5 and above.
  • Brent Self
    Brent Self almost 4 years
    I took a screenshot on my iPhone 7 with iOS 12.0.1, then from Photos shared to Google Drive. Used the default/suggested name when saving and had this error when attempting to open on Ubuntu with Image Viewer. After reading this answer, changed the extension to PNG and the file opened without converting or re-saving in another program.
  • Adarsh TS
    Adarsh TS about 2 years
    Thanks for the answer. What does a jpeg file start with?

Related