Skip to content

Conversation

@akrolsmir
Copy link
Contributor

@akrolsmir akrolsmir commented Jan 21, 2021

Spec from Thiago

Without going so far as completely rethinking how we do sizes, the least we could do is change use_column_width to accept three values:

  • 'auto' : sets the image to its natural size, unless its width is greater than the column width. In which case it scales the image to fit the column width.
  • True or 'always': sets the image size to fit the column width.
  • False or 'never': sets the image to its natural size.

Then we'd make 'auto' the default. (The current default is False)

Spec from Thiago:

Without going so far as completely rethinking how we do sizes, the least we could do is change `use_column_width` to accept three values:

- `'auto'` : sets the image to its natural size, unless its width is greater than the column width. In which case it scales the image to fit the column width.
- `True` or `'always'`: sets the image size to fit the column width.
- `False` or `'never'`: sets the image to its natural size.

Then we'd make `'auto'` the default. (The current default is `False`)
@akrolsmir akrolsmir requested a review from a team January 21, 2021 23:11
Copy link
Contributor

@karriebear karriebear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


st.set_option("deprecation.showImageFormat", True)
img = np.repeat(0, 10000).reshape(100, 100)
img400 = np.repeat(0, 160000).reshape(400, 400)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this 800 just to be safe. The width we use on cypress is 1366. If we divide by 3 it's 455 which is right on the cusp. There's probably margin/padding elsewhere that 400 could be large enough but I figure go big or go home!

Copy link
Contributor Author

@akrolsmir akrolsmir Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 1366 is actually the full screen width of Cypress, but on this test the 3 columns are further restricted by the 798px main column; in my testing the width of each of the beta_columns was about 222px (after padding and stuff), so 400 was more than enough.

That said, nothing wrong with 800 either, so I've updated it here!

Image caption. If displaying multiple images, caption should be a
list of captions (one for each image).
width : int or None
Image width. None means use the image width.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product side note, I feel like none should use column width but that's just me

Copy link
Contributor Author

@akrolsmir akrolsmir Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh -- I agreed, and width=None actually does default to use_column_width='auto', aka the image will use its natural width but not exceed the column.

I've update the docstring here, though it might still be a bit confusing. @asaini , feel free to reword this section!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akrolsmir akrolsmir changed the title Support "auto" as the new default for st.image's use_column_width ✨ Support "auto" as the new default for st.image's use_column_width Jan 22, 2021
@akrolsmir akrolsmir assigned karriebear and unassigned tconkling Jan 22, 2021
@asaini
Copy link

asaini commented Jan 23, 2021

Verified that functionality looks good 👍

Minor question: As mentioned in the notion doc, are we issuing any deprecation warning?

@akrolsmir
Copy link
Contributor Author

Verified that functionality looks good 👍

Minor question: As mentioned in the notion doc, are we issuing any deprecation warning?

I don't think we should issue an in-app warning (eg the one that FileUploader had), as the changes to st.image defaults are not likely to affect a lot of users; I think showing an in-app warning would annoy creators/users a lot more than it'd help the few people who'd notice the changes.

We should absolutely call it out in our changelog release notes, though!

@akrolsmir akrolsmir merged commit 67a3728 into streamlit:develop Jan 25, 2021
@asaini
Copy link

asaini commented Jan 25, 2021

Changelog callout sounds good to me!

tconkling added a commit to tconkling/streamlit that referenced this pull request Jan 25, 2021
* develop:
  ✨ Support "auto" as the new default for st.image's `use_column_width` (streamlit#2635)
  fix branch name in pr-preview (streamlit#2644)
  ♻️ Remove "_proto" from "exception_proto.py" (streamlit#2638)
  ♻️ Remove "_proto" from "media_proto.py" and "iframe_proto.py" (streamlit#2639)
  Refactor: remove "_proto" from "image_proto.py" (streamlit#2626)
  correct info on url shortening behavior (streamlit#2576)
  Set "overflow:visible" on st.expander (streamlit#2611)
  Revert "Revert "Add anchors to Markdown headers (streamlit#2513)""
  Fix file uploader docs + change to getvalue (streamlit#2628)
  Update change log
  Update notices
  Up version to 0.75.0
  Revert "Add anchors to Markdown headers (streamlit#2513)"
  Speed up Cypress tests (streamlit#2600)
  Remove "beta feature" notice on st.color_picker (streamlit#2625)
  Deflake multiselect snapshot test by waiting for stale-element (streamlit#2624)
  Rerender Maybe components when they're first disabled (streamlit#2617)
  Increase side padding to 5rem when app is in wide mode (streamlit#2613)
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

Successfully merging this pull request may close these issues.

4 participants