Programowanie w systemie UNIX/imagemetadata

Z Wikibooks, biblioteki wolnych podręczników.

typy plików graficznych[edytuj]

Pliki graficzne:

  • binarne: png, jpg
  • tekstowe: pgm

Typ pliku sprawdzamy za pomocą komendy file:

 file -i r.png

przykładowy wynik:

r.png: image/png; charset=binary

Aby sprawdzić jakie dane tekstowe zawiera plik binarny, możemy:

  • otworzyć plik binarny w edytorze plików binarnych (np. Bless Hex Editor)
  • przekształcić w plik tekstowy (np. strings z pakietu binutils)
strings -a r.png>r.txt


Binarne plkiki graficzne[edytuj]

Sprawdzamy nagłówek pliku pfm :

 xxd -c 1 memorial.pfm|head -n25 

przykładowy wynik :



00000000: 50  P
00000001: 46  F
00000002: 0a  .
00000003: 35  5
00000004: 31  1
00000005: 32  2
00000006: 20   
00000007: 37  7
00000008: 36  6
00000009: 38  8
0000000a: 0a  .
0000000b: 2d  -
0000000c: 31  1
0000000d: 2e  .
0000000e: 30  0
0000000f: 30  0
00000010: 30  0
00000011: 30  0
00000012: 30  0
00000013: 30  0
00000014: 0a  .
00000015: 00  .
00000016: 80  .
00000017: 20   
00000018: 3c  <

Typy danych tekstowych[edytuj]

  • standardowe
    • exif[1]
    • XMP
    • tEXt chunks (png)[2]
  • niestandardowe:
    • komentarze (ang. Image comments)
    • dane ukryte
    • ICC Profile
    • IPTC[3]

Programy[edytuj]

programy w trybie tekstowym - konsola[edytuj]

Lista: [4]

  • extract[5]
  • Image magic
  • pngmeta
  • pngtools ( sudo apt-get install pngtools )[7]
    • pngchunks
    • pnginfo
  • libpng
  • ps i png[9]
  • exiftool[10]
 pngcheck -v *.png
 extract k.png
 identify k.png
 identify -format "%c" k.ppm
 identify -verbose 1.png |grep "comment"
 head -n 2 k.ppm | tail -n 1
 mediainfo k.png
 exiftool -filename -imagesize -exif:fnumber -xmp:all image.jpg


Konwersja z zachowaniem danych tekstowych:


#!/bin/bash
## mightymandel -- GPU-based Mandelbrot Set explorer
## Copyright (C) 2012,2013,2014,2015 Claude Heiland-Allen
## License GPL3+ http://www.gnu.org/licenses/gpl.html
## http://code.mathr.co.uk/mightymandel/blob_plain/HEAD:/extra/ppm2png.sh
## http://mightymandel.mathr.co.uk/current/usage.html#usagemetadata
## ./extra/ppm2png.sh *.ppm
## 

for X in "$@"
do
  echo -e "Title\t$(head -n 2 "${X}" | tail -c +19)\nSoftware\tmightymandel" > "${X}.txt" &&
  tail -n +3 "${X}" | while read prefix line
  do
    if [[ "${prefix}" == "#" ]]
    then
      if [[ "${line}" == "software mightymandel" ]]
      then
        echo -n "mightymandel"
      else
        echo " ${line}"
      fi
    else
      break
    fi
  done >> "${X}.txt"
  pnmtopng -interlace -force -compression 9 -text "${X}.txt" "${X}" > "${X%ppm}png" &&
  rm "${X}.txt"
done

programy w trybie graficznym[edytuj]

  • online :
    • Forensic Analysis[15]
  • GIMP (image properties dialog)

Źródła[edytuj]

  1. exiv2 man page
  2. text chunk
  3. Tutorial: Metadata Analysis by Hacker Factor
  4. How to get information about an image(picture) from linux commandline?
  5. libextractor - extract
  6. superuser questions: what-software-can-i-use-to-read-png-metadata
  7. pngtools by Michael Still
  8. libpng - pngcheck
  9. PostScript and Portable Net Graphics (PNG), Copyright © 2005, 2006, 2010 Andrew T. Young
  10. exiftool
  11. Insert "text chunks" into PNG files (and read text chunks) by Gregory C Benison
  12. pngcrush
  13. Editing PNG Metadata from the Command Line by Nick Galbreath
  14. Image Magic set
  15. fotoforensics - upload