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.2.tar.gz
(5.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiledimage-0.2.2.tar.gz.
File metadata
- Download URL: tiledimage-0.2.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d83e4b7ed88e5bad69c6c7677b7c24b8d4cf5878a7afc362c66c2e720a32074
|
|
| MD5 |
355031e6bd71b166e0a07a841c5c3bee
|
|
| BLAKE2b-256 |
e718d5412a1778cf576e4d61217786d4d66185efdac7fb2c8763ba1c45c67151
|
File details
Details for the file tiledimage-0.2.2-py3-none-any.whl.
File metadata
- Download URL: tiledimage-0.2.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fd767c8b69de67c7aa5772845ea0a48576a85ab4e716a29ec497988a164f0b3
|
|
| MD5 |
28729ceb1088dd8fb784c2a1a75d2f27
|
|
| BLAKE2b-256 |
30fa1bb600a5ba282c3e6d7f3c95ae57cb6e55f46032f4b45355b1c706b7480a
|