Socket
Socket
Sign inDemoInstall

com.diffplug.gradle:image-grinder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.diffplug.gradle:image-grinder

Image manipulation for Gradle


Version published
Maintainers
1
Source

ImageGrinder:
image manipulation for Gradle

Gradle plugin Maven central Apache 2.0

Changelog Javadoc Live chat CircleCI

Simple image processing

To use it, just add image-grinder to your buildscript, and configure it as so:

imageGrinder {
    // creates a task called 'processEclipseSvg', you can name it whatever you want
    // if the name starts with 'process', then the 'processResources' task will depend on it
    processEclipseSvg {
        srcDir = file('src')
        dstDir = file('dst')
        grinder { img ->
            img.render('.png')
            img.render('@2x.png', 2)
        }
        // used for up-to-date checking, bump this if the function above changes
        bumpThisNumberWhenTheGrinderChanges = 1
    }
}

Every single file in srcDir needs to be an image that ImageGrinder can parse. Each image will be parsed, and wrapped into an Img. Call its methods to grind it into whatever you need in the dstDir.

ImageGrinder uses the gradle Worker API to use all your CPU cores for grinding, the buildcache to minimize the necessary work, and it also supports the configuration cache for near-instant startup times. It does not currently support incremental update, but if you go back to 2.1.3 you can get that back in return for losing the configuration cache (see #9 for details).

Configuration avoidance

The plugin creates tasks eagerly. If you wish to avoid this, you can rewrite the example above like this:

def processEclipseSvg = tasks.register('processEclipseSvg', com.diffplug.gradle.imagegrinder.ImageGrinderTask) {
    srcDir = file('src')
    dstDir = file('dst')
    grinder { img ->
        img.render('.png')
        img.render('@2x.png', 2)
    }
    // used for up-to-date checking, bump this if the function above changes
    bumpThisNumberWhenTheGrinderChanges = 1
}
tasks.named(JavaPlugin.PROCESS_RESOURCES_TASK_NAME) {
  dependsOn processSvg
}

Limitations

  • ImageGrinder can only read SVG images.
  • ImageGrinder can only write PNG images.
  • ImageGrinder needs Gradle 6.0 or higher.

Not much of a grinder, but it does everything we needed. If you need more, we're happy to take PR's!

Acknowledgements

FAQs

Package last updated on 04 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc