Imposition: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
Clone imposition script from the scan-utils. <code>git clone https://git.xpub.nl/repos/scan-utils.git</code>
__TOC__


= 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? Creating a [https://www.designersinsights.com/designer-resources/understanding-and-working-with-print/ Print Signature]?
[[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:impositio1.png|Source: http://www.piratespress.com/art_problems/images/imposition1.png]]
There are many ways to do imposition!


[[File:page-imposition-method-1-638.jpg|Source: https://image.slidesharecdn.com/08imposition3-121128184928-phpapp01/95/16-page-imposition-method-1-638.jpg]]
==Imposition tools==


See [http://www.binderyparts.com/APFI.html POPULAR FOLD IMPOSITIONS]
* 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)


== same size source images ==
==Examples, scripts & boilerplates==


[http://imagemagick.org/ Imagemagick] is a powerful tool to perform all sorts of manipulations on images, and one that affords many options concerning resizing.
* 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
How to resizes images which we want in the imposition onto files of the '''same dimensions'''?
* [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
Taking into consideration the images':
* [[Imposition howto's during SI5]] (using Imagemagick)
* have '''different ratios and orientations''',
* [https://wiki.scribus.net/canvas/How_to_make_a_booklet How to make a booklet with psutils] (at Scribus wiki)
* should '''not be cropped or distorted '''.
 
 
One option that seems to work is to place the images onto frames of the same size.
 
For creatime same size frames Imagemagick provides the <code>-extent</code> operator, which adjusts the final size of an image , without resizing it.
 
But 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;
 
<code>convert -background black -extent 297x421 -gravity Center input.jpg output.jpg</code>
 
If the input image
* '''is larger''' than 297x421 you'll get a cropped image,
* '''is smaller''' than 297x421  space will be added to right or bottom edges of the image.
 
<code>-gravity</code> defines where the center of the image should be. Possible values:  <code>Center</code> <code>North</code>, <code>South</code>, <code>East</code>, <code>West</code>
 
 
'''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|500px]]
 
To perform that operation in all images of a directory, we can use a for loop:
 
<source lang="bash">for i in dir/*; do convert -background black $i -gravity Center -resize 297x421 -extent 297x421 extent_$i;done</source>
 
 
== 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 featured 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|500px]]
 
=== 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|500px]]
 
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|500px]]
 
== 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*resolution 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
 
=Alternatives:pstop=
'''pstops''' (included in the PsUtils package) seems to allow the creation of imposition pdfs from linear PDFs, however the process is intricate and far from obvious
* [https://wiki.scribus.net/canvas/How_to_make_impositions_with_pstops Scribus wiki: How to make impositions with pstops]
* [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]
* [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]


= Bibliography =
==See also==
 
[http://gen.lib.rus.ec/book/index.php?md5=B81926E451AAF52B59AC76AE2233CC1D Johansson, Kay; Lundberg, Peter. Robert Ryberg, ed. A Guide to Graphic Print Production. Wiley. ]


* [[Portable Document Format]]
* [[:Category:PagedMedia]]


[[Category:XPUB]]
[[Category:Special Issue]]
[[Category:Cookbook]]
[[Category:Cookbook]]
[[Category:PagedMedia]]
[[Category:FLOSS design]]

Latest revision as of 17: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