class documentation

class ImageConverter(BaseImageConverter):

Known subclasses: sphinx.ext.imgconverter.ImagemagickConverter

View In Hierarchy

A base class for image converters.

An image converter is kind of Docutils transform module. It is used to convert image files which are not supported by a builder to the appropriate format for that builder.

For example, LaTeX builder supports PDF, PNG and JPEG as image formats. However it does not support SVG images. For such case, using image converters allows to embed these unsupported images into the document. One of the image converters; :ref:`sphinx.ext.imgconverter <sphinx.ext.imgconverter>` can convert a SVG image to PNG format using Imagemagick internally.

There are three steps to make your custom image converter:

  1. Make a subclass of ImageConverter class
  2. Override conversion_rules, is_available() and convert()
  3. Register your image converter to Sphinx using .Sphinx.add_post_transform
Method convert Convert an image file to the expected format.
Method is​_available Return the image converter is available or not.
Class Variable available Undocumented
Class Variable conversion​_rules Undocumented
Method __init__ Undocumented
Method get​_conversion​_rule Undocumented
Method guess​_mimetypes Undocumented
Method handle Undocumented
Method match Undocumented
Class Variable default​_priority Undocumented

Inherited from BaseImageConverter:

Method apply Undocumented
Property imagedir Undocumented

Inherited from SphinxTransform (via BaseImageConverter):

Property app Reference to the .Sphinx object.
Property config Reference to the .Config object.
Property env Reference to the .BuildEnvironment object.
def convert(self, _from, _to):

Convert an image file to the expected format.

_from is a path of the source image file, and _to is a path of the destination file.

Parameters
​_from:strUndocumented
​_to:strUndocumented
Returns
boolUndocumented
def is_available(self):
Return the image converter is available or not.
Returns
boolUndocumented
available: Optional[bool] =

Undocumented

conversion_rules: List[Tuple[str, str]] =
def __init__(self, *args, **kwargs):

Undocumented

Parameters
*args:AnyUndocumented
**kwargs:AnyUndocumented
def get_conversion_rule(self, node):

Undocumented

Parameters
node:nodes.imageUndocumented
Returns
Tuple[str, str]Undocumented
def guess_mimetypes(self, node):

Undocumented

Parameters
node:nodes.imageUndocumented
Returns
List[str]Undocumented
def handle(self, node):

Undocumented

Parameters
node:nodes.imageUndocumented
def match(self, node):

Undocumented

Parameters
node:nodes.imageUndocumented
Returns
boolUndocumented
default_priority: int =

Undocumented