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

Controlling size of uploaded images #18

Open
bdebon opened this issue Oct 24, 2022 · 5 comments
Open

Controlling size of uploaded images #18

bdebon opened this issue Oct 24, 2022 · 5 comments
Labels
enhancement New feature or request intermediate you need some experience so deal with this issue but still doable senior this issue is hard

Comments

@bdebon
Copy link
Owner

bdebon commented Oct 24, 2022

As we mentioned in this PR, for the moment there are absolutely no safeguard for the images' size.
Some people can add huge images in their PR that then will be served like this to the final user which is both bad for performances, ecology, and webserver cost.
Usually we could rely on Next/Image to take care of the formatting of the image. The server would receive the information about or device and would answer with a well formated and optimised images.
Here we don't use the Server Side Rendering. We just export the next project and then upload all the generated files on a mutualised webserver. We can't use the power of next/image.
Can we solve that by a github action that would format and compress the images sent by the contributors?
Any other solution in mind?

@bdebon bdebon added enhancement New feature or request intermediate you need some experience so deal with this issue but still doable senior this issue is hard labels Oct 24, 2022
@glazk0
Copy link

glazk0 commented Oct 24, 2022

Hello there, I did a little research and I didn't really found anything interesting excepting this:

 https://github.com/calibreapp/image-actions

The only thing that can make me hesitate is that the latest version is now 3 years old.

But it could be a first "good" solution to the image size problem.

If you're ok to try it let me know, I'll give it a try and make a pull request.

@BuffaloDebile
Copy link

BuffaloDebile commented Oct 24, 2022

Hi;

As a temporary solution, I suggest that @bdebon could add the maximum file size in KB as well as the ideal file size in pixels in the Readme.

Pull requests that do not respect the ideal file size will be rejected.

Thanks Benjamin for this fun repo :)

@bdebon
Copy link
Owner Author

bdebon commented Oct 24, 2022

Thanks guys for these suggestions.

@glazk0, I think I'm gonna try the action, it does not cost nothing for me since everything is already set up.
If it fails, I will fallback on @BuffaloDebile recommendation but I will be very sad too.

@bdebon
Copy link
Owner Author

bdebon commented Oct 25, 2022

I added that actions:
https://github.com/petems/image-resizer-gh-action

That check the image in our folder, and for the one that are bigger than 800 width or 800 height, that resizes at max 800 width or 800 height with the good ratio. And it optimize the image too which decrease a lot the final image size.
Everything would have been easier with a vps a Next/Image but it also allows us to discover new github actions which is funny!

@bdebon
Copy link
Owner Author

bdebon commented Nov 11, 2022

I would like the CI to just check the images size and throw an error if an image is too big. Then it would ask the user to locally run a certain command to optimize the images and the commit would come from the user and not from the CI. Let's avoid committing with the CI. It's not clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request intermediate you need some experience so deal with this issue but still doable senior this issue is hard
Projects
None yet
Development

No branches or pull requests

3 participants