Skip to content

Instantly share code, notes, and snippets.

@neoneye
Last active November 20, 2022 14:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save neoneye/00fad388e38f5b0361f66cc1a3b2f57e to your computer and use it in GitHub Desktop.
Save neoneye/00fad388e38f5b0361f66cc1a3b2f57e 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
@fosini
Copy link

fosini commented Jun 28, 2018

Great, thanks.

@adityatandon007
Copy link

adityatandon007 commented Jun 29, 2018

Needed this, very badly. Thanks for the rescue buddy 👍

@PARAGJYOTI
Copy link

Thank you so much.

In case libpng12-0 doesn't work install libpng-dev instead.

@dattran92
Copy link

nice instruction. thanks so much. one thing to added is to install the build tool if not already.

sudo apt-get install build-essential

@karljinang
Copy link

remember to reboot after all the steps above

@pmeisam
Copy link

pmeisam commented Aug 17, 2021

it wasn't working, I had to install the build tool first sudo apt-get install build-essential
you are a lifesaver, thank you

@andreafalzetti
Copy link

If you are having issues downloading from the FTP host, it was deprecated due to abuse.

It's recommended to download it from SourceForge

ARG GM_VERSION=1.3.38

wget https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/${GM_VERSION}/GraphicsMagick-${GM_VERSION}.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment