google / WebFundamentals

Former git repo for WebFundamentals on developers.google.com
Apache License 2.0
13.85k stars 2.57k forks source link

PR webhook for image compression #6186

Open jeffposnick opened 6 years ago

jeffposnick commented 6 years ago

I was chatting about this with @petele in the context of checking in a few images as part of #6183, and I wanted to transfer that discussion to a formal issue for a) additional feedback and b) making sure I wouldn't be reinventing the wheel.

I was thinking of creating a new webhook that was triggered as part of PR requests, and which will scan the list of updated files for any images. When it finds an image, it will use a [recommended tool] like imagemin to compress the image with a reasonable default quality, and compare the compressed size to the size of the image in the PR. If the delta is greater than some percentage- or bytes-based threshold, it will fail the PR check. We can then link to the compressed version of the image in a auto-generated PR comment, which folks could download and include in a follow-up commit.

That seems to offer a reasonable balance between automating some of the tasks, without trying to do too much magic without any overrides.

CC: @addyosmani and @PaulKinlan for any thoughts.

jpmedley commented 6 years ago

+1

kaycebasques commented 6 years ago

That sounds purdy good.

Just random brainstorming, it could be nice for the hookbot to paste some code that would download all the images for you and put them in their proper location.

(Assuming you cd to root directory of the repo):

curl https://autogeneratedimage.com/... -o src/content/en/...