termpix 0.1.0 → 0.2.0
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 +2 -0
- data/lib/termpix/protocols.rb +24 -16
- data/lib/termpix/version.rb +1 -1
- data/lib/termpix.rb +3 -5
- 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: 8d70f5043da6be1e4ce59bed60fea4929521d5ab7d2ea0b93c484ebfe1136081
|
|
4
|
+
data.tar.gz: 33fa07448eaf3511b1b49e9d423b5b2cc1ceb6a75a39714eae25c9816c8d119e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6813654407d15f69d0a9aea24f424c799d44f080e0950106371c448779ed50382e1448909034ede08bca181478ef0a970a21714e61940f03dba79f796660cf47
|
|
7
|
+
data.tar.gz: c038cfad651091874e08d6203e4f5551691e23365682c00bd22ef121546892e2cdf3d15b0777277ad7c9f0f86ff65175c82a36252afb7626850597d27f3afb6f
|
data/README.md
CHANGED
data/lib/termpix/protocols.rb
CHANGED
|
@@ -4,21 +4,19 @@ require 'base64'
|
|
|
4
4
|
module Termpix
|
|
5
5
|
module Protocols
|
|
6
6
|
# Kitty Graphics Protocol
|
|
7
|
+
# After extensive testing: Kitty protocol fundamentally incompatible with curses
|
|
8
|
+
# The protocol requires precise cursor control that conflicts with curses' buffer
|
|
9
|
+
# management. Recommend disabling Kitty protocol for curses-based apps.
|
|
7
10
|
module Kitty
|
|
8
11
|
def self.display(image_path, x:, y:, max_width:, max_height:)
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# Transmit image without positioning, let it flow inline
|
|
14
|
-
$stdout.write "\e_Ga=T,f=100,q=2;#{image_data}\e\\"
|
|
15
|
-
$stdout.flush
|
|
12
|
+
# Kitty graphics protocol does not work reliably with curses applications
|
|
13
|
+
# The fundamental issue is that both Kitty and curses need exclusive control
|
|
14
|
+
# of terminal state, causing unavoidable conflicts
|
|
15
|
+
false
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def self.clear
|
|
19
|
-
|
|
20
|
-
$stdout.write "\e_Ga=d,d=A\e\\"
|
|
21
|
-
$stdout.flush
|
|
19
|
+
true
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
private
|
|
@@ -52,8 +50,9 @@ module Termpix
|
|
|
52
50
|
|
|
53
51
|
# Position cursor at the specified character position
|
|
54
52
|
print "\e[#{y};#{x}H"
|
|
55
|
-
#
|
|
56
|
-
|
|
53
|
+
# Use > to only shrink, never enlarge, preserving aspect ratio
|
|
54
|
+
# ImageMagick will fit image within box while maintaining aspect ratio
|
|
55
|
+
system("convert #{escaped} -resize #{pixel_width}x#{pixel_height}\\> sixel:- 2>/dev/null")
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
def self.clear
|
|
@@ -117,14 +116,20 @@ module Termpix
|
|
|
117
116
|
img_max_w = char_w * max_width
|
|
118
117
|
img_max_h = char_h * max_height
|
|
119
118
|
|
|
120
|
-
#
|
|
119
|
+
# Handle EXIF orientation by creating auto-oriented temp file
|
|
121
120
|
escaped = Shellwords.escape(image_path)
|
|
122
|
-
|
|
121
|
+
temp_file = "/tmp/termpix_#{Process.pid}.jpg"
|
|
122
|
+
|
|
123
|
+
# Auto-orient image to respect EXIF rotation, then get dimensions
|
|
124
|
+
system("convert #{escaped}[0] -auto-orient #{temp_file} 2>/dev/null")
|
|
125
|
+
display_path = File.exist?(temp_file) ? temp_file : image_path
|
|
126
|
+
|
|
127
|
+
dimensions = `identify -format "%wx%h" #{Shellwords.escape(display_path)} 2>/dev/null`.strip
|
|
123
128
|
return if dimensions.empty?
|
|
124
129
|
|
|
125
130
|
img_w, img_h = dimensions.split('x').map(&:to_i)
|
|
126
131
|
|
|
127
|
-
# Scale if needed
|
|
132
|
+
# Scale if needed - preserve aspect ratio
|
|
128
133
|
if img_w > img_max_w || img_h > img_max_h
|
|
129
134
|
scale_w = img_max_w.to_f / img_w
|
|
130
135
|
scale_h = img_max_h.to_f / img_h
|
|
@@ -134,9 +139,12 @@ module Termpix
|
|
|
134
139
|
end
|
|
135
140
|
|
|
136
141
|
# Display using w3mimgdisplay protocol
|
|
137
|
-
`echo '0;1;#{img_x};#{img_y};#{img_w};#{img_h};;;;;#{
|
|
142
|
+
`echo '0;1;#{img_x};#{img_y};#{img_w};#{img_h};;;;;#{display_path}
|
|
138
143
|
4;
|
|
139
144
|
3;' | #{@imgdisplay} 2>/dev/null`
|
|
145
|
+
|
|
146
|
+
# Clean up temp file
|
|
147
|
+
File.delete(temp_file) if File.exist?(temp_file) && temp_file != image_path
|
|
140
148
|
end
|
|
141
149
|
|
|
142
150
|
def self.clear(x:, y:, width:, height:, term_width:, term_height:)
|
data/lib/termpix/version.rb
CHANGED
data/lib/termpix.rb
CHANGED
|
@@ -80,11 +80,9 @@ module Termpix
|
|
|
80
80
|
return :sixel if check_dependency('convert')
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
# Kitty graphics protocol disabled - incompatible with curses
|
|
84
|
-
# Kitty protocol
|
|
85
|
-
#
|
|
86
|
-
# 1. Enable w3m for Kitty (has brief flash) - set TERMPIX_KITTY_USE_W3M=1
|
|
87
|
-
# 2. No images in Kitty (clean UI)
|
|
83
|
+
# Kitty graphics protocol disabled - fundamentally incompatible with curses
|
|
84
|
+
# After extensive testing: Kitty protocol requires exclusive terminal control
|
|
85
|
+
# that conflicts with curses' buffer management. Use w3m fallback instead.
|
|
88
86
|
|
|
89
87
|
# Überzug++ - disabled for now (implementation incomplete)
|
|
90
88
|
# TODO: Implement proper Überzug++ JSON-RPC communication
|
metadata
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: termpix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description: Termpix
|
|
14
|
-
|
|
15
|
-
capabilities and falls back gracefully.
|
|
13
|
+
description: 'Termpix v0.2.0: EXIF auto-orient support preserves correct image orientation.
|
|
14
|
+
Provides clean API for displaying images in terminal using best available protocol
|
|
15
|
+
(Sixel or w3m). Auto-detects terminal capabilities and falls back gracefully.'
|
|
16
16
|
email: g@isene.com
|
|
17
17
|
executables: []
|
|
18
18
|
extensions: []
|