photein 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -16
- data/lib/photein/image.rb +16 -1
- data/lib/photein/media_file.rb +7 -0
- data/lib/photein/version.rb +1 -1
- data/lib/photein/video.rb +10 -0
- metadata +5 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5404ec50b0c5a57144fea72eff5639ca90a19a46be319cb8ee634d9f67291617
|
4
|
+
data.tar.gz: bce672716a27ea28f9d4203e1858affa8793a11b5ca94e3642c6d86399969680
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11aba53e3bcdef67a150a549da7c16c45e0350b4bbdcfb4f1d1ce4c0fd778185845ef4719857e9eea4b1c15894578ae4e1b361952da3961c77fb1b0cc56c0bb
|
7
|
+
data.tar.gz: 2967ccf17b7d7631325ff9b18e445b052a52db8ddec3043cc0b4b15945b0b0c0bba52f0862044f554067950b578447235771abd1d97103346492ba6de821029a
|
data/README.md
CHANGED
@@ -14,21 +14,22 @@ no matter where they come from:
|
|
14
14
|
```sh
|
15
15
|
# Before # After
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
~ ~
|
18
|
+
├── Downloads ├── Downloads
|
19
|
+
│ ├── 1619593208911.jpeg └── Pictures
|
20
|
+
│ ├── DCIM ├── 2020
|
21
|
+
│ │ └── 2021_03_26 │ ├── 2020-08-01_113129.heic
|
22
|
+
│ │ ├── R0014285.MOV │ └── 2020-05-20_160209.png
|
23
|
+
│ │ ├── R0014286.DNG └── 2021
|
24
|
+
│ │ ├── R0014286.JPG ├── 2021-02-12_081933a.jpg
|
25
|
+
│ │ ├── R0014287.DNG ├── 2021-02-12_081933b.jpg
|
26
|
+
│ │ └── R0014287.JPG ├── 2021-02-12_081939.mp4
|
27
|
+
│ ├── IMG_20210212_081933_001.jpg ├── 2021-03-26_161245.mp4
|
28
|
+
│ ├── IMG_20210212_081933_002.jpg ├── 2021-03-26_161518.dng
|
29
|
+
│ ├── IMG_8953.HEIC ├── 2021-03-26_161518.jpg
|
30
|
+
│ ├── Screenshot_20200520_160209.png ├── 2021-03-26_170304.dng
|
31
|
+
│ └── VID_20210212_081939.mp4 ├── 2021-03-26_170304.jpg
|
32
|
+
└── Pictures └── 2021-04-28_000008.jpg
|
32
33
|
```
|
33
34
|
|
34
35
|
Photein generates these folders & filenames
|
@@ -38,7 +39,7 @@ based on metadata timestamps, filename timestamps, or file creation times.
|
|
38
39
|
>
|
39
40
|
> If you use a photo management app that decides
|
40
41
|
> where and how your photos should be stored on disk
|
41
|
-
> (
|
42
|
+
> (looking at you, Apple Photos 👀), Photein is not for you.
|
42
43
|
|
43
44
|
It can also optimize photos and videos for reduced file size.
|
44
45
|
|
data/lib/photein/image.rb
CHANGED
@@ -43,7 +43,12 @@ module Photein
|
|
43
43
|
when '.png'
|
44
44
|
FileUtils.cp(path, tempfile, noop: Photein::Config.dry_run)
|
45
45
|
Photein::Logger.info "optimizing #{path}"
|
46
|
-
|
46
|
+
begin
|
47
|
+
Optipng.optimize(tempfile, level: 4) unless Photein::Config.dry_run
|
48
|
+
rescue Errno::ENOENT
|
49
|
+
Photein::Logger.error('optipng is required to compress PNG images')
|
50
|
+
raise
|
51
|
+
end
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
@@ -51,10 +56,20 @@ module Photein
|
|
51
56
|
|
52
57
|
def image
|
53
58
|
@image ||= MiniMagick::Image.open(path)
|
59
|
+
rescue MiniMagick::Invalid => e
|
60
|
+
Photein::Logger.error(<<~MSG) if e.message.match?(/You must have ImageMagick/)
|
61
|
+
ImageMagick is required to manipulate image files
|
62
|
+
MSG
|
63
|
+
raise
|
54
64
|
end
|
55
65
|
|
56
66
|
def metadata_stamp
|
57
67
|
MiniExiftool.new(path.to_s).date_time_original
|
68
|
+
rescue MiniExiftool::Error => e
|
69
|
+
Photein::Logger.error(<<~MSG) if e.message.match?(/exiftool: not found/)
|
70
|
+
exiftool is required to read timestamp metadata
|
71
|
+
MSG
|
72
|
+
raise
|
58
73
|
end
|
59
74
|
|
60
75
|
# NOTE: This may be largely unnecessary:
|
data/lib/photein/media_file.rb
CHANGED
@@ -20,6 +20,7 @@ module Photein
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def import
|
23
|
+
return if corrupted?
|
23
24
|
return if Photein::Config.interactive && denied_by_user?
|
24
25
|
return if Photein::Config.safe && in_use?
|
25
26
|
return if Photein::Config.optimize_for && non_optimizable_format?
|
@@ -44,6 +45,12 @@ module Photein
|
|
44
45
|
|
45
46
|
private
|
46
47
|
|
48
|
+
def corrupted?(result = false)
|
49
|
+
return result.tap do |r|
|
50
|
+
Photein::Logger.error("#{path.basename}: cannot import corrupted file") if r
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
47
54
|
def denied_by_user?
|
48
55
|
$stdout.printf "Import #{path}? [y/N]"
|
49
56
|
(STDIN.getch.downcase != 'y').tap { $stdout.puts }
|
data/lib/photein/version.rb
CHANGED
data/lib/photein/video.rb
CHANGED
@@ -53,13 +53,23 @@ module Photein
|
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
|
+
def corrupted?
|
57
|
+
super(video.bitrate.nil?)
|
58
|
+
end
|
59
|
+
|
56
60
|
def video
|
57
61
|
@video ||= FFMPEG::Movie.new(path.to_s)
|
62
|
+
rescue Errno::ENOENT
|
63
|
+
Photein::Logger.error('ffmpeg is required to manipulate video files')
|
64
|
+
raise
|
58
65
|
end
|
59
66
|
|
60
67
|
def metadata_stamp
|
61
68
|
# video timestamps are typically UTC
|
62
69
|
MediaInfo.from(path.to_s).general.encoded_date&.getlocal
|
70
|
+
rescue MediaInfo::EnvironmentError
|
71
|
+
Photein::Logger.error('mediainfo is required to read timestamp metadata')
|
72
|
+
raise
|
63
73
|
end
|
64
74
|
|
65
75
|
# NOTE: This may be largely unnecessary:
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photein
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Lue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: debouncer
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: mediainfo
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +80,6 @@ dependencies:
|
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0.2'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rb-inotify
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.10'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.10'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: streamio-ffmpeg
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,19 +95,19 @@ dependencies:
|
|
123
95
|
- !ruby/object:Gem::Version
|
124
96
|
version: '3.0'
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: pry
|
98
|
+
name: pry-remote
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
128
100
|
requirements:
|
129
101
|
- - "~>"
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
103
|
+
version: '0.1'
|
132
104
|
type: :development
|
133
105
|
prerelease: false
|
134
106
|
version_requirements: !ruby/object:Gem::Requirement
|
135
107
|
requirements:
|
136
108
|
- - "~>"
|
137
109
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
110
|
+
version: '0.1'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
112
|
name: rspec
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|