TCM i Kultura Prosta Spółka Akcyjna

libImageToPDF

A library that converts images to a multi-page PDF document.

The library is designed for generating a multi-page PDF document from JPEG or PNG images. The executable program is not only a demo for showing how to utilize the library, but also a useful tool that runs on a terminal.

The library is released under GNU Lesser General Public License version 3.0, while the executable program is released under Apache License version 2.0.


Version 1.0.0

Download source: libImageToPDF-1.0.0.tar.xz

Download binary for Linux (amd64): libImageToPDF-1.0.0-linux-amd64.tar.xz (Built using GCC 14.2, cmake and make; tested on Debian 13 for amd64)

Download binary for Linux (arm64): libImageToPDF-1.0.0-linux-arm64.tar.xz (Built using GCC 15.2, cmake and make; tested on 64-bit Raspberry Pi OS on Raspberry Pi 5)

Download binary for Windows 11 (amd64): libImageToPDF-1.0.0-win11-amd64.tar.xz (Built using MSYS2 MinGW-w64 GCC 15.2, cmake and ninja; tested on Windows 11 25H2)

Third-Party Libraries

libImageToPDF dynamically uses libjpeg, libpng and zlib. libjpeg is from libturbojpeg.

The libraries libturbojpeg, libpng and zlib are generally installed by default in Linux distributions. If they are not installed, please install them before using libImageToPDF. The compressed package of libImageToPDF binary for Windows contains the libraries.

The libjpeg library is distributed under libjpeg-turbo Licenses (Copyright (C)2009-2025 D. R. Commander. All Rights Reserved. Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.).

The libpng library is distributed under PNG Reference Library License version 2 (Copyright (c) 1995-2025 The PNG Reference Library Authors. Copyright (c) 2018-2025 Cosmin Truta. Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. Copyright (c) 1996-1997 Andreas Dilger. Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.).

The zlib library is distributed under zlib license (Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler).

The binary for Windows is distributed with GCC runtime libraries and MinGW-w64 winpthreads library. GCC runtime libraries are distributed under GCC Runtime Library Exception. MinGW-w64 winpthreads library is distributed under MIT License and BSD 3-Clause Clear License (Copyright (c) 2011 mingw-w64 project. (C) 2010 Lockless Inc. All rights reserved.).


How to Use the Executable Program

imageToPDF -i image1.jpg image2.png image3.jpg image4.jpg image5.png -o images.pdf -p 210x297 -w 80 -q 90 -n 2 --set-margin 5 5 10 10 --set-spacing 2 4

If the path of a file contains a space, the path should be enclosed in double quotation marks.

Options:

-i

Paths of images.

JPEG and PNG images are supported.

Image paths are separated by a space or a comma.

Images appear in a PDF document with the same order.

For example:

-i image1.jpg image2.jpg image3.jpg

-i image1.jpg,image2.jpg,image3.jpg

-o

The output pdf path.

For example:

-o images.pdf

Note:

Without the option, a random name is given to the output file.

-p

The size of paper in millimeters.

For example:

-p 210x297

Note:

Without the option, the default size is an image's size.

-w

The output width of images in millimeters.

The images will be resized based on the ratio of width and height.

For example:

-w 120

Note:

The option can effectively reduce the size of a PDF document.

Without the option, the original size of images is kept.

-q

The output quality of images.

It's an integer between 1 and 100.

100 is the best quality.

For example:

-q 90

Note:

Without the option, JPEG images keep their original quality, while PNG images are compressed using JPEG format with the quality of 95.

When the value is set to 100, images are encoded with PNG format, which may greatly increase the size of a PDF document.

-n

The number of images per page.

For example:

-n 2

Note:

Without the option, there is only one image per page.

If the number is over 1 but the -p option is not set, the size of paper will be set to 210x297 by default.

--set-margin

Margins of paper in millimeters.

The order of margins is top, bottom, left, right.

For example:

(1) Set all margins to the same: --set-margin 5

(2) Only set top and bottom margins: --set-margin 5 5

(3) Set all margins: --set-margin 5 5 10 10

Note:

Without the option, there is no margin on paper.

--set-spacing

Spacings of images in millimeters.

The order of spacings is horizontal, vertical.

For example:

(1) Set all spacings to the same: --set-spacing 2

(2) Set all spacings: --set-spacing 2 4

Note:

Without the option, there is no spacing between images.

TCM i Kultura Prosta Spółka Akcyjna

Article category:

TCM i Kultura Prosta Spółka Akcyjna © All rights reserved.