Skip to main content

tools for tiled image that can be cached on a filesystem.

Project description

TiledImage

大きな画像を効率的に扱うための Python ライブラリです。メモリ使用量を抑えながら、大きな画像をタイル(小さな断片)に分割して管理します。

特徴

  • 大きな画像をタイルに分割して管理
  • ファイルシステム上でのキャッシュ機能
  • メモリ効率の良い画像処理
  • コンテキストマネージャ(with文)による簡単な使用

インストール

pip install tiledimage

基本的な使い方

画像の分割(PNG → PNGs)

from tiledimage import CachedImage
import cv2

# 画像を読み込み
img = cv2.imread("large_image.png")

# タイル化して保存
with CachedImage(
    mode="new",
    dir="output.pngs",
    tilesize=(64, 64),
    cachesize=10,
    bgcolor=(255, 255, 255),  # 背景色(白)
    fileext="jpg"
) as tiled:
    tiled.put_image((0, 0), img)  # 画像を配置

画像の結合(PNGs → PNG)

from tiledimage import CachedImage
import cv2

# タイル化された画像を読み込み
with CachedImage(mode="inherit", dir="input.pngs") as tiled:
    # 全体の画像を取得
    full_image = tiled.get_image()
    # 保存
    cv2.imwrite("combined_image.png", full_image)

コマンドラインツール

画像の分割:

pngs2 input.png output.pngs

画像の結合:

2pngs input.pngs output.png

API リファレンス

CachedImage

メインのクラス。タイル化された画像を管理します。

CachedImage(
    mode,           # "new" または "inherit"
    dir="image.pngs",  # タイルの保存ディレクトリ
    tilesize=128,   # タイルのサイズ(整数またはタプル)
    cachesize=10,   # キャッシュサイズ
    fileext="png",  # タイルのファイル形式
    bgcolor=(0,0,0), # 背景色
    hook=None,      # タイル書き換え時のフック関数
    disposal=False  # 終了時にディレクトリを削除するか
)

主要メソッド

  • put_image(pos, img, linear_alpha=None): 画像を配置
  • get_image(): 全体の画像を取得
  • write_info(): 情報を保存(通常は自動的に呼ばれる)

TiledImage

基本的なタイル画像クラス。キャッシュ機能はありません。

TiledImage(
    tilesize=128,   # タイルのサイズ
    bgcolor=(100,100,100)  # 背景色
)

開発者向け情報

テスト

make test

ビルド

make build

デプロイ

make deploy

ライセンス

MIT License

作者

Masakazu Matsumoto (vitroid@gmail.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiledimage-0.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiledimage-0.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file tiledimage-0.3.tar.gz.

File metadata

  • Download URL: tiledimage-0.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.4 Darwin/24.3.0

File hashes

Hashes for tiledimage-0.3.tar.gz
Algorithm Hash digest
SHA256 de32905e4aa51352f02a341c1b275c9d42a65f23a5204a185e8af7d2176254f4
MD5 2b28455dbea0a184108cbd5ee1864faf
BLAKE2b-256 871893af4133d60187612a713e20e965a98bceedea893374fee795a617ba06f2

See more details on using hashes here.

File details

Details for the file tiledimage-0.3-py3-none-any.whl.

File metadata

  • Download URL: tiledimage-0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.4 Darwin/24.3.0

File hashes

Hashes for tiledimage-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1e68346892b84662153691555129c4ec79990cf83943751662118dbec22e1769
MD5 85996fffb335f8d437e6524fc7909493
BLAKE2b-256 8da4d3574e3fa49fdd1cad1e886945063b9f3abd521e7a3519e3b7723029c1e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page