Open Eric-Arellano opened 1 month ago
Note that unless the SVG is is significantly bigger than its PNG equivalent, it may still load faster for users. SVGs can be compressed a lot when sent over the network, whereas PNGs are already compressed so the file size we see is much closer to what's actually sent.
https://github.com/Qiskit/documentation/pull/1673 is an example of an enormous file size we didn't realize. That has two major downsides:
I think https://github.com/Qiskit/documentation/issues/1672 may help address this. But either way, we may want to add a check that file sizes don't cross a threshold, e.g. >400MB. This would be at least for Jupyter notebooks, but maybe also for dedicated image files.
The allowlist mechanism should set new thresholds, e.g.
(my-file.ipynb, 600)
to set a threshold of 600MB.FYI: how to reduce Jupyter notebook image size
Often PNGs are smaller than SVGs:
You can reduce the resolution of Matplotlib figures. However, this often makes the image less useful and I think it tends to be better to instead set
figsize
:You can sometimes set
figsize
directly in Qiskit SDK:If
figsize
is not exposed, then you can change the returning figure:One of the other techniques is to see if any of the images can be removed entirely. Are they pulling their weight?