{"id":51307645,"url":"https://github.com/block/microfilm","last_synced_at":"2026-07-01T01:02:39.792Z","repository":{"id":351405327,"uuid":"1210863083","full_name":"block/microfilm","owner":"block","description":"A Gradle plugin that automatically manages image asset compression for Android.","archived":false,"fork":false,"pushed_at":"2026-06-23T21:21:47.000Z","size":1019,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-23T22:24:24.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/block.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-14T20:43:19.000Z","updated_at":"2026-06-23T21:21:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/block/microfilm","commit_stats":null,"previous_names":["block/microfilm"],"tags_count":3,"template":false,"template_full_name":"block/oss-project-template","purl":"pkg:github/block/microfilm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block%2Fmicrofilm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block%2Fmicrofilm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block%2Fmicrofilm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block%2Fmicrofilm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/block","download_url":"https://codeload.github.com/block/microfilm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block%2Fmicrofilm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34988714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-01T01:02:38.899Z","updated_at":"2026-07-01T01:02:39.781Z","avatar_url":"https://github.com/block.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Microfilm\n\nUncompressed PNG images bloat your app's binary. The Android Asset Packaging Tool (AAPT) applies some compression by default, but the compression it applies is suboptimal. You can get better results by compressing the images yourself, but there are a couple of problems with that approach. Each time you add or update an image resource, you have to:\n1. Apply compression manually. If you're new to a project, you might not know to do this. Even if you do know, it's easy to forget.\n2. Choose compression settings. It's not obvious what settings were used to compress other images in the repo, so it's hard to stay consistent.\n\nMicrofilm solves both of these problems by automatically compressing resource images from PNG to WebP (Google's [recommended image format](https://developer.android.com/topic/performance/reduce-apk-size#use-webp)) using explicitly configured compression settings. If Microfilm detects an uncompressed PNG that it doesn't expect, it fails the build and suggests a fix.\n\n## Compression\n\n### Step 1: Add the Microfilm Plugin\n\nIn the `build.gradle.kts` file of an Android application or library module, add:\n\n```kotlin\nplugins {\n  id(\"xyz.block.microfilm\") version \"0.2.1\"\n}\n```\n\n### Step 2: Configure the Microfilm Plugin\n\nIn the same `build.gradle.kts` file, specify the images that you want to compress, and the compression settings that you want to use.\n\nTo use lossless compression for all images, add:\n```kotlin\nmicrofilm {\n  compress {\n    lossless = true\n  }\n}\n```\n\nTo use lossless compression for some images, lossy compression for others, and to exclude still others from compression entirely, add:\n```kotlin\nmicrofilm {\n  compress {\n    lossless = true\n  }\n\n  compress(\"**/*_lossy.png\") {\n    lossless = false\n    compressionFactor = 90\n  }\n\n  exclude(\"**/*_excluded.png\")\n}\n```\n\n### Step 3: Add a PNG Image Resource\n\nAdd a PNG image to any of the Drawable folders within your module's resources folder (e.g. `res/drawable`, `res/drawable-hdpi`).\n\n### Step 4: Compress the PNG Image Resource\n\nRun the generic compression task with:\n\n```shell\n./gradlew my-module:compressMicrofilm\n```\n\nOr the compression task for individual source sets with:\n\n```shell\n./gradlew my-module:compressMicrofilmDebug\n./gradlew my-module:compressMicrofilmRelease\n```\n\nThe compression task does three things:\n1. Moves uncompressed PNG images from the `res` directory to the `microfilm` directory.\n2. Generates compressed WebP images in the `res` directory.\n3. Generates a manifest file in the `microfilm` directory that tracks the image hashes and the compression settings.\n\nThe resulting manifest file will look something like this:\n```json\n{\n  \"entries\": [\n    {\n      \"sourcePath\": \"drawable/my_image.png\",\n      \"sourceSha256\": \"bf4efed5cf7bf4bd245c7a02c2a7a2753621040a729eb2d4eb4a4950fc56324e\",\n      \"compressedPath\": \"drawable/my_image.webp\",\n      \"compressedSha256\": \"c8493453b732d871601cfe03a8c1fc9d652817991e8e2aec8ca6a56df9dbde4d\",\n      \"compressor\": {\n        \"name\": \"cwebp\",\n        \"version\": \"1.6.0\",\n        \"lossless\": true\n      }\n    }\n  ]\n}\n```\n\nCheck this manifest into source control, along with the uncompressed PNG images and the compressed WebP images.\n\n## Verification\n\nRun the generic verification task with:\n\n```shell\n./gradlew my-module:verifyMicrofilm\n```\n\nOr the verification task for individual source sets with:\n\n```shell\n./gradlew my-module:verifyMicrofilmDebug\n./gradlew my-module:verifyMicrofilmRelease\n```\n\nVerification is wired into the standard `check` task, so you can also simply run:\n\n```shell\n./gradlew my-module:check\n```\n\nThe verification task ensures that the images and the compression settings in the manifest file match what's actually in the module. If a PNG image has been added/changed/removed, or if the compression settings in the Gradle module have changed, then the task will report a failure.\n\n## Modules\n\n* [cwebp](cwebp): The cwebp executable, packaged into platform-specific dependencies (currently Mac and Linux).\n* [plugin](plugin): The Gradle plugin, with logic to compress and verify resource images.\n* [sample](sample): A sample Android project that demonstrates usage of the plugin.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblock%2Fmicrofilm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblock%2Fmicrofilm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblock%2Fmicrofilm/lists"}