目次 | CGIレスキュー | 免責・問合
  画像を文字に変換する

(株)友林堂
(株)友林堂



これは技術資料です

例えば、簡易BBS2 は画像ファイルがないのに最下部にロゴ画像が表示されます。 これは、スクリプト内にその画像のデータを英数字に変換して記録しておき、それを復号して出力させています。 そのデータの作り方のご紹介です。ただ、こんな小さな画像(293バイト) なのに、

"47","49","46","38","39","61","2d","00","1d","00","b3","00","00","00","00","00","40","00","00","ff",
"ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff",
"ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff","ff",
"ff","21","f9","04","01","00","00","00","00","2c","00","00","00","00","2d","00","1d","00","40","04",
"d2","10","c8","49","ab","bd","38","67","21","42","f7","5c","20","82","21","57","76","66","b9","a5",
"6c","9b","4a","ae","56","7d","02","10","82","62","7d","ab","36","49","e7","32","d8","6b","e2","32",
"69","86","18","d4","0d","07","a4","f5","48","50","cf","31","b7","ab","d2","96","46","58","0e","18",
"ec","7a","bf","e0","b0","17","6b","fb","f8","b8","49","74","7a","c7","d4","5d","95","6f","f5","6c",
"84","5b","6e","47","66","0f","9d","5e","5b","51","e3","51","26","50","1c","4f","7b","7d","44","78",
"55","89","4e","82","78","4f","57","73","7b","51","86","8d","7c","76","8e","62","99","9a","9b","9c",
"5a","54","42","96","72","91","87","1b","7c","3d","4e","65","84","2d","44","59","a5","8a","80","4c",
"94","98","7e","58","3b","65","81","8f","27","2b","70","7f","7f","80","56","a2","14","45","c3","c4",
"45","53","92","b1","86","b7","a6","c3","16","66","8d","b5","57","be","7d","3f","24","33","79","be",
"92","aa","94","cb","a8","a3","3a","54","9f","6f","29","4d","77","a4","42","bf","c0","6d","82","d0",
"9f","d7","31","cd","a9","2c","f2","f3","12","11","00","00","3b"

こんなに沢山のデータになります。この仕組みを何に使うかはアイデア次第ですが、 大きな画像では効率も悪いし、直接画像を表示させた方がいいに決まっています。 例えば、これとCGIでパスワード制限2を使って応用 (ヒント:sample.cgiの#※#部分を変えてみる)すれば、 パスワードを知らないと画像が見られないというような形にすることもできるでしょう。


サンプル

変換元画像を、 変換処理するとデータが生成されるので、 それをそのままコピー(データ最後のカンマは取り除いても可)して使います。 それを復号実験すると、 その画像が出ます。


ダウンロード

ファイル名 転送モード パーミッション 備考
pack.cgi アスキー(TEXT) 755 変換処理
unpack.cgi アスキー(TEXT) 755 復号実験


Powered by CGI RESCUE(R)