gd.scm 6.5 KB

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