![](https://secure.gravatar.com/avatar/cdac1bce4ec96619cde73d2f2be4e66d.jpg?s=120&d=mm&r=g)
Hi, in an application of ours, we have the situation that quite a number of graphics files are checked for their size and stuff, and then a decision is made whether to use them in the resulting PDF. If we do the checks using \pdfximage, the resulting file handle (and internal data structures) are kept open until the end of the TeX run, waiting to see whether actually a \pdfrefximage will ever occur. Bad. We actually run out of file handles on some platforms because of that. If we do the checks using \immediate\pdfximage, then the graphics file will be written out to the PDF even though it will never get displayed or used. Since probably only one of five files actually _is_ supposed to be printed, this will blow up the PDF completely unnecessarily. Any idea how to deal with this? How about something like [\immediate]\pdfcloseximage which makes PDFTeX forget all about a previously included file, freeing the resources? Or is there something I don't understand? -- David Kastrup