magro 0.6.0 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c544837f96597012ff6cf938a4148b7fcc640237daf460ae26c64f91588767
4
- data.tar.gz: '08915ee5d2d4ed4b535963684b160e2ab4707d7823b56578f5574099ca33d7ad'
3
+ metadata.gz: 94d97619f616e6af0901a6c50f80d66ffeef0254c021a6cb4d6fcc729a11d4a2
4
+ data.tar.gz: 76343ddddc441d51203bd56bb6801da506c5907498045e9ccd80edc6da3e7d31
5
5
  SHA512:
6
- metadata.gz: 4d5cd134c942319d0ecb83fb39b89cf8a42c3cacc9c4336eaf592b0170a4257e597ce5c62e4fdb35b4641f2446e206c79da4b012c009516547ff7ae464745975
7
- data.tar.gz: cd6cdb5059adf3ed20ea6b9625d314f0519c338b0f01b8abb1ea73ecb8c5cb183b0288e1cdbdb22482d8fb71945b26f4761911c606bb81ce62008cb3ee984742
6
+ metadata.gz: adc486b81f8410c7e5ad14f9c4ca94bb908f2d9911fca3dd40776bee5287371644006dc10d7df4d4c7d8486f535a2d9b1679fc99ea238b2734dfb461b1b09e11
7
+ data.tar.gz: b6e7883ba24394d44dbf92e7bfa00ff6afe9bcf1ad3ab78268439eebd795822f62033cc1bc4c3d0066f846ead61b743f101c309b3af536ae3110fc515842e214
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.6.2
2
+
3
+ - Fix build failure with Xcode 14 and Ruby 3.1.x.
4
+
5
+ # 0.6.1
6
+
7
+ - Refactor codes and configs with RuboCop.
8
+
1
9
  # 0.6.0
2
10
  - Reorganize native exntesion codes.
3
11
  - Remove dependent gem's type declaration file from installation files.
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/github/yoshoku/magro/badge.svg?branch=main)](https://coveralls.io/github/yoshoku/magro?branch=main)
5
5
  [![Gem Version](https://badge.fury.io/rb/magro.svg)](https://badge.fury.io/rb/magro)
6
6
  [![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://github.com/yoshoku/numo-liblinear/blob/main/LICENSE.txt)
7
- [![Documentation](http://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/magro/doc/)
7
+ [![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/magro/doc/)
8
8
 
9
9
  Magro is a minimal image processing library in Ruby.
10
10
  Magro uses [Numo::NArray](https://github.com/ruby-numo/numo-narray) arrays as image objects and
@@ -39,6 +39,10 @@ Or install it yourself as:
39
39
 
40
40
  $ gem install magro
41
41
 
42
+ If you use homebrew on Apple M1 mac, specify the homebrew installation directory:
43
+
44
+ $ gem install magro -- --with-opt-dir=/opt/homebrew
45
+
42
46
  ## Documentation
43
47
 
44
48
  - [Magro API Documentation](https://yoshoku.github.io/magro/doc/)
@@ -59,7 +63,7 @@ Or install it yourself as:
59
63
  ## Contributing
60
64
 
61
65
  Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/magro.
62
- This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
66
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://contributor-covenant.org) code of conduct.
63
67
 
64
68
  ## License
65
69
 
data/ext/magro/extconf.rb CHANGED
@@ -20,6 +20,12 @@ if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
20
20
  abort 'libnarray.a not found.' unless have_library('narray', 'nary_new')
21
21
  end
22
22
 
23
+ if RUBY_PLATFORM.match?(/darwin/) && Gem::Version.new('3.1.0') <= Gem::Version.new(RUBY_VERSION)
24
+ if try_link('int main(void){return 0;}', '-Wl,-undefined,dynamic_lookup')
25
+ $LDFLAGS << ' -Wl,-undefined,dynamic_lookup'
26
+ end
27
+ end
28
+
23
29
  abort 'setjmp.h not found.' unless have_header('setjmp.h')
24
30
  abort 'png.h not found.' unless have_header('png.h')
25
31
  abort 'libpng not found.' unless have_library('png')
data/lib/magro/filter.rb CHANGED
@@ -26,6 +26,7 @@ module Magro
26
26
  # @return [Numo::UInt8] (shape: [height, width, n_channels]) Filtered image.
27
27
  def filter2d(image, kernel, scale: nil, offset: 0)
28
28
  raise ArgumentError, 'Expect class of image to be Numo::NArray.' unless image.is_a?(Numo::NArray)
29
+
29
30
  filter_h, filter_w = kernel.shape
30
31
  padded = zero_padding(image, filter_h, filter_w)
31
32
  n_channels = image.shape[2]
@@ -46,11 +47,12 @@ module Magro
46
47
  # @param arr2 [Numo::NArray] (shape: [row2, col2]) Second input array.
47
48
  # @raise [ArgumentError] This error is raised when class of input array is not Numo::NArray.
48
49
  # @return [Numo::NArray] (shape: [row1 - row2 + 1, col1 - col2 + 1]) Convolution of arr1 with arr2.
49
- def convolve2d(arr1, arr2)
50
+ def convolve2d(arr1, arr2) # rubocop:disable Metrics/AbcSize
50
51
  raise ArgumentError, 'Expect class of first input array to be Numo::NArray.' unless arr1.is_a?(Numo::NArray)
51
52
  raise ArgumentError, 'Expect class of second input array to be Numo::NArray.' unless arr2.is_a?(Numo::NArray)
52
53
  raise ArgumentError, 'Expect first input array to be 2-dimensional array.' unless arr1.ndim == 2
53
54
  raise ArgumentError, 'Expect second input array to be 2-dimensional array.' unless arr2.ndim == 2
55
+
54
56
  row1, col1 = arr1.shape
55
57
  row2, col2 = arr2.shape
56
58
  # FIXME: lib/numo/narray/extra.rb:1098: warning: Using the last argument as keyword parameters is deprecated
@@ -61,7 +63,7 @@ module Magro
61
63
 
62
64
  # private
63
65
 
64
- def zero_padding(image, filter_h, filter_w)
66
+ def zero_padding(image, filter_h, filter_w) # rubocop:disable Metrics/AbcSize
65
67
  image_h, image_w, n_channels = image.shape
66
68
  pad_h = filter_h / 2
67
69
  pad_w = filter_w / 2
data/lib/magro/io.rb CHANGED
@@ -16,7 +16,7 @@ module Magro
16
16
  # @raise [IOError] This error is raised when failed to read image file.
17
17
  # @raise [NoMemoryError] If memory allocation of image data fails, this error is raised.
18
18
  # @return [Numo::UInt8] (shape: [height, width, n_channels]) Loaded image.
19
- def imread(filename)
19
+ def imread(filename) # rubocop:disable Metrics/AbcSize
20
20
  raise ArgumentError, 'Expect class of filename to be String.' unless filename.is_a?(String)
21
21
 
22
22
  unless url?(filename)
@@ -30,7 +30,7 @@ module Magro
30
30
 
31
31
  uri = URI.parse(filename)
32
32
  ext = File.extname(uri.path).downcase
33
- raise IOError, 'Failed to detect file extension from given URL.' unless ext =~ /\.(jpeg|jpg|jpe|png)$/
33
+ raise IOError, 'Failed to detect file extension from given URL.' unless /\.(jpeg|jpg|jpe|png)$/.match?(ext)
34
34
 
35
35
  uri.open do |file|
36
36
  temp = Tempfile.new(['magro_', ext])
@@ -55,7 +55,7 @@ module Magro
55
55
  raise ArgumentError, 'Expect class of filename to be String.' unless filename.is_a?(String)
56
56
  raise ArgumentError, 'Expect class of image to be Numo::NArray.' unless image.is_a?(Numo::NArray)
57
57
 
58
- if filename.downcase =~ /\.(jpeg|jpg|jpe)$/
58
+ if /\.(jpeg|jpg|jpe)$/.match?(filename.downcase)
59
59
  unless quality.nil?
60
60
  raise ArgumentError, 'Expect class of quality to be Numeric.' unless quality.is_a?(Numeric)
61
61
  raise ArgumentError, 'Range of quality value between 0 to 100.' unless quality.between?(0, 100)
@@ -63,7 +63,7 @@ module Magro
63
63
  return save_jpg(filename, image, quality)
64
64
  end
65
65
 
66
- return save_png(filename, image) if filename.downcase =~ /\.png$/
66
+ return save_png(filename, image) if /\.png$/.match?(filename.downcase)
67
67
 
68
68
  false
69
69
  end
@@ -32,7 +32,7 @@ module Magro
32
32
 
33
33
  # private
34
34
 
35
- def bilinear_resize(image, new_height, new_width)
35
+ def bilinear_resize(image, new_height, new_width) # rubocop:disable Metrics/AbcSize
36
36
  height, width = image.shape
37
37
 
38
38
  y_ratio = height.fdiv(new_height)
data/lib/magro/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Magro is an image processing library in Ruby.
4
4
  module Magro
5
5
  # The version of Magro you are using.
6
- VERSION = '0.6.0'
6
+ VERSION = '0.6.2'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -59,6 +59,7 @@ metadata:
59
59
  source_code_uri: https://github.com/yoshoku/magro
60
60
  changelog_uri: https://github.com/yoshoku/magro/blob/main/CHANGELOG.md
61
61
  documentation_uri: https://yoshoku.github.io/magro/doc/
62
+ rubygems_mfa_required: 'true'
62
63
  post_install_message:
63
64
  rdoc_options: []
64
65
  require_paths:
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.3.3
78
+ rubygems_version: 3.3.26
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Magro is a minimal image processing library for Ruby.