gnu: Replace uses of 'libjpeg' with 'libjpeg-turbo'.
[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 ;; Note: With libgd.org now pointing to github.com, genuine old
43 ;; tarballs are no longer available. Notably, versions 2.0.x are
44 ;; missing.
45 (version "2.2.5")
46 (source (origin
47 (method url-fetch)
48 (uri (string-append
49 "https://github.com/libgd/libgd/releases/download/gd-"
50 version "/libgd-" version ".tar.xz"))
51 (sha256
52 (base32
53 "0lfy5f241sbv8s3splm2zqiaxv7lxrcshh875xryryk7yk5jqc4c"))
54
55 (patches (search-patches "gd-CVE-2018-5711.patch"
56 "gd-CVE-2018-1000222.patch"
57 "gd-CVE-2019-6977.patch"
58 "gd-CVE-2019-6978.patch"
59 "gd-fix-tests-on-i686.patch"
60 "gd-freetype-test-failure.patch"))))
61 (build-system gnu-build-system)
62 (arguments
63 ;; As recommended by github.com/libgd/libgd/issues/278 to fix rounding
64 ;; issues on aarch64 and other architectures.
65 `(#:make-flags '("CFLAGS=-ffp-contract=off")
66 #:configure-flags '("--disable-static")
67 #:phases
68 (modify-phases %standard-phases
69 ;; This test is known to fail on i686-linux:
70 ;; https://github.com/libgd/libgd/issues/359
71 ;; TODO Replace this substitution with an upstream bug fix.
72 (add-after 'unpack 'disable-failing-test
73 (lambda _
74 (substitute* "tests/gdimagegrayscale/basic.c"
75 (("return gdNumFailures\\(\\)")
76 "return 0"))
77 #t)))))
78 (native-inputs
79 `(("pkg-config" ,pkg-config)))
80 (inputs
81 `(("freetype" ,freetype)
82 ("libpng" ,libpng)
83 ("zlib" ,zlib)))
84 (propagated-inputs
85 `(("fontconfig" ,fontconfig)
86 ("libjpeg" ,libjpeg-turbo)))
87 (home-page "http://www.libgd.org/")
88 (synopsis "Library for the dynamic creation of images by programmers")
89 (description
90 "GD is a library for the dynamic creation of images by programmers. GD
91 is written in C, and \"wrappers\" are available for Perl, PHP and other
92 languages. GD creates PNG, JPEG, GIF, WebP, XPM, BMP images, among other
93 formats. GD is commonly used to generate charts, graphics, thumbnails, and
94 most anything else, on the fly. While not restricted to use on the web, the
95 most common applications of GD involve website development.")
96 (license (non-copyleft "file://COPYING"
97 "See COPYING file in the distribution."))
98 (properties '((cpe-name . "libgd")))))
99
100 (define-public perl-gd
101 (package
102 (name "perl-gd")
103 (version "2.71")
104 (source
105 (origin
106 (method url-fetch)
107 (uri (string-append "mirror://cpan/authors/id/R/RU/RURBAN/"
108 "GD-" version ".tar.gz"))
109 (sha256
110 (base32 "1ivskdb4nwy7ky37369hwkfxp11fkp6ri5k7qlf2dmra7f3y86s5"))))
111 (build-system perl-build-system)
112 (inputs
113 `(("fontconfig" ,fontconfig)
114 ("freetype" ,freetype)
115 ("gd" ,gd)
116 ("libpng" ,libpng)
117 ("libjpeg" ,libjpeg-turbo)
118 ("zlib" ,zlib)))
119 (arguments
120 `(#:make-maker-flags
121 (list (string-append "--lib_jpeg_path="
122 (assoc-ref %build-inputs "libjpeg")))))
123 (home-page "https://metacpan.org/release/GD")
124 (synopsis "Perl interface to the GD graphics library")
125 (description "GD.pm is an autoloadable interface module for libgd, a
126 popular library for creating and manipulating PNG files. With this library
127 you can create PNG images on the fly or modify existing files.")
128 (license perl-license)))
129
130 (define-public perl-gd-securityimage
131 (package
132 (name "perl-gd-securityimage")
133 (version "1.75")
134 (source
135 (origin
136 (method url-fetch)
137 (uri (string-append "mirror://cpan/authors/id/B/BU/BURAK/"
138 "GD-SecurityImage-" version ".tar.gz"))
139 (sha256
140 (base32 "19lf1kzdavrkkx3f900jnpynr55d5kjd2sdmwpfir5dsmkcj9pix"))))
141 (build-system perl-build-system)
142 (arguments
143 '(#:phases
144 (modify-phases %standard-phases
145 (add-after 'unpack 'set-env
146 (lambda _ (setenv "PERL_USE_UNSAFE_INC" "1") #t)))))
147 (native-inputs
148 `(("perl-module-build" ,perl-module-build)))
149 (propagated-inputs
150 `(("perl-gd" ,perl-gd)
151 ("perl-image-magick" ,perl-image-magick)))
152 (home-page "https://metacpan.org/release/GD-SecurityImage")
153 (synopsis "Security image generator")
154 (description "This module provides a basic interface to create
155 security (captcha) images. The final output is the actual graphic data, the
156 mime type of the graphic, and the created random string. The module also has
157 some \"styles\" that are used to create the background (or foreground) of the
158 image.")
159 (license perl-license)))