Python Forum
understanding output of bytes/raw data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
understanding output of bytes/raw data
#1
I can see that the output of this has some interesting info... such as Created With Gimp Big Grin How can I extract useful information out of s[6]? Or is that just the image data itself? What do the 0th-5th elements represent?



import struct
from requests import get


struct_fmt = '=5if255s'
struct_len = struct.calcsize(struct_fmt)
struct_unpack = struct.Struct(struct_fmt).unpack_from
url_img = 'https://www.restwords.com/static/ICON.png'
# print(struct_unpack(get(url_img).content))
s = struct_unpack(get(url_img).content)
print(s)
edit: here's what the output looks like:

(1196314761, 169478669, 218103808, 1380206665, 1912602624, 2.535301200456459e+30, b'\x08\x02\x00\x00\x00\x00\xbf\x12*\x00\x00\x00\tpHYs\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07tIME\x07\xe1\t\x01\x0b\x12 \xeb\xaf\xd8i\x00\x00\x00\x19tEXtComment\x00Created with GIMPW\x81\x0e\x17\x00\x00\x00\x06bKGD\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\x00\x1d\x8cIDATx\xda\xed]\tX\x8di\xfb\x7f\xf7};\xed\xda7[\n\x91\xa5E\xb6\xc1XC\x12\x91"\xb2\x84"\x8d\xa5\x88,1v\t\x83\xa1Bv#\x94\xad\x184*r\xea\x98\xe5\xfb\xbe\x99o\x86\xebb\x98\x19\xe3\xfbf|\x98\xc1\x98\xff\xffy:iB\xa7\xe5tZ\x18\xe7z.\xd7\xd1\xe9<\xbd\xef\xef\xb9\x9f\xfb\xf9\xdd\xeb\x8b\xfc_\x1d\xbc\xee\xdd\xbbW\\\\\x9c}\xf6lNv\xf6W_}\xf5\xc3\x0f?<y\xf2D\xef\xd9\x9e={\x06\xbe\xfe\xf4\xe9S\xf0\xe6\xf9\xf3\xe7\x7f\xfe\xf9')
Reply
#2
maybe this information would help you
Reply
#3
For such a problem, I would look into pypi to find packages related to png or to metadata. For example you have this package ipng. In the source code there are interesting considerations about the contents of the png format and you see that zlib.decompress() is involved in retrieving the metadata.
Reply
#4
both great answers thank you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Common understanding of output processing with conditional statement neail 6 884 Sep-17-2023, 03:58 PM
Last Post: neail
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,664 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  Code should download and output trading data tayy 2 2,650 Mar-04-2021, 04:07 AM
Last Post: tayy
  Four sequential bytes; Need to remove high order bit in each to get correct output GrandSean 5 2,944 Feb-06-2021, 07:17 PM
Last Post: GrandSean
  Help understanding RegEx logic/output pyNewbee 4 2,287 Nov-15-2020, 02:21 AM
Last Post: pyNewbee
  Extracting Rows From Data Frame and Understanding The Code JoeDainton123 0 1,440 Aug-03-2020, 04:08 PM
Last Post: JoeDainton123
  List of mixed data types to bytes medatib531 1 2,341 Mar-16-2020, 11:53 AM
Last Post: scidam
  replace bytes with other byte or bytes BigOldArt 1 10,630 Feb-02-2019, 11:00 PM
Last Post: snippsat
  Retrieve data from Terminal output or from an ASE variable. DreamingInsanity 0 2,215 Jul-08-2018, 05:51 PM
Last Post: DreamingInsanity
  Storing Python data output as a Netcdf file Lightning1800 1 2,639 May-16-2018, 10:14 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020