rmagick 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +32 -6
  3. data/.circleci/config.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +9 -9
  6. data/.rubocop_todo.yml +351 -17
  7. data/.travis.yml +14 -1
  8. data/CHANGELOG.md +55 -0
  9. data/CONTRIBUTING.md +11 -18
  10. data/README.textile +2 -2
  11. data/Rakefile +1 -1
  12. data/before_install_linux.sh +56 -19
  13. data/doc/ex/sparse_color.rb +5 -0
  14. data/doc/magick.html +9 -4
  15. data/doc/rvg.html +2 -2
  16. data/doc/rvgtut.html +1 -1
  17. data/examples/histogram.rb +1 -1
  18. data/ext/RMagick/extconf.rb +90 -264
  19. data/ext/RMagick/rmagick.c +28 -6
  20. data/ext/RMagick/rmagick.h +53 -199
  21. data/ext/RMagick/rmdraw.c +52 -70
  22. data/ext/RMagick/rmenum.c +332 -274
  23. data/ext/RMagick/rmfill.c +62 -112
  24. data/ext/RMagick/rmilist.c +27 -62
  25. data/ext/RMagick/rmimage.c +424 -634
  26. data/ext/RMagick/rminfo.c +46 -37
  27. data/ext/RMagick/rmkinfo.c +47 -42
  28. data/ext/RMagick/rmmain.c +125 -180
  29. data/ext/RMagick/rmmontage.c +5 -5
  30. data/ext/RMagick/rmpixel.c +133 -62
  31. data/ext/RMagick/rmstruct.c +14 -181
  32. data/ext/RMagick/rmutil.c +195 -111
  33. data/lib/rmagick/version.rb +2 -3
  34. data/lib/rvg/deep_equal.rb +1 -1
  35. data/lib/rvg/misc.rb +4 -4
  36. data/lib/rvg/units.rb +2 -2
  37. data/rmagick.gemspec +2 -2
  38. data/spec/rmagick/ImageList1_spec.rb +2 -2
  39. data/spec/rmagick/draw_spec.rb +4 -4
  40. data/spec/rmagick/image/composite_spec.rb +6 -1
  41. data/spec/rmagick/image/properties_spec.rb +8 -8
  42. data/test/Draw.rb +414 -0
  43. data/test/Enum.rb +76 -0
  44. data/test/Fill.rb +93 -0
  45. data/test/Image1.rb +9 -1
  46. data/test/Image2.rb +14 -4
  47. data/test/Image3.rb +73 -3
  48. data/test/ImageList1.rb +22 -9
  49. data/test/ImageList2.rb +41 -9
  50. data/test/Image_attributes.rb +45 -8
  51. data/test/Info.rb +102 -6
  52. data/test/Magick.rb +8 -1
  53. data/test/PolaroidOptions.rb +23 -0
  54. data/test/test_all_basic.rb +4 -0
  55. metadata +28 -8
  56. data/.hound.yml +0 -2
  57. data/wercker.yml +0 -10
@@ -3,6 +3,8 @@ language: ruby
3
3
  cache:
4
4
  directories:
5
5
  - ~/.ccache
6
+ - vendor/bundle
7
+ - build-ImageMagick
6
8
 
7
9
  os:
8
10
  - linux
@@ -10,17 +12,28 @@ os:
10
12
  sudo: required
11
13
 
12
14
  env:
15
+ - IMAGEMAGICK_VERSION=6.7.7-10
16
+ - IMAGEMAGICK_VERSION=6.7.7-10 CONFIGURE_OPTIONS=--enable-hdri
13
17
  - IMAGEMAGICK_VERSION=6.8.9-10
14
18
  - IMAGEMAGICK_VERSION=6.8.9-10 CONFIGURE_OPTIONS=--enable-hdri
19
+ - IMAGEMAGICK_VERSION=6.9.10-40
20
+ - IMAGEMAGICK_VERSION=6.9.10-40 CONFIGURE_OPTIONS=--enable-hdri
15
21
 
16
22
  before_install:
17
23
  - source before_install_$TRAVIS_OS_NAME.sh
18
24
 
19
- install: bundle install --verbose
25
+ install: bundle install --path=vendor/bundle --verbose
20
26
 
21
27
  rvm:
22
28
  - 2.3
23
29
  - 2.4
30
+ - 2.5
31
+ - 2.6
32
+
33
+ matrix:
34
+ include:
35
+ - rvm: 2.3
36
+ env: STYLE_CHECKS=true IMAGEMAGICK_VERSION=6.8.9-10
24
37
 
25
38
  notifications:
26
39
  webhooks:
@@ -3,6 +3,61 @@
3
3
  All notable changes to this project are documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## RMagick 3.1.0
7
+
8
+ Deprecations: (To be removed in RMagick 4.0)
9
+
10
+ - Support for Ruby 2.3
11
+ - `KernelInfo#zero_nans` (#531) (no replacement)
12
+ - `KernelInfo#show` (#532) (no replacement)
13
+ - `ImageList#fx` (#529) (use `Image#fx` instead)
14
+ - `Image#alpha=` (#530) (use `Image#alpha` instead)
15
+ - `Image#mask=` (#530) (use `Image#mask` instead)
16
+ - `Image#matte` (#530) (use `Image#alpha` instead)
17
+ - `Image#matte=` (#530) (use `Image#alpha` instead)
18
+
19
+ Enhancements:
20
+
21
+ - Support ruby-mswin environment on Windows (#425)
22
+ - Add test for supporting webp format (#406)
23
+ - Add explicit Ruby 2.5 support (#339)
24
+ - Add explicit Ruby 2.6 support (#467)
25
+ - Restore support for ImageMagick 6.7 (#475)
26
+ - Add explicit ImageMagick 6.9 support (#340)
27
+ - Work towards ImageMagick 7.0 support (#470) (#487) (#489) (#492) (#494)
28
+ - Improve error messaging (#480) (#517)
29
+ - Add TimeResource support (#402)
30
+ - Add Image#fx method (#529)
31
+
32
+ Bug Fixes:
33
+
34
+ - Many, many memory leaks fixed
35
+ (#362) (#361) (#360) (#359) (#358) (#357) (#367) (#370) (#364) (#372) (#373)
36
+ (#374) (#375) (#376) (#385) (#384) (#383) (#382) (#381) (#380) (#379) (#378)
37
+ (#377) (#391) (#390) (#389) (#396) (#401) (#409) (#419) (#417) (#416) (#415)
38
+ (#414) (#413) (#412) (#411) (#410) (#418) (#454) (#453) (#452) (#451) (#450)
39
+ (#461) (#460) (#459) (#563)
40
+ - Fix SEGV in ImageList methods with invalid image list (#356)
41
+ - Fix SEGV in Image#recolor (#387)
42
+ - Fix SEGV in Image#profile! (#400)
43
+ - Fix build error on Homebrew environment (#426)
44
+ - Fix Image#quantize and ImageList#quantize could not make dither false (#458)
45
+ - Replace obsoleted $defout to $stdout (#463)
46
+ - Avoid SEGV in monitor feature for Ruby 2.5+ (#462)
47
+ - Fix SEGV in Image#write with CMYKColorspace (#465)
48
+ - Avoid problems related to GC in monitor feature (#468)
49
+ - Get rid of compiler warnings (#484) (#491) (#500)
50
+ - Fix rmfill leaks (#528)
51
+ - Removed automatic allocation of the ImageInfo that is broken. (#547)
52
+ - Fix color histogram (#540)
53
+ - Fix Image#iptc_profile does not work with ImageMagick 6.7 (#558)
54
+
55
+ Code Quality:
56
+
57
+ - Many tests written
58
+ - CI improvements
59
+ - Other refactors
60
+
6
61
  ## RMagick 3.0.0
7
62
 
8
63
  Breaking Changes:
@@ -48,30 +48,23 @@ Useful information about RSpec:
48
48
  Committing
49
49
  ----------
50
50
 
51
- All work for a next release is done in the `develop` branch. Please create your branch off of it.
52
-
53
51
  It is better if you follow [Git Style Guide](https://github.com/agis-/git-style-guide).
54
52
 
55
53
 
56
54
  Pull Requests
57
55
  -------------
58
56
 
59
- Please choose the `rmagick/rmagick` repo and the `develop` branch as the destination for your pull request.
60
-
61
- NOTE: GitHub suggests `rmagick-temp/rmagick` repo by default. **This is incorrect.** Please switch to `rmagick/rmagick`. It should be the next repo in the drop-down list.
62
-
63
- Every pull request is tested:
64
-
65
- 1. On [Travis CI](https://travis-ci.org/rmagick/rmagick).
66
- It runs all Minitest and RSpec tests on several Ruby and ImageMagick versions.
67
- See [.travis.yml](.travis.yml) for details.
68
- 2. On [Semaphore CI](https://semaphoreci.com/rmagick/rmagick).
69
- It runs [RuboCop](https://rubocop.readthedocs.io).
70
- RuboCop is run on a different CI server and appears as a different check on pull request pages because this way it is easier to spot what kind of tests are failed.
71
-
72
- An ideal pull request does not fail these tests.
73
- If your pull request fails these tests, please improve it and push the improvements until it doesn't.
74
- You can ignore failures that are not caused by your changes.
57
+ Please choose the `rmagick/rmagick` repo as the destination for your pull
58
+ request. GitHub may suggest `rmagick-temp/rmagick` repo by default. **This is
59
+ incorrect.** Please switch to `rmagick/rmagick`. It should be the next repo in
60
+ the drop-down list.
61
+
62
+ Every pull request is tested on [Travis
63
+ CI](https://travis-ci.org/rmagick/rmagick) to cover Linux builds,
64
+ [Appveyor](https://ci.appveyor.com/project/mockdeep/rmagick) for Windows
65
+ builds, and [CircleCI](https://circleci.com/gh/rmagick/rmagick) for another
66
+ Linux environment and console access for debugging builds. It runs all
67
+ Minitest and RSpec tests on several Ruby and ImageMagick versions.
75
68
 
76
69
  A quick way to fix formatting errors is to run `bundle exec rubocop --autocorrect path/to/file.rb`.
77
70
 
@@ -1,6 +1,6 @@
1
1
  h1. RMagick
2
2
 
3
- !https://img.shields.io/gem/v/rmagick.svg?style=flat(RubyGems)!:http://rubygems.org/gems/rmagick !https://img.shields.io/gem/dt/rmagick.svg?style=flat! !https://www.versioneye.com/ruby/rmagick/reference_badge.svg?style=flat(VersionEye)!:https://www.versioneye.com/ruby/rmagick/references !https://img.shields.io/travis/rmagick/rmagick/master.svg?style=flat(Travis CI)!:https://travis-ci.org/rmagick/rmagick !https://img.shields.io/codeclimate/github/rmagick/rmagick.svg?style=flat(Code Climate)!:https://codeclimate.com/github/rmagick/rmagick !https://badges.gitter.im/Join%20Chat.svg(Gitter)!:https://gitter.im/rmagick/rmagick?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
3
+ !https://img.shields.io/gem/v/rmagick.svg?style=flat!:http://rubygems.org/gems/rmagick !https://travis-ci.org/rmagick/rmagick.svg?branch=master!:https://travis-ci.org/rmagick/rmagick !https://ci.appveyor.com/api/projects/status/xw3usp6s1ghfimb4/branch/master?svg=true!:https://ci.appveyor.com/project/mockdeep/rmagick !https://circleci.com/gh/rmagick/rmagick.svg?style=svg!:https://circleci.com/gh/rmagick/rmagick
4
4
 
5
5
  h3. Table of Contents
6
6
 
@@ -32,7 +32,7 @@ These prerequisites are required for the latest DEVELOPMENT version of RMagick.
32
32
 
33
33
  Ruby must be able to build C-Extensions (e.g. MRI, Rubinius, not JRuby)
34
34
 
35
- *ImageMagick* Version 6.4.9 or later (6.x.x). Version 7 is NOT yet supported; ETA April 2019 ( https://github.com/rmagick/rmagick/pull/299 ). You can get ImageMagick from "www.imagemagick.org":http://www.imagemagick.org.
35
+ *ImageMagick* Version 6.7.7 or later (6.x.x). Version 7 is NOT yet supported; ETA Summer 2019 (https://github.com/rmagick/rmagick/issues/256). You can get ImageMagick from "www.imagemagick.org":http://www.imagemagick.org.
36
36
 
37
37
  On Ubuntu, you can run:
38
38
 
data/Rakefile CHANGED
@@ -190,7 +190,7 @@ task spec: :compile
190
190
  if ENV['STYLE_CHECKS']
191
191
  require 'rubocop/rake_task'
192
192
  RuboCop::RakeTask.new
193
- task default: %i[spec test rubocop]
193
+ task default: %i[rubocop]
194
194
  else
195
195
  task default: %i[spec test]
196
196
  end
@@ -1,3 +1,5 @@
1
+ set -euox pipefail
2
+
1
3
  sudo apt-get update
2
4
 
3
5
  # remove all existing imagemagick related packages
@@ -6,24 +8,59 @@ sudo apt-get autoremove -y imagemagick* libmagick* --purge
6
8
  # install build tools, ImageMagick delegates
7
9
  sudo apt-get install -y build-essential libx11-dev libxext-dev zlib1g-dev \
8
10
  liblcms2-dev libpng-dev libjpeg-dev libfreetype6-dev libxml2-dev \
9
- libtiff5-dev vim ghostscript ccache
10
-
11
- case $IMAGEMAGICK_VERSION in
12
- latest)
13
- wget http://www.imagemagick.org/download/ImageMagick.tar.xz
14
- tar -xf ImageMagick.tar.xz
15
- cd ImageMagick-*
16
- ;;
17
- *)
18
- wget http://www.imagemagick.org/download/releases/ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz
19
- tar -xf ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz
20
- cd ImageMagick-${IMAGEMAGICK_VERSION}
21
- ;;
22
- esac
23
- CC="ccache cc" CXX="ccache c++" ./configure --prefix=/usr $CONFIGURE_OPTIONS
24
- make
25
- sudo make install
26
- cd ..
11
+ libtiff5-dev libwebp-dev vim ghostscript ccache
12
+
13
+ if [ ! -v IMAGEMAGICK_VERSION ]; then
14
+ echo "you must specify an ImageMagick version."
15
+ echo "example: 'IMAGEMAGICK_VERSION=6.8.9-10 bash ./before_install_linux.sh'"
16
+ exit 1
17
+ fi
18
+
19
+ if [ ! -d /usr/include/freetype ]; then
20
+ # If `/usr/include/freetype` is not existed, ImageMagick 6.7 configuration fails about Freetype.
21
+ sudo ln -sf /usr/include/freetype2 /usr/include/freetype
22
+ fi
23
+
24
+ project_dir=`pwd`
25
+ build_dir=${project_dir}/build-ImageMagick/ImageMagick-${IMAGEMAGICK_VERSION}
26
+ if [ -v CONFIGURE_OPTIONS ]; then
27
+ build_dir=${build_dir}-${CONFIGURE_OPTIONS}
28
+ fi
29
+
30
+ build_imagemagick() {
31
+ mkdir -p build-ImageMagick
32
+
33
+ version=(${IMAGEMAGICK_VERSION//./ })
34
+ if (( "${version[0]}${version[1]}" >= 69 )); then
35
+ wget https://github.com/ImageMagick/ImageMagick6/archive/${IMAGEMAGICK_VERSION}.tar.gz
36
+ tar -xf ${IMAGEMAGICK_VERSION}.tar.gz
37
+ mv ImageMagick6-${IMAGEMAGICK_VERSION} $build_dir
38
+ else
39
+ wget https://www.imagemagick.org/download/releases/ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz
40
+ tar -xf ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz
41
+ mv ImageMagick-${IMAGEMAGICK_VERSION} $build_dir
42
+ fi
43
+
44
+ options="--with-magick-plus-plus=no --disable-docs"
45
+ if [ -v CONFIGURE_OPTIONS ]; then
46
+ options="${CONFIGURE_OPTIONS} $options"
47
+ fi
48
+
49
+ cd $build_dir
50
+ CC="ccache cc" CXX="ccache c++" ./configure --prefix=/usr $options
51
+ make -j
52
+ }
53
+
54
+ if [ ! -d $build_dir ]; then
55
+ build_imagemagick
56
+ fi
57
+
58
+ cd $build_dir
59
+ sudo make install -j
60
+ cd $project_dir
61
+
27
62
  sudo ldconfig
28
63
 
29
- gem install bundler -v 1.17.3
64
+ gem install bundler
65
+
66
+ set +ux
@@ -36,6 +36,11 @@ begin
36
36
  img2['Label'] = 'Barycentric'
37
37
  imgl << draw_centers(img2, false)
38
38
 
39
+ img2 = img.sparse_color(Magick::InverseColorInterpolate, 30, 10, 'red',
40
+ 10, 80, 'blue', 70, 60, 'lime')
41
+ img2['Label'] = 'Barycentric'
42
+ imgl << draw_centers(img2, false)
43
+
39
44
  montage = imgl.montage do
40
45
  self.background_color = 'none'
41
46
  self.geometry = '100x100+10+10'
@@ -352,9 +352,9 @@ p Magick.formats &raquo;
352
352
  <dt>resource_type</dt>
353
353
 
354
354
  <dd>One of the symbols <code>:area</code>,
355
- <code>:disk</code>, <code>:file</code>, <code>:map</code>, or
356
- <code>:memory</code>. You may use a string instead of a
357
- symbol.</dd>
355
+ <code>:disk</code>, <code>:file</code>, <code>:map</code>,
356
+ <code>:memory</code>, or <code>:time</code>. You may use a
357
+ string instead of a symbol.</dd>
358
358
 
359
359
  <dt>limit</dt>
360
360
 
@@ -367,7 +367,8 @@ p Magick.formats &raquo;
367
367
  the <span class="arg">resource_type</span> is
368
368
  <code>:area</code> the limit is the maximum width * height of
369
369
  an image in pixels that can reside in pixel cache memory. If
370
- this argument is omitted the limit is not changed.</dd>
370
+ <code>:time</code>, the limit is measured in seconds. If this
371
+ argument is omitted the limit is not changed.</dd>
371
372
  </dl>
372
373
 
373
374
  <h4>Returns</h4>
@@ -378,6 +379,10 @@ p Magick.formats &raquo;
378
379
  <h4>Notes</h4>
379
380
 
380
381
  <p>This method supercedes <code>set_cache_threshold</code>.</p>
382
+
383
+ <p>Setting the <code>:time</code> limit resets the elapsed time
384
+ to zero in the pixel cache. Call it before any operation that
385
+ you need to set a time limit on.</p>
381
386
  </div>
382
387
 
383
388
  <div class="sig">
@@ -893,7 +893,7 @@ canvas.background_position = :scaled
893
893
  <div style="margin-left: 235px; margin-top:1em">
894
894
  <p>RVG supports a subset of the unit identifiers defined by the
895
895
  SVG specification. In RVG, unit identifiers are methods in the
896
- Float and Fixnum classes. The units are (for the most part)
896
+ Float and Integer classes. The units are (for the most part)
897
897
  defined in terms of "dots per inch," accordingly, the unit
898
898
  identifier methods are added only if the value</p>
899
899
  <pre>
@@ -911,7 +911,7 @@ canvas.background_position = :scaled
911
911
  </pre>
912
912
 
913
913
  <p>If the dpi is defined, the following methods are added to
914
- <code>Float</code> and <code>Fixnum</code></p>
914
+ <code>Float</code> and <code>Integer</code></p>
915
915
 
916
916
  <dl>
917
917
  <dt>px</dt>
@@ -140,7 +140,7 @@
140
140
 
141
141
  <p><code>RVG::dpi</code> enables the use of <em>unit methods</em>
142
142
  in RVG. When you set <code>RVG::dpi</code> to a non-nil value,
143
- RVG adds a number of conversion methods to the Fixnum and Float
143
+ RVG adds a number of conversion methods to the Integer and Float
144
144
  classes . These methods allow you to specify measurements in
145
145
  units such as inches, millimeters, and centimeters. <em>DPI</em>
146
146
  stands for "dots per inch," the image resolution. Here I set
@@ -290,7 +290,7 @@ image = image.first
290
290
 
291
291
  # Give the user something to look at while we're working.
292
292
  name = File.basename(filename).sub(/\..*?$/, '')
293
- $defout.sync = true
293
+ $stdout.sync = true
294
294
  printf "Creating #{name}_Histogram.miff"
295
295
 
296
296
  timer = Thread.new do
@@ -14,16 +14,26 @@ module RMagick
14
14
  attr_reader :headers
15
15
 
16
16
  def initialize
17
+ @stdout = $stdout.dup
18
+
19
+ setup_paths_for_homebrew
17
20
  configure_compile_options
18
21
  assert_can_compile!
19
22
  configure_headers
20
23
  end
21
24
 
25
+ def setup_paths_for_homebrew
26
+ return unless find_executable('brew')
27
+
28
+ brew_pkg_config_path = "#{`brew --prefix imagemagick@6`.strip}/lib/pkgconfig"
29
+ pkgconfig_paths = ENV['PKG_CONFIG_PATH'].to_s.split(':')
30
+ if File.exist?(brew_pkg_config_path) && !pkgconfig_paths.include?(brew_pkg_config_path)
31
+ ENV['PKG_CONFIG_PATH'] = [ENV['PKG_CONFIG_PATH'], brew_pkg_config_path].compact.join(':')
32
+ end
33
+ end
34
+
22
35
  def configured_compile_options
23
36
  {
24
- magick_config: $magick_config,
25
- with_magick_wand: $with_magick_wand,
26
- pkg_config: $pkg_config,
27
37
  magick_version: $magick_version,
28
38
  local_libs: $LOCAL_LIBS,
29
39
  cflags: $CFLAGS,
@@ -35,15 +45,13 @@ module RMagick
35
45
  end
36
46
 
37
47
  def configure_headers
38
- # headers = %w{assert.h ctype.h errno.h float.h limits.h math.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h time.h}
39
48
  @headers = %w[assert.h ctype.h stdio.h stdlib.h math.h time.h]
40
- headers << 'stdint.h' if have_header('stdint.h') # defines uint64_t
41
49
  headers << 'sys/types.h' if have_header('sys/types.h')
42
50
 
43
- if have_header('wand/MagickWand.h')
44
- headers << 'wand/MagickWand.h'
51
+ if have_header('magick/MagickCore.h')
52
+ headers << 'magick/MagickCore.h'
45
53
  else
46
- exit_failure "\nCan't install RMagick #{RMAGICK_VERS}. Can't find MagickWand.h."
54
+ exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find magick/MagickCore.h."
47
55
  end
48
56
  end
49
57
 
@@ -56,21 +64,9 @@ module RMagick
56
64
  cc = (ENV['CC'] || config::CONFIG['CC'] || 'gcc').split(' ').first
57
65
  exit_failure "No C compiler found in ${ENV['PATH']}. See mkmf.log for details." unless find_executable(cc)
58
66
 
59
- # ugly way to handle which config tool we're going to use...
60
- $with_magick_wand = false
61
- $magick_config = false
62
- $pkg_config = false
63
-
64
- # Check for Magick-config
65
- if find_executable('Magick-config') && !has_graphicsmagick_libmagick_dev_compat?
66
- $magick_config = true
67
- $magick_version = `Magick-config --version`[/^(\d+\.\d+\.\d+)/]
68
- elsif find_executable('pkg-config')
69
- $pkg_config = true
70
- $magick_version = `pkg-config MagickCore --modversion`[/^(\d+\.\d+\.\d+)/]
71
- else
72
- exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find Magick-config or pkg-config in #{ENV['PATH']}\n"
73
- end
67
+ magick_package = determine_imagemagick_package
68
+
69
+ $magick_version = `pkg-config #{magick_package} --modversion`[/^(\d+\.\d+\.\d+)/]
74
70
 
75
71
  check_multiple_imagemagick_versions
76
72
  check_partial_imagemagick_versions
@@ -83,51 +79,11 @@ module RMagick
83
79
  exit_failure "Can't install RMagick #{RMAGICK_VERS}. You must have ImageMagick #{Magick::MIN_IM_VERSION} or later.\n" if Gem::Version.new($magick_version) < Gem::Version.new(Magick::MIN_IM_VERSION)
84
80
  end
85
81
 
86
- # From ImageMagick 6.9 binaries are split to two and we have to use
87
- # MagickWand instead of MagickCore
88
- checking_for("presence of MagickWand API (ImageMagick version >= #{Magick::MIN_WAND_VERSION})") do
89
- $with_magick_wand = Gem::Version.new($magick_version) >= Gem::Version.new(Magick::MIN_WAND_VERSION)
90
- if $with_magick_wand
91
- Logging.message('Detected 6.9+ version, using MagickWand API')
92
- else
93
- Logging.message('Older version detected, using MagickCore API')
94
- end
95
- end
96
-
97
- # either set flags using Magick-config, MagickWand-config or pkg-config (new Debian default)
98
- if $with_magick_wand
99
- if $magick_config
100
- # Save flags
101
- $CFLAGS = ENV['CFLAGS'].to_s + ' ' + `MagickWand-config --cflags`.chomp
102
- $CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `MagickWand-config --cppflags`.chomp
103
- $LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `MagickWand-config --ldflags`.chomp
104
- $LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `MagickWand-config --libs`.chomp
105
- end
106
-
107
- if $pkg_config
108
- # Save flags
109
- $CFLAGS = ENV['CFLAGS'].to_s + ' ' + `pkg-config --cflags MagickWand`.chomp
110
- $CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `pkg-config --cflags MagickWand`.chomp
111
- $LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `pkg-config --libs MagickWand`.chomp
112
- $LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `pkg-config --libs MagickWand`.chomp
113
- end
114
- else
115
- if $magick_config
116
- # Save flags
117
- $CFLAGS = ENV['CFLAGS'].to_s + ' ' + `Magick-config --cflags`.chomp
118
- $CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `Magick-config --cppflags`.chomp
119
- $LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `Magick-config --ldflags`.chomp
120
- $LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `Magick-config --libs`.chomp
121
- end
122
-
123
- if $pkg_config
124
- # Save flags
125
- $CFLAGS = ENV['CFLAGS'].to_s + ' ' + `pkg-config --cflags MagickCore`.chomp
126
- $CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `pkg-config --cflags MagickCore`.chomp
127
- $LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `pkg-config --libs MagickCore`.chomp
128
- $LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `pkg-config --libs MagickCore`.chomp
129
- end
130
- end
82
+ # Save flags
83
+ $CFLAGS = ENV['CFLAGS'].to_s + ' ' + `pkg-config --cflags #{magick_package}`.chomp
84
+ $CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `pkg-config --cflags #{magick_package}`.chomp
85
+ $LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `pkg-config --libs #{magick_package}`.chomp
86
+ $LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `pkg-config --libs #{magick_package}`.chomp
131
87
 
132
88
  set_archflags_for_osx if RUBY_PLATFORM =~ /darwin/ # osx
133
89
 
@@ -136,7 +92,12 @@ module RMagick
136
92
  `identify -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
137
93
  abort 'Unable to get ImageMagick version' unless Regexp.last_match(1)
138
94
  $magick_version = Regexp.last_match(1)
139
- search_paths_for_library_for_mingw unless have_library('CORE_RL_magick_')
95
+
96
+ dir_paths = search_paths_for_library_for_windows
97
+ $CPPFLAGS = %(-I"#{dir_paths[:include]}")
98
+ $LDFLAGS = %(-L"#{dir_paths[:lib]}")
99
+
100
+ have_library('CORE_RL_magick_')
140
101
  have_library('X11')
141
102
 
142
103
  else # mswin
@@ -144,10 +105,11 @@ module RMagick
144
105
  `identify -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
145
106
  abort 'Unable to get ImageMagick version' unless Regexp.last_match(1)
146
107
  $magick_version = Regexp.last_match(1)
147
- $CFLAGS = '-W3'
148
- $CPPFLAGS = %(-I"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include" -I"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\include")
149
- # The /link option is required by the Makefile but causes warnings in the mkmf.log file.
150
- $LDFLAGS = %(/link /LIBPATH:"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib" /LIBPATH:"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\lib" /LIBPATH:"C:\\ruby\\lib")
108
+
109
+ dir_paths = search_paths_for_library_for_windows
110
+ $CPPFLAGS << %( -I"#{dir_paths[:include]}")
111
+ $LDFLAGS << %( -libpath:"#{dir_paths[:lib]}")
112
+
151
113
  $LOCAL_LIBS = 'CORE_RL_magick_.lib'
152
114
  have_library('X11')
153
115
 
@@ -178,26 +140,49 @@ SRC
178
140
  end
179
141
  end
180
142
 
181
- def has_graphicsmagick_libmagick_dev_compat?
182
- config_path = `which Magick-config`.chomp
183
- if File.exist?(config_path) &&
184
- File.symlink?(config_path) &&
185
- File.readlink(config_path) =~ /GraphicsMagick/
186
- msg = 'Found a graphicsmagick-libmagick-dev-compat installation.'
187
- Logging.message msg
188
- message msg + "\n"
189
- true
143
+ def exit_failure(msg)
144
+ msg = "ERROR: #{msg}"
145
+
146
+ Logging.message msg
147
+
148
+ @stdout.puts "\n\n"
149
+ if ENV['NO_COLOR']
150
+ @stdout.puts msg
190
151
  else
191
- false
152
+ @stdout.print "\e[31m\e[1m#{msg}\e[0m"
192
153
  end
193
- end
154
+ @stdout.puts "\n\n"
155
+ @stdout.flush
194
156
 
195
- def exit_failure(msg)
196
- Logging.message msg
197
- message msg + "\n"
198
157
  exit(1)
199
158
  end
200
159
 
160
+ def determine_imagemagick_package
161
+ unless find_executable('pkg-config')
162
+ exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find pkg-config in #{ENV['PATH']}\n"
163
+ end
164
+
165
+ packages = `pkg-config --list-all`.scan(/(ImageMagick\-6[\.A-Z0-9]+) .*/).flatten
166
+
167
+ # For ancient version of ImageMagick 6 we need a different regex
168
+ if packages.empty?
169
+ packages = `pkg-config --list-all`.scan(/(ImageMagick) .*/).flatten
170
+ end
171
+
172
+ if packages.empty?
173
+ exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find ImageMagick with pkg-config\n"
174
+ end
175
+
176
+ if packages.length > 1
177
+ package_lines = packages.map { |package| " - #{package}" }.join("\n")
178
+ msg = "\nWarning: Found more than one ImageMagick installation. This could cause problems at runtime.\n#{package_lines}\n\n"
179
+ Logging.message msg
180
+ message msg
181
+ end
182
+
183
+ packages.first
184
+ end
185
+
201
186
  # Seems like lots of people have multiple versions of ImageMagick installed.
202
187
  def check_multiple_imagemagick_versions
203
188
  versions = []
@@ -260,12 +245,13 @@ SRC
260
245
  $ARCH_FLAG = archflags.join(' ') unless archflags.empty?
261
246
  end
262
247
 
263
- def search_paths_for_library_for_mingw
248
+ def search_paths_for_library_for_windows
264
249
  msg = 'searching PATH for the ImageMagick library...'
265
250
  Logging.message msg
266
251
  message msg + "\n"
267
252
 
268
253
  found_lib = false
254
+ dir_paths = {}
269
255
 
270
256
  paths = ENV['PATH'].split(File::PATH_SEPARATOR)
271
257
  paths.each do |dir|
@@ -273,13 +259,14 @@ SRC
273
259
  lib_file = File.join(lib, 'CORE_RL_magick_.lib')
274
260
  next unless File.exist?(lib_file)
275
261
 
276
- $CPPFLAGS = %(-I"#{File.join(dir, 'include')}")
277
- $LDFLAGS = %(-L"#{lib}")
278
- found_lib = have_library('CORE_RL_magick_')
279
- break if found_lib
262
+ dir_paths[:include] = File.join(dir, 'include')
263
+ dir_paths[:lib] = lib
264
+
265
+ found_lib = true
266
+ break
280
267
  end
281
268
 
282
- return if found_lib
269
+ return dir_paths if found_lib
283
270
 
284
271
  exit_failure <<END_MINGW
285
272
  Can't install RMagick #{RMAGICK_VERS}.
@@ -292,25 +279,10 @@ END_MINGW
292
279
  end
293
280
 
294
281
  def assert_can_compile!
295
- assert_not_windows!
296
282
  assert_minimum_ruby_version!
297
283
  assert_has_dev_libs!
298
284
  end
299
285
 
300
- def assert_not_windows!
301
- return unless RUBY_PLATFORM =~ /mswin/
302
-
303
- abort <<END_MSWIN
304
- +----------------------------------------------------------------------------+
305
- | This rmagick gem is for use only on Linux, BSD, OS X, and similar systems |
306
- | that have a gnu or similar toolchain installed. The rmagick-win32 gem is a |
307
- | pre-compiled version of RMagick bundled with ImageMagick for use on |
308
- | Microsoft Windows systems. The rmagick-win32 gem is available on RubyForge.|
309
- | See http://rmagick.rubyforge.org/install-faq.html for more information. |
310
- +----------------------------------------------------------------------------+
311
- END_MSWIN
312
- end
313
-
314
286
  def assert_minimum_ruby_version!
315
287
  unless checking_for("Ruby version >= #{MIN_RUBY_VERS}") do
316
288
  version = RUBY_VERSION.tr('.', '').to_i
@@ -323,10 +295,7 @@ END_MSWIN
323
295
  def assert_has_dev_libs!
324
296
  return unless RUBY_PLATFORM !~ /mswin|mingw/
325
297
 
326
- # check for pkg-config if Magick-config doesn't exist
327
- if $magick_config && `Magick-config --libs`[/\bl\s*(MagickCore|Magick)6?\b/]
328
- elsif $pkg_config && `pkg-config --libs MagickCore`[/\bl\s*(MagickCore|Magick)6?\b/]
329
- else
298
+ unless `pkg-config --libs MagickCore`[/\bl\s*(MagickCore|Magick)6?\b/]
330
299
  exit_failure "Can't install RMagick #{RMAGICK_VERS}. " \
331
300
  "Can't find the ImageMagick library or one of the dependent libraries. " \
332
301
  "Check the mkmf.log file for more detailed information.\n"
@@ -335,164 +304,21 @@ END_MSWIN
335
304
 
336
305
  def create_header_file
337
306
  have_func('snprintf', headers)
338
- ['AcquireImage', # 6.4.1
339
- 'AffinityImage', # 6.4.3-6
340
- 'AffinityImages', # 6.4.3-6
341
- 'AutoGammaImageChannel', # 6.5.5-1
342
- 'AutoLevelImageChannel', # 6.5.5-1
343
- 'BlueShiftImage', # 6.5.4-3
344
- 'ColorMatrixImage', # 6.6.1-0
345
- 'ConstituteComponentTerminus', # 6.5.7-9
346
- 'DeskewImage', # 6.4.2-5
347
- 'DestroyConstitute', # 6.5.7-9(deprecated)
348
- 'EncipherImage', # 6.3.8-6
349
- 'EqualizeImageChannel', # 6.3.6-9
350
- 'EvaluateImages', # 6.8.6-4
351
- 'FloodfillPaintImage', # 6.3.7
352
- 'FunctionImageChannel', # 6.4.8-8
353
- 'GetAuthenticIndexQueue', # 6.4.5-6
354
- 'GetAuthenticPixels', # 6.4.5-6
355
- 'GetImageAlphaChannel', # 6.3.9-2
356
- 'GetImageChannelEntropy', # 6.9.0-0
357
- 'GetMagickFeatures', # 6.5.7-1
358
- 'GetVirtualPixels', # 6.4.5-6
359
- 'LevelImageColors', # 6.4.2
360
- 'LevelColorsImageChannel', # 6.5.6-4
361
- 'LevelizeImageChannel', # 6.4.2
362
- 'LiquidRescaleImage', # 6.3.8-2
363
- 'MagickLibAddendum', # 6.5.9-1
364
- 'OpaquePaintImageChannel', # 6.3.7-10
365
- 'QueueAuthenticPixels', # 6.4.5-6
366
- 'RemapImage', # 6.4.4-0
367
- 'RemapImages', # 6.4.4-0
368
- 'RemoveImageArtifact', # 6.3.6
369
- 'RotationalBlurImage', # 6.8.8-9
370
- 'RotationalBlurImageChannel', # 6.8.8-9
371
- 'SelectiveBlurImageChannel', # 6.5.0-3
372
- 'SetImageAlphaChannel', # 6.3.6-9
373
- 'SetImageArtifact', # 6.3.6
374
- 'SetMagickMemoryMethods', # 6.4.1
375
- 'SparseColorImage', # 6.3.6-?
376
- 'StatisticImage', # 6.6.8-6
377
- 'SyncAuthenticPixels', # 6.4.5-6
378
- 'TransformImageColorspace', # 6.5.1
379
- 'TransparentPaintImage', # 6.3.7-10
380
- 'TransparentPaintImageChroma' # 6.4.5-6
307
+ [
308
+ 'GetImageChannelEntropy', # 6.9.0-0
309
+ 'SetImageGray' # 6.9.1-10
381
310
  ].each do |func|
382
311
  have_func(func, headers)
383
312
  end
384
313
 
385
- checking_for('QueryMagickColorname() new signature') do
386
- if try_compile(<<"SRC")
387
- #{COMMON_HEADERS}
388
- #{cpp_include(headers)}
389
- /*top*/
390
- int main() {
391
- MagickBooleanType okay;
392
- Image *image;
393
- MagickPixelPacket *color;
394
- char *name;
395
- ExceptionInfo *exception;
396
- okay = QueryMagickColorname(image, color, SVGCompliance, name, exception);
397
- return 0;
398
- }
399
- SRC
400
- $defs.push('-DHAVE_NEW_QUERYMAGICKCOLORNAME')
401
- true
402
- else
403
- false
404
- end
405
- end
406
-
407
- have_struct_member('Image', 'type', headers) # ???
408
- have_struct_member('DrawInfo', 'kerning', headers) # 6.4.7-8
409
- have_struct_member('DrawInfo', 'interline_spacing', headers) # 6.5.5-8
410
- have_struct_member('DrawInfo', 'interword_spacing', headers) # 6.4.8-0
411
- have_type('DitherMethod', headers) # 6.4.2
412
- have_type('MagickFunction', headers) # 6.4.8-8
413
- have_type('ImageLayerMethod', headers) # 6.3.6 replaces MagickLayerMethod
414
- have_type('long double', headers)
415
- # have_type("unsigned long long", headers)
416
- # have_type("uint64_t", headers)
417
- # have_type("__int64", headers)
418
- # have_type("uintmax_t", headers)
419
- # check_sizeof("unsigned long", headers)
420
- # check_sizeof("Image *", headers)
421
-
422
- have_enum_values('AlphaChannelType', ['CopyAlphaChannel', # 6.4.3-7
423
- 'BackgroundAlphaChannel', # 6.5.2-5
424
- 'RemoveAlphaChannel'], headers) # 6.7.5-1
425
- have_enum_values('CompositeOperator', ['BlurCompositeOp', # 6.5.3-7
426
- 'DistortCompositeOp', # 6.5.3-10
427
- 'LinearBurnCompositeOp', # 6.5.4-3
428
- 'LinearDodgeCompositeOp', # 6.5.4-3
429
- 'MathematicsCompositeOp', # 6.5.4-3
430
- 'PegtopLightCompositeOp', # 6.5.4-3
431
- 'PinLightCompositeOp', # 6.5.4-3
432
- 'VividLightCompositeOp'], headers) # 6.5.4-3
433
- have_enum_values('CompressionType', ['DXT1Compression', # 6.3.9-3
434
- 'DXT3Compression', # 6.3.9-3
435
- 'DXT5Compression', # 6.3.9-3
436
- 'ZipSCompression', # 6.5.5-4
437
- 'PizCompression', # 6.5.5-4
438
- 'Pxr24Compression', # 6.5.5-4
439
- 'B44Compression', # 6.5.5-4
440
- 'B44ACompression'], headers) # 6.5.5-4
441
-
442
- have_enum_values('DistortImageMethod', ['BarrelDistortion', # 6.4.2-5
443
- 'BarrelInverseDistortion', # 6.4.3-8
444
- 'BilinearForwardDistortion', # 6.5.1-2
445
- 'BilinearReverseDistortion', # 6.5.1-2
446
- 'DePolarDistortion', # 6.4.2-6
447
- 'PolarDistortion', # 6.4.2-6
448
- 'PolynomialDistortion', # 6.4.2-4
449
- 'ShepardsDistortion'], headers) # 6.4.2-4
450
- have_enum_value('DitherMethod', 'NoDitherMethod', headers) # 6.4.3
451
- have_enum_values('FilterTypes', ['KaiserFilter', # 6.3.6
452
- 'WelshFilter', # 6.3.6-4
453
- 'ParzenFilter', # 6.3.6-4
454
- 'LagrangeFilter', # 6.3.7-2
455
- 'BohmanFilter', # 6.3.7-2
456
- 'BartlettFilter', # 6.3.7-2
457
- 'SentinelFilter'], headers) # 6.3.7-2
458
- have_enum_values('MagickEvaluateOperator', ['PowEvaluateOperator', # 6.4.1-9
459
- 'LogEvaluateOperator', # 6.4.2
460
- 'ThresholdEvaluateOperator', # 6.4.3
461
- 'ThresholdBlackEvaluateOperator', # 6.4.3
462
- 'ThresholdWhiteEvaluateOperator', # 6.4.3
463
- 'GaussianNoiseEvaluateOperator', # 6.4.3
464
- 'ImpulseNoiseEvaluateOperator', # 6.4.3
465
- 'LaplacianNoiseEvaluateOperator', # 6.4.3
466
- 'MultiplicativeNoiseEvaluateOperator', # 6.4.3
467
- 'PoissonNoiseEvaluateOperator', # 6.4.3
468
- 'UniformNoiseEvaluateOperator', # 6.4.3
469
- 'CosineEvaluateOperator', # 6.4.8-5
470
- 'SineEvaluateOperator', # 6.4.8-5
471
- 'AddModulusEvaluateOperator'], # 6.4.8-5
472
- headers)
473
- have_enum_values('MagickFunction', ['ArcsinFunction', # 6.5.2-8
474
- 'ArctanFunction', # 6.5.2-8
475
- 'PolynomialFunction', # 6.4.8-8
476
- 'SinusoidFunction'], headers) # 6.4.8-8
477
- have_enum_values('ImageLayerMethod', ['FlattenLayer', # 6.3.6-2
478
- 'MergeLayer', # 6.3.6
479
- 'MosaicLayer', # 6.3.6-2
480
- 'TrimBoundsLayer'], headers) # 6.4.3-8
481
- have_enum_values('VirtualPixelMethod', ['HorizontalTileVirtualPixelMethod', # 6.4.2-6
482
- 'VerticalTileVirtualPixelMethod', # 6.4.2-6
483
- 'HorizontalTileEdgeVirtualPixelMethod', # 6.5.0-1
484
- 'VerticalTileEdgeVirtualPixelMethod', # 6.5.0-1
485
- 'CheckerTileVirtualPixelMethod'], # 6.5.0-1
486
- headers)
487
-
488
- headers = ['ruby.h', 'ruby/io.h']
489
-
490
- have_func('rb_frame_this_func', headers)
491
-
492
314
  # Miscellaneous constants
493
315
  $defs.push("-DRUBY_VERSION_STRING=\"ruby #{RUBY_VERSION}\"")
494
316
  $defs.push("-DRMAGICK_VERSION_STRING=\"RMagick #{RMAGICK_VERS}\"")
495
317
 
318
+ if Gem::Version.new($magick_version) >= Gem::Version.new('6.8.9')
319
+ $defs.push('-DIMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9=1')
320
+ end
321
+
496
322
  create_header
497
323
  end
498
324
 
@@ -514,10 +340,10 @@ SRC
514
340
 
515
341
 
516
342
  #{'=' * 70}
517
- #{DateTime.now.strftime('%a %d%b%y %T')}
343
+ #{DateTime.now.strftime('%a %d %b %y %T')}
518
344
  This installation of RMagick #{RMAGICK_VERS} is configured for
519
345
  Ruby #{RUBY_VERSION} (#{RUBY_PLATFORM}) and ImageMagick #{$magick_version}
520
- #{'=' * 70}
346
+ #{'=' * 70}
521
347
 
522
348
 
523
349
  END_SUMMARY