Skip to content

Instantly share code, notes, and snippets.

@amit08255
Forked from neoneye/guide.md
Created November 20, 2022 14:26
Show Gist options
  • Save amit08255/fa64a464fbdbb164b4e48236c59f8c1e to your computer and use it in GitHub Desktop.
Save amit08255/fa64a464fbdbb164b4e48236c59f8c1e to your computer and use it in GitHub Desktop.
Install GraphicsMagick on AWS EC2 running Ubuntu Linux

I use GM to render thumbnails of png and jpg images.

Sadly the GM installation guide doesn't describe how to get things working on AWS EC2.

http://www.graphicsmagick.org/INSTALL-unix.html

Prepare for installing GraphicsMagick

PROMPT> sudo apt-get update
PROMPT> sudo apt-get install libpng12-0
PROMPT> sudo apt-get install libjpeg-dev
PROMPT> sudo apt-get install ghostscript
PROMPT> sudo apt-get install libtiff5-dev
PROMPT> sudo apt-get install libfreetype6
PROMPT> sudo apt-get install libfreetype6-dev

Download GraphicsMagick's source code (9 MB). This takes about 10 minutes

PROMPT> wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.26.tar.gz

Unzip and configure GraphicsMagick

PROMPT> tar xzvf GraphicsMagick-1.3.26.tar.gz
PROMPT> cd GraphicsMagick-1.3.26
PROMPT> ./configure

Check that the result of configure looks like this

It must have png and jpg support, otherwise GraphicsMagick won't be to much help making thumbnails.

GraphicsMagick is configured as follows. Please verify that this
configuration matches your expectations.

Host system type : x86_64-unknown-linux-gnu
Build system type : x86_64-unknown-linux-gnu

Option            Configure option           	Configured value
-----------------------------------------------------------------
Shared libraries  --enable-shared=no    	no
Static libraries  --enable-static=yes    	yes
GNU ld            --with-gnu-ld=yes        	yes
Quantum depth     --with-quantum-depth=8 	8
Modules           --with-modules=no        	no

Delegate Configuration:
BZLIB             --with-bzlib=yes          	no
DPS               --with-dps=yes              	no
FlashPIX          --with-fpx=no              	no
FreeType 2.0      --with-ttf=yes          	yes
Ghostscript       None                   	gs (9.18)
Ghostscript fonts --with-gs-font-dir=default    /usr/share/fonts/type1/gsfonts/
Ghostscript lib   --with-gslib=no       	no
JBIG              --with-jbig=yes        	yes
JPEG v1           --with-jpeg=yes        	yes
JPEG-2000         --with-jp2=yes          	no
LCMS v2           --with-lcms2=yes        	no
LZMA              --with-lzma=yes        	yes
Magick++          --with-magick-plus-plus=yes 	yes
PERL              --with-perl=no            	no
PNG               --with-png=yes          	yes (-lpng12)
TIFF              --with-tiff=yes        	yes
TRIO              --with-trio=yes        	no
WEBP              --with-webp=yes        	no
Windows fonts     --with-windows-font-dir=	none
WMF               --with-wmf=yes          	no
X11               --with-x=             	no
XML               --with-xml=yes          	yes
ZLIB              --with-zlib=yes        	yes

X11 Configuration:

  Not using X11.

Options used to compile and link:
  CC       = gcc
  CFLAGS   = -fopenmp -g -O2 -Wall -pthread
  CPPFLAGS = -I/usr/include/freetype2 -I/usr/include/libxml2
  CXX      = g++
  CXXFLAGS = -pthread
  DEFS     = -DHAVE_CONFIG_H
  LDFLAGS  = 
  LIBS     = -ljbig -ltiff -lfreetype -ljpeg -lpng12 -llzma -lxml2 -lz -lm -lgomp -lpthread

Compile GraphicsMagick

PROMPT> make
PROMPT> sudo make install

Check GraphicsMagick version

PROMPT> gm version
GraphicsMagick 1.3.26 2017-07-04 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2017 GraphicsMagick Group.

Obtain path to gm

PROMPT> which gm
/usr/local/bin/gm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment