What Is a PNG File? How to Check a Portable Network Graphics File Before You Trust It
PNG files store pixels without losing detail, and six readers still disagreed on 117 of 806 test files. Jump to your question below, or work through it in order.
What Is a PNG File? A lossless picture file that starts with 8 fixed bytes
Short answer
A PNG file is a picture file in the Portable Network Graphics format, and it stores pixels without losing detail. It starts with 8 bytes, 89 50 4e 47 0d 0a 1a 0a, and then comes a series of blocks called chunks. Every chunk has a length, a four letter name, data and a check value.
We read 806 PNG files from four public projects with six readers. We also damaged one PNG file in 52 ways. All six readers opened 680 PNG files and refused 9, and they split on 117. Of the 52 damaged copies, all five decoders refused 8, and only 3 matched the intact pixels in all five.
To check PNG files without an image editor, read the check steps. To see what is inside, read the layout. If your PNG file will not open, begin with the eight causes.
A PNG file is a picture file in the Portable Network Graphics format. It stores pixels without losing detail, and its first 8 bytes, 89 50 4e 47 0d 0a 1a 0a, name it. The ending .png is only a label, because the first bytes decide what a file is.
Picture a screenshot saved as capture.png or a logo saved as logo.png. A text editor shows odd symbols with the letters PNG near the start, because a PNG file is binary. The file is a signature followed by blocks called chunks, and the pixels are stored in chunks named IDAT.
Wikipedia describes PNG as a raster graphics format with lossless compression, built as an improved and non-patented replacement for GIF. It says the name began as PING, a recursive joke for PING is not GIF, in a Usenet thread that started on 4 January 1995.
The W3C specification is the main document. Its third edition became a W3C Recommendation on 24 June 2025. It says a PNG datastream contains a single image, built from chunks that begin with IHDR and end with IEND.
The IANA registry lists the type image/png with the ending .png and the first bytes 89 50 4E 47 0D 0A 1A 0A. The entry was last modified on 7 December 2021, and it points to the W3C specification.
Sources disagree on the date. FileInfo says PNG was created in 1995. Wikipedia dates the first idea to 4 January 1995 and the full specification to 1 October 1996. Both can be true, because one dates the idea and the other dates the release.
Lossless means that the pixels you save are the pixels you get back. We tested that in the convert part. Lossless WebP and a smaller PNG file gave back identical pixels, and JPG at quality 85 changed pixels in all three pictures.
Where our PNG files come from
Our 806 PNG files come from the test folders of four public projects. Pillow gave 410, image-png 211, libpng 178 and libspng 7. We collected 1,048 PNG files and removed 242 copies with the same SHA-256 hash.
Many are built to be odd, so they include cases that a normal PNG file does not. The 806 PNG files total 19,924,758 bytes and range from 41 bytes to 6,965,828, with a median of 589. The largest valid picture is 2,812 by 3,982 pixels.
The ending is no guide. We saved a valid PNG file under 7 other names, like .jpg, .gif, .txt and .zip, and 11 other files under the name .png. The tests below also use 52 damaged PNG files made from one 6,074 byte PNG file.
PNG file facts at a glance
| Property | Value |
|---|---|
| Meaning | Portable Network Graphics. FileInfo lists the PNG Development Group as the developer. |
| Ending | .png. IANA and Wikipedia list no other ending. |
| First bytes |
89 50 4e 47 0d 0a 1a 0a, per IANA and Wikipedia. The letters PNG are bytes 1 to 3.
|
| Type | image/png, registered with IANA. |
| Structure | A signature, then chunks. Every chunk has a 4 byte length, a 4 byte name, data and a 4 byte CRC. |
| Compression | Lossless. The W3C specification defines one method, deflate, for the pixel data. |
| Colors | Gray, RGB or palette, with or without an alpha channel, at 1 to 16 bits. 15 combinations are allowed, and all 15 appear in our files. |
| Images | One image per file, plus the animation chunks of the third edition. 55 of our 806 PNG files have them. |
| Opens with | FileInfo lists most image editors, video editors and web browsers. We tested six readers on 806 PNG files. |
| Our tests | 806 PNG files, 52 damaged PNG files, 18 renamed files, 3 pictures converted six ways and one 5 frame animation. |
Wrong page? A photo that ends in .jpg is a different format. See the JPG file page.
What Is Inside a PNG File? A signature, then chunks that end in a CRC
A PNG file is an 8 byte signature followed by chunks, and every chunk ends with a CRC check value. Our example, base.png, is 6,074 bytes long and has 5 chunks. IHDR comes first, the pixel data is split over three IDAT chunks and IEND comes last.
We built one PNG file with Pillow and called it base.png, so every byte can be read. It is 320 pixels wide and 240 tall, in RGB color at 8 bits. The figure shows its blocks from the outside in.
Read the figure from the top. The first check in a PNG file is the signature. The signature rule in the specification says it differentiates a PNG datastream from other datastreams and allows early detection of some transmission errors.
The start of a PNG file, byte by byte
xxd -l 48 base.png
00000000: 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 .PNG........IHDR
00000010: 00 00 01 40 00 00 00 f0 08 02 00 00 00 fe 4f 2a ...@..........O*
00000020: 3c 00 00 07 d0 49 44 41 54 78 da ed 5d 6b 54 14 <....IDATx..]kT.
Bytes 0 to 7 are the signature. Bytes 1 to 3, 50 4e 47, spell PNG. Bytes 4 to 7, 0d 0a 1a 0a, are a carriage return, a line feed, a control character and another line feed. The damage tests include a copy where every 0d 0a became 0a, as a text mode transfer does.
Bytes 8 to 11, 00 00 00 0d, are the length of the first chunk, which is 13. Bytes 12 to 15, 49 48 44 52, spell IHDR. PNG stores numbers with the high byte first, so 00 00 01 40 is 320 and 00 00 00 f0 is 240.
Byte 24 is the bit depth, 08. Byte 25 is the color type, 02, which means RGB. Bytes 26, 27 and 28 are the compression method, the filter method and the interlace method, and all three are 0. Bytes 29 to 32, fe 4f 2a 3c, are the CRC of the chunk.
The next chunk starts at byte 33 with its length, 00 00 07 d0, which is 2,000. The letters 49 44 41 54 spell IDAT, and 78 da is the header of the zlib stream. The three IDAT chunks contain 2,000, 2,000 and 1,993 bytes, and together they inflate to 230,640 bytes.
That number is easy to check. Every row of base.png has 320 pixels at 3 bytes, plus 1 filter byte, so it takes 961 bytes. Multiply 961 by 240 rows and you get 230,640. Our script uses the same sum to spot a file with damaged pixel data.
The chunks we found in 806 PNG files
| Chunk | What it stores and how often we found it |
|---|---|
IHDR
|
The image header. It stores the width, height, bit depth, color type and the compression, filter and interlace methods. Every valid file has one, and it must come first. |
PLTE
|
A palette of 1 to 256 colors, 3 bytes per color. It is required for color type 3, and 152 of our files have one. |
IDAT
|
The compressed pixels. 33 PNG files split them over more than one IDAT chunk, like base.png. |
IEND
|
The end of the file. Its data is empty. 33 of our files have no IEND chunk. |
gAMA
|
The image gamma. It is the most common extra chunk, in 245 PNG files. The sRGB chunk is in 51 and iCCP, an ICC profile, in 16. |
cHRM
|
Primary chromaticities and the white point. 71 PNG files have it. The cICP chunk, which stores video signal codes, appears in 3. |
tRNS
|
Transparency for palette, gray and RGB files that have no alpha channel. 71 PNG files have it. |
tEXt
|
Text with a keyword. 141 PNG files have tEXt chunks, 125 have iTXt chunks and 15 have zTXt chunks. 161 PNG files have text or an Exif chunk. |
eXIf
|
An Exif profile, which can store camera data. 5 of our files have one. |
pHYs
|
Physical pixel size. 67 PNG files have it. The sBIT chunk, with the significant bits, is in 61 and bKGD, a background color, in 40. |
tIME
|
The time of the last change. 37 PNG files have it. |
acTL
|
Animation control, defined in the third edition. 55 PNG files have it, and 54 of them come from the Pillow folder. |
How the case of a chunk name guides a reader
The case of the four letters sets four properties. The chunk naming rules say the first letter marks the chunk as critical when it is uppercase and ancillary when it is lowercase. The second marks public or private, the third is reserved and the fourth says if an editor may copy the chunk.
So tEXt is ancillary, public and safe to copy, and IHDR is critical. A decoder that meets an unknown ancillary chunk can ignore it. For an unknown critical chunk, the rules say the decoder must warn the user that the image has information it cannot safely interpret.
We tested both. A chunk named abCd, which is ancillary, changed nothing, and all five decoders drew the intact pixels. A chunk named ABCD, which is critical, was refused by ImageMagick and OpenCV and drawn intact by Pillow, ffmpeg and Chromium. We did not check whether those three showed a warning.
The list is small. Our script reads the signature, the chunk list and the size of the pixel data. It does not read palette values or decode a picture, so damage deeper in the file can pass it, as the damaged copies show.
Which Kind of PNG File Do You Have? The ending names none of the colors, depths or frames
Four questions sort a PNG file, how its colors are stored, how deep they are, whether the rows are interlaced and whether it has animation frames. Of 791 valid files, 337 are RGB and 169 use a palette, and 541 have a bit depth of 8. The ending names none of this.
Most questions about PNG files come down to how the colors are stored and how big the pictures are. The header answers both without decoding a picture, and the chunk list answers the rest.
Color type
The color type is byte 25 of the file. In our 791 valid files, 337 are RGB (type 2) and 169 use a palette (type 3). 148 are gray (type 0), 114 are RGBA (type 6) and 23 are gray with alpha (type 4).
The color type table allows 15 pairs of color type and bit depth, and all 15 appear in our files. It does not use the names PNG-8, PNG-24 or PNG-32, and we found none of them in its text. Editors use those labels, and they are not types you can read from a PNG file.
Bit depth
A bit depth of 8 is used by 541 of the 791 PNG files, 1 by 74, 4 by 72, 16 by 63 and 2 by 41. Palette files use 1, 2, 4 or 8 bits per index. A 16 bit file stores two bytes for every sample.
Sizes vary widely. 507 of our 806 PNG files are under 1 KB, and 230 are between 1 KB and 9.9 KB. 48 are between 10 KB and 99 KB, and 21 are 100 KB or more. Among the valid files, 28 are a single pixel and 174 are 32 by 32.
Interlaced files
The last header byte is the interlace method. A value of 1 means Adam7, which stores the picture in seven passes so that a rough version can appear early. 64 of our 791 valid files use it. The others, 727, store the rows in order.
Animated files
FileInfo calls PNG a single image format. The third edition of the specification adds the chunks acTL, fcTL and fdAT for animation, and 55 of our 806 PNG files have an acTL chunk. We made our own 5 frame animation to see how readers treat one.
file -b anim.png
PNG image data, 160 x 120, 8-bit/color RGBA, non-interlaced
The file command printed a line like the one for a still picture and said nothing about frames. Pillow, ffprobe and Chromium found 5 frames. ImageMagick listed 1 and OpenCV imread returned 1, while imreadmulti returned 5. A reader that shows the first frame is not broken.
Not sure the file is a PNG file at all? Check it with our script.
What Did We Find in 806 PNG Files? Six readers, and a split on 117 files
We read 806 PNG files from four public projects with six readers. The file command opened 797, Chromium 760, Pillow 751, OpenCV 750, ImageMagick 742 and ffmpeg 704. All six opened 680 PNG files together. None opened 9, and 117 split the readers.
We took 806 PNG files from the test folders of Pillow, image-png, libpng and libspng. They are public test files and not a sample of the PNG files on a typical PC. Many are odd on purpose.
The readers were the file command 5.45, Pillow 12.3.0, ImageMagick 6.9.12, ffmpeg 6.1.1, OpenCV 5.0.0 and Chromium 141. We also wrote a 64 line Python script. We worked on Linux with Python 3.13, and we opened no PNG file in Windows Explorer, Paint or Photos.
The file command opened a PNG file when it named the type. It reads the header and decodes nothing. The five decoders had to draw the pixels. Pillow had to load them and ImageMagick had to write them. ffmpeg had to decode a frame without an error, OpenCV had to return an image and Chromium had to decode it.
| Test | Result |
|---|---|
| Opened | The file command opened 797 of 806 PNG files, Chromium 760, Pillow 751, OpenCV 750, ImageMagick 742 and ffmpeg 704. |
| Together | All six readers opened 680 PNG files. None opened 9, and the readers split on 117. |
| Decoders only | The five decoders, without the file command, all opened 680 PNG files, none opened 40 and they split on 86. |
| Chunks in order | 758 PNG files have a good signature, good CRCs, an IEND chunk and no extra bytes. All six readers opened 679 of them, and none was refused by all six. |
| Refusals | Among those 758 PNG files, ffmpeg refused 62 and ImageMagick refused 20. Pillow, OpenCV and Chromium refused 12 PNG files. |
| Defective files | The other 48 PNG files have a defect in the chunks. All six readers refused 9, one was opened by all six and the file command opened 39. |
| Sizes | From 41 to 6,965,828 bytes. The median is 589, and the 806 PNG files total 19,924,758 bytes. |
All six readers opened 680 of the 806 PNG files. Nine files were opened by none. The other 117 split the readers, and 79 of those 117 have their chunks in order.
The 117 PNG files that split the readers
79 of the 117 splits are PNG files that pass our chunk check. The other 38 have a defect in the chunks, and 9 more defective files were refused by all six readers. So a good chunk list does not make the readers agree.
The file command named 797 PNG files PNG images, because it reads only the header. That is why it opened 39 of the 48 defective files, while Chromium opened 14, ffmpeg 8, Pillow 5, ImageMagick 4 and OpenCV 4. A pass from the file command is the weakest sign in this study.
Why ffmpeg refused 62 PNG files
ffmpeg refused 62 of the 758 good files. 46 of them are palette files with an sBIT chunk, and ffmpeg refused every palette file that has one. It opened all 14 PNG files that have another color type and an sBIT chunk. The chunk stores the number of significant bits.
We tested the link on the 43 refused files with a bit depth under 8. We removed only the sBIT chunk, and ffmpeg opened all 43. The other 16 refusals have other causes that we did not trace. We tested ffmpeg 6.1.1 only, and other versions may differ.
Why ImageMagick refused the badpal folder
The libpng project ships a folder named badpal with 9 palette files. ImageMagick refused all 9 and printed that a colormap index is invalid. Pillow, ffmpeg, OpenCV, Chromium and the file command opened all 9, and our script passed all 9.
ImageMagick refused 11 more files, including invalid_palette_index.png, badadler.png and missing_plte.png. Pillow, OpenCV and Chromium refused 12 PNG files. The same 8 PNG files are on all three lists, so the refusals are not random.
Read the study with care. It shows what six readers do with 806 public test files. Many are odd on purpose, and 410 come from one project. A reader that agrees on our files can still fail on your PNG file.
What Do Readers Do With a Damaged PNG File? 52 broken copies, five decoders and 40 split decisions
We damaged one 6,074 byte PNG file in 52 ways. All five decoders refused 8 damaged copies, and only 3 copies came back with the same pixels in all five. They split on 40, and 32 copies gave different pixels in at least one decoder. Chromium opened 39 copies, ffmpeg 20, Pillow 13, OpenCV 6 and ImageMagick 5.
The 52 damaged PNG files are copies of base.png and come in six groups. Group A changes the signature, B cuts the file short and C changes header fields. D damages the pixel data, E adds or changes chunks and F changes bytes. Every damaged PNG file changes one thing.
We asked two questions about every damaged PNG file. Did the five decoders open it? And did they draw the same pixels as the intact file? The second question is the strict one, and we compared a hash of the drawn pixels.
The 8 copies that every decoder refused
Copies A1 to A4 flip one byte of the signature, at byte 0, 1, 4 or 7. All five decoders refused all four, and the file command did not name any of them a PNG file. C7 sets a bit depth of 3 and C9 a color type of 5, and the specification allows neither.
E7 removes the IHDR chunk, and F1 changes every 0d 0a in the file to 0a, as a text mode transfer can. All five decoders refused both. The specification says the signature allows early detection of some transmission errors, and F1 shows what that means.
The 3 copies that every decoder drew the same
E1 adds 100 junk bytes after IEND and E2 adds a ZIP header after IEND. E5 adds an unknown ancillary chunk. All five decoders drew the intact pixels from all three. Our script flagged E1 and E2 for the extra bytes, and it passed E5.
The pixels matching does not make extra bytes harmless. The security note warns that data after IEND can contain anything, including malicious code. It adds that there is no known risk of it running when the picture is decoded.
The copies that gave other pixels
Of the 44 copies that at least one decoder opened, 32 gave different pixels in at least one decoder. C5 sets the height to 120. All five decoders opened it, and all five drew a picture 120 rows high, which is not the intact pixels.
C4 sets the height to 480, and Pillow, ffmpeg and Chromium drew other pixels while ImageMagick and OpenCV refused.
Pixel damage was handled in odd ways. D13 sets 200 bytes of the pixel stream to zero. Pillow, ImageMagick, OpenCV and Chromium drew a picture, but none matched the intact pixels. ffmpeg refused it. F2 puts a 4 KB block of zeros in the middle, and only Pillow and Chromium drew a picture.
What Chromium draws from a cut file
B1 to B7 cut the file to 5, 15, 30, 50, 70, 90 and 98 percent of its bytes. Pillow, ImageMagick, ffmpeg and OpenCV refused all seven. Chromium opened all seven and drew the rows it could decode, which were 9, 36, 39, 96, 141, 187 and 226 of 240 rows.
So a viewer that shows a partial picture is not showing an intact file. The rows that Chromium did not decode stayed transparent in our test. A file that is 98 percent complete still lost its last 14 rows, and nothing in the picture says so.
Checksums and header rules
Checksums were handled one reader at a time. D11 breaks the Adler-32 checksum of the pixel stream, and only Chromium drew the intact pixels. E8 sets every CRC to zero, and only ffmpeg drew the intact pixels. E3 breaks the IEND CRC, and only ImageMagick refused it.
The decoder rules say a decoder reports an error for an unrecognized header value. Pillow drew the intact pixels from C10, which sets compression method 1, and ffmpeg did the same for C11, which sets filter method 1. The other four decoders refused both copies.
What our script passes
Our script flagged 51 of the 52 damaged PNG files and passed only E5. It flagged copies that at least three decoders drew intact, like E1, E2 and B8. A flag from the script means a check failed. It does not mean that no reader can draw the picture.
Read the grid with care. Every copy changes one thing in one PNG file made by Pillow. Damage in the wild changes many things at once. Same pixels means a hash of the drawn pixels matched the intact file. We opened no copy in Windows Explorer, Paint or Photos.
What Does Our Expert Say About PNG Files? A note from Neeraj Singh on trusting one reader
Check PNG files with two readers before you trust one answer. Six readers opened 680 of 806 PNG files together, and five decoders split on 40 of 52 damaged copies. A signature check takes seconds, and a second reader takes a little longer.
Expert insight
“PNG files look safe because they are lossless, so people trust the first viewer that opens them. In our tests six readers split on 117 of 806 PNG files, and only 3 of 52 damaged PNG files came back with the same pixels in all five decoders. Check every PNG file with two readers, read the first 8 bytes and compare the chunk list before you rely on the ending.”
Why one reader proves little
A reader that opens a PNG file shows that it could draw something. It does not show that the picture is intact or that another reader agrees. In our tests the file command opened 39 of the 48 defective files, and Chromium drew 226 of 240 rows from a cut file.
The check has a limit. Two readers that agree can both be wrong, and neither says whether the picture looks right. The script from the check reads the signature, the chunk list and the pixel size, so compare its answer with a second reader and look at the picture.
Copy the PNG file before you touch it. Write down the SHA256 hash of the original and work on a copy. The hash shows which PNG file you received, and it lets you spot a changed download later.
How Do You Open a PNG File? Six readers we tested and two viewers from outside pages
Most image editors, video editors and web browsers open PNG files, and Windows and macOS include viewers. We tested six readers on 806 PNG files instead. We opened no PNG file in a Windows or Mac viewer, so we say nothing about them beyond what FileInfo lists.
The table lists the programs we tested and the ones FileInfo names. The readers with a version number are the ones we tested. We worked on Linux, so we opened no PNG file in Windows Explorer, Paint or Photos.
| Program | What it does |
|---|---|
| Windows and Mac viewers | FileInfo names Microsoft Photos and Microsoft Paint on Windows and Apple Preview on macOS as programs that come with the system. We tested none of them. |
| Web browsers | FileInfo says most web browsers open PNG files. Chromium 141 opened 760 of our 806 PNG files, and we tested no other browser. |
| The file command | Version 5.45. It names the type from the header and opened 797 of 806 PNG files. For a PNG file it prints the size, bit depth, color type and interlace. |
| Our script | A 64 line Python script that reads the signature, the chunk list and the size of the pixel data. It passed 748 of 806 PNG files and draws no picture. |
| Pillow | A Python library, version 12.3.0. It opened 751 PNG files, and the load call decodes the pixels. |
| ImageMagick | Version 6.9.12. It opened 742 PNG files, and the identify program prints the size and format. |
| ffmpeg | Version 6.1.1. It opened 704 PNG files, fewer than any other reader, and the ffprobe program lists the codec and size. |
| OpenCV | Version 5.0.0. It opened 750 PNG files, and its imread call returns the pixels or nothing. |
Open PNG files on the command line
Three commands print the size of a PNG file. For base.png, the file command prints the type, size, bit depth, color type and interlace. The identify program adds the file size, and ffprobe prints the codec name and the pixel format.
file -b base.png
PNG image data, 320 x 240, 8-bit/color RGB, non-interlaced
identify base.png
base.png PNG 320x240 320x240+0+0 8-bit sRGB 6074B 0.000u 0:00.000
ffprobe -v error -show_entries stream=codec_name,width,height,pix_fmt -of csv=p=0 base.png
png,320,240,rgb24
All three agree on 320 by 240 pixels. The identify program prints 6074B, which is the size of the file. The ffprobe output ends with rgb24, which means 3 bytes for every pixel and no alpha channel.
Open PNG files with Python
The Python package Pillow reads the same facts. Four lines print the format, size and color mode of a PNG file. The load call decodes the pixels, so a file with damaged pixel data fails here and not at the open.
from PIL import Image
im = Image.open('base.png')
im.load()
print(im.format, im.size, im.mode)
PNG (320, 240) RGB
Pillow refused 55 of the 806 PNG files and 39 of the 52 damaged copies, so read its answer with care. The damage grid lists the copies where its pixels differed from the intact file.
Viewers and converters for PNG files
These two links open outside pages for PNG files. One comes from SysTools and one from Freeviewer. We describe them from their own pages and tested neither.
The SysTools Image Converter page lists PNG among the formats it supports and among its saving options, so it reads and writes PNG. Its demo processes the first 5 files and adds a watermark. It works on Windows and Mac.
Freeviewer's page describes an image viewer for Windows that lists PNG among its formats. It adds images in bulk, moves them up and down and prints them. We list no prices, because they change.
Install a viewer from its maker. Download a viewer from the maker's own page, and write down the file hash if the page gives one. PNG files do not need special software, and our six readers worked without any.
How Do You Check a PNG File? Six steps, and only the last two draw the picture
Check PNG files in six steps. Read the first 8 bytes, then the chunk list, then the size of the pixel data with our 64 line script. Only a decoder draws the picture. The script flagged 58 of our 806 PNG files, and it passed 69 that split the readers.
The first reads need no Python. The xxd command prints bytes, and the file command names the type of a PNG file. For base.png they show the signature, the header and the first chunk.
xxd -l 48 base.png
00000000: 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 .PNG........IHDR
00000010: 00 00 01 40 00 00 00 f0 08 02 00 00 00 fe 4f 2a ...@..........O*
00000020: 3c 00 00 07 d0 49 44 41 54 78 da ed 5d 6b 54 14 <....IDATx..]kT.
file -b base.png
PNG image data, 320 x 240, 8-bit/color RGB, non-interlaced
Read the first line from the left. Bytes 0 to 7, 89 50 4e 47 0d 0a 1a 0a, are the signature. Bytes 8 to 15 are the length and name of IHDR. The file command prints the width, height, bit depth, color type and interlace as words.
Step 4 starts at byte 8 of the PNG file. Every chunk has a length, a name, data and a CRC. The script walks that list and checks every CRC.
Check PNG files with Python
The script reads the signature and then every chunk. It prints the size, the header values and the chunk list, then one line that says OK or lists the problems. It inflates the pixel data to compare its size with the header, and it never changes a PNG file.
import sys, struct, zlib
SIG = b'\x89PNG\r\n\x1a\n'
DEPTHS = {0: (1, 2, 4, 8, 16), 2: (8, 16), 3: (1, 2, 4, 8), 4: (8, 16), 6: (8, 16)}
CHANNELS = {0: 1, 2: 3, 3: 1, 4: 2, 6: 4}
KIND = {0: 'gray', 2: 'RGB', 3: 'palette', 4: 'gray+alpha', 6: 'RGBA'}
ADAM7 = [(0, 0, 8, 8), (4, 0, 8, 8), (0, 4, 4, 8), (2, 0, 4, 4), (0, 2, 2, 4), (1, 0, 2, 2), (0, 1, 1, 2)]
def expected(w, h, bd, ct, il):
bits = bd * CHANNELS[ct]
rows = lambda ww, hh: hh * (1 + (ww * bits + 7) // 8) if ww and hh else 0
if not il:
return rows(w, h)
return sum(rows((w - x + dx - 1) // dx, (h - y + dy - 1) // dy) for x, y, dx, dy in ADAM7)
def peek(path):
b, bad, seen, idat, i, hdr = open(path, 'rb').read(), [], [], b'', 8, None
print(f'{path}: {len(b)} bytes')
if b[:8] != SIG:
return print(' refused: the first 8 bytes are not 89 50 4e 47 0d 0a 1a 0a')
while i < len(b):
if i + 12 > len(b):
bad.append(f'cut inside a chunk header at byte {i}'); break
n, t = struct.unpack('>I4s', b[i:i + 8]); name = t.decode('latin1')
if i + 12 + n > len(b):
bad.append(f'{name} says {n} bytes but only {len(b) - i - 8} remain'); break
data, crc = b[i + 8:i + 8 + n], struct.unpack('>I', b[i + 8 + n:i + 12 + n])[0]
if zlib.crc32(t + data) != crc:
bad.append(f'{name} at {i} has a wrong CRC')
if not seen and name != 'IHDR':
bad.append(f'first chunk is {name}, not IHDR')
if name == 'IHDR' and n == 13:
hdr = struct.unpack('>IIBBBBB', data)
if name == 'IDAT':
idat += data
if t[0] & 32 == 0 and name not in ('IHDR', 'PLTE', 'IDAT', 'IEND'):
bad.append(f'unknown critical chunk {name}')
seen.append(name); i += 12 + n
if name == 'IEND':
break
if 'IEND' not in seen:
bad.append('no IEND chunk')
elif i < len(b):
bad.append(f'{len(b) - i} bytes after IEND')
if hdr:
w, h, bd, ct, cm, fm, il = hdr
print(f' image: {w} x {h}, bit depth {bd}, color type {ct} ({KIND.get(ct, "unknown")}), ' + ('Adam7 interlace' if il == 1 else 'not interlaced'))
if ct not in DEPTHS or bd not in DEPTHS[ct] or cm or fm or il > 1 or not w or not h:
bad.append('IHDR has a value the specification does not allow')
elif ct == 3 and 'PLTE' not in seen:
bad.append('color type 3 needs a PLTE chunk')
else:
try:
raw = zlib.decompressobj().decompress(idat)
if len(raw) != expected(w, h, bd, ct, il):
bad.append(f'IDAT inflates to {len(raw)} bytes, expected {expected(w, h, bd, ct, il)}')
except zlib.error as e:
bad.append('IDAT will not inflate: ' + str(e))
else:
bad.append('no usable IHDR')
print(' chunks: ' + ' '.join(seen))
print(' ' + ('OK: signature, chunk CRCs, header and pixel data size agree' if not bad else 'PROBLEMS: ' + '; '.join(bad)))
for p in sys.argv[1:]:
peek(p)
Here is what it printed for three files. They are base.png, a logo with an alpha channel and a 5 frame animation.
python3 png_peek.py base.png logo.png anim.png
base.png: 6074 bytes
image: 320 x 240, bit depth 8, color type 2 (RGB), not interlaced
chunks: IHDR IDAT IDAT IDAT IEND
OK: signature, chunk CRCs, header and pixel data size agree
logo.png: 2721 bytes
image: 400 x 300, bit depth 8, color type 6 (RGBA), not interlaced
chunks: IHDR IDAT IEND
OK: signature, chunk CRCs, header and pixel data size agree
anim.png: 1885 bytes
image: 160 x 120, bit depth 8, color type 6 (RGBA), not interlaced
chunks: IHDR acTL fcTL IDAT fcTL fdAT fcTL fdAT fcTL fdAT fcTL fdAT IEND
OK: signature, chunk CRCs, header and pixel data size agree
The first line of every answer gives the name and the size in bytes. The next lines give the picture size, bit depth and color type, then the chunks in order. The animation has acTL, fcTL and fdAT chunks, and the script lists them without decoding any frame.
python3 png_peek.py B4.png C2.png E1.png fake.png
B4.png: 3037 bytes
image: 320 x 240, bit depth 8, color type 2 (RGB), not interlaced
chunks: IHDR IDAT
PROBLEMS: IDAT says 2000 bytes but only 984 remain; no IEND chunk; IDAT inflates to 38810 bytes, expected 230640
C2.png: 6074 bytes
image: 640 x 240, bit depth 8, color type 2 (RGB), not interlaced
chunks: IHDR IDAT IDAT IDAT IEND
PROBLEMS: IDAT inflates to 230640 bytes, expected 461040
E1.png: 6174 bytes
image: 320 x 240, bit depth 8, color type 2 (RGB), not interlaced
chunks: IHDR IDAT IDAT IDAT IEND
PROBLEMS: 100 bytes after IEND
fake.png: 10516 bytes
refused: the first 8 bytes are not 89 50 4e 47 0d 0a 1a 0a
B4 is base.png cut in half, so its first IDAT says 2,000 bytes and only 984 remain. C2 has a width of 640 with a correct CRC, so the pixel data is half the size the header expects. E1 has 100 bytes after IEND. The file fake.png is a JPEG picture named .png and fails the first check.
What the script found in our files
| Result | Cases |
|---|---|
| Passed (748 of 806) | The signature, chunk CRCs, header values and pixel data size make sense. All six readers opened 679 of the 748, and the other 69 split the readers. |
| Flagged (58 of 806) | All six readers refused 9 of the 58, all six opened 1 and the other 48 split the readers. The 1 has a single byte after IEND. |
| Flagged, chunks in order (10 of 758) | 5 have a header value that the specification does not allow, 3 inflate to 0 bytes, badadler.png has a bad Adler-32 checksum and missing_plte.png has no palette. |
| Damaged copies (51 of 52) | It flagged every damaged copy except E5, the unknown ancillary chunk. It flagged E1, E2 and B8, which at least three decoders drew intact. |
| Passed, split the readers (69) | It passed 46 palette files with an sBIT chunk that ffmpeg refused, and the 9 PNG files in the badpal folder that ImageMagick refused. |
The script has two limits. It does not read palette values, so the 9 badpal files pass. It does not decode filters or compare pixels, so a file with damaged pixel data and a correct size can pass. The damaged PNG files show how often decoders disagree about pixels.
Check order for any PNG file
- Copy the PNG file, write its SHA256 hash and work on the copy.
-
Read the first 8 bytes of the PNG file. They must be
89 50 4e 47 0d 0a 1a 0a. - Name the type with the file command, and compare the size with identify or ffprobe. A difference points to damage or a reader limit.
- Read the chunk list with our script. A problem names the point where the PNG file stops making sense.
- Draw the picture with two decoders, as in the Python example, and compare the sizes. Only this step reads pixels.
- Look at the picture, and check the bottom rows. A cut file can draw most of the picture and lose the last rows.
Is a PNG File Safe to Open? The format is quiet, and a name proves nothing
A PNG file is data, and IANA says its defined chunks only cause an image to be rendered. That describes the format and not every program, so open files from unknown senders with an updated reader. The name proves nothing, and a PNG file can store text.
We opened no PNG file in a viewer and scanned none for malware. The six readers only read bytes. The files come from public test folders, so their contents are not the worry here.
The IANA entry says the chunk types defined in the specification only cause an image to be rendered, with one exception named gIFx. It adds that the risks of future chunk types cannot be evaluated. That describes the format. A program that reads it is a separate question, and we tested only six readers.
The rename test
We saved base.png under 7 other names, ending in .jpg, .gif, .bmp, .webp, .txt, .zip or nothing at all. The file command, Pillow, ImageMagick, ffmpeg, OpenCV and Chromium opened all 7. Every one of them reads the first bytes and not the ending.
The reverse also works. We gave 11 other files the ending .png. Seven are pictures in other formats, and four are not pictures.
The seven are JPEG, GIF, BMP, WebP, TIFF, ICO and SVG files. The four are an HTML page, a text note, an empty file and a ZIP archive. The file command named the true type of all 11, and our script refused all 11.
The decoders opened some of the seven pictures as pictures. Pillow opened 6 of the 11 PNG files, ImageMagick 5, ffmpeg 7, OpenCV 5 and Chromium 5. None of them opened the HTML page, the text, the empty file or the ZIP. If your file manager hides endings, read the first bytes of anything you doubt.
Text and metadata in a PNG file
A PNG file can store text in tEXt, zTXt and iTXt chunks, and camera data in an eXIf chunk. 161 of our 806 PNG files have one of these.
The keyword Copyright appears in 113 PNG files and Licensing in 105. Comment appears in 12 PNG files, Author in 12 and Software in 10. The keywords date:create and date:modify appear in 13 PNG files.
The 5 PNG files with an eXIf chunk showed no GPS tags in exiftool. We read no other metadata, so check your own file before you publish it. The IANA entry adds that text chunks can contain control characters, and the specification recommends filtering them before direct display.
The Pillow test folder has a file that shows why. The png_decompression_dos.png file is 6,289 bytes with a 1 by 1 picture and three zTXt chunks. Pillow refused it with the message Decompressed data too large for PngImagePlugin.MAX_TEXT_CHUNK, and the other four decoders opened it.
Bytes after the end
The security section says there could be data after the IEND chunk, and it could contain anything, including malicious code. It adds that there is no known risk of that code running when the picture is decoded. A malicious application could hide it inside an innocent looking picture and then execute it.
2 of our 806 PNG files have a single byte after IEND, and our script flags both. Our damaged copies E1 and E2 add 100 junk bytes and a ZIP header, and all five decoders drew the intact pixels. So the picture looks fine and the extra bytes stay unseen.
Not sure? Check it first. Copy the hash, read the file with the chunk list script and compare a second reader. If the PNG file came in an email you did not expect, delete the message and ask the sender through another route.
Why Will Your PNG File Not Open? Eight causes, and what to do about every one
Most PNG files that will not open fail for one of eight reasons. Read the first 8 bytes first, then the chunk list, then draw the picture. All five decoders refused 8 of 52 damaged PNG files and split on 40. 32 copies drew different pixels in at least one decoder.
We read 806 PNG files and 52 damaged PNG files with six readers. The table groups what we saw into eight causes. The number in brackets matches the cause.
Every row says what happens to the PNG file and what to try. The fixes work on a copy, and none changes the original. A reader that says nothing is no sign that the picture is intact.
| Cause | Result and fix |
|---|---|
| A damaged signature (1) |
All five decoders refused the four copies with one flipped signature byte, and the file command did not name them PNG files. The copy with every 0d 0a changed to 0a was refused as well. Fix: Copy the PNG file again from the source and compare the SHA256 hash. We tested no repair.
|
| A cut copy (2) | Pillow, ImageMagick, ffmpeg and OpenCV refused all seven copies cut to between 5 and 98 percent of their bytes. Chromium drew between 9 and 226 of 240 rows. Fix: Compare the size and the hash with the source, then copy the PNG file again. Do not trust a picture that stops early. |
| A file that is not a PNG (3) |
A JPEG, GIF, BMP, WebP, TIFF, ICO or SVG file named .png has no PNG signature. Our script refused all 11 other files, and the five decoders opened 5 to 7 of them as pictures. Fix: Read the first 8 bytes. If they are not 89 50 4e 47 0d 0a 1a 0a, name the type with the file command and open the file as that type.
|
| A header the specification does not allow (4) | 6 of our 806 PNG files have a forbidden header value, like a bit depth of 3 or a color type of 5. All five decoders refused our copies with those two values. Fix: Read the header with our script, which names the field. A new copy is the only cure. |
| Damaged pixel data (5) | Chunks can look fine while the pixel stream is not. badadler.png has a bad Adler-32 checksum, and four decoders refused it while Chromium opened it. Zeroing 200 bytes of pixel data (D13) drew other pixels in four decoders. Fix: Draw the picture with two decoders and compare the sizes, then ask for a new file. |
| A palette problem (6) | ImageMagick refused all 9 PNG files in the libpng badpal folder. ffmpeg refused all 46 palette files with an sBIT chunk. missing_plte.png has color type 3 and no palette, and ImageMagick and OpenCV refused it. Fix: Try Pillow or Chromium. In our test, ffmpeg opened 43 of 43 copies that had no sBIT chunk. |
| A strict reader (7) | ffmpeg refused 62 good files and ImageMagick refused 20. Pillow, OpenCV and Chromium refused 12. An unknown critical chunk (E4) was refused by ImageMagick and OpenCV and drawn by the other three. Fix: Try a second reader before you decide. |
| An animation in a still picture reader (8) | 55 of our 806 PNG files have an acTL chunk. ImageMagick listed 1 frame in our 5 frame file, and OpenCV imread returned 1. Fix: Use Pillow, ffprobe or Chromium to list the frames, or use OpenCV imreadmulti. |
Check PNG files that will not open, step by step
We tested the reading steps on Python 3.13 and Linux. We opened no PNG file in a Windows or Mac viewer, and the steps keep the original untouched at every point.
- Copy the PNG file, write its SHA256 hash and work on the copy.
-
Read the first 8 bytes of the PNG file with the six step order. If they are not
89 50 4e 47 0d 0a 1a 0a, name the type with the file command. - Read the chunk list with the chunk script. A problem names the point where the PNG file stops making sense.
- Compare with identify or ffprobe, as in the command line listing. A matching size means the header makes sense.
- Draw the picture with Pillow, as in the Python drawing, and compare the sizes with the header.
- If the PNG file is smaller than the source says, copy it again and compare the hash.
- If one reader refuses the PNG file, try another before you decide, as the split files show.
What to send a helper
Short messages about a PNG file get faster answers. Include the details below, and add the script output. Its first lines give the size, the header values and the chunk list.
Subject: PNG file will not open
File: name, size in bytes and SHA256 hash
Header: the output of png_peek.py
Reader: name, version and the exact words of the error
Platform: Windows, Mac or Linux and the program you used
Source: where the file came from and when it was copied
What no step can fix
Do not try online repair sites. A site that offers to fix or convert any PNG file for free can keep the upload. A PNG file can have text chunks, as the privacy check shows. Try the steps above on a copy first.
How Do You Convert a PNG File to JPG or WebP? Three pictures, six methods and what changed
Lossless WebP and a smaller PNG file gave back identical pixels in all three of our pictures, and JPG at quality 85 changed pixels in all three. For our logo, PNG took 2,721 bytes against 12,277 for JPG. For our photo, JPG took 77,670 bytes against 602,078 for PNG.
We converted three PNG pictures. The photo is a 512 by 768 test picture from the Kodak set. The screenshot is a 1280 by 720 page that we rendered in Chromium. The logo is 400 by 300 with 4 colors, and 49.4 percent of its pixels are fully transparent and 18.5 percent partly transparent.
| Method | Photo | Screenshot | Logo |
|---|---|---|---|
| Original PNG | 602,078 | 65,222 | 2,721 |
| Smaller PNG (optipng) | 602,066 | 58,336 | 1,033 |
| Lossless WebP | 447,076 | 13,888 | 876 |
| Lossy WebP, quality 80 | 44,072 | 32,512 | 4,630 |
| JPG, quality 85 | 77,670 | 101,281 | 12,277 |
| PNG with 256 colors | 263,103 | 33,707 | 2,593 |
| GIF | 308,314 | 40,588 | 2,048 |
| BMP | 1,179,702 | 2,764,854 | 360,054 |
No method wins every row. JPG is far smaller for the photo and larger than PNG for the screenshot. Lossless WebP is smaller than PNG for all three. The BMP files are uncompressed and range from about 2 times the PNG size for the photo to 132 times for the logo.
Make a smaller PNG file
The optipng program rewrote the three PNG files with the same pixels. It saved 12 bytes on the photo, 6,886 bytes or 10.6 percent on the screenshot and 1,688 bytes or 62.0 percent on the logo. A higher setting, -o5, gave the same size as -o2 on all three.
So a photo gains nothing and a flat picture gains a lot. Lossless WebP gave identical pixels too, and it saved more on the screenshot and the logo. We did not test whether your software opens WebP files.
JPG is smaller for photos, with changes and no transparency
JPG at quality 85 changed 98.8 percent of the photo pixels by up to 77 levels out of 255. It changed 17.7 percent of the screenshot pixels by up to 106 levels, and the file grew to 101,281 bytes, which is 55 percent more than the PNG file.
The logo had to be flattened first. We put it over a white background, so the transparent pixels became white. After that, JPG changed 31.6 percent of the logo pixels by up to 103 levels. A JPG file cannot bring the transparency back.
256 colors and GIF
Reducing the photo to 256 colors with Pillow gave a PNG file of 263,103 bytes and changed 89.0 percent of the pixels, by up to 90 levels. The screenshot changed 0.4 percent by up to 17 levels. The logo has 4 colors, so nothing changed. We did not compare the GIF pixels.
FileInfo says GIF supports only fully opaque or fully transparent pixels, while PNG may include an 8 bit transparency channel. Our GIF logo took 2,048 bytes against 2,721 for the PNG file. We did not test how the edges look.
The commands we used
python3 -c "from PIL import Image; Image.open('photo.png').save('photo_q85.jpg', quality=85)"
python3 -c "from PIL import Image; Image.open('photo.png').save('photo.webp', lossless=True)"
optipng -o2 -quiet -out photo_o2.png photo.png
python3 -c "from PIL import Image; Image.open('photo.png').quantize(colors=256).save('photo_p8.png')"
ls -l photo* | awk '{print $5, $9}'
602078 photo.png
447076 photo.webp
602066 photo_o2.png
263103 photo_p8.png
77670 photo_q85.jpg
The first two commands save a JPG and a lossless WebP file with Pillow. The third rewrites the PNG file with optipng, and the fourth reduces it to 256 colors. The last command lists the sizes, and they match the first column of the table.
Keep the original picture. Convert from the largest PNG file and keep it. JPG at quality 85 changed pixels in all three of our pictures, and you cannot get them back.
How Does a PNG File Differ From JPG, GIF and BMP Files? The first bytes name the type
The first bytes name the type. PNG files start with 89 50 4e 47, JPG files with ff d8 ff, BMP files with BM and WebP files with RIFF. An animated PNG file has the same signature and an extra acTL chunk. The ending names none of them.
Eight things get mixed up with PNG files because they all show a picture. The table lists what separates them. Every row ends with its source.
| Type | What separates it |
|---|---|
| PNG file |
Starts with 89 50 4e 47 0d 0a 1a 0a. Lossless, with one picture and an optional alpha channel. Source: IANA and our tests.
|
| APNG file | Starts with the PNG signature and has an acTL chunk before the pixel data. Pillow, ffprobe and Chromium found 5 frames in our file, and ImageMagick found 1. Source: The W3C specification and our tests. |
| JPG file |
Starts with ff d8 ff. At quality 85 it changed pixels in all three of our pictures, and we had to flatten the logo onto white first. Source: Our tests.
|
| GIF file | Starts with the letters GIF87a or GIF89a. FileInfo says it supports only fully opaque or fully transparent pixels. Source: FileInfo and our tests. |
| BMP file |
Starts with the letters BM (42 4d). Our BMP copies were 1,179,702, 2,764,854 and 360,054 bytes. Source: Our tests.
|
| WebP file | Starts with the letters RIFF, 4 size bytes and the letters WEBP. Lossless WebP gave identical pixels in all three of our pictures. Source: Our tests. |
| ICO file |
Starts with 00 00 01 00. A container for one or more small images, and some of them are PNG files. Source: Our ICO tests.
|
| SVG file |
A text file that starts with the letters of its first tag, like <svg. It is drawn from instructions and not from pixels. Source: Our tests.
|
Separate them with our script
Our script reads the first 8 bytes of a file and refuses any file that does not start with the PNG signature. For fake.png, a JPEG picture named .png, it says the first 8 bytes are not 89 50 4e 47 0d 0a 1a 0a. It never guesses.
Why the ending misleads
We saved one PNG file under 7 other names, and all six readers opened all 7. We gave 11 other files the name .png, and the file command named the true type of all 11. An ending is a label, and the first bytes say what a file is.
Which one do you have
ff d8 ff.
42 4d.
00 00 01 00.
What Is the PNG File Format Made Of? The facts we could check, and where they came from
The PNG Development Group created the PNG format, and W3C, IANA and Wikipedia document it. The facts below come from those sources, from FileInfo and from our checks of 806 PNG files and 52 damaged PNG files.
| Part | What we could check |
|---|---|
| Maker | The PNG Development Group, per FileInfo and Wikipedia. Wikipedia says the group donated the format to W3C. |
| Name | Portable Network Graphics. IANA registers image/png with the ending .png. |
| First bytes |
89 50 4e 47 0d 0a 1a 0a, as IANA and Wikipedia list. 800 of our 806 PNG files start with them.
|
| Structure | A signature, then chunks. The first chunk is IHDR and the last is IEND, per the W3C specification. |
| Chunk fields | A 4 byte length, a 4 byte name made of letters, the data and a 4 byte CRC. |
| Header | IHDR is 13 bytes. It stores the width and height as 4 byte numbers, then the bit depth, color type, compression method, filter method and interlace method as single bytes. |
| Color | Five color types, 0, 2, 3, 4 and 6, with 15 allowed pairs of color type and bit depth. All 15 appear in our files. |
| Compression | Deflate, as compression method 0, after filtering with filter method 0. The specification defines no other method. |
| Interlace | 0 for none or 1 for Adam7, which defines seven passes. 64 of our 791 valid files use Adam7. |
| Animation | The chunks acTL, fcTL and fdAT, defined in the third edition. 55 of our 806 PNG files have acTL. |
| Standard | The third edition became a W3C Recommendation on 24 June 2025. Wikipedia also lists ISO/IEC 15948 and RFC 2083. |
| Our tests | 806 PNG files, 52 damaged PNG files, 18 renamed files, 3 pictures converted six ways and one 5 frame animation. Six readers and a 64 line script all worked on Linux. |
About the values we list
Facts about the layout come from the W3C specification, Wikipedia and IANA, and every row names its source. The first bytes and the header sizes were also checked against our files. FileInfo is a directory, so we use it for the name, the developer and the programs only.
Where sources disagree, we say so. FileInfo dates PNG to 1995, and Wikipedia dates the specification to 1996. FileInfo calls PNG a single image format, and the third edition of the specification defines animation chunks.
What we left out
We opened no PNG file in Windows Explorer, Paint, Photos or Preview, and we tested no browser except Chromium. We tested no repair and no deletion, and we scanned no PNG file for malware. We tested no viewer from an outside page.
Our 806 PNG files come from 4 public test folders, and 410 come from Pillow. Our damaged copies change one thing at a time in one PNG file. We did not compare the pixels of GIF files or lossy WebP files. A reader that fails on our files can still work on your PNG file.
Sources checked
For the layout, see the W3C specification, third edition. For the type, see the IANA entry for image/png.
For the history, see the Wikipedia article on PNG. For the programs and the date, see the FileInfo page on PNG files. Every count came from the files and scripts in our research folder.
Frequently Asked Questions About PNG Files
What is a PNG file?
A PNG file is a picture file in the Portable Network Graphics format. It stores pixels without losing detail. It starts with 8 bytes, 89 50 4e 47 0d 0a 1a 0a, and then a series of chunks. Our 806 test files range from 41 bytes to 6,965,828.
How do I open a PNG file?
FileInfo says most image editors, video editors and web browsers open PNG files, and Windows and macOS include viewers. We tested six other readers on 806 PNG files instead. The file command opened 797, Chromium 760 and Pillow 751. We opened no file in a Windows or Mac viewer.
What does PNG stand for?
PNG stands for Portable Network Graphics. Wikipedia says the name began as PING, a recursive joke for PING is not GIF. IANA registers the type image/png for the ending .png.
Is a PNG file safe to open?
IANA says the chunk types defined in the specification only cause an image to be rendered. That describes the format and not every program. A name proves nothing, because a PNG file read the same under all 7 other names. 161 of our 806 PNG files have text or Exif chunks, so check yours before you publish it.
What is inside a PNG file?
A signature and then chunks. Every chunk has a length, a four letter name, data and a CRC. Our example, base.png, is 6,074 bytes long with an IHDR chunk, three IDAT chunks and an IEND chunk. The IDAT chunks inflate to 230,640 bytes of pixels.
Can I delete a PNG file?
We did not test deletion, and the sources we read give no deletion steps. Check which program or web page uses the file first, because documents and sites can point to it. Copy the PNG file and write its hash before you delete anything.
How do I convert a PNG file to JPG or make it smaller?
Pillow saves a JPG with one call, but JPG at quality 85 changed pixels in all three of our pictures and has no transparency. To keep every pixel, optipng rewrote our logo from 2,721 to 1,033 bytes, and lossless WebP made it 876. A photo gained only 12 bytes from optipng.
Why will my PNG file not open?
Eight causes cover what we found. The first four are a damaged signature, a cut copy, a file that is not a PNG and a forbidden header value. The last four are damaged pixel data, a palette problem, a strict reader and an animation in a still picture reader. Read the first 8 bytes first.
What is the difference between PNG and JPG?
A PNG file starts with 89 50 4e 47 and stores pixels without losing detail. A JPG file starts with ff d8 ff. At quality 85, JPG took 77,670 bytes for our photo against 602,078 for PNG, but it changed 98.8 percent of the pixels. For our screenshot, JPG was larger than PNG.
How can I check if a PNG file is damaged?
Read the first 8 bytes, then the chunk list, then draw the picture with two decoders. Our script flagged 51 of 52 damaged copies, and five decoders split on 40 of them. Only 3 copies came back with the same pixels in all five.
Can I rename a JPG to PNG?
No. A JPEG picture with the ending .png is still a JPEG. The file command named it and our script refused it. Pillow, ImageMagick, ffmpeg, OpenCV and Chromium opened it as a picture. To get a PNG file, save the picture again in a program that writes PNG.
Does a PNG file keep transparency?
Yes. A PNG file can have an alpha channel (color type 6 or 4) or a tRNS chunk for palette, gray and RGB files. 114 of our 791 valid files are RGBA, 23 are gray with alpha and 71 have a tRNS chunk. FileInfo says GIF supports only fully opaque or fully transparent pixels.
Still Stuck With a PNG File? Seven routes out, depending on what went wrong
Read the first bytes and the chunk list of the PNG file. The cause table lists what to try in order.
The size comparison covers a smaller PNG file, lossless WebP, JPG and 256 colors.
Is it a JPG picture? The page on JPG files covers pictures that start with ff d8 ff.
Is it a GIF? The page on GIF files covers pictures that start with GIF87a or GIF89a.
Is it an icon? The page on ICO files covers icons, some of which store PNG images.
Is it a file type you do not know? Browse the file extension resource library, or send it on the submit a file type page.
Do you need the format facts? Read the format part for the header, chunks and sources of PNG files.