photein 0.2.6 → 0.2.8

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: 786766a470966476665ebc0ef22d7cbd939c7b78eb184f0af98037dd1b24f20d
4
- data.tar.gz: b70c2a242e2ede4206460e2f99c0b612709531baf80edfaa58c5f6e7f6df7376
3
+ metadata.gz: 90c0015e4ed6ddf01fc10f31be6d495141cfd2956871942830e23ec02abc27c4
4
+ data.tar.gz: 4044c6f5652c612f82cae652a7c393a375843c88afa5802d94aa54ea05743932
5
5
  SHA512:
6
- metadata.gz: cbf4010ed2ed511a248072ce94a7c558203d4b24df56d8c7809c23be55613523543d631cf4c13b4c6be03443e6d3cfb8c42139b02e272d5464eb236c56c9847a
7
- data.tar.gz: 45c7f373992b3b4a36f0c7d89e041fbf22beef6140dc8ec48b046e318ded6eb85d1529cf3f767129bab45e74979c1a3681778cdde5102d5eab5bada0ba7d7253
6
+ metadata.gz: 121843b572493a4b52ea385046a9f014e236f47b420f048c00eb0136b32d8ab32c87b454a30c6fce14f2acbbd8cdbc81b2863fe80109239b8ed254ee844f06fd
7
+ data.tar.gz: 543d87cc88c3460f2cffd7b86d4dcdc047042cdcf4886a470385f8de72bfe6381cadc13d5169d19f822712c2121c3f35386f7aaca7af01886e611d84e77c5243
data/README.md CHANGED
@@ -106,12 +106,15 @@ $ gem install photein
106
106
  * Ruby 2.6+
107
107
  * [ExifTool][]
108
108
  * [MediaInfo][]
109
+ files)
109
110
  * ImageMagick (for `--optimize-for=web` option)
110
111
  * OptiPNG (for `--optimize-for=web` option)
111
112
  * ffmpeg (for `--optimize-for={web,desktop}` options)
113
+ * [mkvtoolnix][] (for `--shift-timestamp` / `--local-tz` options on .webm
112
114
 
113
115
  [ExifTool]: https://exiftool.org/
114
116
  [MediaInfo]: https://mediaarea.net/MediaInfo
117
+ [mkvtoolnix]: https://mkvtoolnix.download/
115
118
 
116
119
  Usage
117
120
  -----
data/lib/photein/image.rb CHANGED
@@ -14,6 +14,7 @@ module Photein
14
14
  .jpg
15
15
  .jpeg
16
16
  .dng
17
+ .raf
17
18
  .heic
18
19
  .png
19
20
  ).freeze
@@ -96,7 +97,7 @@ module Photein
96
97
  end
97
98
 
98
99
  def non_optimizable_format?(lib_type)
99
- return true if lib_type == :web && extname == '.dng'
100
+ return true if lib_type == :web && %w(.dng .raf).include?(extname)
100
101
 
101
102
  return false
102
103
  end
@@ -52,13 +52,13 @@ module Photein
52
52
  FileUtils.mv(tempfile, dest_path, noop: config.dry_run)
53
53
  else
54
54
  FileUtils.cp(path, dest_path, noop: config.dry_run)
55
- FileUtils.chmod('-x', dest_path, noop: config.dry_run)
56
55
  end
57
56
 
57
+ FileUtils.chmod('0644', dest_path, noop: config.dry_run)
58
58
  update_exif_tags(dest_path.realdirpath.to_s) if !config.dry_run
59
59
  end
60
60
  end.compact.map(&:join).then do |threads|
61
- # e.g.: with --library-web only, .dngs are skipped, so DON'T DELETE!
61
+ # e.g.: with --library-web only, raw files are skipped, so DON'T DELETE!
62
62
  FileUtils.rm(path, noop: threads.empty? || config.dry_run || config.keep)
63
63
  end
64
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Photein
4
- VERSION = '0.2.6'
4
+ VERSION = '0.2.8'
5
5
  end
data/lib/photein/video.rb CHANGED
@@ -21,6 +21,7 @@ module Photein
21
21
  SUPPORTED_FORMATS = %w(
22
22
  .mov
23
23
  .mp4
24
+ .mkv
24
25
  .webm
25
26
  ).freeze
26
27
 
@@ -111,7 +112,20 @@ module Photein
111
112
  @local_tz ||= ActiveSupport::TimeZone[
112
113
  MiniExiftool.new(path).then(&method(:gps_coords))&.then(&method(:coords_to_tz)) ||
113
114
  config.local_tz ||
114
- Time.now.gmt_offset
115
+ # Hardcode common zones that observe DST
116
+ # (Time.now.gmt_offset produces the wrong value during DST)
117
+ {
118
+ 'PST' => 'America/Los_Angeles',
119
+ 'PDT' => 'America/Los_Angeles',
120
+ 'EST' => 'America/New_York',
121
+ 'EDT' => 'America/New_York',
122
+ 'CST' => 'America/Chicago',
123
+ 'CDT' => 'America/Chicago',
124
+ 'MST' => 'America/Denver',
125
+ 'MDT' => 'America/Denver',
126
+ 'GMT' => 'Europe/London',
127
+ 'BST' => 'Europe/London',
128
+ }.fetch(Time.now.zone, Time.now.gmt_offset)
115
129
  ]
116
130
  end
117
131
 
@@ -147,14 +161,28 @@ module Photein
147
161
  return if config.timestamp_delta.zero? && config.local_tz.nil?
148
162
 
149
163
  args = []
150
- args.push("-AllDates=#{new_timestamp.strftime('%Y:%m:%d\\ %H:%M:%S')}") if config.timestamp_delta != 0
151
164
 
152
- if (lat, lon = config.tz_coordinates)
153
- args.push("-xmp:GPSLatitude=#{lat}")
154
- args.push("-xmp:GPSLongitude=#{lon}")
155
- end
165
+ case path.extname
166
+ when '.mp4', '.mov'
167
+ args.push("-AllDates=#{new_timestamp.strftime('%Y:%m:%d\\ %H:%M:%S')}") if config.timestamp_delta != 0
168
+
169
+ if (lat, lon = config.tz_coordinates)
170
+ args.push("-xmp:GPSLatitude=#{lat}")
171
+ args.push("-xmp:GPSLongitude=#{lon}")
172
+ end
173
+
174
+ system("exiftool -overwrite_original #{args.join(' ')} #{path}", out: File::NULL, err: File::NULL)
175
+ when '.webm', '.mkv'
176
+ args.concat(['--set', "date=#{new_timestamp.strftime('%FT%H:%M:%SZ')}"]) if config.timestamp_delta != 0
156
177
 
157
- system("exiftool -overwrite_original #{args.join(' ')} #{path}", out: File::NULL, err: File::NULL)
178
+ # FIXME
179
+ if (lat, lon = config.tz_coordinates)
180
+ args.push("-xmp:GPSLatitude=#{lat}")
181
+ args.push("-xmp:GPSLongitude=#{lon}")
182
+ end
183
+
184
+ system("mkvpropedit #{path} #{args.join(' ')}", out: File::NULL, err: File::NULL)
185
+ end
158
186
  end
159
187
  end
160
188
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photein
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Lue
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-11 00:00:00.000000000 Z
10
+ date: 2025-07-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport