スライド画像/PDF から PowerPoint を自動生成するパイプライン (Windows 専用)
Project description
img2ppt
スライド画像(JPG/PNG)または PDF を PowerPoint(.pptx)に自動変換するツールです。
テキスト・図形・背景を自動認識し、16:9 スライドとして再構成します。
動作環境: Windows 11 専用 / Python 3.12 以上
インストール
pip install .
これだけで全依存ライブラリ(OpenCV / Pillow / python-pptx / pypdfium2 / janome 等)が一括インストールされます。
インストール確認
img2ppt --help
使い方
基本
:: 画像ファイルを変換
img2ppt スライド.jpg -d 出力フォルダ
:: クリップボードの画像を変換(引数なし)
img2ppt -d 出力フォルダ
:: PDF を変換(全ページ → 1 ファイルの PPTX)
img2ppt 資料.pdf -d 出力フォルダ
入力モード
| モード | 方法 | 説明 |
|---|---|---|
| ファイル指定 | img2ppt <ファイルパス> |
JPG / PNG / PDF を直接指定 |
| クリップボード | img2ppt(引数なし) |
画像をコピーしてからそのまま実行 |
拡張子 .pdf のファイルを指定 |
全ページを 1 つの PPTX にまとめる |
出力ファイル
-d で指定したディレクトリに以下が出力されます。
| ファイル | 説明 |
|---|---|
{stem}.pptx |
最終 PowerPoint |
{stem}.json |
認識結果の構造化 JSON |
{stem}_04_inpainted.png |
テキスト除去後の画像 |
{stem}_05_1_segment_filled.png |
セグメント検出結果(シルエット) |
{stem}_05_2_mask_segment.png |
セグメントマスク画像 |
{stem}_06_1_content_inpainted.png |
コンテンツ除去後の画像 |
{stem}_06_2_mask_colorize.png |
カラー分割マスク |
{stem}_06_3_colorized.png |
カラー分割結果 |
デバッグ用の可視化画像(vis_ プレフィックス)は --debug を付けると追加出力されます。
オプション一覧
基本オプション
| オプション | デフォルト | 説明 |
|---|---|---|
-d, --output-dir |
test/ |
出力ディレクトリ |
-o, --output-json |
自動 | 最終 JSON の出力パス(単一ページ時のみ有効) |
-v, --verbose |
オフ | 詳細ログを表示(省略時はプログレスバーのみ) |
--debug |
オフ | デバッグ用可視化画像(vis_xxx)を出力 |
--keep-tmp |
オフ | 処理後も一時ディレクトリを削除しない |
--tmp-dir |
システム一時領域 | 一時ディレクトリの作成場所を指定 |
--pdf-dpi |
150 |
PDF ページ変換の解像度(DPI) |
出力パス個別指定
| オプション | 説明 |
|---|---|
--output-inpaint |
Step4 テキスト除去画像の出力パス |
--output-seg-filled |
Step5 シルエット画像の出力パス |
--output-mask-seg |
Step5 マスク画像の出力パス |
画像鮮明化(Step1)
低解像度・圧縮ノイズが多い画像の OCR 精度を上げるための前処理です。
PNG または長辺 1280px 以上の JPG は自動スキップされます。
| オプション | デフォルト | 説明 |
|---|---|---|
--denoise-h |
10 |
ノイズ除去強度(大きいほど強く除去、ぼけやすい) |
--bilateral-d |
9 |
エッジ保持フィルタの近傍径 |
--sigma-color |
60.0 |
エッジ保持フィルタの色シグマ |
--sigma-space |
60.0 |
エッジ保持フィルタの空間シグマ |
--unsharp-radius |
2 |
輪郭強調の半径(px) |
--unsharp-percent |
200 |
輪郭強調の強度(%) |
--unsharp-threshold |
2 |
輪郭強調の閾値 |
テキスト除去(Step4)
| オプション | デフォルト | 説明 |
|---|---|---|
--sample-offset |
3 |
背景色サンプリング位置(bbox 端から何 px 外側か) |
--fill-expand |
2 |
テキスト除去の塗り範囲拡張量(px) |
セグメント検出(Step5)
| オプション | デフォルト | 説明 |
|---|---|---|
--sat-max |
40 |
背景とみなす最大彩度(HSV-S、0〜255) |
--val-min |
200 |
背景とみなす最小輝度(HSV-V、0〜255) |
OCR 品質フィルタ(Step2.5)
| オプション | デフォルト | 説明 |
|---|---|---|
--ocr-min-height |
8 |
bbox 最小高さ(px)。これ未満は除外 |
--ocr-threshold |
0.45 |
総合スコア閾値(0.0〜1.0)。これ未満のテキストを除外 |
PowerPoint 生成(Step7)
| オプション | デフォルト | 説明 |
|---|---|---|
--bg-tolerance |
20 |
図形の背景透過許容幅(RGB 各チャンネル ±n) |
実行例
:: 高解像度 PDF を変換
img2ppt 資料.pdf -d C:\output --pdf-dpi 200
:: デバッグ: 全中間ファイルを残して詳細ログを表示
img2ppt スライド.jpg -d C:\output --debug --keep-tmp --verbose
:: クリップボード画像を変換してデスクトップに保存
img2ppt -d %USERPROFILE%\Desktop
:: OCR フィルタを緩めて誤除外を減らす
img2ppt スライド.jpg -d C:\output --ocr-threshold 0.35
うまくいかないときは
| 症状 | 試すこと |
|---|---|
| テキストが認識されない | --ocr-threshold を下げる(例: 0.35) |
| 誤認識テキストが残る | --ocr-threshold を上げる(例: 0.55) |
| 背景色で塗りつぶしがうまくいかない | --sample-offset や --fill-expand を調整する |
| 図形の背景が透過しすぎる / されない | --bg-tolerance を調整する(大きくすると透過が広がる) |
| 低彩度アイコンが検出されない | --sat-max を上げる(例: 50) |
| 処理の途中経過を確認したい | --debug --keep-tmp --verbose を付けて実行する |
パイプライン概要
| ステップ | モジュール | 処理内容 |
|---|---|---|
| Step1 | clarify.py |
画像鮮明化(ノイズ除去・輪郭強調) |
| Step2 | ocr.py |
Windows.Media.Ocr でテキスト検出・認識 |
| Step2.5 | ocr_filter.py |
geometric / unicode / bigram / morph スコアで文字化けを除外 |
| Step3 | split.py |
OCR bbox 後処理・複数テキスト混入 bbox を分割 |
| Step4 | inpaint.py |
テキスト領域を背景色で除去・修復 |
| Step5 | segment.py |
HSV 2値化 + 連結成分ラベリングでオブジェクト検出 |
| Step6 | colorize.py |
container を投影プロファイル法で矩形分割・内包正規化 |
| Step7 | pptx_gen.py |
JSON + 中間画像から PowerPoint スライドを生成 |
依存ライブラリ
| ライブラリ | ライセンス | 用途 |
|---|---|---|
winrt-Windows.Media.Ocr |
MIT | テキスト検出・認識(Windows 標準 OCR) |
opencv-python |
Apache 2.0 | 画像処理 |
Pillow |
HPND(MIT互換) | 画像入出力 |
numpy |
BSD | 配列処理 |
python-pptx |
MIT | PowerPoint ファイル生成 |
pypdfium2 |
Apache 2.0 | PDF → 画像変換 |
janome |
MIT | 形態素解析(OCR 品質フィルタ) |
ライセンス
MIT License
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
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 img2ppt-1.3.5.tar.gz.
File metadata
- Download URL: img2ppt-1.3.5.tar.gz
- Upload date:
- Size: 56.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28f5422404d141da8cf525471c31d2cabd8805e3e0c16fe31f138c2a3a54b99d
|
|
| MD5 |
f38ba461468fbf3627c91181c219807a
|
|
| BLAKE2b-256 |
5b30e65dad1a4edbb3d5c237f7813d9d71dd73033ed017cc251398f4c9b679ab
|
File details
Details for the file img2ppt-1.3.5-py3-none-any.whl.
File metadata
- Download URL: img2ppt-1.3.5-py3-none-any.whl
- Upload date:
- Size: 60.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fdfca9739c172a3d4398f44e33e13b20f9fbf6540f79ae05af25d2e271b152e
|
|
| MD5 |
3b7476ce71dca82bd4a580596a00d7d2
|
|
| BLAKE2b-256 |
e7442abc2158a6c3dacf42e3c79f27cc8378514b9794e72cf64d48dac22f6a06
|