Skip to content

Instantly share code, notes, and snippets.

@yowasou
Created September 8, 2024 08:10
Show Gist options
  • Save yowasou/fef20c3feb9c5059dab8c2cb484c24b3 to your computer and use it in GitHub Desktop.
Save yowasou/fef20c3feb9c5059dab8c2cb484c24b3 to your computer and use it in GitHub Desktop.
#
# PNGファイルのメタデータを全部読み込んでメモ帳に表示
#
require 'chunky_png'
require 'securerandom'
tempdir = 'C:\SD\pnglog'
if (ARGV.count < 1)
puts "please set parameter for file"
exit
end
file = ARGV[0]
png = ChunkyPNG::Image.from_file(file)
metastr = ""
metadata = png.metadata
metadata.each do |key, value|
metastr = metastr + "#{key}: #{value}" + "\r\n"
end
txtfilename = SecureRandom.hex(10) # 10バイト(20文字)のランダムな16進数文字列を生成
extension = ".txt" # ファイルの拡張子を指定
txtfilename = txtfilename + extension
File.open(tempdir + "\\" + txtfilename,"w") do |txt|
txt.puts(metastr)
end
system("start notepad.exe #{tempdir + "\\" + txtfilename}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment