Skip to content

About

Automated Python pipeline for extracting tile images, names, dimensions, and structured metadata from PDF catalogues.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tile Catalogue Extractor

An automated Python pipeline for extracting tile images and structured tile metadata from a PDF catalogue.

The system is designed to process a tile catalogue with minimal manual intervention and generate:

  • Cleaned tile images
  • Tile titles
  • Tile dimensions
  • Structured metadata in an Excel file

The pipeline follows a reproducible workflow so that the same process can be executed on the catalogue again with a single command.


Features

  • Extracts text and metadata from PDF pages
  • Detects tile dimensions from catalogue text
  • Renders PDF pages at high resolution
  • Splits catalogue spreads into left and right pages
  • Prepares rendered pages for automatic tile detection
  • Extracts individual tile images
  • Matches tile images with corresponding titles
  • Validates image dimensions and aspect ratios
  • Detects potential duplicate images
  • Generates an Excel file containing structured tile metadata
  • Saves intermediate outputs for debugging and validation
  • Supports reproducible execution through a command-line interface

Technology Stack

  • Python 3.12
  • PyMuPDF
  • OpenCV
  • NumPy
  • Pandas
  • openpyxl

Project Structure

tile_catalog_extractor/
│
├── .gitignore
├── README.md
├── requirements.txt
├── run.py
│
├── input/
│   └── catalogue.pdf
│
├── output/
│   ├── rendered_pages/
│   ├── split_pages/
│   ├── images/
│   ├── logs/
│   └── tile_data.xlsx
│
├── src/
│   ├── __init__.py
│   ├── pdf_renderer.py
│   ├── spread_splitter.py
│   ├── metadata_extractor.py
│   ├── tile_detector.py
│   ├── image_processor.py
│   ├── title_matcher.py
│   ├── validator.py
│   └── excel_exporter.py
│
└── venv/

Installation

1. Clone the Repository

git clone <repository-url>
cd tile_catalog_extractor

Alternatively, download the project and navigate to the project directory.


2. Create a Python 3.12 Virtual Environment

On Windows:

py -3.12 -m venv venv

This ensures that the virtual environment uses Python 3.12.


3. Activate the Virtual Environment

Windows Command Prompt

venv\Scripts\activate

Windows PowerShell

.\venv\Scripts\Activate.ps1

After activation, verify the Python version:

python --version

Expected output:

Python 3.12.x

4. Install Dependencies

Upgrade pip:

python -m pip install --upgrade pip

Install the project dependencies:

pip install -r requirements.txt

Input

Place the tile catalogue PDF inside:

input/

The default expected file name is:

input/catalogue.pdf

Running the Pipeline

Run the pipeline using:

python run.py

The default command expects the input file at:

input/catalogue.pdf

and saves results inside:

output/

Custom Input and Output Paths

You can explicitly specify the input and output paths:

python run.py --input input/catalogue.pdf --output output

Configure PDF Rendering Resolution

The PDF rendering scale can also be configured:

python run.py --input input/catalogue.pdf --output output --zoom 3

Higher zoom values produce higher-resolution rendered pages but require more processing time and memory.


Pipeline Workflow

Tile Catalogue PDF
        │
        ▼
Extract PDF Metadata
        │
        ▼
Extract Tile Dimensions
        │
        ▼
Render PDF Pages
at High Resolution
        │
        ▼
Split Catalogue Spreads
        │
        ├───────────────┐
        ▼               ▼
    Left Page       Right Page
        │               │
        └───────┬───────┘
                │
                ▼
        Detect Tile Samples
                │
                ▼
        Extract Tile Images
                │
                ▼
        Match Tile Titles
                │
                ▼
        Process Tile Images
                │
                ▼
        Validate Results
                │
                ├───────────────┐
                ▼               ▼
         Tile Images        Metadata
                │               │
                └───────┬───────┘
                        │
                        ▼
                Generate Excel

Current Processing Stages

Stage 1: PDF Metadata Extraction

The pipeline reads text from every PDF page.

The extracted text is used to identify information such as:

  • Tile dimensions
  • Tile codes
  • Tile names
  • Product categories

Example dimension formats include:

600x1200mm
600 x 1200 mm
600X1200MM
600 × 1200 mm

Stage 2: High-Resolution PDF Rendering

Each PDF page is rendered into a high-resolution image.

Example output:

output/rendered_pages/
├── pdf_page_001.png
├── pdf_page_002.png
├── pdf_page_003.png
└── ...

High-resolution rendering is used to preserve enough visual detail for tile detection and extraction.


Stage 3: Catalogue Spread Splitting

Some PDF pages contain two catalogue pages within a single spread.

The pipeline splits these pages into:

LEFT PAGE
RIGHT PAGE

Example output:

output/split_pages/
├── pdf_001_left.png
├── pdf_001_right.png
├── pdf_002_left.png
├── pdf_002_right.png
└── ...

This simplifies subsequent tile detection and metadata matching.


Stage 4: Tile Detection

The tile detection stage identifies individual tile samples from rendered catalogue pages.

The detection process uses computer vision techniques such as:

  • Grayscale conversion
  • Edge detection
  • Morphological operations
  • Contour detection
  • Bounding rectangle extraction
  • Area filtering
  • Aspect ratio filtering
  • Positional filtering

The system attempts to distinguish tile samples from other catalogue visuals such as:

  • Interior room images
  • Decorative images
  • Logos
  • Icons
  • Text regions

Stage 5: Tile Image Extraction

Each detected tile sample is cropped from the catalogue page.

The extraction process aims to remove unnecessary elements such as:

  • White margins
  • Borders
  • Labels
  • Frames
  • Shadows

The actual tile pattern is preserved during processing.


Stage 6: Tile Title Matching

Tile titles are matched with tile images using their spatial relationship within the catalogue page.

The process uses positional information from:

  • Tile bounding boxes
  • Text bounding boxes
  • Nearby labels

The nearest relevant text label is associated with the corresponding tile image.

This approach is more reliable than relying only on the order of extracted text.


Stage 7: Image Processing

Extracted tile images are processed to produce cleaner outputs.

The processing stage may include:

  • Border removal
  • Margin trimming
  • Background removal where applicable
  • Image normalization
  • Resolution validation
  • Format conversion

Stage 8: Validation

The pipeline includes validation checks to reduce incorrect output.

Dimension Validation

Extracted tile dimensions are checked against expected formats.

Aspect Ratio Validation

The aspect ratio of the extracted image is compared with the tile dimensions.

For example:

600 × 1200 mm

Expected aspect ratio:

600 / 1200 = 0.5

The extracted image is checked against the expected ratio while accounting for image orientation.

Resolution Validation

The image resolution is checked to ensure that the extracted tile image has sufficient pixel dimensions.

Duplicate Detection

Image hashes can be used to identify duplicate extracted images.

Metadata Validation

The pipeline can flag:

  • Missing tile titles
  • Missing dimensions
  • Unmatched tile images
  • Invalid image crops
  • Duplicate filenames

Output

After successful processing, the pipeline generates the following outputs.

Rendered PDF Pages

output/rendered_pages/

Contains high-resolution PNG versions of PDF pages.

Example:

pdf_page_001.png
pdf_page_002.png
pdf_page_003.png

Split Catalogue Pages

output/split_pages/

Contains left and right halves of catalogue spreads.

Example:

pdf_003_left.png
pdf_003_right.png

Extracted Tile Images

output/images/

Contains individual processed tile images.

Example:

GOLD-02.png
GOLD-03.png
GOLD-09.png

Excel Metadata File

The final metadata is exported to:

output/tile_data.xlsx

The Excel file contains the following columns:

Title Length (mm) Width (mm) Image Name
GOLD-02 600 1200 GOLD-02.png
GOLD-03 600 1200 GOLD-03.png
GOLD-09 600 1200 GOLD-09.png

Validation and Debugging

Intermediate outputs are intentionally saved to support debugging.

The following outputs can be inspected during development:

output/rendered_pages/
output/split_pages/
output/images/
output/logs/

This allows visual validation of:

  • PDF rendering quality
  • Catalogue spread splitting
  • Tile detection
  • Tile cropping
  • Title matching
  • Image quality

Reproducibility

The project is designed to be reproducible.

The complete processing pipeline can be executed using:

python run.py --input input/catalogue.pdf --output output

The pipeline is intended to minimize manual intervention and automate the transformation of a catalogue PDF into structured image and metadata outputs.


Limitations

The catalogue may contain different layouts, tile categories, image sizes, and text structures.

Potential challenges include:

  • Multiple tiles on a single page
  • Large lifestyle or interior images
  • Different tile layouts across catalogue sections
  • Decorative or highlight tiles
  • Text labels positioned differently across pages
  • Tiles with light or white borders
  • Low-contrast tile boundaries
  • Duplicate tile samples
  • Complex page designs

The pipeline uses validation and intermediate outputs to identify uncertain cases.


Future Improvements

Possible improvements include:

  • More robust layout detection
  • Adaptive tile detection based on catalogue sections
  • OCR fallback for image-based PDFs
  • Perceptual hashing for near-duplicate images
  • Confidence scores for title matching
  • Automated review reports for low-confidence detections
  • Parallel PDF page processing
  • Structured logging
  • Unit and integration tests
  • Docker-based reproducible execution

Requirements

The project requires:

Python 3.12

Main dependencies include:

PyMuPDF
OpenCV
NumPy
Pandas
openpyxl

Install all dependencies using:

pip install -r requirements.txt

Example Usage

py -3.12 -m venv venv
venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
python run.py --input input/catalogue.pdf --output output --zoom 3

Project Goal

The goal of this project is to provide an automated and reproducible pipeline that transforms an unstructured tile catalogue PDF into structured outputs containing:

  • Individual tile images
  • Tile names
  • Tile dimensions
  • Excel-based metadata

The final system is designed to require minimal manual intervention while providing validation and intermediate outputs for debugging and quality assurance.

About

Automated Python pipeline for extracting tile images, names, dimensions, and structured metadata from PDF catalogues.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages