Is it Possible to Extract Image Dimensions in TeX/LaTeX Without OS-specific commands?

23 views Asked by At

As a follow-up to this question and this and this posts, I am working on a project in TeX/LaTeX and facing a challenge related to image processing. Specifically, I need to develop a macro that can take a relative path to an image file (like a .jpg or .png) and return its width and height in integers. The key requirement is that this solution be cross-platform, functioning independently of the operating system and without additional installations beyond standard LaTeX distributions (e.g., MikTeX, TeX Live).

In my research, I've considered using the \write18{} command, which allows for shell-escape and could potentially be used to invoke OS-specific commands to get image dimensions. However, this approach is not ideal as it is not cross-platform and relies on external shell commands.

I'm looking for a method that works natively within TeX/LaTeX, ideally without needing shell-escape or external dependencies. The solution should be compatible across different platforms and LaTeX distributions. Is there a LaTeX package or method that can achieve this? How can I extract the dimensions of an image file within a TeX/LaTeX document in a platform-independent way?

P.S. I decided to ask the question here instead of tex.stackexchange.com because it is the programming language aspect of Tex, in contrast to its markup language nature.

0

There are 0 answers