Skip to content

Commit

Permalink
Remove aspect ratio check from upload_image.py (#5806)
Browse files Browse the repository at this point in the history
### What

That check dates back from when we used the screenshot as thumbnail, so
we needed it to have some sensible aspect ratio. That's history now, and
bypassing this check every time is most annoying.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[rerun.io/viewer](https://rerun.io/viewer/pr/5806)
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/5806?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/5806?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5806)
- [Docs
preview](https://rerun.io/preview/3382c7c3964426d42115a8b9e3476c313145a153/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/3382c7c3964426d42115a8b9e3476c313145a153/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 committed Apr 5, 2024
1 parent eb6270d commit ee51fe8
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions scripts/upload_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
1200,
]

ASPECT_RATIO_RANGE = (1.6, 1.8)


def build_image_stack(image: Image) -> list[tuple[int | None, Image]]:
image_stack: list[tuple[int | None, Image]] = [(None, image)]
Expand Down Expand Up @@ -120,32 +118,14 @@ def image_from_clipboard() -> Image:


class Uploader:
def __init__(self, auto_accept: bool):
def __init__(self):
gcs = storage.Client("rerun-open")
self.bucket = gcs.bucket("rerun-static-img")
self.auto_accept = auto_accept

def _check_aspect_ratio(self, image: Path | Image) -> None:
if isinstance(image, Path):
image = PIL.Image.open(image)

aspect_ratio = image.width / image.height
aspect_ok = ASPECT_RATIO_RANGE[0] < aspect_ratio < ASPECT_RATIO_RANGE[1]

if not aspect_ok and not self.auto_accept:
logging.warning(
f"Aspect ratio is {aspect_ratio:.2f} but should be between {ASPECT_RATIO_RANGE[0]} and "
f"{ASPECT_RATIO_RANGE[1]}."
)
# do not pass prompt to input as this goes to stdout
print(
"The image aspect ratio is outside the range recommended for example screenshots. Continue? [y/N] ",
end="",
file=sys.stderr,
)
if input().lower() != "y":
sys.exit(1)

def upload_file(self, path: Path) -> str:
"""
Upload a single file to Google Cloud.
Expand Down Expand Up @@ -355,7 +335,7 @@ def download_file(url: str, path: Path) -> None:
def run(args: argparse.Namespace) -> None:
"""Run the script based on the provided args."""
try:
uploader = Uploader(args.auto_accept)
uploader = Uploader()

if args.single:
if args.path is None:
Expand Down Expand Up @@ -415,7 +395,6 @@ def main() -> None:
"--single", action="store_true", help="Upload a single image instead of creating a multi-resolution stack."
)
parser.add_argument("--name", type=str, help="Image name (required when uploading from clipboard).")
parser.add_argument("--auto-accept", action="store_true", help="Auto-accept the aspect ratio confirmation prompt")
parser.add_argument("--debug", action="store_true", help="Enable debug logging.")
args = parser.parse_args()

Expand Down

0 comments on commit ee51fe8

Please sign in to comment.