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.2.1.tar.gz (5.7 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.2.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tiledimage-0.2.1.tar.gz
  • Upload date:
  • Size: 5.7 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.2.1.tar.gz
Algorithm Hash digest
SHA256 e098e1c314f975e3a1efb1cb73ba1cdc091bea22ac4a293858684820ee9d7667
MD5 7fc9b9882565d1d41cf7bd9f6896057c
BLAKE2b-256 cc7d737f9e073b3d4273faa392de593646ce6110f04d8e59455e81b79aff1f84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tiledimage-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd60e3235f81cb6c5fa613c5fe2cf00aa8544e8f1f567300629efdbec180c194
MD5 671fa8313327e5bb7eb2bedc75ffa056
BLAKE2b-256 d37c25a5ddf018031b7e17a461949164fbf3b792a2d69475b56271fe9357ec57

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