Skip to content
/ Imgbot Public template
forked from imgbot/Imgbot

An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. help@imgbot.net

License

Notifications You must be signed in to change notification settings

majacQ/Imgbot

Repository files navigation

ImgBot

ImgBot crawls all your image files in GitHub and submits pull requests after applying a lossless compression. This will make the file size go down, but leave the dimensions and quality just as good.

The backend

The core of ImgBot runs on a serverless stack called Azure Functions. This is what is running the image compression, pushing commits, and opening Pull Requests. Once you get the tools you need to work with Azure functions you can run the app locally from ImgBot.Function.

You can either get the tools integrated with Visual Studio and use F5 or you can get the CLI standalone and use func run ImgBot.Function. All operating systems welcome :)

Within the ImgBot.Function directory you will see the following key classes

  • Functions.cs - the triggers for starting the workflows
  • CompressImages.cs - clone the repo, compress the images, open the PR
  • InstallationToken.cs - uses a pem file and the GitHub API to get access to repos

Note: For security reasons we cannot provide you with the pem file as this is a secret reserved for the production service. You can run every part of the function except parts where authentication is required without this secret. If you are working on a part of the function that requires this secret then you can generate one for yourself to test with. Register a GitHub app for development purpose and install this app into the repo you are using to test with. If there is a part of this process that isn't clear or you have any questions at all feel free to open an issue in this repo and we'll work it out :)

The frontend

The frontend that drives https://imgbot.net/ is a lightweight web app running on ASP.NET Core - Again, all operating systems welcome :) The purpose of this website is to run the landing page for ImgBot as well as an endpoint for the webhooks from GitHub for installed repos.

Within the ImgBot.Web directory you will see the follwing key files

  • Views/Home/Index.cshtml - the landing page markup
  • Views/Shared/_Layout.cshtml - the layout for the landing page
  • wwwroot/css/site.css - the landing page stylesheet
  • Controllers/HookController.cs - the route for the webhooks

The 2 main events we deal with through webhooks are installation events and push events. Each time a repo has ImgBot installed, GitHub fires a hook to HookController.cs and we start the installation workflow. Each time a repo that already has ImgBot installed gets pushed to, GitHub fires a hook to HookController.cs and, if the commit contains an image update, we start the compression worflow.

The end result

About

An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. help@imgbot.net

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 78.7%
  • HTML 9.8%
  • Vue 5.3%
  • Less 3.6%
  • JavaScript 1.7%
  • EJS 0.9%