2

I am need in unix tool, that get info of every page in multipage tiff and pdf. Some solution give pdf_info.ps (i reed answer in this topic), but it is only for pdf. Help me please.

Also how i can dont allow print documents large than A4 format? Thanks!

Solution for TIFF:

  • For tiff (also multipage tiff) use tiffinfo lib (part of LibTIFF)
Community
  • 1
  • 1
MikeLP
  • 198
  • 1
  • 1
  • 9

1 Answers1

2

You can use the identify command from the ImageMagick package to get the page sizes. It can consume different files (even with different filetypes) in one go:

identify multipage.*

Sample output:

multipage.pdf[0] PDF 421x595 421x595+0+0 16-bit Bilevel DirectClass 31.6KB 0.000u 0:00.000
multipage.pdf[1] PDF 421x595 421x595+0+0 16-bit Bilevel DirectClass 31.6KB 0.000u 0:00.000
multipage.pdf[2] PDF 421x595 421x595+0+0 16-bit Bilevel DirectClass 31.6KB 0.000u 0:00.000
multipage.pdf[3] PDF 421x595 421x595+0+0 16-bit Bilevel DirectClass 31.6KB 0.000u 0:00.000
multipage.tif[0] TIFF 1728x2156 1728x2156+0+0 1-bit Bilevel DirectClass 3.02KB 0.000u 0:00.000
multipage.tif[1] TIFF 1728x2156 1728x2156+0+0 1-bit Bilevel DirectClass 3.02KB 0.000u 0:00.000
multipage.tif[2] TIFF 1728x2156 1728x2156+0+0 1-bit Bilevel DirectClass 3.02KB 0.000u 0:00.000

There was 1 PDF with 4 pages (each on of size A5 == 421x595 pt), and a 3-page TIFF (echo page of 1728x2156 pixels).

You can even customize the output format of identify to suit your needs:

identify -format "%f: Page-Number: %p --  Width: %W -- Height: %H\n" multipage.*

Output now:

multipage.pdf: Page-Number: 0 --  Width: 421 -- Height: 595
multipage.pdf: Page-Number: 1 --  Width: 421 -- Height: 595
multipage.pdf: Page-Number: 2 --  Width: 421 -- Height: 595
multipage.pdf: Page-Number: 3 --  Width: 421 -- Height: 595
multipage.tif: Page-Number: 0 --  Width: 1728 -- Height: 2156
multipage.tif: Page-Number: 1 --  Width: 1728 -- Height: 2156
multipage.tif: Page-Number: 2 --  Width: 1728 -- Height: 2156

Just note that the default output for the page/image number is 0-based.


Update:

I should have mentioned in the first version of this answer already:

  1. identify can be rather slow when it comes to returning page info of PDFs (it's OK for multipage TIFFs).

  2. For PDF page info you're better off with pdfinfo -f 1 -l 33 file.pdf. This will return various meta data about the PDF, plus for each page number in the range from 1 to 33 the sizes (and if you use a recent version of Poppler's pdfinfo -- not XPDF's! -- then you'll even get the rotation status of the page).

So: use the right tool for the job: for multi-page TIFFs it's identify, for PDFs it's pdfinfo.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • Thanks for the good idea! I will try to use it! But unfortunately my hardware has limited resources (used pbx) and I need to test the amount spent by the CPU using imagemagic. – MikeLP Jul 12 '12 at 09:33
  • @MikeL: As long as you only use `identify` it shouldn't be a big load of CPU. However, to install ImageMagick it may draw in a lot of dependencies so that it can run at all... So probably disk space could be a concern for you. Assume around 100+ MB... – Kurt Pfeifle Jul 12 '12 at 10:59