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

Added support for creating multi-resolution stacks with upload_image.py #2411

Merged
merged 7 commits into from Jun 13, 2023

Conversation

abey79
Copy link
Contributor

@abey79 abey79 commented Jun 13, 2023

What

Create and upload multi-resolution stacks with upload_image.py

Clock example screenshot updated as an example of the result obtained.

Relates to #2273

TODO:

  • pngcrush stuff?
  • docs
  • test with jpg as well

Usage

$ just upload --help
python3 "scripts/upload_image.py" --help
usage: upload_image.py [-h] [--single] [--name NAME] [--skip-pngcrush] [--debug] [path]

Upload an image.

positional arguments:
  path             File path to the image. If not provided, use the clipboard's content.

options:
  -h, --help       show this help message and exit
  --single         Upload a single image instead of creating a multi-resolution stack.
  --name NAME      Image name (required when uploading from clipboard).
  --skip-pngcrush  Skip PNGCrush.
  --debug          Enable debug logging.

Example output

INFO:root:Base image width: 2348px
INFO:root:Resizing to: 480px
INFO:root:Resizing to: 768px
INFO:root:Resizing to: 1024px
INFO:root:Resizing to: 1200px
INFO:root:pngcrush reduced size from 76341 to 71599 bytes
INFO:root:Uploading 30a2659cb4f9b6ac39c808c3312a3f89b71d040c_clock_480w.png (size: 71599, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 145632 to 134514 bytes
INFO:root:Uploading acfb95102e353d67d0525e3a3d40fbe7f0ed638f_clock_768w.png (size: 134514, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 208771 to 188959 bytes
INFO:root:Uploading 7b1b0435cd8de9318c301036853d5c0d190b155f_clock_1024w.png (size: 188959, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 254562 to 231188 bytes
INFO:root:Uploading 51938f84bdb0df1baa1d72e09f2a1daac6e66d1c_clock_1200w.png (size: 231188, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 293024 to 265268 bytes
INFO:root:Uploading 4040806d866f246eda1a1434f3a1ab083764eb56_clock_full.png (size: 265268, type: image/png, encoding: None)

<picture>
  <source media="(max-width: 480px)" srcset="https://static.rerun.io/30a2659cb4f9b6ac39c808c3312a3f89b71d040c_clock_480w.png">
  <source media="(max-width: 768px)" srcset="https://static.rerun.io/acfb95102e353d67d0525e3a3d40fbe7f0ed638f_clock_768w.png">
  <source media="(max-width: 1024px)" srcset="https://static.rerun.io/7b1b0435cd8de9318c301036853d5c0d190b155f_clock_1024w.png">
  <source media="(max-width: 1200px)" srcset="https://static.rerun.io/51938f84bdb0df1baa1d72e09f2a1daac6e66d1c_clock_1200w.png">
  <img src="https://static.rerun.io/4040806d866f246eda1a1434f3a1ab083764eb56_clock_full.png" alt="">
</picture>

Checklist

PR Build Summary: https://build.rerun.io/pr/2411

Docs preview: https://rerun.io/preview/479fa5f/docs
Examples preview: https://rerun.io/preview/479fa5f/examples

@abey79 abey79 changed the title Added support for creating multi-resolution stacks to upload_image.py Added support for creating multi-resolution stacks with upload_image.py Jun 13, 2023
@abey79 abey79 added 📖 documentation Improvements or additions to documentation 🧑‍💻 dev experience developer experience (excluding CI) labels Jun 13, 2023
@emilk
Copy link
Member

emilk commented Jun 13, 2023

I definitely thing pngcrush or similar is worth it. On the highest setting it can sometime half the png size

@abey79
Copy link
Contributor Author

abey79 commented Jun 13, 2023

I definitely thing pngcrush or similar is worth it. On the highest setting it can sometime half the png size

Yes, some cursory testing I just did showed 2.8MB -> 1.9MB with default setting, 1.8MB with brute force (2.5min though!). There doesn't seem to be a nice python package, so I'll have to get the binary installed via the setup.sh scripts and call into it from upload_image.py (unless someone has a better idea).

@abey79 abey79 marked this pull request as ready for review June 13, 2023 14:46
@abey79 abey79 requested a review from jprochazk June 13, 2023 14:46
@abey79 abey79 mentioned this pull request Jun 13, 2023
1 task
Copy link
Member

@jprochazk jprochazk left a comment

Choose a reason for hiding this comment

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

Awesome!

scripts/upload_image.py Show resolved Hide resolved
@abey79 abey79 merged commit b625e7e into main Jun 13, 2023
20 checks passed
@abey79 abey79 deleted the antoine/multi-resolution-screenshots-2273 branch June 13, 2023 18:10
emilk pushed a commit that referenced this pull request Jun 15, 2023
…py (#2411)

### What

Create and upload multi-resolution stacks with `upload_image.py`

Clock example screenshot updated as an example of the result obtained.

Relates to #2273

TODO:
- [x] pngcrush stuff?
- [x] docs
- [x] test with jpg as well

### Usage

```sh
$ just upload --help
python3 "scripts/upload_image.py" --help
usage: upload_image.py [-h] [--single] [--name NAME] [--skip-pngcrush] [--debug] [path]

Upload an image.

positional arguments:
  path             File path to the image. If not provided, use the clipboard's content.

options:
  -h, --help       show this help message and exit
  --single         Upload a single image instead of creating a multi-resolution stack.
  --name NAME      Image name (required when uploading from clipboard).
  --skip-pngcrush  Skip PNGCrush.
  --debug          Enable debug logging.
```

### Example output


```
INFO:root:Base image width: 2348px
INFO:root:Resizing to: 480px
INFO:root:Resizing to: 768px
INFO:root:Resizing to: 1024px
INFO:root:Resizing to: 1200px
INFO:root:pngcrush reduced size from 76341 to 71599 bytes
INFO:root:Uploading 30a2659cb4f9b6ac39c808c3312a3f89b71d040c_clock_480w.png (size: 71599, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 145632 to 134514 bytes
INFO:root:Uploading acfb95102e353d67d0525e3a3d40fbe7f0ed638f_clock_768w.png (size: 134514, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 208771 to 188959 bytes
INFO:root:Uploading 7b1b0435cd8de9318c301036853d5c0d190b155f_clock_1024w.png (size: 188959, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 254562 to 231188 bytes
INFO:root:Uploading 51938f84bdb0df1baa1d72e09f2a1daac6e66d1c_clock_1200w.png (size: 231188, type: image/png, encoding: None)
INFO:root:pngcrush reduced size from 293024 to 265268 bytes
INFO:root:Uploading 4040806d866f246eda1a1434f3a1ab083764eb56_clock_full.png (size: 265268, type: image/png, encoding: None)

<picture>
  <source media="(max-width: 480px)" srcset="https://static.rerun.io/30a2659cb4f9b6ac39c808c3312a3f89b71d040c_clock_480w.png">
  <source media="(max-width: 768px)" srcset="https://static.rerun.io/acfb95102e353d67d0525e3a3d40fbe7f0ed638f_clock_768w.png">
  <source media="(max-width: 1024px)" srcset="https://static.rerun.io/7b1b0435cd8de9318c301036853d5c0d190b155f_clock_1024w.png">
  <source media="(max-width: 1200px)" srcset="https://static.rerun.io/51938f84bdb0df1baa1d72e09f2a1daac6e66d1c_clock_1200w.png">
  <img src="https://static.rerun.io/4040806d866f246eda1a1434f3a1ab083764eb56_clock_full.png" alt="">
</picture>
```



### 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)
* [ ] I've included a screenshot or gif (if applicable)

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2411

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/479fa5f/docs
Examples preview: https://rerun.io/preview/479fa5f/examples
<!-- pr-link-docs:end -->
This was referenced Jun 15, 2023
abey79 added a commit that referenced this pull request Jun 16, 2023
### What

This PR updates the examples' READMEs with new screenshots and adds the
`thumbnail:` entry to their front matter.

This uses #2411 and highlighted some bugs with it, to be fixed in a
follow-up PR.

TODO:
- [x] deal with signed_distance_fields
- [x] deal with detect_and_track_objects
- [x] deal with ros_node

### 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 WHOLE LOT of screenshots in the PR

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2440

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/b2d508b/docs
Examples preview: https://rerun.io/preview/b2d508b/examples
<!-- pr-link-docs:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) 📖 documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants