Skip to content

Commit 5608428

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR #21890: Drop retina images when building PDF docs
1 parent b903093 commit 5608428

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ def _check_dependencies():
167167

168168
# Sphinx gallery configuration
169169

170+
def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf,
171+
**kwargs):
172+
"""
173+
Reduce srcset when creating a PDF.
174+
175+
Because sphinx-gallery runs *very* early, we cannot modify this even in the
176+
earliest builder-inited signal. Thus we do it at scraping time.
177+
"""
178+
from sphinx_gallery.scrapers import matplotlib_scraper
179+
180+
if gallery_conf['builder_name'] == 'latex':
181+
gallery_conf['image_srcset'] = []
182+
return matplotlib_scraper(block, block_vars, gallery_conf, **kwargs)
183+
184+
170185
sphinx_gallery_conf = {
171186
'examples_dirs': ['../examples', '../tutorials', '../plot_types'],
172187
'filename_pattern': '^((?!sgskip).)*$',
@@ -183,6 +198,7 @@ def _check_dependencies():
183198
'remove_config_comments': True,
184199
'min_reported_time': 1,
185200
'thumbnail_size': (320, 224),
201+
'image_scrapers': (matplotlib_reduced_latex_scraper, ),
186202
# Compression is a significant effort that we skip for local and CI builds.
187203
'compress_images': ('thumbnails', 'images') if is_release_build else (),
188204
'matplotlib_animations': True,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy