ukliviu
ukliviu

Reputation: 3134

How to fetch the height and width of PDF/EPS files without using ImageMagick?

Is there any efficient way to grab the width and height information from PDF and EPS files? I'm working with large files (50+ MB), which makes ImageMagick too slow for my needs.

Unfortunately PHP's builtin imagesize() function doesn't seem to work for these specific formats.

Upvotes: 2

Views: 1396

Answers (1)

Mel
Mel

Reputation: 76

Each XObject in PDF has its own /Width and /Height (original value before transformations). Page, CropBox and MediaBox also have Width and Height. So you can parse em. But you have not got predictable outcome, due to following transformations inside PDF BBoxes e.g. clipping, scaling ...

For EPS is the same situation, the post script is more readable (but you should apply all necessery transformations on object before get its size). Only the page has the constant size ;)

... /HWResolution [600 600] /PageSize [842 595] ...

Upvotes: 2

Related Questions