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

[Merged by Bors] - Add additional image validation #464

Closed
wants to merge 4 commits into from

Conversation

rparrett
Copy link
Contributor

@rparrett rparrett commented Sep 30, 2022

Updating this old code on top of the recent improvements to the validator.

Some previous discussion in #443
Some recent motivation in #253

Objective

  • Shorten the feedback loop for users submitting their projects to bevy_assets
  • Help maintainers enforce restrictions related to image size
  • Improve the overall look and feel of the assets page by enforcing a reasonable aspect ratio
  • Improve the performance of the assets page and reduce the repository size by enforcing a maximum file size
  • Make validation errors output a little more clear for users

Example Output

Note: Some of these validations are no longer present in this PR.

Fish Fight: Punchy
  Image dimensions must not exceed 1000x1000 px.
  Image aspect ratio must be between 1 and 2.

taipo
  Description must be at most 100 chars in length.
  Image file not found.

Bevy Combat
  Image file must be at most 1000000 bytes.

Typey Birb
  Image aspect ratio must be between 1 and 2.

Cheaters Never Win
  Image dimensions must not exceed 1000x1000 px.
  Image aspect ratio must be between 1 and 2.

Error: 28 asset(s) are invalid.

Discussion Points

This is currently a draft because many existing images do not currently meet these restrictions.

For file size restrictions, we could manually fix up the files.

But for image aspect ratio, I think we would need to find a way to "grandfather in" the old images. I contemplated a static list of grandfathered assets, but that would prevent validations from working if users attempt to update those in the future.

Also, see #448 where we decided to use a single aspect ratio on the website. If that were fixed, we might want to rework the some of the validations like

  • Enforce a fixed image size rather than a maximum
  • Remove the separate aspect ratio check all-together

The current file size limit in the PR seems clearly too large. I think something like 250kb would be more appropriate, but that would require a lot more work on existing assets.

@alice-i-cecile alice-i-cecile added A-Assets The collection of ecosystem crates found on the Bevy Assets page A-Build-System C-Usability labels Nov 12, 2022
@IceSentry
Copy link
Contributor

I believe this should be updated to only check for file size restrictions and ignore aspect ratio. With the current card layout, using the wrong aspect ratio might not look great, but it isn't an issue like size is.

@rparrett
Copy link
Contributor Author

rparrett commented Jan 18, 2023

That's fine.

Unfortunately, image is now choking on a webp image due to image-rs/image#1712

I guess I'll just rip out the rest of the image validation (leaving file size) as well.

With a constant and common aspect ratio on the website to aim for,
more users are getting it right.
@rparrett
Copy link
Contributor Author

Okay, that is done.

bevy_ecs_ldtk
  Image file size 4201746 exceeds maximum 2097152 bytes.

Kataster
  Image file size 3046854 exceeds maximum 2097152 bytes.

Error: 2 asset(s) are invalid.

@IceSentry
Copy link
Contributor

Unfortunately, image is now choking on a webp

Oh, 😦 that is unfortunate, well, I guess we'll be able to add it back in the future

For the CI failure, #520 this should fix it, it's not caused by this PR

@rparrett
Copy link
Contributor Author

Oh, 😦 that is unfortunate, well, I guess we'll be able to add it back in the future

Yeah, happy to do that later. I am pretty sure that the next release of image will fix the issue.

@rparrett rparrett marked this pull request as ready for review January 19, 2023 20:51
@rparrett
Copy link
Contributor Author

We will need to do something about the images for kataster and bevy_ecs_ldtk or I assume the next person to submit something to bevy-assets will get stuck with that problem.

bors bot pushed a commit to bevyengine/bevy-assets that referenced this pull request Jan 20, 2023
@BorisBoutillier with your permission, I'd like to swap out Kataster's image with this smaller `webp` version.

([link to animated preview](https://raw.githubusercontent.com/bevyengine/bevy-assets/f1ad2af8b53adaff68622cbe981791f66b80e974/Apps/Games/Kataster.webp))
<img width="309" alt="image" src="https://user-images.githubusercontent.com/200550/213757436-e4919ad1-6df4-4b14-9628-1cce7bcb7135.png">

This is a re-recording that hopefully captures the same spirit and quality. I took some liberties to remove the title bar and match the game's aspect ratio to what's displayed on the website.

Context: I'm trying to add image size validation to the CI (bevyengine/bevy-website#464), and there are a few images that are currently over the size limit.

If you'd prefer to cut a new recording yourself, that's great.
bors bot pushed a commit to bevyengine/bevy-assets that referenced this pull request Jan 21, 2023
@Trouv with your permission, I'd like to swap out `bevy_ecs_ldtk`'s image with this smaller version.

You can see it animated side by side with the previous version in the changed files tab.

<img width="311" alt="image" src="https://user-images.githubusercontent.com/200550/213820696-40d1b246-fa25-4feb-8ebc-5b3a4f401576.png">

This is a re-recording that hopefully captures the same spirit and image quality. I took some liberties to match the game's aspect ratio to what's displayed on the website and get the file size down.

Context: I'm trying to add image size validation to the CI (bevyengine/bevy-website#464), and there are a few images that are currently over the size limit.

If you'd prefer to cut a new recording yourself, that's great. There's no rush. I just thought it would be rude to ask you to re-do it without giving you an easy option.
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review Ready for a maintainer to consider for merging label Jan 31, 2023
@alice-i-cecile
Copy link
Member

Fingers crossed this should work now.

bors r+

bors bot pushed a commit that referenced this pull request Jan 31, 2023
Updating this old code on top of the recent improvements to the validator.

Some previous discussion in #443
Some recent motivation in [#253](bevyengine/bevy-assets#253)

## Objective

- Shorten the feedback loop for users submitting their projects to `bevy_assets`
- Help maintainers enforce restrictions related to image size
- ~~Improve the overall look and feel of the assets page by enforcing a reasonable aspect ratio~~
- Improve the performance of the assets page and reduce the repository size by enforcing a maximum file size
- Make validation errors output a little more clear for users

## Example Output

Note: Some of these validations are no longer present in this PR.

```
Fish Fight: Punchy
  Image dimensions must not exceed 1000x1000 px.
  Image aspect ratio must be between 1 and 2.

taipo
  Description must be at most 100 chars in length.
  Image file not found.

Bevy Combat
  Image file must be at most 1000000 bytes.

Typey Birb
  Image aspect ratio must be between 1 and 2.

Cheaters Never Win
  Image dimensions must not exceed 1000x1000 px.
  Image aspect ratio must be between 1 and 2.

Error: 28 asset(s) are invalid.
```

## Discussion Points

This is currently a draft because many existing images do not currently meet these restrictions.

For file size restrictions, we could manually fix up the files.

But for image aspect ratio, I think we would need to find a way to "grandfather in" the old images. I contemplated a static list of grandfathered assets, but that would prevent validations from working if users attempt to update those in the future.

Also, see #448 where we decided to use a single aspect ratio on the website. If that were fixed, we might want to rework the some of the validations like

- Enforce a fixed image size rather than a maximum
- Remove the separate aspect ratio check all-together

The current file size limit in the PR seems clearly too large. I think something like 250kb would be more appropriate, but that would require a lot more work on existing assets.
@bors
Copy link

bors bot commented Jan 31, 2023

Build failed:

@rparrett
Copy link
Contributor Author

error: usage of sparse registries requires -Z sparse-registry

well that's new and exciting

@mockersf
Copy link
Member

bors r+

@mockersf
Copy link
Member

error: usage of sparse registries requires -Z sparse-registry

well that's new and exciting

I'm going to go with cargo bug on the server side 🤷

bors bot pushed a commit that referenced this pull request Jan 31, 2023
Updating this old code on top of the recent improvements to the validator.

Some previous discussion in #443
Some recent motivation in [#253](bevyengine/bevy-assets#253)

## Objective

- Shorten the feedback loop for users submitting their projects to `bevy_assets`
- Help maintainers enforce restrictions related to image size
- ~~Improve the overall look and feel of the assets page by enforcing a reasonable aspect ratio~~
- Improve the performance of the assets page and reduce the repository size by enforcing a maximum file size
- Make validation errors output a little more clear for users

## Example Output

Note: Some of these validations are no longer present in this PR.

```
Fish Fight: Punchy
  Image dimensions must not exceed 1000x1000 px.
  Image aspect ratio must be between 1 and 2.

taipo
  Description must be at most 100 chars in length.
  Image file not found.

Bevy Combat
  Image file must be at most 1000000 bytes.

Typey Birb
  Image aspect ratio must be between 1 and 2.

Cheaters Never Win
  Image dimensions must not exceed 1000x1000 px.
  Image aspect ratio must be between 1 and 2.

Error: 28 asset(s) are invalid.
```

## Discussion Points

This is currently a draft because many existing images do not currently meet these restrictions.

For file size restrictions, we could manually fix up the files.

But for image aspect ratio, I think we would need to find a way to "grandfather in" the old images. I contemplated a static list of grandfathered assets, but that would prevent validations from working if users attempt to update those in the future.

Also, see #448 where we decided to use a single aspect ratio on the website. If that were fixed, we might want to rework the some of the validations like

- Enforce a fixed image size rather than a maximum
- Remove the separate aspect ratio check all-together

The current file size limit in the PR seems clearly too large. I think something like 250kb would be more appropriate, but that would require a lot more work on existing assets.
@bors
Copy link

bors bot commented Jan 31, 2023

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title Add additional image validation [Merged by Bors] - Add additional image validation Jan 31, 2023
@bors bors bot closed this Jan 31, 2023
yopox pushed a commit to yopox/bevy-assets that referenced this pull request Apr 3, 2023
@BorisBoutillier with your permission, I'd like to swap out Kataster's image with this smaller `webp` version.

([link to animated preview](https://raw.githubusercontent.com/bevyengine/bevy-assets/f1ad2af8b53adaff68622cbe981791f66b80e974/Apps/Games/Kataster.webp))
<img width="309" alt="image" src="https://user-images.githubusercontent.com/200550/213757436-e4919ad1-6df4-4b14-9628-1cce7bcb7135.png">

This is a re-recording that hopefully captures the same spirit and quality. I took some liberties to remove the title bar and match the game's aspect ratio to what's displayed on the website.

Context: I'm trying to add image size validation to the CI (bevyengine/bevy-website#464), and there are a few images that are currently over the size limit.

If you'd prefer to cut a new recording yourself, that's great.
yopox pushed a commit to yopox/bevy-assets that referenced this pull request Apr 3, 2023
@Trouv with your permission, I'd like to swap out `bevy_ecs_ldtk`'s image with this smaller version.

You can see it animated side by side with the previous version in the changed files tab.

<img width="311" alt="image" src="https://user-images.githubusercontent.com/200550/213820696-40d1b246-fa25-4feb-8ebc-5b3a4f401576.png">

This is a re-recording that hopefully captures the same spirit and image quality. I took some liberties to match the game's aspect ratio to what's displayed on the website and get the file size down.

Context: I'm trying to add image size validation to the CI (bevyengine/bevy-website#464), and there are a few images that are currently over the size limit.

If you'd prefer to cut a new recording yourself, that's great. There's no rush. I just thought it would be rude to ask you to re-do it without giving you an easy option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets The collection of ecosystem crates found on the Bevy Assets page A-Build-System C-Usability S-Ready-For-Final-Review Ready for a maintainer to consider for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants