plasTeX 3.0 — A Python Framework for Processing LaTeX Documents

5.2.5 Static Images

There are some images in a document that don’t need to be generated, they simply need to be copied to the output directory and possibly converted to an appropriate formate. This is accomplished with the imageoverride attribute. When the image property is accessed, the imageoverride attribute is checked to see if an image is already available for that node. If there is, the image is copied to the image output directory using a name generated using the same method as described in the previous section. The image is copied to that new filename and converted to the appropriate image format if needed. While it would be possible to simply copy the image over using the same filename, this may cause filename collisions depending on the directory structure that the original images were store in.

Below is an example of using imageoverride for copying stock icons that are used throughout the document.

from plasTeX import Command

class dangericon(Command):
    imageoverride = 'danger.gif'

class warningicon(Command):
    imageoverride = 'warning.gif'

It is also possible to make imageoverride a property so that the image override can done conditionally. In the case where no override is desired in a property implementation, simply raise an AttributeError exception.