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:
identify
can be rather slow when it comes to returning page info of PDFs (it's OK for multipage TIFFs).
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
.