magro 0.5.0 → 0.6.1

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.
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])
@@ -48,14 +48,14 @@ module Magro
48
48
  # @param image [Numo::UInt8] (shape: [height, width, n_channels]) Image data to be saved.
49
49
  # @param quality [Integer] Quality parameter of jpeg image that takes a value between 0 to 100.
50
50
  # @raise [ArgumentError] If filename is not String or image is not Numo::NArray, this error is raised.
51
- # @raise [IOError] This error is raised when failed to read image file.
51
+ # @raise [IOError] This error is raised when failed to write image file.
52
52
  # @raise [NoMemoryError] If memory allocation of image data fails, this error is raised.
53
53
  # @return [Boolean] true if file save is successful.
54
54
  def imsave(filename, image, quality: nil)
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.5.0'
6
+ VERSION = '0.6.1'
7
7
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-19 00:00:00.000000000 Z
11
+ date: 2022-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.9.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.1
27
27
  description: |
@@ -36,24 +36,10 @@ extensions:
36
36
  - ext/magro/extconf.rb
37
37
  extra_rdoc_files: []
38
38
  files:
39
- - ".clang-format"
40
- - ".coveralls.yml"
41
- - ".github/workflows/build.yml"
42
- - ".github/workflows/coverage.yml"
43
- - ".gitignore"
44
- - ".rspec"
45
39
  - CHANGELOG.md
46
- - CODE_OF_CONDUCT.md
47
- - Gemfile
48
40
  - LICENSE.txt
49
41
  - README.md
50
- - Rakefile
51
- - Steepfile
52
- - bin/console
53
- - bin/setup
54
42
  - ext/magro/extconf.rb
55
- - ext/magro/imgrw.c
56
- - ext/magro/imgrw.h
57
43
  - ext/magro/magro.c
58
44
  - ext/magro/magro.h
59
45
  - lib/magro.rb
@@ -61,12 +47,10 @@ files:
61
47
  - lib/magro/io.rb
62
48
  - lib/magro/transform.rb
63
49
  - lib/magro/version.rb
64
- - magro.gemspec
65
50
  - sig/magro.rbs
66
51
  - sig/magro/filter.rbs
67
52
  - sig/magro/io.rbs
68
53
  - sig/magro/transform.rbs
69
- - sig/patch.rbs
70
54
  homepage: https://github.com/yoshoku/magro
71
55
  licenses:
72
56
  - BSD-3-Clause
@@ -75,7 +59,8 @@ metadata:
75
59
  source_code_uri: https://github.com/yoshoku/magro
76
60
  changelog_uri: https://github.com/yoshoku/magro/blob/main/CHANGELOG.md
77
61
  documentation_uri: https://yoshoku.github.io/magro/doc/
78
- post_install_message:
62
+ rubygems_mfa_required: 'true'
63
+ post_install_message:
79
64
  rdoc_options: []
80
65
  require_paths:
81
66
  - lib
@@ -90,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
75
  - !ruby/object:Gem::Version
91
76
  version: '0'
92
77
  requirements: []
93
- rubygems_version: 3.1.6
94
- signing_key:
78
+ rubygems_version: 3.2.33
79
+ signing_key:
95
80
  specification_version: 4
96
81
  summary: Magro is a minimal image processing library for Ruby.
97
82
  test_files: []
data/.clang-format DELETED
@@ -1,149 +0,0 @@
1
- ---
2
- Language: Cpp
3
- # BasedOnStyle: LLVM
4
- AccessModifierOffset: -2
5
- AlignAfterOpenBracket: Align
6
- AlignConsecutiveMacros: false
7
- AlignConsecutiveAssignments: false
8
- AlignConsecutiveBitFields: false
9
- AlignConsecutiveDeclarations: false
10
- AlignEscapedNewlines: Right
11
- AlignOperands: Align
12
- AlignTrailingComments: true
13
- AllowAllArgumentsOnNextLine: true
14
- AllowAllConstructorInitializersOnNextLine: true
15
- AllowAllParametersOfDeclarationOnNextLine: true
16
- AllowShortEnumsOnASingleLine: true
17
- AllowShortBlocksOnASingleLine: Never
18
- AllowShortCaseLabelsOnASingleLine: false
19
- AllowShortFunctionsOnASingleLine: All
20
- AllowShortLambdasOnASingleLine: All
21
- AllowShortIfStatementsOnASingleLine: Never
22
- AllowShortLoopsOnASingleLine: false
23
- AlwaysBreakAfterDefinitionReturnType: None
24
- AlwaysBreakAfterReturnType: None
25
- AlwaysBreakBeforeMultilineStrings: false
26
- AlwaysBreakTemplateDeclarations: MultiLine
27
- BinPackArguments: true
28
- BinPackParameters: true
29
- BraceWrapping:
30
- AfterCaseLabel: false
31
- AfterClass: false
32
- AfterControlStatement: Never
33
- AfterEnum: false
34
- AfterFunction: false
35
- AfterNamespace: false
36
- AfterObjCDeclaration: false
37
- AfterStruct: false
38
- AfterUnion: false
39
- AfterExternBlock: false
40
- BeforeCatch: false
41
- BeforeElse: false
42
- BeforeLambdaBody: false
43
- BeforeWhile: false
44
- IndentBraces: false
45
- SplitEmptyFunction: true
46
- SplitEmptyRecord: true
47
- SplitEmptyNamespace: true
48
- BreakBeforeBinaryOperators: None
49
- BreakBeforeBraces: Attach
50
- BreakBeforeInheritanceComma: false
51
- BreakInheritanceList: BeforeColon
52
- BreakBeforeTernaryOperators: true
53
- BreakConstructorInitializersBeforeComma: false
54
- BreakConstructorInitializers: BeforeColon
55
- BreakAfterJavaFieldAnnotations: false
56
- BreakStringLiterals: true
57
- ColumnLimit: 128
58
- CommentPragmas: '^ IWYU pragma:'
59
- CompactNamespaces: false
60
- ConstructorInitializerAllOnOneLineOrOnePerLine: false
61
- ConstructorInitializerIndentWidth: 4
62
- ContinuationIndentWidth: 4
63
- Cpp11BracedListStyle: true
64
- DeriveLineEnding: true
65
- DerivePointerAlignment: false
66
- DisableFormat: false
67
- ExperimentalAutoDetectBinPacking: false
68
- FixNamespaceComments: true
69
- ForEachMacros:
70
- - foreach
71
- - Q_FOREACH
72
- - BOOST_FOREACH
73
- IncludeBlocks: Preserve
74
- IncludeCategories:
75
- - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
76
- Priority: 2
77
- SortPriority: 0
78
- - Regex: '^(<|"(gtest|gmock|isl|json)/)'
79
- Priority: 3
80
- SortPriority: 0
81
- - Regex: '.*'
82
- Priority: 1
83
- SortPriority: 0
84
- IncludeIsMainRegex: '(Test)?$'
85
- IncludeIsMainSourceRegex: ''
86
- IndentCaseLabels: false
87
- IndentCaseBlocks: false
88
- IndentGotoLabels: true
89
- IndentPPDirectives: None
90
- IndentExternBlock: AfterExternBlock
91
- IndentWidth: 2
92
- IndentWrappedFunctionNames: false
93
- InsertTrailingCommas: None
94
- JavaScriptQuotes: Leave
95
- JavaScriptWrapImports: true
96
- KeepEmptyLinesAtTheStartOfBlocks: true
97
- MacroBlockBegin: ''
98
- MacroBlockEnd: ''
99
- MaxEmptyLinesToKeep: 1
100
- NamespaceIndentation: None
101
- ObjCBinPackProtocolList: Auto
102
- ObjCBlockIndentWidth: 2
103
- ObjCBreakBeforeNestedBlockParam: true
104
- ObjCSpaceAfterProperty: false
105
- ObjCSpaceBeforeProtocolList: true
106
- PenaltyBreakAssignment: 2
107
- PenaltyBreakBeforeFirstCallParameter: 19
108
- PenaltyBreakComment: 300
109
- PenaltyBreakFirstLessLess: 120
110
- PenaltyBreakString: 1000
111
- PenaltyBreakTemplateDeclaration: 10
112
- PenaltyExcessCharacter: 1000000
113
- PenaltyReturnTypeOnItsOwnLine: 60
114
- PointerAlignment: Left
115
- ReflowComments: true
116
- SortIncludes: true
117
- SortUsingDeclarations: true
118
- SpaceAfterCStyleCast: false
119
- SpaceAfterLogicalNot: false
120
- SpaceAfterTemplateKeyword: true
121
- SpaceBeforeAssignmentOperators: true
122
- SpaceBeforeCpp11BracedList: false
123
- SpaceBeforeCtorInitializerColon: true
124
- SpaceBeforeInheritanceColon: true
125
- SpaceBeforeParens: ControlStatements
126
- SpaceBeforeRangeBasedForLoopColon: true
127
- SpaceInEmptyBlock: false
128
- SpaceInEmptyParentheses: false
129
- SpacesBeforeTrailingComments: 1
130
- SpacesInAngles: false
131
- SpacesInConditionalStatement: false
132
- SpacesInContainerLiterals: true
133
- SpacesInCStyleCastParentheses: false
134
- SpacesInParentheses: false
135
- SpacesInSquareBrackets: false
136
- SpaceBeforeSquareBrackets: false
137
- Standard: Latest
138
- StatementMacros:
139
- - Q_UNUSED
140
- - QT_REQUIRE_VERSION
141
- TabWidth: 8
142
- UseCRLF: false
143
- UseTab: Never
144
- WhitespaceSensitiveMacros:
145
- - STRINGIZE
146
- - PP_STRINGIZE
147
- - BOOST_PP_STRINGIZE
148
- ...
149
-
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: github-ci
@@ -1,23 +0,0 @@
1
- name: build
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-20.04
8
- strategy:
9
- matrix:
10
- ruby: [ '2.6', '2.7', '3.0' ]
11
- steps:
12
- - uses: actions/checkout@v2
13
- - name: Install libpng and libjpeg
14
- run: sudo apt-get install -y libpng-dev libjpeg-dev
15
- - name: Set up Ruby ${{ matrix.ruby }}
16
- uses: actions/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- - name: Build and test with Rake
20
- run: |
21
- gem install --no-document bundler
22
- bundle install --jobs 4 --retry 3
23
- bundle exec rake
@@ -1,29 +0,0 @@
1
- name: coverage
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
- branches: [ main ]
8
-
9
- jobs:
10
- coverage:
11
- runs-on: ubuntu-20.04
12
- steps:
13
- - uses: actions/checkout@v2
14
- - name: Install libpng and libjpeg
15
- run: sudo apt-get install -y libpng-dev libjpeg-dev
16
- - uses: actions/checkout@v2
17
- - name: Set up Ruby 2.7
18
- uses: actions/setup-ruby@v1
19
- with:
20
- ruby-version: '2.7'
21
- - name: Build and test with Rake
22
- run: |
23
- gem install bundler
24
- bundle install
25
- bundle exec rake
26
- - name: Coveralls GitHub Action
27
- uses: coverallsapp/github-action@v1.1.2
28
- with:
29
- github-token: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /spec/files/tmp.jpeg
11
- /spec/files/tmp.png
12
- /spec/files/tmp_UC.JPEG
13
- /spec/files/tmp_UC.PNG
14
-
15
- # rspec failure tracking
16
- .rspec_status
17
-
18
- *.swp
19
- *.bundle
20
- tags
21
- .DS_Store
22
- .ruby-version
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at yoshoku@outlook.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in magro.gemspec
4
- gemspec
5
-
6
- gem 'bundler', '~> 2.0'
7
- gem 'rake', '~> 13.0'
8
- gem 'rake-compiler', '~> 1.0'
9
- gem 'rspec', '~> 3.0'
10
- gem 'simplecov', '~> 0.19'
11
- gem 'simplecov-lcov', '~> 0.8'
12
- gem 'rbs', '~> 1.2'
13
- gem 'steep', '~> 0.44'
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- require 'rake/extensiontask'
7
-
8
- task build: :compile
9
-
10
- Rake::ExtensionTask.new('magro') do |ext|
11
- ext.lib_dir = 'lib/magro'
12
- end
13
-
14
- task default: %i[clobber compile spec]
data/Steepfile DELETED
@@ -1,20 +0,0 @@
1
- target :lib do
2
- signature "sig"
3
- #
4
- check "lib" # Directory name
5
- # check "Gemfile" # File name
6
- # check "app/models/**/*.rb" # Glob
7
- # # ignore "lib/templates/*.rb"
8
- #
9
- # # library "pathname", "set" # Standard libraries
10
- # # library "strong_json" # Gems
11
- end
12
-
13
- # target :spec do
14
- # signature "sig", "sig-private"
15
- #
16
- # check "spec"
17
- #
18
- # # library "pathname", "set" # Standard libraries
19
- # # library "rspec"
20
- # end
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "magro"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here