'Is there a way to set the image scaling method in reST/Sphinx?
when I use the :scale: property on my pixel art, its very blurry. How can i change the scaling method to nearest neighbor for sharper scaling in Sphinx/reST?
Solution 1:[1]
You can't do this with Sphinx. You need to preprocess the image with a graphic tool, not with a documentation tool. For example, ImageMagick has various resize interpolation methods including nearest.
To clarify what :scale:
actually does: For example, for HTML output, :scale:
option only set new dimensions to <img>
- doesn't actually resize the image.
For example, if img/foo.png
has 500x300 px
.. image:: img/foo.png
:scale: 50%
in HTML will be
<img src="../_images/foo.png"
style="width: 250.0px; height: 150.0px;"/>
Solution 2:[2]
For me it worked:
.. _target to image:
.. figure:: /img/logo.png
:alt: Logo
:align: center
:width: 240px
Link me!
I'm using sphinx and docxbuilder to generate MS Word documentation and using the :width: option I managed to resize the image without distorting it.
Reference: https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matt |
Solution 2 | FilipeTavares |