フォトショップなどのレタッチソフトを使えば、簡単に分身の写真を作ることができるという記事がありました。
分身の術!自分のクローンを増殖させてみた写真22枚
http://labaq.com/archives/51723286.html
面白そうだし、簡単に出来そうなので、子どもたちの写真で作ってみました。三脚を使ってデジカメを固定して、車のまわりでポーズをさせた子どもの写真を何枚か撮影しました。撮影した複数の写真をレタッチソフトで合成するだけで、簡単に面白い写真が作れました。
$ python setup.py installインストールを確認します。
$ python Python 2.4.3 (#1, May 5 2011, 16:39:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> import photologue >>> photologue.VERSION (2, 2)setting.pyに設定を追加していきます。
INSTALLED_APPS = (
# ...other installed applications,
'photologue',
)
django-photologue は、PIL(Python Imaging Library)を利用するので、インストールします。PIL(Python Imaging Library)のインストールの前に、libjpeg-develをインストールしておきます。
$ sudo yum install libjpeg-develPIL(Python Imaging Library)の1.1.7をソースからインストールします。
$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz $ cd Imaging-1.1.7 $ python setup.py build $ sudo python setup.py installPIL(Python Imaging Library)インストールを確認します。
$ python selftest.py -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from /usr/lib64/python2.4/site-packages/PIL -------------------------------------------------------------------- *** PIL CORE support not installed *** TKINTER support not installed --- JPEG support ok --- ZLIB (PNG/ZIP) support ok *** FREETYPE2 support not installed *** LITTLECMS support not installed -------------------------------------------------------------------- Running selftest: --- 57 tests passed.syncdbを行います。
$ python manage.py syncdb /usr/lib/python2.4/site-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.' DeprecationWarning Creating tables ... Creating table photologue_gallery_photos Creating table photologue_gallery Creating table photologue_galleryupload Creating table photologue_photo Creating table photologue_photoeffect Creating table photologue_watermark Creating table photologue_photosize Installing custom SQL ... Installing indexes ... No fixtures found.Photologueを初期化します。サムネール画像等のサイズ指定、エフェクトの初期指定を行います。ここで行った設定は、後でも変更可能です。
$ python manage.py pliniturls.pyにphotologueを追加します。
# urls.py:
urlpatterns += patterns('',
(r'^admin/(.*)', admin.site.root),
(r'^photologue/', include('photologue.urls')),
)
ソースに含まれているphotologue用のtemplatesを配置します。
myproject/
myapp/
...
templates/
photologue/
...
Djangoを起動して、管理画面にアクセスします。
AWS の新規お客様のクラウド使用開始のお役に立てるよう、AWS は無料使用範囲を提供しています。AWS の新規のお客様は、Amazon EC2 マイクロインスタンスを1年間無料でご利用いただけると共に、Amazon S3、Amazon Elastic Block Store、Amazon Elastic Load Balancing、および AWS データ転送の無料使用範囲もご活用いただけます。AWS 無料使用範囲は、新しいアプリケーションの起動、既存アプリケーションのクラウドでのテスト、または単なる AWS 実地経験など、クラウドで実行するどのようなものにもご利用いただけます。Amazon EC2であれば、Linux マイクロインスタンス使用(613 MB メモリと、32ビットと 64ビットプラットフォームサポート)750時間 毎月継続的に実行するのに十分な時間が無料で使用できます。
$ sudo vi /etc/yum.repos.d/10gen.repo [10gen] name=10gen Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 gpgcheck=0 $ sudo yum install mongo-10gen* --enablerepo=10gen
Installed: mongo-10gen.x86_64 0:2.0.0-mongodb_1 mongo-10gen-server.x86_64 0:2.0.0-mongodb_1関連するファイル、ディレクトリは下記のように設定されます。
設定ファイル:/etc/mongod.conf ログファイル:/var/log/mongo/mongod.log データディレクトリ:/var/lib/mongo/起動は起動スクリプトでOK
$ sudo /etc/init.d/mongod start
Starting mongod: all output going to: /var/log/mongo/mongod.log
forked process: 31800
[ OK ]
PyMongoのインストール
$ sudo easy_install pip $ sudo pip install pymongoPyMongoを使って、MongoDBを操作してみます
$ python
Python 2.4.3 (#1, May 5 2011, 16:39:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo
コネクションを作成して
>>>con = Connection('localhost', 27017)
コネクションからvivoデータベースを取得
>>>db = con.vivo
vivoデータベースからbarコレクションを取得
>>>col = db.bar
事前に、データベースのスキーマ作ることも、データベースを作成することもなしに、データベースに接続出来ました。
>>>col.insert({'ariki' : 2011})
ObjectId('4e91a2648eacfc7c8c000001')
>>> col.insert({'fujii' : 2010,'suwa' : 2009})
ObjectId('4e91a2d98eacfc7c8c000002')
>>> print col.find_one()
{u'_id': ObjectId('4e91a2648eacfc7c8c000001'), u'ariki': 2011}
>>> for data in col.find():
... print data
...
{u'_id': ObjectId('4e91a2648eacfc7c8c000001'), u'ariki': 2011}
{u'fujii': 2010, u'_id': ObjectId('4e91a2d98eacfc7c8c000002'), u'suwa': 2009}
>>>
データの更新をします。
>>>data = col.find_one({'ariki' : 2011})
>>>data['ariki'] = 2008
>>>col.save(data)
>>>for data in col.find():
... print data
...
{u'_id': ObjectId('4e91a2648eacfc7c8c000001'), u'ariki': 2008}
{u'fujii': 2010, u'_id': ObjectId('4e91a2d98eacfc7c8c000002'), u'suwa': 2009}
>>>
データを削除します。
>>>col.remove({'ariki' : 2008})
>>> for data in col.find():
... print data
...
{u'fujii': 2010, u'_id': ObjectId('4e91a2d98eacfc7c8c000002'), u'suwa': 2009}
>>>
データディレクトリの /var/lib/mongo/ に、下記のファイルが出来ていることを確認しました。
vivo.ns vivo.0 vivo.1
SyntaxError at / invalid syntax (maps.py, line 129) Request Method: GET Request URL: http://hogehost:8000/ Django Version: 1.3 Exception Type: SyntaxError Exception Value: invalid syntax (maps.py, line 129) Exception Location: /path/to/django/gmapitest/myapp/views.py in ?, line 3調べてみると、現在のPython 2.4.3では動かないようです。
$ python2.6.7 Python 2.6.7 (r267:88850, Oct 8 2011, 17:43:16) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> django.VERSION (1, 3, 0, 'final', 0)django-gmapi-1.0.1 をPython 2.6.7でインストールした後
# -*- coding: utf-8 -*-
from django import forms
from django.shortcuts import render_to_response
from gmapi import maps
from gmapi.forms.widgets import GoogleMap
class MapForm(forms.Form):
map = forms.Field(widget=GoogleMap(attrs={'width':900, 'height':600}))
def index(request):
gmap = maps.Map(opts = {
'center': maps.LatLng(34.687428,133.916473),
'mapTypeId': maps.MapTypeId.ROADMAP,
'zoom': 13,
'mapTypeControlOptions': {
'style': maps.MapTypeControlStyle.DROPDOWN_MENU
},
})
marker = maps.Marker(opts = {
'map': gmap,
'position': maps.LatLng(34.687428,133.916473),
})
maps.event.addListener(marker, 'mouseover', 'myobj.markerOver')
maps.event.addListener(marker, 'mouseout', 'myobj.markerOut')
info = maps.InfoWindow({
'content': 'Hello! 岡山の地図',
'disableAutoPan': True
})
info.open(gmap, marker)
context = {'form': MapForm(initial={'map': gmap})}
return render_to_response('index.html', context)
MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media') MEDIA_URL = '/m/'/path/to/django/mysite/urls.py
from django.conf.urls.defaults import *
from mysite import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),
url(r'^admin/', include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^m/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
/path/to/django/mysite/templates/polls/index.html