ImageMagick の identify コマンドを使うと PNG ファイルの情報を出力できる。

コメント情報、画像作成ソフトウェア名、画像タイトルなどのテキストデータが埋め込まれているかどうか確認するのに便利。

identify コマンドに -verbose オプションを指定して、詳細な情報を出力してみる。


$ identify -verbose test.png
Image: test.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 600x450+0+0
  Resolution: 72x72
(中略)
  Properties:
    date:create: 2014-04-29T16:18:04+09:00
    date:modify: 2014-04-29T16:18:04+09:00
    png:cHRM                 : chunk was found (see Chromaticity, above)
    png:gAMA                 : gamma=0.45454544 (See Gamma, above)
    png:IHDR.bit_depth       : 8
    png:IHDR.color_type      : 2 (Truecolor)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height    : 600, 450
    png:sRGB                 : intent=0 (See Rendering intent)
    png:text                 : 2 tEXt/zTXt/iTXt chunks were found
    signature: 6c25810144c7222775c5be03dc1c6336853615a74af6e8cdb249c63939dfdafa
    Software: ViX
    Title: 20140429_windows_modules_installer_worker.png
  Artifacts:
    filename: test.png
    verbose: true
(以下略)

「Software: ViX」と「Title: 20140429_windows_modules_installer_worker.png」の2つのテキストデータが付加されているのがわかる。

テキストデータを削除するには、 ImageMagick の convert -strip コマンドを使う。

入力ファイルが test.png で、不要なデータを削除した出力ファイルが test2.png の実行例。


$ convert -strip test.png test2.png

不要なデータを削除したファイルの中身を identify コマンドで確認。


$ identify -verbose test2.png
Image: test2.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 600x450+0+0
  Resolution: 72x72
(中略)
  Properties:
    date:create: 2014-04-29T16:20:35+09:00
    date:modify: 2014-04-29T16:20:35+09:00
    png:cHRM                 : chunk was found (see Chromaticity, above)
    png:gAMA                 : gamma=0.45454544 (See Gamma, above)
    png:IHDR.bit_depth       : 8
    png:IHDR.color_type      : 2 (Truecolor)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height    : 600, 450
    png:sRGB                 : intent=0 (See Rendering intent)
    signature: 6c25810144c7222775c5be03dc1c6336853615a74af6e8cdb249c63939dfdafa
  Artifacts:
    filename: test2.png
    verbose: true
(以下略)

「Software: ViX」と「Title: 20140429_windows_modules_installer_worker.png」の2つのテキストデータが削除された。

今回の環境は Debian GNU/Linux wheezy の ImageMagick 6.7.7-10


$ uname -mrsv
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3 x86_64
 
$ cat /etc/debian_version
7.5
 
$ identify --version
Version: ImageMagick 6.7.7-10 2014-03-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

tags: png

Posted by NI-Lab. (@nilab)