All Projects → calibreapp → Image Actions

calibreapp / Image Actions

Licence: gpl-3.0
A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Image Actions

Imager
Automated image compression for efficiently distributing images on the web.
Stars: ✭ 266 (-68.48%)
Mutual labels:  image-processing, image-compression, compression
Essential Image Optimization
Essential Image Optimization - an eBook
Stars: ✭ 1,950 (+131.04%)
Mutual labels:  image-processing, image-compression, compression
Lerc
Limited Error Raster Compression
Stars: ✭ 126 (-85.07%)
Mutual labels:  image-processing, image-compression, compression
Crunch
Crunch is a tool for lossy PNG image file optimization. It combines selective bit depth, color type, and color palette reduction with zopfli DEFLATE compression algorithm encoding using the pngquant and zopflipng PNG optimization tools. This approach leads to a significant file size gain relative to lossless approaches at the expense of a relatively modest decrease in image quality (see example images below).
Stars: ✭ 3,074 (+264.22%)
Mutual labels:  image-processing, image-compression, compression
Gaussianblur
An easy and fast library to apply gaussian blur filter on any images. 🎩
Stars: ✭ 473 (-43.96%)
Mutual labels:  image-processing, image-compression
Halide
a language for fast, portable data-parallel computation
Stars: ✭ 4,722 (+459.48%)
Mutual labels:  image-processing, performance
Watchdoginspector
Shows your current framerate (fps) in the status bar of your iOS app
Stars: ✭ 497 (-41.11%)
Mutual labels:  performance-monitoring, performance
Youku Sdk Tool Woodpecker
In-app-debug tool for iOS
Stars: ✭ 600 (-28.91%)
Mutual labels:  performance, performance-testing
Sharp
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Stars: ✭ 21,131 (+2403.67%)
Mutual labels:  image-processing, performance
Inspectit
inspectIT is the leading Open Source APM (Application Performance Management) tool for analyzing your Java (EE) applications.
Stars: ✭ 513 (-39.22%)
Mutual labels:  performance, performance-testing
Caesium Image Compressor
Caesium is a cross-platform image compression software aimed at helping photographers, bloggers, webmasters, businesses or casual users at storing, sending and sharing digital pictures. Based on libcaesium.
Stars: ✭ 595 (-29.5%)
Mutual labels:  image-compression, compression
Dwarfs
A fast high compression read-only file system
Stars: ✭ 444 (-47.39%)
Mutual labels:  performance, compression
Performance
⏱ PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
Stars: ✭ 429 (-49.17%)
Mutual labels:  performance, performance-testing
Processhacker
A free, powerful, multi-purpose tool that helps you monitor system resources, debug software and detect malware.
Stars: ✭ 6,285 (+644.67%)
Mutual labels:  performance-monitoring, performance
Resizer
An image resizing library for Android
Stars: ✭ 406 (-51.9%)
Mutual labels:  image-processing, image-compression
Automon
Automon combines the power of AOP (AspectJ) with monitoring or logging tools you already use to declaratively monitor your Java code, the JDK, and 3rd party libraries.
Stars: ✭ 548 (-35.07%)
Mutual labels:  performance-monitoring, performance
Tcpreplay
Pcap editing and replay tools for *NIX and Windows - Users please download source from
Stars: ✭ 745 (-11.73%)
Mutual labels:  performance, performance-testing
Imgp
📸 High-performance cli batch image resizer and rotator
Stars: ✭ 744 (-11.85%)
Mutual labels:  image-processing, image-compression
Falco
Falco helps you monitor, analyze, and optimize your websites.
Stars: ✭ 752 (-10.9%)
Mutual labels:  performance-monitoring, performance-testing
Drill
Drill is a HTTP load testing application written in Rust inspired by Ansible syntax
Stars: ✭ 767 (-9.12%)
Mutual labels:  performance, performance-testing

Calibre Image Actions

Introduction

Image Actions is a Github Action built by performance experts at Calibre that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.

Image Actions offers:

  • Fast, efficient and near-lossless compression
  • Best image compression algorithms available (mozjpeg and libvips)
  • Ease of customisation: use default settings or adapt to your needs
  • Running on demand or schedule

...and more!

Table of Contents

Usage

  1. Create a .github/workflows/calibreapp-image-actions.yml file in your repository with the following configuration:
name: Compress Images
on:
  pull_request:
    # Run Image Actions when JPG, JPEG, PNG or WebP files are added or changed.
    # See https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths for reference.
    paths:
      - '**.jpg'
      - '**.jpeg'
      - '**.png'
      - '**.webp'
jobs:
  build:
    # Only run on Pull Requests within the same repository, and not from forks.
    if: github.event.pull_request.head.repo.full_name == github.repository
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/[email protected]

      - name: Compress Images
        uses: calibreapp/[email protected]
        with:
          # The `GITHUB_TOKEN` is automatically generated by GitHub and scoped only to the repository that is currently running the action. By default, the action can’t update Pull Requests initiated from forked repositories.
          # See https://docs.github.com/en/actions/reference/authentication-in-a-workflow and https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
          githubToken: ${{ secrets.GITHUB_TOKEN }}
  1. Open a Pull Request with added or changed imagery. Image Actions will process the files and post a comment, like so:

Calibre Image Actions Preview

  1. Merge your Pull Request and enjoy lighter images or explore what’s possible further with configuration options. 👇🏻

Configuration

By default, Image Actions will compress images so that they’re smaller and will leave your assets looking clear and crisp. If you want to change or expand those defaults, read on for available options.

⚠️ If you are using an older version of Image Actions referencing .github/calibre/image-actions.yml, we suggest you migrate to the latest configuration format.

Control image quality settings

Add the following arguments to the workflow definition to control compression settings:

with:
  jpegQuality: '80'
  jpegProgressive: false
  pngQuality: '80'
  webpQuality: '80'

Options:

  • jpegQuality: Number, integer 1-100, default 80 stored in a string.
  • jpegProgressive: Boolean, true or false, default false.
  • pngQuality: Number, integer 1-100, default 80 stored in a string.
  • webpQuality: Number, integer 1-100, default 80 stored in a string.

Ignore paths

Add the following argument to the workflow definition to ignore selected paths:

with:
  ignorePaths: 'node_modules/**,build'

ignorePaths accepts a comma-separated string with globbing support of paths to ignore when looking for images to compress.

Run compression only

By default, Image Actions adds optimised images to the current Pull Request and posts a summary comment.

Use the compressOnly option with true value to skip the commit and summary comment if you want to handle this separately (including for forks):

with:
  compressOnly: true

compressOnly accepts a Boolean value (true or false) and defaults to false.

Compress on demand or on schedule

It is also possible to run Image Actions on demand or on a recurring schedule. By using the compressOnly option, in conjunction with create-pull-request action by @peter-evans, a new Pull Request will be raised if there are optimised images in a repository.

See an example below:

# Compress images on demand (workflow_dispatch), and at 11pm every Sunday (schedule).
# Open a Pull Request if any images can be compressed.
name: Compress Images
on:
  workflow_dispatch:
  schedule:
    - cron: '00 23 * * 0'
jobs:
  build:
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/[email protected]
      - name: Compress Images
        id: calibre
        uses: calibreapp/[email protected]
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          compressOnly: true
      - name: Create New Pull Request If Needed
        if: steps.calibre.outputs.markdown != ''
        uses: peter-evans/[email protected]
        with:
          title: Compressed Images Nightly
          branch-suffix: timestamp
          commit-message: Compressed Images
          body: ${{ steps.calibre.outputs.markdown }}

Process Pull Requests from forked repositories

By default, GitHub Actions do not have permission to alter forked repositories. For this reason, Image Actions only works for Pull Requests from branches in the same repository as the destination branch. There are several workarounds for this limitation:

  1. Replace the default GITHUB_TOKEN with a Personal Access Token (PAT) which does have permission to access forked repositories. Be aware that this introduces potential security concerns (which is why it not available by default).

  2. Run Image Actions only for Pull Requests in the current repository. This approach is advised when not using Personal Access Tokens (PATs) to avoid wasting time and compute for compressions that will not be committed. Use the following configuration to check if a Pull Request belongs to the repository:

if: github.event.pull_request.head.repo.full_name == github.repository
  1. Run an additional instance of Image Actions in compressOnly mode on pushes to main, and then raise a new Pull Request for any images committed without being compressed (e.g. from a forked repository PR). See the configuration in the below example which uses the create-pull-request action by @peter-evans to open the new Pull Request (this only raises a Pull Request if any files are changed in previous steps).
name: Compress Images on Push to main branch
on:
  push:
    branches:
      - main
    paths:
      - '**.jpg'
      - '**.jpeg'
      - '**.png'
      - '**.webp'
jobs:
  build:
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/[email protected]
      - name: Compress Images
        id: calibre
        uses: calibreapp/[email protected]
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          compressOnly: true
      - name: Create New Pull Request If Needed
        if: steps.calibre.outputs.markdown != ''
        uses: peter-evans/[email protected]
        with:
          title: Compressed Images
          branch-suffix: timestamp
          commit-message: Compressed Images
          body: ${{ steps.calibre.outputs.markdown }}

Combined workflow

You can combine all of the above customisation options into one all-encompassing workflow to avoid having to set up separate workflows with a lot of duplication.

The example below ensures the right order of task execution within Image Actions. If you’d like to reuse it, make sure to change example/example_repo to your repository details.

# Image Actions will run in the following scenarios:
# - on Pull Requests containing images (not including forks)
# - on pushing of images to `main` (for forks)
# - on demand (https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/)
# - at 11 PM every Sunday in anything gets missed with any of the above scenarios
# For Pull Requests, the images are added to the PR.
# For other scenarios, a new PR will be opened if any images are compressed.
name: Compress images
on:
  pull_request:
    paths:
      - '**.jpg'
      - '**.jpeg'
      - '**.png'
      - '**.webp'
  push:
    branches:
      - main
    paths:
      - '**.jpg'
      - '**.jpeg'
      - '**.png'
      - '**.webp'
  workflow_dispatch:
  schedule:
    - cron: '00 23 * * 0'
jobs:
  build:
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    # Only run on main repo on and PRs that match the main repo.
    if: |
      github.repository == 'example/example_repo' &&
      (github.event_name != 'pull_request' ||
       github.event.pull_request.head.repo.full_name == github.repository)
    steps:
      - name: Checkout Branch
        uses: actions/[email protected]
      - name: Compress Images
        id: calibre
        uses: calibreapp/[email protected]
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          # For non-Pull Requests, run in compressOnly mode and we'll PR after.
          compressOnly: ${{ github.event_name != 'pull_request' }}
      - name: Create Pull Request
        # If it's not a Pull Request then commit any changes as a new PR.
        if: |
          github.event_name != 'pull_request' &&
          steps.calibre.outputs.markdown != ''
        uses: peter-evans/[email protected]
        with:
          title: Auto Compress Images
          branch-suffix: timestamp
          commit-message: Compress Images
          body: ${{ steps.calibre.outputs.markdown }}

Migrate legacy configuration

If you are using an older version of Image Actions, we recommend checking that your settings are up-to-date.

Uses and GITHUB_TOKEN definition

If your calibreapp-image-actions.yml file has a reference to docker:// or GITHUB_TOKEN as follows:

- name: calibreapp/image-actions
    uses: docker://calibreapp/github-image-actions
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Update your configuration to:

- name: Compress Images
  uses: calibreapp/[email protected]
  with:
    githubToken: ${{ secrets.GITHUB_TOKEN }}

Location and name of the configuration file

If your repository uses .github/calibre/image-actions.yml for configuration, it should be moved into .github/workflows/calibreapp-image-actions.yml. Then delete the image-actions.yml file.

Listing ignorePaths

ignorePaths is no longer an array and is now a comma separated list. E.g. ignorePaths: "node_modules/**,bin".

Contributing

To submit a feature, bug fix, or enhancement to Image Actions, follow these steps:

  1. Fork this repository.
  2. Install dependencies with npm install.
  3. Run npm run build or npm run watch (for continuous rebuild-on-save) to build the project.
  4. Make desired changes.
  5. Run npm run test to run the test suite.
  6. Confirm a successful Docker build with docker build -t calibreapp/image-actions:dev ..
  7. Open a Pull Request and follow the prompts.

We value and appreciate all contributions.

Used By

Image Actions is helping developers, designers and organisations across the world to make their sites and applications faster. Here’s some of them:

Authors

Resources

Related reading:

Image compression tools:

License

Image Actions is licensed under a GNU General Public License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].