Skip to content

:scale: option of image/figure directive not working for SVG images in HTML builds #6696

@quba42

Description

@quba42

Describe the bug
When including an SVG image, using the .. image:: or .. figure:: directives, The :scale: option (e.g. :scale: 50%) appears to have no effect on the output of HTML builds.

To reproduce
Steps to reproduce the behavior:

Include any SVG image in a sphinx document as follows:

.. image:: example_image.svg
  :scale: 50%

Build the HTML version of the document:

make html

Expected behaviour
The image in the HTML output is half the size as compared to when I am not using the option :scale: 50%.

Actual behaviour
The :scale: 50% directive has no effect on the resultant HTML.

Environment info

  • OS: [Debian Buster]
  • Python version: 3.7.4+
    Sphinx was installed in a virtual python environment as follows:
pip install -U sphinx
pip install sphinxcontrib-svg2pdfconverter

This resulted in the following versions:

  • sphinx 2.2.0
  • sphinxcontrib-svg2pdfconverter 0.1.0

Here, sphinxcontrib-svg2pdfconverter is only needed to compare the HTML behaviour with a successful LaTeX build. The HTML issue itself can be recreated with Sphinx alone.

Additional context
The :scale: option works as expected for SVG imgaes in latexpdf builds (in conjunction with this extension).

The :width: and :height: options, do work as expected for SVG images in HTML builds.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions