Skip to content

Commit 18127a7

Browse files
committed
readme
1 parent f0832a8 commit 18127a7

File tree

2 files changed

+73
-32
lines changed

2 files changed

+73
-32
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ImageMagick for AWS Lambda (Amazon Linux 2)
2+
3+
Scripts to compile ImageMagick utilities for AWS Lambda instances powered by Amazon Linux 2.x, such as the `nodejs10.x` runtime.
4+
5+
Amazon Linux 2 instances for Lambda no longer contain system utilities, so `convert`, `mogrify` and `identify` from the [ImageMagick](https://imagemagick.org) package are no longer available.
6+
7+
## Prerequisites
8+
9+
* Docker desktop
10+
* Unix Make environment
11+
12+
## Compiling the code
13+
14+
* `make all`
15+
16+
The `Makefile` in the root directory just starts a Docker container matching the AWS Linux 2 environment for Lambda runtimes, and compiles a static version of ImageMagick tools. They will be in the `result` dir. By default, this compiles a version expecting to run as a Lambda layer from `/opt/imagemagick` (you can change the expected location in the (`Makefile`)[Makefile].
17+
18+
## Bundled libraries
19+
20+
This is not a full-blown ImageMagick setup you can expect on a regular Linux box, it's a slimmed down version to save space that works with the most common formats. You can add more formats by including another library into the build process in [`src/Makefile`](src/Makefile).
21+
* libpng
22+
* libtiff
23+
* libjpeg
24+
* openjpeg2
25+
26+
## Info on scripts
27+
28+
For more information, check out:
29+
30+
* https://imagemagick.org/script/install-source.php
31+
* http://www.linuxfromscratch.org/blfs/view/cvs/general/imagemagick.html
32+
33+
## Author
34+
35+
Gojko Adzic <https://gojko.net>
36+
37+
## License
38+
39+
* These scripts: [MIT](https://opensource.org/licenses/MIT)
40+
* ImageMagick: https://imagemagick.org/script/license.php
41+
* Contained libraries all have separate licenses, check the respective web sites for more information

src/Makefile

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11

2-
PNG_SOURCE=libpng-1.6.37.tar.xz
3-
JPG_SOURCE=jpegsrc.v9c.tar.gz
2+
LIBPNG_SOURCE=libpng-1.6.37.tar.xz
3+
LIBJPG_SOURCE=jpegsrc.v9c.tar.gz
44
OPENJP2_VERSION=2.3.1
55
OPENJP2_SOURCE=openjp2-$(OPENJP2_VERSION)
6+
LIBTIFF_SOURCE=tiff-4.0.9.tar.gz
67
IMAGE_MAGICK_SOURCE=ImageMagick.tar.gz
78
TARGET_DIR ?= /opt/imagemagick
89

@@ -11,62 +12,61 @@ TARGET_DIR ?= /opt/imagemagick
1112
$(IMAGE_MAGICK_SOURCE):
1213
curl -LO https://imagemagick.org/download/$(IMAGE_MAGICK_SOURCE)
1314

14-
$(JPG_SOURCE):
15-
curl -LO http://ijg.org/files/$(JPG_SOURCE)
15+
$(LIBJPG_SOURCE):
16+
curl -LO http://ijg.org/files/$(LIBJPG_SOURCE)
1617

17-
$(PNG_SOURCE):
18-
curl -LO http://prdownloads.sourceforge.net/libpng/$(PNG_SOURCE)
18+
$(LIBPNG_SOURCE):
19+
curl -LO http://prdownloads.sourceforge.net/libpng/$(LIBPNG_SOURCE)
1920

2021
$(OPENJP2_SOURCE):
2122
curl -L https://github.com/uclouvain/openjpeg/archive/v$(OPENJP2_VERSION).tar.gz -o $(OPENJP2_SOURCE)
2223

23-
$(TARGET_DIR)/lib/libpng.a: $(PNG_SOURCE)
24-
tar xf $(PNG_SOURCE) &&
24+
$(LIBTIFF_SOURCE):
25+
curl -LO http://download.osgeo.org/libtiff/$(LIBTIFF_SOURCE)
26+
27+
CONFIGURE = PKG_CONFIG_PATH=$(TARGET_DIR)/lib/pkgconfig ./configure CPPFLAGS=-I$(TARGET_DIR)/include LDFLAGS=-L$(TARGET_DIR)/lib --disable-dependency-tracking --disable-shared --enable-static --prefix=$(TARGET_DIR)
28+
29+
$(TARGET_DIR)/lib/libpng.a: $(LIBPNG_SOURCE)
30+
tar xf $(LIBPNG_SOURCE) &&
2531
cd libpng*
26-
./configure \
27-
--disable-dependency-tracking \
28-
--disable-shared \
29-
--enable-static \
30-
--prefix=$(TARGET_DIR)
32+
$(CONFIGURE)
3133
make
3234
make install
3335

34-
$(TARGET_DIR)/lib/libjpeg.a: $(JPG_SOURCE)
35-
tar xf $(JPG_SOURCE)
36+
$(TARGET_DIR)/lib/libjpeg.a: $(LIBJPG_SOURCE)
37+
tar xf $(LIBJPG_SOURCE)
3638
cd jpeg*
37-
./configure \
38-
--disable-dependency-tracking \
39-
--disable-shared \
40-
--enable-static \
41-
--prefix=$(TARGET_DIR)
39+
$(CONFIGURE)
40+
make
41+
make install
42+
43+
$(TARGET_DIR)/lib/libtiff.a: $(LIBTIFF_SOURCE) $(TARGET_DIR)/lib/libjpeg.a
44+
tar xf $(LIBTIFF_SOURCE) &&
45+
cd tiff-*
46+
$(CONFIGURE)
4247
make
4348
make install
4449

45-
$(TARGET_DIR)/lib/libopenjp2.a: $(OPENJP2_SOURCE) $(TARGET_DIR)/lib/libpng.a
50+
$(TARGET_DIR)/lib/libopenjp2.a: $(OPENJP2_SOURCE) $(TARGET_DIR)/lib/libpng.a $(TARGET_DIR)/lib/libtiff.a
4651
tar xf $(OPENJP2_SOURCE) &&
4752
cd openjpeg-*
4853
mkdir -p build
4954
cd build
50-
cmake .. \
55+
PKG_CONFIG_PATH=$(TARGET_DIR)/lib/pkgconfig cmake .. \
5156
-DCMAKE_BUILD_TYPE=Release \
5257
-DCMAKE_INSTALL_PREFIX=$(TARGET_DIR) \
53-
-DBUILD_SHARED_LIBS:bool=off
54-
make
58+
-DBUILD_SHARED_LIBS:bool=off \
59+
-DBUILD_CODEC:bool=off
60+
make clean
5561
make install
5662

57-
LIBS:=$(TARGET_DIR)/lib/libjpeg.a $(TARGET_DIR)/lib/libpng.a $(TARGET_DIR)/lib/libopenjp2.a
63+
LIBS:=$(TARGET_DIR)/lib/libjpeg.a $(TARGET_DIR)/lib/libpng.a $(TARGET_DIR)/lib/libopenjp2.a $(TARGET_DIR)/lib/libtiff.a
5864

5965
$(TARGET_DIR)/bin/identify: $(LIBS) $(IMAGE_MAGICK_SOURCE)
6066
tar xf $(IMAGE_MAGICK_SOURCE)
6167
cd ImageMa*
62-
PKG_CONFIG_PATH=$(TARGET_DIR)/lib/pkgconfig ./configure \
63-
CPPFLAGS=-I$(TARGET_DIR)/include \
64-
LDFLAGS=-L$(TARGET_DIR)/lib \
65-
--prefix=$(TARGET_DIR) \
66-
--disable-dependency-tracking \
68+
$(CONFIGURE) \
6769
--enable-delegate-build \
68-
--disable-shared \
69-
--enable-static \
7070
--without-modules \
7171
--disable-docs \
7272
--without-magick-plus-plus \

0 commit comments

Comments
 (0)