Hello everyone, I am Lu Yao, every Friday I will recommend you a high-quality Github project of pan-mobile terminal.

Imgbot helps you compress images in your Github repository.

Author github.com/imgbot
Url Github.com/imgbot/Imgb…
Language C#/HTML/Vue/Less
Star 874
Fork 212
Issue 26 Open/147 Closed
Commits 1003
Last Update Mar 7, 2022
License MIT

Above data as of March 11, 2022.

use

Imagebot is an open source Github App that provides lossless compression of image resources. It has the following features:

  1. Lossless compression
  2. Open source implementation
  3. Based on the PR
  4. Use the Github app to provide permissions
  5. Planned execution of tasks
  6. You can configure to ignore files/folders
  7. Stronger compression options
  8. Support public/private repositories
  9. Free for open source projects

Simply put, Imagebot automatically helps you compress images in your repository and submit PR to you.

You can find it on Github’s app Marketplace, here:

Github.com/marketplace…

After installing, do a simple configuration and select the repository you want to apply to. I tested it with my demo project:

A few hours later, you’ll get A PR from the imgbot, as shown below:

Beep Boop helped me reduce my image resources by 25%. It shows the detailed compressed data of the image in the form of a table.

configuration

Imgbot also provides personalized configuration items that create an.imgbotConfig file in json format in the warehouse root. Here is an example:

{
    "schedule": "daily", // daily|weekly|monthly
    "ignoredFiles": [
        "*.jpg",                   // ignore by extension
        "image1.png",              // ignore by filename
        "public/special_images/*", // ignore by folderpath
    ],
    "aggressiveCompression": "true", // true|false
    "compressWiki": "true", // true|false
    "minKBReduced": 500, // delay new prs until size reduction meets this threshold (default to 10)
    "prTitle" : "Your own pr title",        
    "prBody" : " Text before optimization ratio {optimization_ratio} Text after optimization ratio 
                 Text before optimization details {optimization_details} Text after optimization details",
}
Copy the code

schedule

Detection cycle. By default, PR is raised only when there are images to compress. You can also set it to daily or weekly or monthly.

ignoredFiles

Configure the ignore file. The format is as follows:

"IgnoredFiles ": ["*.jpeg" // filter by suffix]Copy the code

Provides a variety of filtering methods:

"Public /special_images/*" // ignores specified folder "special-image1.png" // ignores single file "**/test_images/**" // ignores nested folder "path/to/prefix*" // Ignore by regularCopy the code

aggressiveCompression

{
    "aggressiveCompression": false
}
Copy the code

The default value is false, indicating lossless compression. True indicates lossy compression.

compressWiki

Sets whether images in the wiki need to be compressed.

prTitle

The title of PR.

prBody

PR content. There is default content, which can be customized for a fee.

{
    "prBody" : " Text before optimization ratio {optimization_ratio} Text after optimization ratio 
                 Text before optimization details {optimization_details} Text after optimization details",
}
Copy the code

The last

Imgbot’s solution is also a good way to step in and compress and replace images during the packaging process. Perfect integration with Workflow in a PR way outside of your daily development work.

That’s all for this introduction, and I’ll see you next Friday.

If you have a good project recommendation, welcome to contribute to me, WX: bingxinshuo_.