f9864d7784287b8cee3fb0e451f15327fdf730c6
[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 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages gd)
25 #:use-module (guix packages)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build-system perl)
28 #:use-module (guix download)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages perl)
31 #:use-module (gnu packages image)
32 #:use-module (gnu packages imagemagick)
33 #:use-module (gnu packages fontutils)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages pkg-config)
36 #:use-module ((guix licenses) #:select (non-copyleft perl-license)))
37
38 (define-public gd
39 (package
40 (name "gd")
41 ;; Note: With libgd.org now pointing to github.com, genuine old
42 ;; tarballs are no longer available. Notably, versions 2.0.x are
43 ;; missing.
44 (version "2.2.5")
45 (source (origin
46 (method url-fetch)
47 (uri (string-append
48 "https://github.com/libgd/libgd/releases/download/gd-"
49 version "/libgd-" version ".tar.xz"))
50 (sha256
51 (base32
52 "0lfy5f241sbv8s3splm2zqiaxv7lxrcshh875xryryk7yk5jqc4c"))
53 (patches (search-patches "gd-fix-tests-on-i686.patch"
54 "gd-freetype-test-failure.patch"))))
55 (build-system gnu-build-system)
56 (arguments
57 ;; As recommended by github.com/libgd/libgd/issues/278 to fix rounding
58 ;; issues on aarch64 and other architectures.
59 `(#:make-flags '("CFLAGS=-ffp-contract=off")
60 #:phases
61 (modify-phases %standard-phases
62 ;; This test is known to fail on i686-linux:
63 ;; https://github.com/libgd/libgd/issues/359
64 ;; TODO Replace this substitution with an upstream bug fix.
65 (add-after 'unpack 'disable-failing-test
66 (lambda _
67 (substitute* "tests/gdimagegrayscale/basic.c"
68 (("return gdNumFailures\\(\\)")
69 "return 0"))
70 #t)))))
71 (native-inputs
72 `(("pkg-config" ,pkg-config)))
73 (inputs
74 `(("freetype" ,freetype)
75 ("libpng" ,libpng)
76 ("zlib" ,zlib)))
77 (propagated-inputs
78 `(("fontconfig" ,fontconfig)
79 ("libjpeg" ,libjpeg)))
80 (home-page "http://www.libgd.org/")
81 (synopsis "Library for the dynamic creation of images by programmers")
82 (description
83 "GD is a library for the dynamic creation of images by programmers. GD
84 is written in C, and \"wrappers\" are available for Perl, PHP and other
85 languages. GD creates PNG, JPEG, GIF, WebP, XPM, BMP images, among other
86 formats. GD is commonly used to generate charts, graphics, thumbnails, and
87 most anything else, on the fly. While not restricted to use on the web, the
88 most common applications of GD involve website development.")
89 (license (non-copyleft "file://COPYING"
90 "See COPYING file in the distribution."))
91 (properties '((cpe-name . "libgd")))))
92
93 (define-public perl-gd
94 (package
95 (name "perl-gd")
96 (version "2.56")
97 (source
98 (origin
99 (method url-fetch)
100 (uri (string-append "mirror://cpan/authors/id/L/LD/LDS/"
101 "GD-" version ".tar.gz"))
102 (sha256
103 (base32
104 "1ya8f9hpiax8j29vwaiwlvvgah0vkyvpzva28r8231nyk0f3s40z"))
105 (patches (search-patches
106 "perl-gd-options-passthrough-and-fontconfig.patch"))))
107 (build-system perl-build-system)
108 (native-inputs
109 `(("perl-module-build" ,perl-module-build))) ;needs Module::Build >= 0.42
110 (inputs
111 `(("gd" ,gd)
112 ("zlib" ,zlib)
113 ("png" ,libpng)
114 ("ft" ,freetype)
115 ("jpeg" ,libjpeg)
116 ("fontconfig" ,fontconfig)))
117 (arguments
118 ;; We must use Build.PL for building because Makefile.PL fails to build
119 ;; the XS source.
120 `(#:module-build-flags (map (lambda (i)
121 (string-append "--lib_" i "_path="
122 (assoc-ref %build-inputs i)))
123 '("zlib" "png" "ft" "jpeg" "fontconfig"))
124 #:tests? #f ;; Failed 1/2 test programs. 1/12 subtests failed.
125 #:phases (alist-cons-after
126 'configure 'clear-autogenerated-files
127 (lambda _
128 ;; This file is autogenerated by its .PLS script at build
129 ;; time, but file creation fails because that file already
130 ;; exists in the distribution with non-writable
131 ;; permissions, so delete it first.
132 (delete-file "bdf_scripts/bdf2gdfont.pl"))
133 %standard-phases)))
134 (home-page "http://search.cpan.org/dist/GD")
135 (synopsis "Perl interface to the GD graphics library")
136 (description "GD.pm is an autoloadable interface module for libgd, a
137 popular library for creating and manipulating PNG files. With this library
138 you can create PNG images on the fly or modify existing files.")
139 (license perl-license)))
140
141 (define-public perl-gd-securityimage
142 (package
143 (name "perl-gd-securityimage")
144 (version "1.73")
145 (source
146 (origin
147 (method url-fetch)
148 (uri (string-append "mirror://cpan/authors/id/B/BU/BURAK/"
149 "GD-SecurityImage-" version ".tar.gz"))
150 (sha256
151 (base32
152 "1kaxs67rfd4w46lxgcg3pa05a596l0h1k8n4zk2gwrrar4022wpx"))))
153 (build-system perl-build-system)
154 (arguments
155 '(#:phases
156 (modify-phases %standard-phases
157 (add-after 'unpack 'set-env
158 (lambda _ (setenv "PERL_USE_UNSAFE_INC" "1"))))))
159 (native-inputs
160 `(("perl-module-build" ,perl-module-build)))
161 (propagated-inputs
162 `(("perl-gd" ,perl-gd)
163 ("perl-image-magick" ,perl-image-magick)))
164 (home-page "http://search.cpan.org/dist/GD-SecurityImage")
165 (synopsis "Security image generator")
166 (description "This module provides a basic interface to create
167 security (captcha) images. The final output is the actual graphic data, the
168 mime type of the graphic, and the created random string. The module also has
169 some \"styles\" that are used to create the background (or foreground) of the
170 image.")
171 (license perl-license)))