Skip to content

Commit

Permalink
revert back to 3.1.0 tag
Browse files Browse the repository at this point in the history
  • Loading branch information
zoellner committed Oct 31, 2023
1 parent 14b99c6 commit f6421a2
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 285 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,3 @@ typings/
.aws-sam
samconfig.toml
packaged-template.yaml

tmp
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ AWS Lambda Layer providing [sharp](https://github.com/lovell/sharp) with HEIC (a

## Prerequisites

* Docker
* [SAM v1.33.0 or higher](https://github.com/awsdocs/aws-sam-developer-guide/blob/master/doc_source/serverless-sam-cli-install.md)
* Node v18 (for v4.x)
* Docker
* [SAM v1.33.0 or higher](https://github.com/awsdocs/aws-sam-developer-guide/blob/master/doc_source/serverless-sam-cli-install.md)
* Node v16 (for v3.x)

## Usage

Due to potential license concerns for the HEVC patent group, this repo can't be provided in the most convenient way which would be a shared lambda layer or an Application in the AWS Serverless Repo.

But you can compile and deploy this lambda layer yourself at your own risk and use it wihin your own accounts. All you need is an S3 bucket to deploy the compiled code to (replace `your-s3-bucket` in the code snippet below). Please see the note below regarding the build process.

It is recommended to automate this process using AWS CodeBuild. A buildspec file is provided in the repo. In that case you'll have to set the `SAM_BUCKET` environment variable in CodeBuild. For other environment variables see the table below. The base image that should be used is `aws/codebuild/amazonlinux2-x86_64-standard:5.0`.
It is recommended to automate this process using AWS CodeBuild. A buildspec file is provided in the repo. In that case you'll have to set the `SAM_BUCKET` environment variable in CodeBuild. For other environment variables see the table below. The base image that should be used is `aws/codebuild/amazonlinux2-x86_64-standard:4.0`.

A sample CloudFormation template is provided to setup the CodeBuild project, [sample-buildproject.yaml](sample-buildproject.yaml).

Expand Down Expand Up @@ -67,21 +67,19 @@ This lambda layer contains the node module [sharp](https://github.com/lovell/sha

### Dependencies
The following table lists the release version of this repo together with the version of each dependency. Patch versions are related to the build process or documentation and have the same dependencies as the minor version.
| release | sharp | libvips | libheif | libwebp | libde265 | nodejs |
|---------|--------|---------|---------|---------|-----------|--------|
| 1.1.0 | 0.27.0 | 8.10.5 | 1.10.0 | 1.1.0 | 1.0.8 | 12 |
| 1.2.0 | 0.28.2 | 8.10.6 | 1.12.0 | 1.2.0 | 1.0.8 | 12 |
| 2.0.0 | 0.29.1 | 8.11.3 | 1.12.0 | 1.2.1 | 1.0.8 | 14 |
| 3.0.0 | 0.30.7 | 8.12.2 | 1.12.0 | 1.2.4 | 1.0.8 | 16 |
| 3.1.0 | 0.30.7 | 8.12.2 | 1.12.0 | 1.2.4 | 1.0.8 | 16 |
| 4.0.0 | 0.30.7 | 8.12.2 | 1.12.0 | 1.2.4 | 1.0.8 | 18 |
<!-- | 4.0.0 | 0.32.6 | 8.14.5 | 1.17.1 | 1.3.2 | 1.0.12 | 18 | -->
| release | sharp | libvips | libheif | libwebp | libde265 | nodejs |
|---------|--------|---------|---------|---------|----------|--------|
| 1.1.0 | 0.27.0 | 8.10.5 | 1.10.0 | 1.1.0 | 1.0.8 | 12 |
| 1.2.0 | 0.28.2 | 8.10.6 | 1.12.0 | 1.2.0 | 1.0.8 | 12 |
| 2.0.0 | 0.29.1 | 8.11.3 | 1.12.0 | 1.2.1 | 1.0.8 | 14 |
| 3.0.0 | 0.30.7 | 8.12.2 | 1.12.0 | 1.2.4 | 1.0.8 | 16 |
| 3.1.0 | 0.30.7 | 8.12.2 | 1.12.0 | 1.2.4 | 1.0.8 | 16 |

### CompatibleRuntimes
- `nodejs12.x` (v1.x)
- `nodejs14.x` (v2.x)
- `nodejs16.x` (v3.x)
- `nodejs18.x` (v4.x)


## Contributions
If you would like to contribute to this repository, please open an issue or submit a PR.
Expand Down
4 changes: 3 additions & 1 deletion buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ env:
phases:
install:
runtime-versions:
nodejs: 18
nodejs: 16
commands:
- pip3 install aws-sam-cli --upgrade --user
pre_build:
commands:
- NODE_ENV=development npm ci
Expand Down
64 changes: 20 additions & 44 deletions layer/Makefile
Original file line number Diff line number Diff line change
@@ -1,76 +1,52 @@
# Library Versions
WEBP_VERSION=1.3.2
LIBDE265_VERSION=1.0.12
LIBHEIF_VERSION=1.17.1
VIPS_VERSION=8.14.5
SHARP_VERSION=0.32.6
WEBP_VERSION=1.2.4
LIBDE265_VERSION=1.0.8
LIBHEIF_VERSION=1.12.0
VIPS_VERSION=8.12.2
SHARP_VERSION=0.30.7

PREFIX_PATH=/usr/local
LIB_PATH=$(PREFIX_PATH)/lib64
LIBRARY_PATH=$(LIB_PATH)
EXAMPLE_IMAGE_PATH=$(CURDIR)/example-images
PREFIX_PATH=/opt

export PKG_CONFIG_PATH=$(LIB_PATH)/pkgconfig
export LD_LIBRARY_PATH=$(LIB_PATH):$$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$(PREFIX_PATH)/lib/pkgconfig

build-SharpHEICLayer: libvips
mkdir -p "$(ARTIFACTS_DIR)/nodejs"
mkdir -p "$(ARTIFACTS_DIR)/lib"

# sharp uses several of the libs we installed or compiled. extract the full list and copy all of those into $(ARTIFACTS_DIR)/lib
# extract list with ldd from sharp.node, manipulate a bit to only get the absolute paths, then copy

PKG_CONFIG_PATH=$(LIB_PATH)/pkgconfig LD_LIBRARY_PATH=$(LIB_PATH) npm install --prefix "$(ARTIFACTS_DIR)/nodejs/" --verbose --foreground-scripts sharp@$(SHARP_VERSION)
PKG_CONFIG_PATH=$(LIB_PATH)/pkgconfig LD_LIBRARY_PATH=$(LIB_PATH) ldd $(ARTIFACTS_DIR)/nodejs/node_modules/sharp/build/Release/sharp-linux-x64.node | awk 'BEGIN{OFS=" "}{ print $$3 }' | grep '/' | xargs -I '{}' cp '{}' $(ARTIFACTS_DIR)/lib

# debug logs
PKG_CONFIG_PATH=$(LIB_PATH)/pkgconfig LD_LIBRARY_PATH=$(LIB_PATH) ldd $(ARTIFACTS_DIR)/nodejs/node_modules/sharp/build/Release/sharp-linux-x64.node
ls -la $(ARTIFACTS_DIR)/lib
# sharp uses several of the libs we installed or compiled. extract the full list and copy all of those into /opt/lib
# extract list with ldd from sharp.node, manipulate a bit with sed to only get the absolute paths, then copy
LD_LIBRARY_PATH=$(PREFIX_PATH)/lib npm --prefix "$(ARTIFACTS_DIR)/nodejs/" install sharp@$(SHARP_VERSION)
LD_LIBRARY_PATH=$(PREFIX_PATH)/lib ldd $(ARTIFACTS_DIR)/nodejs/node_modules/sharp/build/Release/sharp-linux-x64.node | sed -nE "s/^[^\/\n]*(\/[^ ]+)(.*)/\1/p" | xargs cp -t $(ARTIFACTS_DIR)/lib

libwebp:
curl -L https://github.com/webmproject/libwebp/archive/v$(WEBP_VERSION).tar.gz | tar zx
cd libwebp-$(WEBP_VERSION) && ./autogen.sh && ./configure --enable-libwebpmux --prefix=$(PREFIX_PATH) && make V=0 && make install

libde265:
# libde265
curl -L https://github.com/strukturag/libde265/releases/download/v$(LIBDE265_VERSION)/libde265-$(LIBDE265_VERSION).tar.gz | tar zx
cd libde265-$(LIBDE265_VERSION) && ./autogen.sh && ./configure --disable-dec265 --disable-sherlock265 --prefix=$(PREFIX_PATH) && make V=0 && make install

libheif: libde265
# libheif
curl -L https://github.com/strukturag/libheif/releases/download/v$(LIBHEIF_VERSION)/libheif-$(LIBHEIF_VERSION).tar.gz | tar zx
cd libheif-$(LIBHEIF_VERSION) && mkdir build && cd build && cmake -DCMAKE_INSTALL_LIBDIR=$(LIB_PATH) --preset=release .. && make && make install
cd libheif-$(LIBHEIF_VERSION) && ./autogen.sh && ./configure --prefix=$(PREFIX_PATH) && make V=0 && make install

libvips: installLib
libvips: installLib libheif libwebp
# libvips
curl -L https://github.com/libvips/libvips/releases/download/v$(VIPS_VERSION)/vips-$(VIPS_VERSION).tar.xz | tar xJ
cd vips-$(VIPS_VERSION) && meson setup build -Dexamples=true && cd build && meson compile && meson test && meson install

# libheif: libde265
# # libheif
# curl -L https://github.com/strukturag/libheif/releases/download/v$(LIBHEIF_VERSION)/libheif-$(LIBHEIF_VERSION).tar.gz | tar zx
# cd libheif-$(LIBHEIF_VERSION) && ./autogen.sh && ./configure --prefix=$(PREFIX_PATH) && make V=0 && make install
# cd libheif-$(LIBHEIF_VERSION)/examples && ./heif-convert example.heic example.jpeg && cp example*.jpeg $(EXAMPLE_IMAGE_PATH) && cp example.heic $(EXAMPLE_IMAGE_PATH)

# libvips: installLib libheif libwebp
# # libvips
# curl -L https://github.com/libvips/libvips/releases/download/v$(VIPS_VERSION)/vips-$(VIPS_VERSION).tar.gz | tar zx
# cd vips-$(VIPS_VERSION) && ./configure --prefix=$(PREFIX_PATH) && make V=0 && make install
# cd vips-$(VIPS_VERSION)/tools && ./vips rot $(EXAMPLE_IMAGE_PATH)/example.heic $(EXAMPLE_IMAGE_PATH)/example-rot.jpeg d90
curl -L https://github.com/libvips/libvips/releases/download/v$(VIPS_VERSION)/vips-$(VIPS_VERSION).tar.gz | tar zx
cd vips-$(VIPS_VERSION) && ./configure --prefix=$(PREFIX_PATH) && make V=0 && make install

installLib:
dnf groupinstall -y "Development Tools" -x system-rpm-config && \
dnf install -y \
yum install -y yum-plugin-ovl && \
yum install -y \
glib2-devel \
expat-devel \
libjpeg-devel \
libjpeg-turbo-devel \
libpng-devel \
giflib-devel \
libexif-devel \
librsvg2-devel \
libtiff-devel \
lcms2-devel \
gobject-introspection-devel \
cmake \
pkgconfig \
meson \
ninja-build
lcms2-devel
4 changes: 2 additions & 2 deletions layer/src/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "sharp-heic",
"version": "4.0.0",
"version": "2.0.2",
"description": "",
"main": "index.js",
"scripts": {},
"author": "Andreas Zoellner",
"license": "MIT",
"devDependencies": {},
"engines": {
"node": ">=18.0"
"node": ">=16.0"
},
"dependencies": {
"sharp": "^0.30.7"
Expand Down
Loading

0 comments on commit f6421a2

Please sign in to comment.