gd.scm 6.7 KB

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