Skip to main content
Python / Computer Vision / OCR•2023 — 2024Open Source

Comic Translator

Python CLI tool for speech bubble extraction, dominant-color text cleaning, and automated dialogue typesetting.

Interactive Preview
Comic Translator Pipeline
Stage 1 of 4
[Panel Artwork]
이것은… 시작이다!
Chapter Images SortedPython CLI Pipeline

Vertical Concatenation

Extracts chapter zip files and stitches image strips vertically using OpenCV vconcat for continuous processing.

main.py executionPaddleOCR + Tesseract
$ python3 main.py
[✓] Extracting Comic Chapter
[✓] Sorting Chapter Images (natsort)
[✓] Running PaddleOCR & Morphological Dilation
[✓] Translated and typeset to files/output/
Context

Overview

A Python CLI tool built to automate comic and manga translation workflows. It stitches multi-page chapters, extracts text boundaries with PaddleOCR, expands mask regions with OpenCV morphological dilation, clears original lettering using dominant perimeter color sampling, and typesets translated lines using Pillow font metrics.

Key Features

  • Vertical chapter concatenation for multi-page images using OpenCV
  • Speech bubble boundary detection using PaddleOCR and morphological dilation
  • Dominant-color text removal to cleanly erase text on non-white bubble backgrounds
  • Dynamic font sizing and typesetting using Pillow font metrics
  • Command-line workflow for batch chapter translation
Impact

Outcomes

Processing Speed~20 pages / 3 min
TypesettingFully automated
Batch ModeFull chapters per run
Process

How It Works

1

Page Stitching

Combines individual image cuts into a continuous strip using cv2.vconcat.

2

Bubble Detection & OCR

Finds text boundaries with PaddleOCR and dilates coordinates with cv2.dilate to encapsulate speech bubble areas.

3

Dominant-Color Inpainting

Samples background color around text boxes to clear original lettering without leaving white patches.

4

Translation & Typesetting

Translates dialogue and renders wrapped text cleanly into the cleared bubble areas using Pillow.

Screenshots & Interface

Visual Captures

[Screenshot Placeholder]
Alt: "Comic Translator terminal output and processed panels"
Suggested capture: Terminal command execution log shown next to before-and-after comic panel translations.
Decisions

Technical Choices & Trade-offs

Morphological dilation for boundary margins

Decision: Apply morphological dilation (cv2.dilate) on OCR boundary boxes instead of raw bounding rectangles.
Why: Raw OCR bounding boxes often clipped character tails and punctuation edges. Dilation slightly expanded the mask margin, ensuring 100% of the old text was erased.

Dominant color sampling over white fill

Decision: Sample outer perimeter pixel colors rather than filling bubbles with pure white (#FFFFFF).
Why: Many comics use off-white, yellowish, or styled colored speech bubbles. Filling with plain white caused ugly rectangular patches.
Stack

Technologies Used

Languages & Core
Python 3
AI & Vision
PaddleOCRPyTesseractOpenCV (cv2)
Frontend & UI
Pillow (PIL)
Tools & DevOps
Bash / CLI