Generating thumbnails from a collection of pictures is an easy task and there are many tools for the job. But I didn’t find a tool who can clip out a centered box of my pictures to get quadratic thumbs of my originals. Because I am a developer and I dont want to try out many tools: I will hack a short python script (with help of the PIL) myself. simple solution The following python script can be f
Here’s a simple django view which creates a PIL image on the fly, and returns it as a PNG image: from django.utils.httpwrappers import HttpResponse from PIL import Image import random INK = "red", "blue", "green", "yellow" def image(request): # ... create/load image here ... image = Image.new("RGB", (800, 600), random.choice(INK)) # serialize to HTTP response response = HttpResponse(mimetype="imag
Django thumbnails, resize image with PIL and python There is a wide variety of django filters and tags to crop, resize or make a thumbnail out of an image but most of them seem to reinvent the wheel. How to resize, crop or create a thumbnail with python and PILYou need to install the Python Image Library and this snake image to run this example. #!/usr/bin/env python try: from PIL import Image, Im
« Return to page index Python Imaging Library Handbookの一部であるチュートリアルの超訳です。 Imageクラスを使う PILにおいて最も重要なImageクラス PILにおいて最も重要なクラスはImageクラスです。これは同じ名前のモジュールの中で定義されています。あなたは例えばファイルから画像を読み込んだり、他の画像を処理したり、スクラッチから画像を生成したりすることによってこのクラスのインスタンスを生成することができます。 ファイルを画像から読み込むためには、Imageモジュールのopen関数を使います。 >>> import Image >>> im = Image.open("lena.ppm") openに成功すると、open関数はImageオブジェクトを返します。そうすればあなたはファイルの中身を調べるためにアトリビュートを使
Python Image Library - Examples import Image global ext ext = ".jpg" imageFile = "test.jpg" im1 = Image.open(imageFile) Original image Resize def imgResize(im): div = 2 width = im.size[0] / div height = im.size[1] / div im2 = im.resize((width, height), Image.NEAREST) # use nearest neighbour im3 = im.resize((width, height), Image.BILINEAR) # linear interpolation in a 2x2 environment im4 = im.resize
Last week, I was trying to find out how to get my photo’s metadata. I had noticed that Windows could display the camera model, creation date and lots of other data on my photos, but I couldn’t remember what that data was called. I finally found what I was looking for. The term is EXIF (Exchangeable Image File Format). For this post, we’ll take a look at the various 3rd party packages that give you
Python Imaging Libraryの関数を使いながらのメモです。 テスト用のモジュールTestPIL.pyを作成し、同じディレクトリに全て同じサイズの適当なRGB画像"test.bmp","test2.bmp","mask.bmp"を用意して実行してみました。以下使えそうな関数をひたすらピックアップ&リストアップ。関数の書き方は、変数名:型、関数名(引数名:引数型):返却値型という表記を使うことにします。 モジュールのインポート from PIL import Image Imageクラスのメンバ変数 format:string 画像ファイルのフォーマット mode:string 階調。"1":2値画像,"L":グレースケール,"RGB","CMYK"など size:turple (width, height) 画像サイズ pallete:palette 画像モードが"P"のとき
画像が編集できるらしいので実験。 snow.jpgを縮小。 640*480なので縦200くらいにしてみる。 >>> import Image >>> snow = Image.open(r"C:\pyphot\snow.jpg") >>> snow.thumbnail((200,200),Image.ANTIALIAS) >>> snow.save(r"C:\pyphot\snow_resize.jpg") できた。 フォルダに入ってる.jpgを全部一度に同じサイズにリサイズ出来ないかな? ん~ 考えてみよう。
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く