How to determine an image's encoding
Asked Answered
S

4

8

I have an image with a PNG extension.

I suspect it's not really a PNG though (I think it might be a GIF).

How can I confirm an image's encoding?

NB: A solution for Windows would be preferable

Summerwood answered 24/2, 2017 at 12:9 Comment(2)
Can't you just right-click and look at the image "properties" on Windows?Larkin
@GlennRanders-Pehrson... no.Summerwood
P
4

You need to do a quick check of the file's internals.

The first 8 bytes of a PNG image are always

137 80 78 71 13 10 26 10

It is vanishingly unlikely that a non-malicious non-PNG has the same 8 bytes.

Pack answered 24/2, 2017 at 12:15 Comment(0)
F
8

on Linux, you can use file command

$ file branches.gif
branches.gif: PNG image data, 1257 x 782, 8-bit/color RGBA, non-interlaced

or ImageMagick part called identify

identify branches.gif
branches.gif PNG 1257x782 1257x782+0+0 8-bit sRGB 114KB 0.000u 0:00.000
Frowsty answered 24/2, 2017 at 12:12 Comment(2)
Cheers, I didn't mention that I'm on Windows though. That would be a perfect answer otherwise!Summerwood
@Summerwood use a Windows binary release for ImageMagick: imagemagick.org/script/download.phpDecisive
P
4

You need to do a quick check of the file's internals.

The first 8 bytes of a PNG image are always

137 80 78 71 13 10 26 10

It is vanishingly unlikely that a non-malicious non-PNG has the same 8 bytes.

Pack answered 24/2, 2017 at 12:15 Comment(0)
C
3

For windows open the file in a text editor, e.g. Sublime, and the first part should be the png magic number 89 50 4e 47 0d 0a 1a 0a.

Collegian answered 21/11, 2017 at 18:11 Comment(0)
D
0

One can use https://exiftool.org/ (gratis, portable, works on Microsoft Windows, macOS and Linux).

Demo, running the command exiftool.exe test.png in cmd:

Microsoft Windows [Version 10.0.19042.1706]
(c) Microsoft Corporation. All rights reserved.

C:\PortableProgs\exiftool-12.44>"exiftool(-k).exe" test.png
ExifTool Version Number         : 12.44
File Name                       : test.png
Directory                       : .
File Size                       : 1837 kB
Zone Identifier                 : Exists
File Modification Date/Time     : 2022:08:07 17:15:39-07:00
File Access Date/Time           : 2022:08:07 18:55:55-07:00
File Creation Date/Time         : 2022:08:07 18:55:55-07:00
File Permissions                : -rw-rw-rw-
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 2123
Image Height                    : 1134
Bit Depth                       : 8
Color Type                      : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
SRGB Rendering                  : Perceptual
Gamma                           : 2.2
Pixels Per Unit X               : 9448
Pixels Per Unit Y               : 9448
Pixel Units                     : meters
Exif Byte Order                 : Big-endian (Motorola, MM)
Orientation                     : Horizontal (normal)
Date/Time Original              : 2022:08:07 14:24:32
User Comment                    : Screenshot
Color Space                     : sRGB
Exif Image Width                : 2160
Exif Image Height               : 1620
XMP Toolkit                     : XMP Core 6.0.0
Date Created                    : 2022:08:07 14:24:32
Image Size                      : 2123x1134
Megapixels                      : 2.4
-- press ENTER --
Decisive answered 8/8, 2022 at 1:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.