image_quality_check 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f464a43936793939abade67315eede661024e50014b4aeff0722659d0ea5a56
4
- data.tar.gz: ef7ef680f25e0519d93758da9d2c2bf17916b5d2c955727bba43cf7cfb35bc84
3
+ metadata.gz: a810f6dcf2ceadf8e6304d9f8541f940f09372dccf6e030e545d568cf8958fd5
4
+ data.tar.gz: 96fa32d7aee06e29793a458adf07ccacea40e522772aac775ebd088b31a15a15
5
5
  SHA512:
6
- metadata.gz: 19a03ee429e6abd1047ec6e48caead939eb306da1806b00adcd4e6f7e073f80bb89dc6d9862ab55945237af9fe88e7c96aa18a48b91cb7c82e4c0ec71bf30aff
7
- data.tar.gz: 519449db3f4fb2f9731843913d69a9dcc238b5c994b6491963fe1f45f717248ee7b3eccd378c9b4385270ecd242bf53977e696799e59de7e6b7f1c40e72689e1
6
+ metadata.gz: 16bf50f9ba0f0da20af8941714ea6ff96aa6369786a54669bd29197d5f9f36b08df1ee0af2c7fc3605e3c03afc51aae5d25f42620ce7ed1ebeb138f52993b668
7
+ data.tar.gz: ece0ea9ec666d0917faba163245e340ca34d5e78ac560fb2c23ce14162ccbc99ba6b4fa45ed438be96142e46f25ea8b9b4a134473127127e7d900366ddcb3d3a
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  spec/.examples.txt
10
+ Gemfile.lock
11
+ .tool-versions
@@ -12,7 +12,12 @@ img = cv2.imread(sys.argv[1], 0)
12
12
  clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
13
13
  img = clahe.apply(img)
14
14
 
15
- face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
15
+ if hasattr(cv2, 'data'):
16
+ prefix = cv2.data.haarcascades
17
+ else:
18
+ prefix = '/usr/share/opencv4/haarcascades/'
19
+
20
+ face_cascade = cv2.CascadeClassifier(prefix + 'haarcascade_frontalface_default.xml')
16
21
  faces_detect = face_cascade.detectMultiScale(img, scaleFactor=1.5, minNeighbors=3)
17
22
 
18
23
  for (x, y, w, h) in faces_detect:
@@ -32,10 +37,10 @@ else:
32
37
  face = img
33
38
 
34
39
 
35
- smile_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_smile.xml')
40
+ smile_cascade = cv2.CascadeClassifier(prefix + 'haarcascade_smile.xml')
36
41
  smile_detect = smile_cascade.detectMultiScale(face, minNeighbors=40, scaleFactor=1.14)
37
42
 
38
- eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_eye.xml')
43
+ eye_cascade = cv2.CascadeClassifier(prefix + 'haarcascade_eye.xml')
39
44
  eye_detect = eye_cascade.detectMultiScale(face, minNeighbors=15)
40
45
 
41
46
  out['hasSmile'] = len(smile_detect) > 0
@@ -62,6 +62,13 @@ class ImageQualityCheck::DetermineQuality
62
62
 
63
63
  def read!(tmp_file)
64
64
  case @column.class.to_s
65
+ when 'ActiveStorage::Attached::One'
66
+ if !@column.blob || !File.exist?(@column.blob.service.send(:path_for, @column.blob.key))
67
+ false
68
+ else
69
+ FileUtils.cp(@column.blob.service.send(:path_for, @column.blob.key), tmp_file.path)
70
+ true
71
+ end
65
72
  when "Paperclip::Attachment"
66
73
  if !@column.path || !File.exist?(@column.path)
67
74
  false
@@ -9,7 +9,7 @@ module ImageQualityCheck::DSL
9
9
  def rules_for(klass, attachment)
10
10
  rule = @rules[[klass.to_s, attachment.to_s]]
11
11
  unless rule
12
- raise NotImplemented, I18n.t("image_quality_check.dsl.no_qualities_defined_for", klass: (klass), attachment: (attachment))
12
+ raise NotImplementedError, I18n.t("image_quality_check.dsl.no_qualities_defined_for", klass: (klass), attachment: (attachment))
13
13
  end
14
14
  @current_rule = []
15
15
  class_exec(&rule)
@@ -20,7 +20,7 @@ module ImageQualityCheck::DSL
20
20
  @current_rule << { name: name, block: block, weight: weight }
21
21
  end
22
22
 
23
- def preferred_formats_rule(formats, weight: 1)
23
+ def preferred_formats_rule(weight: 1, **formats)
24
24
  rule I18n.t("image_quality_check.dsl.format"), weight: weight do |result, on_error|
25
25
  final_score = nil
26
26
  formats.each do |f, score|
@@ -1,3 +1,3 @@
1
1
  module ImageQualityCheck
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_quality_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Wienert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.2.15
76
+ rubygems_version: 3.5.16
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Thin gem wrapper that uses imagemagick and python-opencv to help determine