Skip to main content

convert zip file including image to pdf file

Project description

izip2pdf (image zip to pdf)

This library convert zip file containing image file to pdf file.

  • fast convert
  • pdf page width is same
  • This library convert on memory, not use tmp folder.

Support image format in zip

  • jpeg, jpeg2000, png, webp, avif, heif, psd, tiff, etc.

Usage

$ izip2pdf sample1.zip
$ izip2pdf sample2.zip sample3.zip

As result, this library make sample1.pdf sample2.pdf sample3.pdf

In the case of Linux environment, you can use

$ izip2pdf sample*.zip

Installation

If you want to install, you can run:

$ pip install izip2pdf

Library

The package can also be used as a library:

Basic Usage

import izip2pdf

# usecase 1: file path to file path
izip2pdf.convert("input.zip", "output.pdf")

# usecase 2: bytes to file
with open("input.zip", "rb") as f:
    zip_bin = f.read()
izip2pdf.convert(zip_bin, "output/output2.pdf")

# usecase 3: file to bytes
pdf_bin = izip2pdf.convert("input.zip")
with open("output.pdf", "wb") as f:
    f.write(pdf_bin)

# usecase 4: bytes to bytes
with open("input.zip", "rb") as f:
    zip_bin = f.read()
pdf_bin = izip2pdf.convert(zip_bin)
with open("output.pdf", "wb") as f:
    f.write(pdf_bin)

Advanced Options

import izip2pdf

# With progress bar
izip2pdf.convert("input.zip", "output.pdf", progress=True)

# Custom JPEG quality and dimensions
izip2pdf.convert(
    "input.zip",
    "output.pdf",
    jpeg_quality=95,
    max_width=4096,
    max_height=4096
)

# Handle transparency with different background colors
izip2pdf.convert("input.zip", "output.pdf", alpha_mode="white")  # white background
izip2pdf.convert("input.zip", "output.pdf", alpha_mode="black")  # black background
izip2pdf.convert("input.zip", "output.pdf", alpha_mode="drop")   # drop alpha channel

# Error handling options
izip2pdf.convert("input.zip", "output.pdf", on_error="warn")   # warn and continue (default)
izip2pdf.convert("input.zip", "output.pdf", on_error="skip")   # silently skip errors
izip2pdf.convert("input.zip", "output.pdf", on_error="raise")  # raise exception on error

Security Options

For processing untrusted ZIP files, you can configure safety limits:

import izip2pdf

# Default: safe limits (recommended for untrusted input)
izip2pdf.convert("untrusted.zip", "output.pdf")  # Uses ~178MP pixel limit

# Custom pixel limit to prevent decompression bombs
izip2pdf.convert(
    "untrusted.zip",
    "output.pdf",
    max_image_pixels=100_000_000  # 100 megapixels max
)

# For trusted input only: disable limits (use with caution!)
izip2pdf.convert(
    "trusted.zip",
    "output.pdf",
    max_image_pixels=0,              # Disable pixel limit (WARNING: DoS risk!)
    load_truncated_images=True       # Allow incomplete images (WARNING: risky!)
)

Security Notes:

  • By default, izip2pdf uses Pillow's safe limits (~178 megapixels) to protect against decompression bomb attacks
  • Setting max_image_pixels=0 disables this protection and may expose you to DoS attacks from malicious ZIP files
  • Only disable safety limits when processing ZIP files from trusted sources

Reference

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

izip2pdf-0.1.9.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

izip2pdf-0.1.9-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file izip2pdf-0.1.9.tar.gz.

File metadata

  • Download URL: izip2pdf-0.1.9.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for izip2pdf-0.1.9.tar.gz
Algorithm Hash digest
SHA256 2eb9c9a8fd0cc6312d10bf62cbce75325726c4874db3ab5f8036d5fb14564511
MD5 8fca7a08f6773f70dda3790e9105b697
BLAKE2b-256 792bbac01dfdc975caa748568055026a01a15db07ae301b41f0b35c8235c4c47

See more details on using hashes here.

Provenance

The following attestation bundles were made for izip2pdf-0.1.9.tar.gz:

Publisher: publish-to-test-pypi.yml on hy20191108/izip2pdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file izip2pdf-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: izip2pdf-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for izip2pdf-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 79aa2441931fc84aa77bf1aca948d4d642ff076175fd9094773632fc6f038eeb
MD5 82da03cfb086d5b6156fac537a449986
BLAKE2b-256 4e620c72c7cfc80b3dac528b553ef154f3a5d3dd1dd384e9239f9949708a7b43

See more details on using hashes here.

Provenance

The following attestation bundles were made for izip2pdf-0.1.9-py3-none-any.whl:

Publisher: publish-to-test-pypi.yml on hy20191108/izip2pdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page