rmagick 5.4.4 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +15 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop_todo.yml +16 -8
  5. data/CHANGELOG.md +43 -0
  6. data/Gemfile +20 -0
  7. data/Rakefile +11 -0
  8. data/before_install_osx.sh +1 -1
  9. data/ext/RMagick/extconf.rb +24 -6
  10. data/ext/RMagick/rmagick.h +3 -1
  11. data/ext/RMagick/rmdraw.cpp +10 -10
  12. data/ext/RMagick/rmfill.cpp +4 -4
  13. data/ext/RMagick/rmilist.cpp +10 -2
  14. data/ext/RMagick/rmimage.cpp +321 -294
  15. data/ext/RMagick/rminfo.cpp +22 -21
  16. data/ext/RMagick/rmkinfo.cpp +5 -18
  17. data/ext/RMagick/rmmain.cpp +30 -64
  18. data/ext/RMagick/rmmontage.cpp +5 -5
  19. data/ext/RMagick/rmpixel.cpp +1 -1
  20. data/ext/RMagick/rmutil.cpp +31 -71
  21. data/lib/rmagick/version.rb +1 -1
  22. data/lib/rmagick_internal.rb +67 -65
  23. data/lib/rvg/embellishable.rb +6 -2
  24. data/lib/rvg/misc.rb +7 -7
  25. data/lib/rvg/rvg.rb +2 -0
  26. data/lib/rvg/stretchable.rb +2 -2
  27. data/lib/rvg/transformable.rb +1 -1
  28. data/rmagick.gemspec +1 -13
  29. data/sig/rmagick/_draw_common_methods.rbs +64 -0
  30. data/sig/rmagick/_image_common_methods.rbs +389 -0
  31. data/sig/rmagick/draw.rbs +38 -0
  32. data/sig/rmagick/draw_attribute.rbs +28 -0
  33. data/sig/rmagick/enum.rbs +814 -0
  34. data/sig/rmagick/error.rbs +11 -0
  35. data/sig/rmagick/fill.rbs +21 -0
  36. data/sig/rmagick/geometry.rbs +14 -0
  37. data/sig/rmagick/image.rbs +194 -0
  38. data/sig/rmagick/image_list.rbs +181 -0
  39. data/sig/rmagick/iptc.rbs +101 -0
  40. data/sig/rmagick/kernel_info.rbs +12 -0
  41. data/sig/rmagick/optional_method_arguments.rbs +10 -0
  42. data/sig/rmagick/pixel.rbs +46 -0
  43. data/sig/rmagick/struct.rbs +90 -0
  44. data/sig/rmagick.rbs +43 -0
  45. data/sig/rvg/clippath.rbs +34 -0
  46. data/sig/rvg/container.rbs +78 -0
  47. data/sig/rvg/deep_equal.rbs +48 -0
  48. data/sig/rvg/describable.rbs +30 -0
  49. data/sig/rvg/embellishable.rbs +226 -0
  50. data/sig/rvg/misc.rbs +145 -0
  51. data/sig/rvg/paint.rbs +55 -0
  52. data/sig/rvg/pathdata.rbs +77 -0
  53. data/sig/rvg/rvg.rbs +125 -0
  54. data/sig/rvg/stretchable.rbs +56 -0
  55. data/sig/rvg/stylable.rbs +66 -0
  56. data/sig/rvg/text.rbs +118 -0
  57. data/sig/rvg/transformable.rbs +59 -0
  58. data/sig/rvg/units.rbs +33 -0
  59. metadata +32 -128
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fd768daa5bf84d7e835a4c300d57f6826b3fd86820dd3048a12d73db62ec89f
4
- data.tar.gz: b7afe50d7396365282e6d5e8ff7b8a6c2b0e91e7f1e2d9562d1078dd26bda7a4
3
+ metadata.gz: 41d6b9634204858bad669688ff19fc54c14dc3578f011696ade0295b5e4f7e88
4
+ data.tar.gz: 781493a793ec5ee4b9a60063761484e8b1d44e622963c2593caefac314d7ed8a
5
5
  SHA512:
6
- metadata.gz: 23b6376b8c659276107e35c4e58428bc68a4cd8d2d24830ee27c99a83dea0349516af72bf8746a9064f115d35ae3e2f8affa376c6b6ec77d8b7a89aa7ddede8c
7
- data.tar.gz: 7633f97e950e07f2381f25d1a181b427408fa8e46790b0506c31d83d029f58f5098a073446d659d82a05988c20848f60a37fbfe5759340a8613da87bdbc53cae
6
+ metadata.gz: e90299bfe4a9b5d9a6291d53707db9ec772fb2247517f4e9ca9e4633320a6a9c2067195dcc90109bc743cd9f0a12882adfd679fb4e06c6995958e8b962125e0e
7
+ data.tar.gz: 1e2b528111b27b48ec4f3dc8be1e65d3bf181ec8888c5e1562959b98af4762f12dd9285d4d78520eb400ffb16e09f93950e8527b27e552396487c56fd1258b95
@@ -25,6 +25,21 @@ jobs:
25
25
  bundle install --path=vendor/bundle --jobs 4 --retry 3
26
26
  STYLE_CHECKS=true bundle exec rubocop
27
27
 
28
+ rbs:
29
+ runs-on: ubuntu-latest
30
+ name: RBS
31
+ timeout-minutes: 20
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - name: Set up Ruby 3.0
35
+ uses: ruby/setup-ruby@master
36
+ with:
37
+ ruby-version: '3.0'
38
+ - name: Validate RBS signatures
39
+ run: |
40
+ bundle install --path=vendor/bundle --jobs 4 --retry 3
41
+ bundle exec rake rbs:validate && bundle exec steep check
42
+
28
43
  test-linux:
29
44
  runs-on: ubuntu-latest
30
45
  timeout-minutes: 20
data/.gitignore CHANGED
@@ -23,6 +23,7 @@ tmp
23
23
  *.def
24
24
  Makefile
25
25
  extconf.h
26
+ compile_flags.txt
26
27
  build-ImageMagick/
27
28
  doc/node_modules/
28
29
  doc/package-lock.json
data/.rubocop_todo.yml CHANGED
@@ -6,6 +6,21 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 9
10
+ # Configuration parameters: Include, IgnoredGems.
11
+ # Include: **/*.gemfile, **/Gemfile, **/gems.rb
12
+ Bundler/GemComment:
13
+ Exclude:
14
+ - 'Gemfile'
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
19
+ # Include: **/*.gemfile, **/Gemfile, **/gems.rb
20
+ Bundler/OrderedGems:
21
+ Exclude:
22
+ - 'Gemfile'
23
+
9
24
  # Offense count: 1
10
25
  # Cop supports --auto-correct.
11
26
  # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
@@ -26,7 +41,6 @@ Layout/ClassStructure:
26
41
  - 'lib/rvg/misc.rb'
27
42
  - 'lib/rvg/pathdata.rb'
28
43
  - 'lib/rvg/rvg.rb'
29
- - 'lib/rvg/to_c.rb'
30
44
 
31
45
  # Offense count: 2312
32
46
  # Cop supports --auto-correct.
@@ -79,7 +93,6 @@ Lint/NumberConversion:
79
93
  - 'examples/thumbnail.rb'
80
94
  - 'lib/rmagick_internal.rb'
81
95
  - 'lib/rvg/misc.rb'
82
- - 'lib/rvg/to_c.rb'
83
96
  - 'spec/magick_spec.rb'
84
97
  - 'spec/rmagick/align_type/class_methods/values_spec.rb'
85
98
  - 'spec/rmagick/enum/bitwise_or_spec.rb'
@@ -127,7 +140,7 @@ Metrics/BlockNesting:
127
140
  # Offense count: 9
128
141
  # Configuration parameters: CountComments.
129
142
  Metrics/ClassLength:
130
- Max: 460
143
+ Max: 469
131
144
 
132
145
  # Offense count: 21
133
146
  # Configuration parameters: IgnoredMethods.
@@ -226,11 +239,6 @@ Security/MarshalLoad:
226
239
  - 'spec/rmagick/image/marshal_spec.rb'
227
240
  - 'spec/rmagick/image_list/marshal_spec.rb'
228
241
 
229
- # Offense count: 1
230
- Style/AutoResourceCleanup:
231
- Exclude:
232
- - 'lib/rvg/to_c.rb'
233
-
234
242
  # Offense count: 7
235
243
  Style/CaseEquality:
236
244
  Exclude:
data/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
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 5.5.0
7
+
8
+ Improvements
9
+
10
+ - Add RBS signatures (#1458)
11
+ - Remove unnecessary type check in KernelInfo#{unity_add, scale} (#1514)
12
+ - Remove unnecessary type check in Image#{morphology, morphology_channel} (#1513)
13
+ - Improve HatchFill.new to accept Pixel object as color (#1512)
14
+ - Fix GraphicContext#font_weight to accept Numeric object (#1510)
15
+ - Improve GraphicContext#font_weight to accept Symbol object (#1509)
16
+ - Improve Stretchable#viewbox to use implicitly conversioned value (#1507)
17
+ - Improve RVG::Transformable#rotate to convert to Float implicitly (#1506)
18
+ - Fix Image#modulate in order to accept negative number (#1505)
19
+ - Improve Image#modulate to accept "NN%" form string (#1504)
20
+ - Implicit conversion to string with methods that expect a string (#1496)
21
+ - Coerce to string instead of using #to_s (#1495)
22
+ - Coerce to string where pass object into string interpolation (#1494)
23
+ - Fix Draw#{fill_opacity, opacity, stroke_opacity} to correctly handle arguments (#1492)
24
+ - Fix Draw#{interline_spacing, interword_spacing, kerning} to correctly handle arguments that can be converted to Float (#1491)
25
+ - Remove unnecessary type check in KernelInfo methods (#1489)
26
+ - Generate compile_flags.txt for clangd for development (#1488)
27
+ - Fix Draw#{stroke_dasharray, stroke_miterlimit} to accept object which has #to_f method (#1486)
28
+ - Fix Image#composite_affine to accept ImageList object (#1484)
29
+ - Fix Image#add_compose_mask to accept ImageList object (#1483)
30
+ - Fix incorrect number of required arguments in ArgumentError (#1482)
31
+ - Fix ImageList#sort! that should return self (#1481)
32
+ - Fix ImageList#eql? that should not raise exception if can't compare (#1479)
33
+ - Fix ImageList#<=> that should return nil if can't compare (#1478)
34
+ - Add DrawAttribute module to simplify Draw, DrawOptions and PolaroidOptions (#1477)
35
+ - Add missing attribute writer methods in Image::{DrawOptions, PolaroidOptions} (#1476)
36
+ - Add Image::PolaroidOptions#affine= (#1475)
37
+ - Add Image::PolaroidOptions#tile= (#1474)
38
+ - Attribute writer methods should return passed value (#1473)
39
+ - Return self with ImageList if Image's method return self (#1472)
40
+ - Fix Image#clut_channel to accept ImageList object (#1471)
41
+ - Fix Magick::GradientFill#fill and Magick::TextureFill#fill to accept ImageList object (#1467)
42
+
43
+ Bug Fixes
44
+
45
+ - Fix typo in order to fix NoMethodError (#1515)
46
+ - Sync compression value in order fix the problem of compression being ignored by ImageMagick 7 (#1503)
47
+ - Add PKG_CONFIG_PATH for ImageMagick 7 in order to fix installation error on macOS (#1501)
48
+
6
49
  ## RMagick 5.4.4
7
50
 
8
51
  Bug Fixes
data/Gemfile CHANGED
@@ -2,3 +2,23 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rmagick.gemspec
4
4
  gemspec
5
+
6
+ gem 'pry', '~> 0.14'
7
+ gem 'rake-compiler', '~> 1.0'
8
+ gem 'rspec', '~> 3.8'
9
+ gem 'rspec_junit_formatter', '~> 0.6.0'
10
+ gem 'simplecov', '~> 0.16.1'
11
+ gem 'yard', '~> 0.9.24'
12
+
13
+ if RUBY_PLATFORM !~ /mswin|mingw/
14
+ gem 'rubocop', '~> 0.81.0'
15
+ gem 'rubocop-rspec', '~> 1.38.1'
16
+ gem 'rubocop-performance', '~> 1.5.2'
17
+ end
18
+
19
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
20
+ # For CI
21
+ gem 'rbs', '~> 3.4'
22
+
23
+ gem 'steep', '~> 1.6'
24
+ end
data/Rakefile CHANGED
@@ -143,6 +143,17 @@ namespace :website do
143
143
  end
144
144
  end
145
145
 
146
+ namespace :rbs do
147
+ desc 'Validate RBS definitions'
148
+ task :validate do
149
+ all_sigs = Dir.glob('sig').map { |dir| "-I #{dir}" }.join(' ')
150
+ sh("bundle exec rbs #{all_sigs} validate") do |ok, _|
151
+ abort('one or more rbs validate failed') unless ok
152
+ end
153
+ end
154
+ end
155
+
156
+ require 'bundler/gem_tasks'
146
157
  require 'rake/extensiontask'
147
158
  require 'rspec/core/rake_task'
148
159
  RSpec::Core::RakeTask.new(:spec)
@@ -43,7 +43,7 @@ build_imagemagick() {
43
43
  fi
44
44
 
45
45
  cd "${build_dir}"
46
- ./configure --prefix=/usr/local "${options}" --without-raw --without-jxl
46
+ ./configure --prefix=/usr/local "${options}" --without-raw --without-jxl --without-openjp2
47
47
  make -j
48
48
  }
49
49
 
@@ -58,16 +58,17 @@ module RMagick
58
58
  return if RUBY_PLATFORM =~ /mswin|mingw/
59
59
 
60
60
  if find_executable('brew')
61
- pkg_config_path = "#{`brew --prefix imagemagick@6`.strip}/lib/pkgconfig"
61
+ append_pkg_config_path("#{`brew --prefix imagemagick`.strip}/lib/pkgconfig")
62
+ append_pkg_config_path("#{`brew --prefix imagemagick@6`.strip}/lib/pkgconfig")
62
63
  elsif find_executable('pacman')
63
- pkg_config_path = '/usr/lib/imagemagick6/pkgconfig'
64
- else
65
- return
64
+ append_pkg_config_path('/usr/lib/imagemagick6/pkgconfig')
66
65
  end
66
+ end
67
67
 
68
+ def append_pkg_config_path(path)
68
69
  pkg_config_paths = ENV['PKG_CONFIG_PATH'].to_s.split(':')
69
- if File.exist?(pkg_config_path) && !pkg_config_paths.include?(pkg_config_path)
70
- ENV['PKG_CONFIG_PATH'] = [ENV['PKG_CONFIG_PATH'], pkg_config_path].compact.join(':')
70
+ if File.exist?(path) && !pkg_config_paths.include?(path)
71
+ ENV['PKG_CONFIG_PATH'] = [ENV['PKG_CONFIG_PATH'], path].compact.join(':')
71
72
  end
72
73
  end
73
74
 
@@ -413,6 +414,22 @@ module RMagick
413
414
  print_summary
414
415
  end
415
416
 
417
+ def create_compile_flags_txt
418
+ cppflags = $CPPFLAGS.split(' ')
419
+ include_flags = cppflags.select { |flag| flag.start_with?('-I') }
420
+ define_flags = cppflags.select { |flag| flag.start_with?('-D') } + $defs
421
+
422
+ File.open('compile_flags.txt', 'w') do |f|
423
+ include_flags.each { |flag| f.puts(flag) }
424
+ f.puts "-I#{Dir.pwd}"
425
+ f.puts "-I#{RbConfig::CONFIG['rubyhdrdir']}"
426
+ f.puts "-I#{RbConfig::CONFIG['rubyhdrdir']}/ruby/backward"
427
+ f.puts "-I#{RbConfig::CONFIG['rubyarchhdrdir']}"
428
+ f.puts "-std=c++11"
429
+ define_flags.each { |flag| f.puts(flag) }
430
+ end
431
+ end
432
+
416
433
  def magick_command
417
434
  @magick_command ||= if find_executable('magick')
418
435
  'magick'
@@ -451,3 +468,4 @@ at_exit do
451
468
  message msg + "\n"
452
469
  end
453
470
  extconf.create_makefile_file
471
+ extconf.create_compile_flags_txt
@@ -333,6 +333,7 @@ typedef enum _QuantumExpressionOperator
333
333
  * RMagick Module and Class VALUEs
334
334
  */
335
335
  EXTERN VALUE Module_Magick;
336
+ EXTERN VALUE Module_DrawAttribute;
336
337
  EXTERN VALUE Class_ImageList;
337
338
  EXTERN VALUE Class_Info;
338
339
  EXTERN VALUE Class_KernelInfo;
@@ -1173,7 +1174,8 @@ extern int rm_check_num2dbl(VALUE);
1173
1174
  extern double rm_fuzz_to_dbl(VALUE);
1174
1175
  extern Quantum rm_app2quantum(VALUE);
1175
1176
  extern double rm_percentage(VALUE, double);
1176
- extern double rm_str_to_pct(VALUE);
1177
+ extern double rm_percentage2(VALUE, double, bool);
1178
+ extern double rm_str_to_pct(VALUE, bool);
1177
1179
  extern VALUE rm_define_enum_type(const char *);
1178
1180
  extern void rm_write_temp_image(Image *, char *, size_t);
1179
1181
  extern void rm_delete_temp_image(char *);
@@ -950,20 +950,20 @@ Draw_clone(VALUE self)
950
950
  * Draw the image.
951
951
  *
952
952
  * @overload composite(x, y, width, height, image)
953
- * @param x [Float] x position
954
- * @param y [Float] y position
955
- * @param width [Float] the width
956
- * @param height [Float] the height
953
+ * @param x [Numeric] x position
954
+ * @param y [Numeric] y position
955
+ * @param width [Numeric] the width
956
+ * @param height [Numeric] the height
957
957
  * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
958
958
  * imagelist, uses the current image.
959
959
  *
960
960
  * @overload composite(x, y, width, height, image, composite_op = Magick::OverCompositeOp)
961
961
  * - The "image" argument can be either an ImageList object or an Image
962
962
  * argument.
963
- * @param x [Float] x position
964
- * @param y [Float] y position
965
- * @param width [Float] the width
966
- * @param height [Float] the height
963
+ * @param x [Numeric] x position
964
+ * @param y [Numeric] y position
965
+ * @param width [Numeric] the width
966
+ * @param height [Numeric] the height
967
967
  * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
968
968
  * imagelist, uses the current image.
969
969
  * @param composite_op [Magick::CompositeOperator] the operator
@@ -1463,8 +1463,8 @@ PolaroidOptions_alloc(VALUE klass)
1463
1463
  /**
1464
1464
  * Initialize a PolaroidOptions object.
1465
1465
  *
1466
- * @yield [self]
1467
- * @yieldparam self [Magick::Image::PolaroidOptions] self
1466
+ * @yield [opt]
1467
+ * @yieldparam opt [Magick::Image::PolaroidOptions] self
1468
1468
  * @return [Magick::Image::PolaroidOptions] self
1469
1469
  */
1470
1470
  VALUE
@@ -634,7 +634,7 @@ h_diagonal_fill(
634
634
  * Call GradientFill with the start and stop colors specified when this fill
635
635
  * object was created.
636
636
  *
637
- * @param image_obj [Magick::Image] the image to fill
637
+ * @param image_obj [Magick::Image, Magick::ImageList] the image to fill
638
638
  * @return [Magick::GradientFill] self
639
639
  */
640
640
  VALUE
@@ -646,7 +646,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
646
646
  double x1, y1, x2, y2; // points on the line
647
647
 
648
648
  TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
649
- image = rm_check_destroyed(image_obj);
649
+ image = rm_check_destroyed(rm_cur_image(image_obj));
650
650
 
651
651
  x1 = fill->x1;
652
652
  y1 = fill->y1;
@@ -780,7 +780,7 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
780
780
  * Call TextureFill with the texture specified when this fill object was
781
781
  * created.
782
782
  *
783
- * @param image_obj [Magick::Image] the image to fill
783
+ * @param image_obj [Magick::Image, Magick::ImageList] the image to fill
784
784
  * @return [Magick::TextureFill] self
785
785
  */
786
786
  VALUE
@@ -792,7 +792,7 @@ TextureFill_fill(VALUE self, VALUE image_obj)
792
792
  ExceptionInfo *exception;
793
793
  #endif
794
794
 
795
- image = rm_check_destroyed(image_obj);
795
+ image = rm_check_destroyed(rm_cur_image(image_obj));
796
796
  TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
797
797
 
798
798
  #if defined(IMAGEMAGICK_7)
@@ -64,6 +64,8 @@ DEFINE_GVL_VOID_STUB2(RemoveZeroDelayLayers, Image **, ExceptionInfo *);
64
64
  *
65
65
  * @overload animate(delay)
66
66
  * @param delay [Numeric] the length of time between each image in an animation
67
+ * @yield [info]
68
+ * @yieldparam info [Magick::Image::Info]
67
69
  *
68
70
  * @return [Magick::ImageList] self
69
71
  */
@@ -400,6 +402,8 @@ ImageList_deconstruct(VALUE self)
400
402
  /**
401
403
  * Display all the images to an X window screen.
402
404
  *
405
+ * @yield [info]
406
+ * @yieldparam info [Magick::Image::Info]
403
407
  * @return [Magick::ImageList] self
404
408
  */
405
409
  VALUE
@@ -469,7 +473,8 @@ ImageList_flatten_images(VALUE self)
469
473
  * @overload montage
470
474
  * Creates {Magick::ImageList::Montage} object, yields to block
471
475
  * if present in {Magick::ImageList::Montage} object's scope.
472
- * @yield [Magick::ImageList::Montage]
476
+ * @yield [opt]
477
+ * @yieldparam opt [Magick::ImageList::Montage]
473
478
  *
474
479
  * @return [Magick::ImageList] a new image list
475
480
  */
@@ -1094,7 +1099,8 @@ ImageList_remap(int argc, VALUE *argv, VALUE self)
1094
1099
  *
1095
1100
  * @overload to_blob
1096
1101
  * Runs an info parm block if present - the user can specify the image format and depth
1097
- * @yield [Magick::Image::Info]
1102
+ * @yield [info]
1103
+ * @yieldparam info [Magick::Image::Info]
1098
1104
  *
1099
1105
  * @return [String] the blob
1100
1106
  */
@@ -1171,6 +1177,8 @@ ImageList_to_blob(VALUE self)
1171
1177
  * the images will be written as a single multi-image file. Otherwise each image
1172
1178
  * will be written to a separate file.
1173
1179
  *
1180
+ * @yield [info]
1181
+ * @yieldparam info [Magick::Image::Info]
1174
1182
  * @param file [File, String] the file
1175
1183
  */
1176
1184
  VALUE