Skip to content

Commit

Permalink
Support webp in linux os with aarch64 architecture (#286)
Browse files Browse the repository at this point in the history
* Add webp binaries for linux-aarch64

* Detect linux os with aarch64 architecture

* Update README.md

linux-aarch64 binaries are included
  • Loading branch information
wafflejuice authored Apr 23, 2024
1 parent c6374ae commit 6e78255
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/webp.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Scrimage provides support for webp through the `scrimage-webp` module. To use webp, add this module to your build.

This module uses the `dwebp`, `cwebp` and `gif2webp` binaries, created by Google. The `scrimage-webp` module comes with the
linux_x64, window_x64, mac-x64 and mac-arm64 binaries already included (see required [copyright notice](https://github.com/sksamuel/scrimage/blob/master/scrimage-webp/src/main/resources/dist_webp_binaries/LICENSE)).
linux_x64, linux_aarch64, window_x64, mac-x64 and mac-arm64 binaries already included (see required [copyright notice](https://github.com/sksamuel/scrimage/blob/master/scrimage-webp/src/main/resources/dist_webp_binaries/LICENSE)).

Note: If you are using mac-arm64 then you must specify the system-property: `com.sksamuel.scrimage.webp.platform=mac-arm64` because scrimage is unable to detect mac-x64 from mac-arm64, and defaults to the former.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ protected static String[] getBinaryPaths(String binaryName) {
return macArm(binaryName);
} else if (SystemUtils.IS_OS_MAC) {
return macIntel(binaryName);
} else if (SystemUtils.IS_OS_LINUX && (osArch.startsWith("arm") || osArch.startsWith("aarch64"))) {
return linuxArm(binaryName);
} else {
return linux(binaryName);
}
Expand Down Expand Up @@ -115,6 +117,14 @@ private static String[] linux(String binaryName) {
};
}

private static String[] linuxArm(String binaryName) {
return new String[]{
"/webp_binaries/" + binaryName,
"/webp_binaries/linux/" + binaryName,
"/dist_webp_binaries/libwebp-1.3.2-linux-aarch64/bin/" + binaryName,
};
}

private static void setExecutable(Path output) throws IOException {
try {
new ProcessBuilder("chmod", "+x", output.toAbsolutePath().toString())
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 6e78255

Please sign in to comment.