pdfimages won't export images in hidden elements
TL;DR:
Since pdfimages works by creating a fake output device that ignore all draw calls except for images, and poppler of course doesn't issue draw calls for hidden elements, this means that pdfimages doesn't extract images on such hidden elements.
There should be a way in poppler, probably to ignore or override all "hidden" settings, so that all elements are always displayed. This option can then be used by pdfimages to grab all images.
Long explanation follows:
Note: the PDFs I talk about are non-free/commercial in nature, so I can't provide a sample. One example is here, but again, proprietary: https://paizo.com/products/btpy8src?Pathfinder-Adventure-Path-Skull-Shackles-Interactive-Maps . Hopefully, my description is enough to give a clue on what is going on and could be done about it.
My use-case is the following: I GM several groups of Pathfinder and because of the pandemic, this has mostly shifted online now. Luckily, Paizo offers PDFs for all their Pathfinder products and I can use pdfimages to grab those images and use them in my personal games. Several PDFs I use of theirs are their "Interactive Maps", which are PDFs with several pages of battlemaps used in their adventure modules, with buttons that allow you to show/hide the grid and sometimes show/hide GM-only information (that makes them "interactive", I guess).
Now, evince or any other Linux PDF viewer don't seem to support those buttons. Clicking on them does nothing and only the gridded versions of the maps are show. When I run pdfimages over such a file, I only get the gridded versions of the map.
However, one program that runs on Linux does support the buttons: masterpdfeditor (it's a commercial program, tho, and I only used the demo version). And while it can normally save images, it can't save the images on the elements that holds the maps. But: when I use masterpdfeditor to click on a button that switches a map to the gridless version, save a copy of the PDF (which adds a watermark to the PDF in the demo version, but here it doesn't matter) and then run pdfimages on that copy, I do get the gridless version of the map!
Looking at the PDF in masterpdfeditor, I can see that the way Paizo implemented that feature is a bit of a hack: those elements that hold the map, they're not image elements. Instead, they're form elements, also buttons to be precise, with custom icons, and those icons are the map images. So, if you click on the button to switch display of the map from gridded to gridless, the buttons that you click has Actions on it that first shows the button that contains the gridless version of the map, then hides the button that contains the gridded version of the map, giving the illusion of switching off the grid. (And then the button you click also does the same switcheroo with itself, so the text on the button you click changes to show the changed state.)
This explains why masterpdfeditor can't save the images here: because save image is only implemented for image elements, not form buttons.
It also explains why pdfimages only grabs the current state (which I had to find out afterwards, when I looked up how pdfimages is actually implemented): for a hidden form element, there's of course no draw calls issued.
I sat down and traced pdfimages/poppler to see where the hidden state is decided, and found that the check at the top of Annot::isVisible() is responsible. Literally, this one line change "fixes" my use-case for me: https://github.com/DrMcCoy/poppler/commit/5f8ea1663e5058b2bbdf3553af4d4b1783a9c8cc . With that, pdfimages always grabs all the images in Paizo's Pathfinder Interactive Maps. (It's all from AnnotWidget, though, in case that matters.)
Now, this of course breaks normal PDF rendering, so it's of course not the correct fix. But the easy maybe-proper way, as I can see it, would be added a "overrideHidden" or something bool to the 6 or so method in the callstack there. That feels a bit...eh, and also, since there's already a few optional parameters on the functions there (Page::displaySlice(), et al), this isn't exactly "pretty".
Also, I'm not sure if there's no other places where such a change would be useful for pdfimages, if there's other elements that can be hidden that can have images on them.
In conclusion:
Basically, I'm throwing the ball to you here, to decide on what to do here, if anything.