地図をつくる

<br>変換 http://www.geocities.jp/curonikeru/brhenkan.html

全体表示

[ リスト ]

python,PIL,base64,PHP

 
# coding: shift_jis
#import sqlite3
#import pickle
import base64
import StringIO
import Image, ImageDraw
im=Image.open("chojamachi5c.jpg")
#size:278*361 pixel
draw=ImageDraw.Draw(im)
poslistxy = [(50,50),(100,200),(200,200),(200,100)]
draw.polygon(poslistxy,outline='rgb(128,128,128)',fill='rgb(192,192,192)')
f = StringIO.StringIO()
im.save(f, "JPEG")
data = f.getvalue()
base64data = base64.b64encode(data)
f2 = open('datafile', 'w') #データベースのつもり
f2.write(base64data)
f2.close()
 
-------
 
<?php
header("Content-type: image/jpeg");
$file = 'c:\python26\datafile';
$imgtext = file_get_contents($file); //データベースから
$imgbin = base64_decode($imgtext);
$image = imagecreatefromstring($imgbin);
imagejpeg($image);
imagedestroy($image);
?>
 
----
chojamachi5c,33KB
datafile,43KB
33 * 1.3 = 43 ← 完璧!

閉じる コメント(1)

顔アイコン

f = StringIO.StringIO()
im.save(f, "JPEG")
data = f.getvalue()

できた!

2010/8/19(木) 午後 9:31 [ curonikeru ]


よしもとブログランキング

もっと見る

[PR]お得情報

ふるさと納税サイト『さとふる』
11/30まで5周年記念キャンペーン中!
Amazonギフト券1000円分当たる!
いまならもらえる!ウィスパーうすさら
薄いしモレを防ぐ尿ケアパッド
話題の新製品を10,000名様にプレゼント
いまならもらえる!ウィスパーWガード
薄いしモレを防ぐパンティライナー
話題の新製品を10,000名様にプレゼント

その他のキャンペーン


プライバシー -  利用規約 -  メディアステートメント -  ガイドライン -  順守事項 -  ご意見・ご要望 -  ヘルプ・お問い合わせ

Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved.

みんなの更新記事