Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
quba42 opened this issue Sep 11, 2019 · 4 comments

Comments

@quba42
Copy link

quba42 commented Sep 11, 2019

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.

@quba42 quba42 changed the title :scale: option of image/figure directive broken for SVG images in HTML builds :scale: option of image/figure directive not working for SVG images in HTML builds Sep 11, 2019
@tk0miya tk0miya added this to the 2.4.0 milestone Dec 10, 2019
@tk0miya
Copy link
Member

tk0miya commented Dec 14, 2019

Unfortunately, :scale: option is not implemented now. To do that, I posted shibukawa/imagesize_py#27 to imagesize_py project as a preparaton. I will post another PR to sphinx to support it laster.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 2, 2020
… working for SVG

Note: imagesize-1.2.0 or above is required
tk0miya added a commit that referenced this issue Jan 4, 2020
Fix #6696: html: scale option of image/figure directive not working for SVG
@tk0miya
Copy link
Member

tk0miya commented Jan 4, 2020

Fixed by #6985
Thank you for reporting!

@tk0miya tk0miya closed this as completed Jan 4, 2020
@quba42
Copy link
Author

quba42 commented Jan 13, 2020

Thank you for the good work!

@pfheatwole
Copy link

pfheatwole commented Jun 25, 2020

Be aware, there are currently some issues with how "imagesize_py" handles SVG files. For example, my SVG <img> widths and heights were enormous in HTML builds because of shibukawa/imagesize_py/issues/42

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants