gnu: r-fastseg: Update to 1.30.0.
[jackhill/guix/guix.git] / gnu / packages / gd.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
5 ;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
6 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages gd)
26 #:use-module (guix packages)
27 #:use-module (guix build-system gnu)
28 #:use-module (guix build-system perl)
29 #:use-module (guix download)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages image)
33 #:use-module (gnu packages imagemagick)
34 #:use-module (gnu packages fontutils)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages pkg-config)
37 #:use-module ((guix licenses) #:select (non-copyleft perl-license)))
38
39 (define-public gd
40 (package
41 (name "gd")
42 (replacement gd/fixed)
43 ;; Note: With libgd.org now pointing to github.com, genuine old
44 ;; tarballs are no longer available. Notably, versions 2.0.x are
45 ;; missing.
46 (version "2.2.5")
47 (source (origin
48 (method url-fetch)
49 (uri (string-append
50 "https://github.com/libgd/libgd/releases/download/gd-"
51 version "/libgd-" version ".tar.xz"))
52 (sha256
53 (base32
54 "0lfy5f241sbv8s3splm2zqiaxv7lxrcshh875xryryk7yk5jqc4c"))
55
56 (patches (search-patches "gd-CVE-2018-5711.patch"
57 "gd-CVE-2018-1000222.patch"
58 "gd-fix-tests-on-i686.patch"
59 "gd-freetype-test-failure.patch"))))
60 (build-system gnu-build-system)
61 (arguments
62 ;; As recommended by github.com/libgd/libgd/issues/278 to fix rounding
63 ;; issues on aarch64 and other architectures.
64 `(#:make-flags '("CFLAGS=-ffp-contract=off")
65 #:phases
66 (modify-phases %standard-phases
67 ;; This test is known to fail on i686-linux:
68 ;; https://github.com/libgd/libgd/issues/359
69 ;; TODO Replace this substitution with an upstream bug fix.
70 (add-after 'unpack 'disable-failing-test
71 (lambda _
72 (substitute* "tests/gdimagegrayscale/basic.c"
73 (("return gdNumFailures\\(\\)")
74 "return 0"))
75 #t)))))
76 (native-inputs
77 `(("pkg-config" ,pkg-config)))
78 (inputs
79 `(("freetype" ,freetype)
80 ("libpng" ,libpng)
81 ("zlib" ,zlib)))
82 (propagated-inputs
83 `(("fontconfig" ,fontconfig)
84 ("libjpeg" ,libjpeg)))
85 (home-page "http://www.libgd.org/")
86 (synopsis "Library for the dynamic creation of images by programmers")
87 (description
88 "GD is a library for the dynamic creation of images by programmers. GD
89 is written in C, and \"wrappers\" are available for Perl, PHP and other
90 languages. GD creates PNG, JPEG, GIF, WebP, XPM, BMP images, among other
91 formats. GD is commonly used to generate charts, graphics, thumbnails, and
92 most anything else, on the fly. While not restricted to use on the web, the
93 most common applications of GD involve website development.")
94 (license (non-copyleft "file://COPYING"
95 "See COPYING file in the distribution."))
96 (properties '((cpe-name . "libgd")))))
97
98 (define-public gd/fixed
99 (hidden-package
100 (package
101 (inherit gd)
102 (source (origin
103 (inherit (package-source gd))
104 (patches (append (origin-patches (package-source gd))
105 (search-patches "gd-CVE-2019-6977.patch"
106 "gd-CVE-2019-6978.patch"))))))))
107
108 (define-public perl-gd
109 (package
110 (name "perl-gd")
111 (version "2.71")
112 (source
113 (origin
114 (method url-fetch)
115 (uri (string-append "mirror://cpan/authors/id/R/RU/RURBAN/"
116 "GD-" version ".tar.gz"))
117 (sha256
118 (base32 "1ivskdb4nwy7ky37369hwkfxp11fkp6ri5k7qlf2dmra7f3y86s5"))))
119 (build-system perl-build-system)
120 (inputs
121 `(("fontconfig" ,fontconfig)
122 ("freetype" ,freetype)
123 ("gd" ,gd)
124 ("libpng" ,libpng)
125 ("libjpeg" ,libjpeg)
126 ("zlib" ,zlib)))
127 (arguments
128 `(#:make-maker-flags
129 (list (string-append "--lib_jpeg_path="
130 (assoc-ref %build-inputs "libjpeg")))))
131 (home-page "https://metacpan.org/release/GD")
132 (synopsis "Perl interface to the GD graphics library")
133 (description "GD.pm is an autoloadable interface module for libgd, a
134 popular library for creating and manipulating PNG files. With this library
135 you can create PNG images on the fly or modify existing files.")
136 (license perl-license)))
137
138 (define-public perl-gd-securityimage
139 (package
140 (name "perl-gd-securityimage")
141 (version "1.75")
142 (source
143 (origin
144 (method url-fetch)
145 (uri (string-append "mirror://cpan/authors/id/B/BU/BURAK/"
146 "GD-SecurityImage-" version ".tar.gz"))
147 (sha256
148 (base32 "19lf1kzdavrkkx3f900jnpynr55d5kjd2sdmwpfir5dsmkcj9pix"))))
149 (build-system perl-build-system)
150 (arguments
151 '(#:phases
152 (modify-phases %standard-phases
153 (add-after 'unpack 'set-env
154 (lambda _ (setenv "PERL_USE_UNSAFE_INC" "1") #t)))))
155 (native-inputs
156 `(("perl-module-build" ,perl-module-build)))
157 (propagated-inputs
158 `(("perl-gd" ,perl-gd)
159 ("perl-image-magick" ,perl-image-magick)))
160 (home-page "https://metacpan.org/release/GD-SecurityImage")
161 (synopsis "Security image generator")
162 (description "This module provides a basic interface to create
163 security (captcha) images. The final output is the actual graphic data, the
164 mime type of the graphic, and the created random string. The module also has
165 some \"styles\" that are used to create the background (or foreground) of the
166 image.")
167 (license perl-license)))