merge-book-cover

Merge a cover image into a PDF while preserving aspect ratio.

Updated Dec 25, 2025
One-click install
npx skills add https://github.com/dparedesi/Data-Science-with-Python-book --skill merge-book-cover
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: merge-book-cover
Source: https://github.com/dparedesi/Data-Science-with-Python-book/tree/main/.agent/skills/merge-book-cover
Command: npx skills add https://github.com/dparedesi/Data-Science-with-Python-book --skill merge-book-cover

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires img2pdf, pikepdf, Pillow, and includes scripts (resource) and assets (resource) components.

What problem does it solve?

This Skill merges a cover image into a PDF book, preserving aspect ratio and matching the book's page width. It ensures the cover aligns perfectly with the book's first page and avoids distortions when combining files.

Core Features & Use Cases

  • Attach a branded cover image (PNG/JPG) to an existing PDF while preserving the original aspect ratio.
  • Resize the cover to the book's width so the first page matches the rest of the document.
  • Use case: prepare a multi-book PDF library with consistent cover pages for cataloging.

Quick Start

  1. Ensure assets/cover.png exists.
  2. Ensure docs/Data-Science-with-Python.pdf exists.
  3. Run the script: python3 .agent/skills/merge-book-cover/scripts/merge_cover.py

Frequently Asked Questions about merge-book-cover

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I merge a cover image into a PDF without distorting the aspect ratio?

To merge a cover image into a PDF without distortion, this skill uses Python libraries like Pillow and img2pdf to resize the image to match the book's exact page width while preserving its original aspect ratio, then seamlessly attaches it to the document.

What is the best way to add a branded cover page to an existing PDF?

The best way to add a branded cover page to an existing PDF is using an automated Python script that matches the image width to the document width, ensuring visual consistency across all pages without manual image resizing or format conversion.

Do I need Python libraries like pikepdf and Pillow to attach a cover to a PDF?

Yes, you need Python libraries like pikepdf, Pillow, and img2pdf installed to automate the cover attachment process. These dependencies handle image resizing, conversion, and PDF merging without distorting the original aspect ratio.

Can I use a PNG or JPG image as a cover and match the PDF page width automatically?

Yes, you can use a PNG or JPG image as a cover. The script automatically matches the image width to the target PDF page width using Pillow and img2pdf, preventing any stretching or distortion when merging the files.

Why does my cover image look stretched when I merge it into a PDF?

A cover image looks stretched when merged into a PDF if the aspect ratio is not preserved. This skill solves that by resizing the image to match the exact PDF page width first, then merging the files to avoid any distortion.