Imposition: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "= Imposition = How to program an [https://en.wikipedia.org/wiki/Imposition imposition] of different images (of different ratios and orientations) into a single sheet of paper...")
 
No edit summary
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Imposition =
__TOC__


How to program an [https://en.wikipedia.org/wiki/Imposition imposition] of different images (of different ratios and orientations) into a single sheet of paper? Creating a [https://www.designersinsights.com/designer-resources/understanding-and-working-with-print/ Print Signature], to be folded into a saddle stitched book of 16 pages from one single sheet of paper.


[[File:impositio1.png|Source: http://www.piratespress.com/art_problems/images/imposition1.png]]  
[[File:Screenshot from 2023-10-03 14-35-08.png|thumb|An example of an imposition of a PDF, in this case to print a PDF in a booklet format. Screenshot from https://pdfcpu.io/generate/booklet.]]


[[File:page-imposition-method-1-638.jpg|Source: https://image.slidesharecdn.com/08imposition3-121128184928-phpapp01/95/16-page-imposition-method-1-638.jpg]]
There are many ways to do imposition!


== same size source images ==
==Imposition tools==


[http://imagemagick.org/ Imagemagick] is a powerfull tool to perform all sorts of manipulations on images, and one that affords many options concerning resizing. Although possible it is not always obvious how to perform slighlty more complex tasks with it.
* Manual way: CTRL+P, write the order of printing in the field "Pages"
* [https://psutil.readthedocs.io/en/latest/ psutil] (Python)
* [https://manpages.debian.org/bookworm/texlive-extra-utils/pdfbook2.1.en.html pdfbook2] (CLI, part of the [https://manpages.debian.org/bookworm/texlive-extra-utils/ texlive-extra-utils] in Debian)
* [https://manpages.debian.org/bookworm/texlive-extra-utils/pdfjam.1.en.html pdfjam] (CLI, part of the [https://manpages.debian.org/bookworm/texlive-extra-utils/ texlive-extra-utils] in Debian)
* [https://manpages.debian.org/bookworm/texlive-extra-utils/pdfxup.1.en.html pdfxup] (CLI, part of the [https://manpages.debian.org/bookworm/texlive-extra-utils/ texlive-extra-utils] in Debian)
* [https://github.com/podofo/podofo podofo] + [http://printlab.leseptantecinq.be/logiciels/podofo_impose/ documentation from 75] (CLI)
* [http://kjo.herbesfolles.org/bookletimposer/ BookletImposer] (GUI)
* [http://jpdftweak.sourceforge.net/ jPDF Tweak] (GUI)
* [https://pdfcpu.io/generate/booklet pdfcpu] (CLI)
* [[Imagemagick]] (CLI; using montage, convert)


How to resizes images which we want in the imposition onto files of the '''same dimensions'''? Taking into consideration the images' '''different ratios and orientations''', which should '''not be cropped or distorted '''.
==Examples, scripts & boilerplates==


One option is to place the images onto frames of the same size.
* Example of an impositioned PDF for booklet printing: [[:File:Wiki-wiki-book.pdf]]
* [https://gitlab.com/yanntrividic/the-moral-of-the-xerox-vf/-/blob/main/make_booklet.sh make_booklet.sh], by Yann Trividic
* [https://gitlab.com/quentinjuhel/Bookletor Bookletor], by Quentin Juhel
* [https://gitlab.coko.foundation/pagedjs/hackathon-mars-2021/-/tree/master/imposition_quentin_juhel?ref_type=heads Paged.js imposition "extension"], by Quentin Juhel and Julien Taquet; see also this [https://maisondeseditions.fr/ideal/tools/aquatre/ live example] made by Julien Bidoret
* [[Imposition howto's during SI5]] (using Imagemagick)
* [https://wiki.scribus.net/canvas/How_to_make_a_booklet How to make a booklet with psutils] (at Scribus wiki)
* [https://wiki.scribus.net/canvas/How_to_make_impositions_with_pstops Scribus wiki: How to make impositions with pstops]
* [http://www.peppertop.com/blog/?p=35 Making booklets from PDF files using psbook and psnup]
* [https://cc.vvvvvvaria.org/wiki/Two-a4-on-one-a3.sh Two A4 on one A3 using pdfjam]


In order to create same size frames Imagemagick provides the <code>-extent</code> operator which adjust the final size of an image , without resizing it. According to IM [http://www.imagemagick.org/Usage/crop/ documentation], &quot;[i]f the image size increases, space will be added to right or bottom edges of the image. If it decreases the image data is just junked or cropped to fit the new image size.&quot;
==See also==


<code>convert -background black -extent 297x421 -gravity Center input.jpg output.jpg</code>
* [[Portable Document Format]]
* [[:Category:PagedMedia]]


If the input image '''is larger''' than 297x421 you should get a cropped image, with its gravity point in the center of the image. Although <code>North</code>, <code>South</code>, <code>East</code>, <code>West</code> are other possible values for <code>-gravity</code>. Input images with dimensions larger than <code>-extent</code> values, space will be added to right or bottom edges of the image.
[[Category:Cookbook]]
 
[[Category:PagedMedia]]
Note: to find an image's dimension of an image IM provides the <code>identify</code> utility which can be invoked simply with: <code>identify image.jpg</code>
[[Category:FLOSS design]]
 
As cropping or junking the image is something we want to avoid, a solution might be to '''also resize the image to the same dimensions given to <code>-extent</code> using the <code>-resize</code> parameter'''
 
<code>convert -background black original.jpeg -gravity Center -resize 297x421 -extent 297x421 extend_297x421.jpeg</code>
 
[[File:01_extent.png|frame|none]]
 
To perform that operation in all images of a directory, we can use a for loop:
 
<pre class="sh">for i in dir/*; do convert -background black $i -gravity Center -resize 297x421 -extent 297x421 extent_$i;done</pre>
== Montage ==
 
After resizing all images, the next step, towards the imposition, is to use those images to create a mosaic using the IM [http://www.imagemagick.org/Usage/montage/ montage] command.
 
It is useful to look at the bash script feautured in this [https://wiki.scribus.net/canvas/Imagemagick_Imposition Scribus page on imposition] to get a few hints on how this is done. Although programming such a task in bash is a daring and messy job :).
 
In its simplest form a 4x2 montage can be invoked with:
 
<code>montage -geometry +1+1 -tile 4x2 01.png 02.png 03.png 04.png 05.png 06.png 07.png 08.png 4x2.jpg</code>
 
* <code>-geometry '+1+1'</code> defines the spacing between tiles: <code>+from_left_to_right+from_top_to_bottom</code>
* <code>-tile 4x2</code>: how the tiled images are to be laid out
 
[[File:4x2.jpg|frame|none]]
 
=== Montage: Order &amp; Rotation ===
 
Notice that the distribution of tiles goes from top left to bottom right. Such order, wont result in a correct page ordering when folded into a booklet.
 
To achieve the correct page ordering for the book let we'll have to provide the order: * single-side: <code>[3, 6, 5, 4, 2, 7, 8, 1]</code> * double-sided: <code>[5, 12, 9, 8, 4, 13, 16], [1, 7, 10, 11, 6, 2, 15, 14, 3]</code>
 
<code>montage -geometry +1+1 -tile 4x2 03.png 06.png 05.png 04.png 02.png 07.png 08.png 01.png  4x2_order.jpg</code>
 
[[File:4x2_order.jpg|frame|none]]
 
As the top part of the imposition sheet will be folded down, its content will be inverted in the booklet. To correct that we can rotate the uppper 4 tiles 180 degrees with <code>-rotate 180</code>.
 
<code>montage -geometry +1+1 -tile 4x2  \( -rotate 180 03.png 06.png 05.png 04.png \) 02.png 07.png 08.png 01.png  4x2_top180.jpg</code>
 
[[File:4x2_top180.jpg|frame|none]]
 
== page size ==
 
If IM's <code>identify</code> is asked provide to give information on A4 and A3 pdfs: <code>identify A4.pdf</code>. I will get the following reply: * A4 210x297mm 8.3x11.7inch 2480x3508px (at 300 dpi) 595x842 (at 72dpi) * A3 297x420mm 11.7x16.5inch 3508x4960px (at 300 dpi) 842x1191px (at 72dpi)
 
Note the size in pixels changes when in relation to the resolution: 300 or 72 pdi.
 
The resulting value is nothing more than: <code>page_height_inches*resoltuion X page_height_inches*resoltuion</code>
 
<code>(8.3inch * 300dpi) X (11.7inch * 300dpi) = 2480x3508px</code>
 
More of paper sizes in inch,mm,px: http://www.papersizes.org/a-paper-sizes.htm
 
=== convert to page size ===
 
After creating the montage with the same ratio as A4 &amp; A3 the next step will be convert it to a PDF with the right dimensions PDF, so it can be sent to the printer.
 
<code>convert 4x2.jpg -gravity Center -resize 3508x2480 -units PixelsPerInch -density 300x300 4x2_a4_300dpi.pdf</code>
 
Produces a PDF with 3508x2480px and 11.6x8.26inch
 
* <code>-units</code> specifies the units of image resolution: Undefined, PixelsPerInch, or PixelsPerCentimete
* <code>-density</code> specifies the resoltion
* <code>-gravity Center</code> resize gravity point
 
= Bibliography =
 
[http://gen.lib.rus.ec/book/index.php?md5=B81926E451AAF52B59AC76AE2233CC1D
Johansson, Kay; Lundberg, Peter. Robert Ryberg, ed. A Guide to Graphic Print Production. Wiley. ]

Latest revision as of 18:04, 1 March 2024


An example of an imposition of a PDF, in this case to print a PDF in a booklet format. Screenshot from https://pdfcpu.io/generate/booklet.

There are many ways to do imposition!

Imposition tools

Examples, scripts & boilerplates

See also