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

Thumbnail size #679

Closed
gianlucadetommaso opened this issue Oct 27, 2022 · 8 comments
Closed

Thumbnail size #679

gianlucadetommaso opened this issue Oct 27, 2022 · 8 comments

Comments

@gianlucadetommaso
Copy link

Hi, is there a way to add thumbnail size when adding nbsphinx-thumbnail as cell metadata for nbgallery? Is there any way in general to change the thumbnail size? The thumbnail_size option from Sphinx Gallery is not working for me.

@mgeier
Copy link
Member

mgeier commented Nov 13, 2022

I wasn't aware of this option. So I guess it is currently not supported.

@mgeier
Copy link
Member

mgeier commented Jan 7, 2023

@gianlucadetommaso can you please clarify what you mean by "thumbnail size"?

  1. the size as displayed in the rendered web page
  2. the size of the thumbnail image file, which may or may not be the same as (1)

The thumbnail feature of nbsphinx only links to existing image files, it doesn't create separate thumbnail image files, therefore (2) cannot be changed (except by changing the original image).

(1) could be easily changed via CSS.

Can you please elaborate about what you want to achieve?

@gianlucadetommaso
Copy link
Author

I meant 1. I wanted to resize the thumbnail of the rendered image, as achieved in sphinx-gallery via thumbnail_size - see here. For galleries created via nbsphinx, however, I did not find an option to resize the rendered images, and thumbnail_size did not work.

@mgeier
Copy link
Member

mgeier commented Jan 8, 2023

I still don't understand.

The link you provided says:

The gallery uses various CSS classes to display these thumbnails, which default to maximum 160x112px.

This means that however large you make the thumbnails with thumbnail_size, they will still not be displayed larger than 160x112px.

I'm not really a user of Sphinx Gallery, but looking at the example gallery at https://sphinx-gallery.github.io/stable/auto_examples/index.html#general-examples confirms that:

  1. the images are shown in the web page as 160x112px
  2. the image files (e.g. https://sphinx-gallery.github.io/stable/_images/sphx_glr_plot_0_sin_thumb.png) have a size of 400x280px

From that I have to conclude that thumbnail_size would only change (2).

If you want to change (1), you can use your own custom CSS for that.

Please note that the CSS for galleries will likely change in future nbsphinx versions, see (and participate in!) the discussion at mgeier#2.

@gianlucadetommaso
Copy link
Author

Now that I better read through you replies, I think what I was expecting to change with thumbnail_size was actually 2), not 1) - sorry about that. Yet, the reason why I felt the need of changing the image file size was very related to spatialaudio#655: the horizontal layout of the newer version of Sphinx generated images far too small with respect to the size of their canvas. Personally, I found the grid-based layout given by the older version of Sphinx more appealing to the eye.

@mgeier
Copy link
Member

mgeier commented Jan 8, 2023

related to spatialaudio#655: the horizontal layout of the newer version of Sphinx generated images

This is not an intentional change, this is a bug!

The short-term work-around is to restrict the Sphinx Gallery version (see #691):

sphinx-gallery<0.11

The long-term solution is maybe to come up with new HTML and CSS, see e.g. mgeier#2 (comment)

@gianlucadetommaso
Copy link
Author

Got it, thanks a lot for your answers!

@mgeier
Copy link
Member

mgeier commented Jan 17, 2023

I think this can be closed. If you have further questions, please let me know!

@mgeier mgeier closed this as completed Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants