gnu: Add python-pyshp.
[jackhill/guix/guix.git] / gnu / packages / imagemagick.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
4 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
6 ;;; Copyright © 2016, 2021 Mark H Weaver <mhw@netris.org>
7 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
10 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
11 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
12 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages imagemagick)
29 #:use-module (guix packages)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system perl)
32 #:use-module (guix download)
33 #:use-module (guix utils)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages algebra)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages ghostscript)
40 #:use-module (gnu packages graphviz)
41 #:use-module (gnu packages gtk)
42 #:use-module (gnu packages image)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages xml)
45 #:use-module (gnu packages xorg)
46 #:use-module (srfi srfi-1))
47
48 ;; This is a variant of the 'imagemagick' package that is not updated often.
49 ;; It is intended to be used as a native-input at build-time only, e.g. by
50 ;; 'gtk-doc' (via 'dblatex') for generating package documentation. This
51 ;; allows the main 'imagemagick' package to be freely updated on the 'master'
52 ;; branch without triggering an excessive number of rebuilds.
53 ;;
54 ;; Normally the grafts mechanism would be used, but there are often
55 ;; difficulties grafting imagemagick, e.g. because upstream changes the ABI
56 ;; between micro version updates. Also, the overwhelming majority of
57 ;; dependencies on imagemagick are via 'gtk-doc' in 'native-inputs', where
58 ;; grafting is ineffective. See:
59 ;; <https://lists.gnu.org/archive/html/guix-devel/2021-03/msg00381.html>.
60 (define-public imagemagick/stable
61 (hidden-package
62 (package
63 (name "imagemagick")
64 ;; The 7 release series has an incompatible API, while the 6 series is still
65 ;; maintained. Don't update to 7 until we've made sure that the ImageMagick
66 ;; users are ready for the 7-series API.
67 (version "6.9.11-48")
68 (source (origin
69 (method url-fetch)
70 (uri (string-append "mirror://imagemagick/ImageMagick-"
71 version ".tar.xz"))
72 (sha256
73 (base32
74 "0m8nkmywkqwyrr01q7aiakj6mi4rb2psjgzv8n0x82x3s1rpfyql"))))
75 (build-system gnu-build-system)
76 (arguments
77 `(#:configure-flags '("--with-frozenpaths" "--without-gcc-arch"
78
79 ;; Do not embed the build date in binaries.
80 "--enable-reproducible-build")
81
82 ;; FIXME: The test suite succeeded before version 6.9.6-2.
83 ;; Try enabling it again with newer releases.
84 #:tests? #f
85 #:phases (modify-phases %standard-phases
86 (add-before
87 'build 'pre-build
88 (lambda* (#:key outputs #:allow-other-keys)
89 (substitute* "Makefile"
90 ;; Clear the `LIBRARY_PATH' setting, which otherwise
91 ;; interferes with our own use.
92 (("^LIBRARY_PATH[[:blank:]]*=.*$")
93 "")
94
95 ;; Since the Makefile overrides $docdir, modify it to
96 ;; refer to what we want.
97 (("^DOCUMENTATION_PATH[[:blank:]]*=.*$")
98 (let ((doc (assoc-ref outputs "doc")))
99 (string-append "DOCUMENTATION_PATH = "
100 doc "/share/doc/"
101 ,name "-"
102 ,(package-version this-package) "\n"))))
103 #t))
104 (add-before
105 'configure 'strip-configure-xml
106 (lambda _
107 (substitute* "config/configure.xml.in"
108 ;; Do not record 'configure' arguments in the
109 ;; configure.xml file that gets installed: That would
110 ;; include --docdir, and thus retain a reference to the
111 ;; 'doc' output.
112 (("@CONFIGURE_ARGS@")
113 "not recorded"))
114 #t)))))
115 ;; TODO: Add Jasper etc.
116 (inputs `(("fftw" ,fftw)
117 ("graphviz" ,graphviz)
118 ("ghostscript" ,ghostscript)
119 ("lcms" ,lcms)
120 ("libx11" ,libx11)
121 ("zlib" ,zlib)
122 ("libxml2" ,libxml2)
123 ("libtiff" ,libtiff)
124 ("libpng" ,libpng)
125 ("libjpeg" ,libjpeg-turbo)
126 ("pango" ,pango)
127 ("freetype" ,freetype)
128 ("bzip2" ,bzip2)
129 ("xz" ,xz)))
130 (native-inputs `(("pkg-config" ,pkg-config)))
131 (outputs '("out"
132 "doc")) ; 26 MiB of HTML documentation
133 (home-page "https://www.imagemagick.org/")
134 (synopsis "Create, edit, compose, or convert bitmap images")
135 (description
136 "ImageMagick is a software suite to create, edit, compose, or convert
137 bitmap images. It can read and write images in a variety of formats (over 100)
138 including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG,
139 and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and
140 transform images, adjust image colors, apply various special effects, or draw
141 text, lines, polygons, ellipses and Bézier curves.")
142 (license (license:fsf-free "http://www.imagemagick.org/script/license.php")))))
143
144 (define-public imagemagick
145 (package
146 (inherit imagemagick/stable)
147 (properties (alist-delete 'hidden? (package-properties imagemagick/stable)))
148 ;; The 7 release series has an incompatible API, while the 6 series is still
149 ;; maintained. Don't update to 7 until we've made sure that the ImageMagick
150 ;; users are ready for the 7-series API.
151 (version "6.9.12-4")
152 (source (origin
153 (method url-fetch)
154 (uri (string-append "mirror://imagemagick/ImageMagick-"
155 version ".tar.xz"))
156 (sha256
157 (base32
158 "1pkwij76yz7vd5grl6520pgpa912qb6kh34qamx4zfndwcx6cf6b"))
159 (patches
160 (search-patches "imagemagick-ReadDCMImage-fix.patch"
161 "imagemagick-ReadDCMPixels-fix.patch"
162 "imagemagick-WriteTHUMBNAILImage-fix.patch"
163 "imagemagick-CVE-2020-27829.patch"))))))
164
165 (define-public perl-image-magick
166 (package
167 (name "perl-image-magick")
168 (version "6.89")
169 (source
170 (origin
171 (method url-fetch)
172 (uri (string-append "mirror://cpan/authors/id/J/JC/JCRISTY/"
173 "PerlMagick-" version "-1.tar.gz"))
174 (sha256
175 (base32
176 "0n9afy1z5bhf9phrbahnkwhgcmijn8jggpbzwrivw1zhliliiy68"))))
177 (build-system perl-build-system)
178 (native-inputs `(("pkg-config" ,pkg-config)))
179 (inputs `(("imagemagick" ,imagemagick)))
180 (arguments
181 `(#:tests? #f ;;Failed 2/23 test programs. 2/353 subtests failed.
182 #:phases
183 (modify-phases %standard-phases
184 (add-before
185 'configure 'image-magick-flags
186 (lambda* (#:key inputs #:allow-other-keys)
187 (let ((im (assoc-ref inputs "imagemagick")))
188 (substitute* "Makefile.PL"
189 (("my \\$INC_magick = .*")
190 "my $INC_magick = `pkg-config --cflags ImageMagick`;\n")
191 (("my \\$LIBS_magick = .*")
192 "my $LIBS_magick = `pkg-config --libs ImageMagick`;\n"))
193 #t)))
194 (add-before
195 'check 'skip-mpeg-tests
196 (lambda _
197 ;; TODO: MPEG tests fail even though our imagemagick supports
198 ;; MPEG. Has been reported elsewhere,
199 ;; http://www.imagemagick.org/discourse-server/viewtopic.php?f=7&t=25036,
200 ;; so skip for now.
201 (delete-file "t/mpeg/read.t")
202 #t)))))
203 (home-page "https://metacpan.org/release/PerlMagick")
204 (synopsis "Perl interface to ImageMagick")
205 (description "This Perl extension allows the reading, manipulation and
206 writing of a large number of image file formats using the ImageMagick library.
207 Use it to create, edit, compose, or convert bitmap images from within a Perl
208 script.")
209 ;; See Magick.pm
210 (license (package-license imagemagick))))
211
212 (define-public graphicsmagick
213 (package
214 (name "graphicsmagick")
215 (version "1.3.36")
216 (source
217 (origin
218 (method url-fetch)
219 (uri
220 (list
221 (string-append "mirror://sourceforge/graphicsmagick/graphicsmagick"
222 "/" version "/GraphicsMagick-" version ".tar.xz")
223 (string-append "ftp://ftp.graphicsmagick.org/pub/"
224 "GraphicsMagick/" (version-major+minor version)
225 "/GraphicsMagick-" version ".tar.xz")))
226 (sha256
227 (base32
228 "0ilg6fkppb4avzais1dvi3qf6ln7v3mzj7gjm83w7pwwfpg3ynsx"))))
229 (build-system gnu-build-system)
230 (arguments
231 `(#:configure-flags
232 (list "--with-frozenpaths"
233 "--enable-shared=yes"
234 "--with-x=yes"
235 "--with-quantum-depth=16" ; required by Octave
236 "--enable-quantum-library-names"
237 (string-append "--with-gs-font-dir="
238 (assoc-ref %build-inputs "gs-fonts")
239 "/share/fonts/type1/ghostscript"))))
240 (inputs
241 `(("graphviz" ,graphviz)
242 ("ghostscript" ,ghostscript)
243 ("gs-fonts" ,gs-fonts)
244 ("lcms" ,lcms)
245 ("libx11" ,libx11)
246 ("libxml2" ,libxml2)
247 ("libtiff" ,libtiff)
248 ("libpng" ,libpng)
249 ("libjpeg" ,libjpeg-turbo)
250 ("libwebp" ,libwebp)
251 ("freetype" ,freetype)
252 ("bzip2" ,bzip2)
253 ("xz" ,xz)
254 ("zlib" ,zlib)))
255 (native-inputs
256 `(("pkg-config" ,pkg-config)))
257 (outputs '("out" ; 13 MiB
258 "doc")) ; ~7 MiB
259 (home-page "http://www.graphicsmagick.org")
260 (synopsis "Create, edit, compose, or convert bitmap images")
261 (description
262 "GraphicsMagick provides a comprehensive collection of utilities,
263 programming interfaces, and GUIs, to support file format conversion, image
264 processing, and 2D vector rendering.")
265 (license license:expat)))