imsg-grep 0.1.6.pre-darwin → 0.1.7-darwin
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 +4 -4
- data/README.md +1 -0
- data/bin/imsg-grep +9 -9
- data/lib/imsg-grep/VERSION +1 -1
- data/lib/imsg-grep/images/img2png.rb +21 -23
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5e2dfdd74fe32aea6304caa61d2891aea0ecd679759091e76b4af416fbe8991
|
|
4
|
+
data.tar.gz: c2e667c507d979e73b4f3efc2e474fac450133b8207a63ac55e06b9e31433896
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 447da88e82acd98f66a82f3486866ebe1e04bf9d9e56804b2fe8c5b9e7ecf5f66a100ad487fb3060fc51bbfbd78143dc14fd9b49006edc6750389c79716cb8e4
|
|
7
|
+
data.tar.gz: 57174003bbfe1a38c1865593b2f925314976e4aaa952863121c26f2de3e55a679f9fa7f4a64bada094d3ec827c909f826c7c3152000460300d5928b1bdcd777c
|
data/README.md
CHANGED
data/bin/imsg-grep
CHANGED
|
@@ -578,12 +578,12 @@ begin
|
|
|
578
578
|
messages.each do |msg|
|
|
579
579
|
preview?(:links) and
|
|
580
580
|
link = msg[:link] and
|
|
581
|
+
link.tap{ it[:guid] = msg[:guid] } and # adding guid ensures link is a uniq key so identical links dont overwrite the prev
|
|
581
582
|
@link_images[link] = Concurrent::Promises.future_on(POOL, msg) do |msg|
|
|
582
|
-
ix = link[:image_idx]
|
|
583
|
-
file = msg.dig(:files, ix)
|
|
584
|
-
path = file[:filename]
|
|
585
|
-
path = File.expand_path path
|
|
586
|
-
File.exist?(path) or next
|
|
583
|
+
ix = link[:image_idx] and
|
|
584
|
+
file = msg.dig(:files, ix) and
|
|
585
|
+
path = file[:filename] and
|
|
586
|
+
path = File.expand_path(path) and File.exist?(path) and
|
|
587
587
|
img = Imaginator::Image.new(path).load or next
|
|
588
588
|
fit, fits = img.fit @link_preview_cols, @link_preview_min_rows
|
|
589
589
|
png = img.png_transform w:fit.w, h:fit.h, pad_w:fits[:cfit].pad_w
|
|
@@ -595,11 +595,11 @@ begin
|
|
|
595
595
|
[fit, png, img]
|
|
596
596
|
end
|
|
597
597
|
msg[:images] = msg[:files].select{ it[:mime_type]&.start_with?('image/') }
|
|
598
|
-
preview?(:images) and
|
|
598
|
+
preview?(:images) and
|
|
599
|
+
msg[:images].each do |im|
|
|
599
600
|
@images[im] = Concurrent::Promises.future_on(POOL, im) do |im|
|
|
600
|
-
path = im[:filename]
|
|
601
|
-
path = File.expand_path path
|
|
602
|
-
File.exist?(path) or next
|
|
601
|
+
path = im[:filename] and
|
|
602
|
+
path = File.expand_path(path) and File.exist?(path) and
|
|
603
603
|
img = Imaginator::Image.new(path).load or next
|
|
604
604
|
fit, = img.fit 25, @img_rows
|
|
605
605
|
png = img.png_transform w:fit.w, h:fit.h
|
data/lib/imsg-grep/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.7
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
require "
|
|
2
|
-
require "fiddle/import"
|
|
1
|
+
require "ffi"
|
|
3
2
|
|
|
4
3
|
module Img2png
|
|
5
|
-
extend
|
|
4
|
+
extend FFI::Library
|
|
5
|
+
ffi_lib "#{__dir__}/img2png.dylib"
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
extern "void img2png_release(void*)"
|
|
13
|
-
extern "void img2png_free(void*)"
|
|
7
|
+
attach_function :img2png_load_path, [:string, :pointer, :pointer], :pointer, blocking: true
|
|
8
|
+
attach_function :img2png_load, [:pointer, :int, :pointer, :pointer], :pointer, blocking: true
|
|
9
|
+
attach_function :img2png_convert, [:pointer, :int, :int, :int, :int, :pointer, :pointer], :bool, blocking: true
|
|
10
|
+
attach_function :img2png_release, [:pointer], :void
|
|
11
|
+
attach_function :img2png_free, [:pointer], :void
|
|
14
12
|
|
|
15
13
|
class Image
|
|
16
|
-
def initialize(path:
|
|
14
|
+
def initialize(path:nil, data:nil)
|
|
17
15
|
[path, data].compact.size == 1 or raise ArgumentError, "One of path: or data: must be specified"
|
|
18
|
-
out_w =
|
|
19
|
-
out_h =
|
|
16
|
+
out_w = FFI::MemoryPointer.new(:int)
|
|
17
|
+
out_h = FFI::MemoryPointer.new(:int)
|
|
20
18
|
|
|
21
19
|
@handle = case
|
|
22
20
|
when data then Img2png.img2png_load(data, data.bytesize, out_w, out_h)
|
|
@@ -24,15 +22,15 @@ module Img2png
|
|
|
24
22
|
end
|
|
25
23
|
raise "Failed to load image" if @handle.null?
|
|
26
24
|
|
|
27
|
-
@width = out_w
|
|
28
|
-
@height = out_h
|
|
25
|
+
@width = out_w.read_int
|
|
26
|
+
@height = out_h.read_int
|
|
29
27
|
end
|
|
30
28
|
|
|
31
29
|
def dimensions = [@width, @height]
|
|
32
30
|
|
|
33
31
|
def convert(fit_w: nil, fit_h: nil, box_w: nil, box_h: nil)
|
|
34
|
-
out_data =
|
|
35
|
-
out_len =
|
|
32
|
+
out_data = FFI::MemoryPointer.new(:pointer)
|
|
33
|
+
out_len = FFI::MemoryPointer.new(:int)
|
|
36
34
|
|
|
37
35
|
success = Img2png.img2png_convert(
|
|
38
36
|
@handle,
|
|
@@ -41,18 +39,18 @@ module Img2png
|
|
|
41
39
|
out_data, out_len
|
|
42
40
|
)
|
|
43
41
|
|
|
44
|
-
return nil
|
|
42
|
+
return nil unless success
|
|
45
43
|
|
|
46
|
-
ptr =
|
|
47
|
-
len = out_len
|
|
48
|
-
result = ptr
|
|
44
|
+
ptr = out_data.read_pointer
|
|
45
|
+
len = out_len.read_int
|
|
46
|
+
result = ptr.read_bytes(len)
|
|
49
47
|
Img2png.img2png_free(ptr)
|
|
50
48
|
result
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
def release
|
|
54
52
|
Img2png.img2png_release(@handle) unless @handle.null?
|
|
55
|
-
@handle =
|
|
53
|
+
@handle = FFI::Pointer::NULL
|
|
56
54
|
end
|
|
57
55
|
|
|
58
56
|
def self.finalize(handle)
|
|
@@ -65,7 +63,7 @@ end
|
|
|
65
63
|
# input = File.binread("x.heic")
|
|
66
64
|
|
|
67
65
|
# # Load once, use multiple times
|
|
68
|
-
# img = Img2png::Image.new(
|
|
66
|
+
# img = Img2png::Image.new(input)
|
|
69
67
|
|
|
70
68
|
# # Get dimensions
|
|
71
69
|
# p img.dimensions # => [4032, 3024]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: imsg-grep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: darwin
|
|
6
6
|
authors:
|
|
7
7
|
- Caio Chassot
|
|
@@ -24,19 +24,19 @@ dependencies:
|
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0.3'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: ffi
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 1.
|
|
32
|
+
version: '1.17'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 1.
|
|
39
|
+
version: '1.17'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: io-console
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
210
210
|
- !ruby/object:Gem::Version
|
|
211
211
|
version: '0'
|
|
212
212
|
requirements: []
|
|
213
|
-
rubygems_version: 4.0.
|
|
213
|
+
rubygems_version: 4.0.1
|
|
214
214
|
specification_version: 4
|
|
215
215
|
summary: iMessage database search
|
|
216
216
|
test_files: []
|