distorted 0.5.7 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/distorted/checking_you_out.rb +116 -0
- data/lib/distorted/error_code.rb +43 -0
- data/lib/distorted/injection_of_love.rb +247 -0
- data/lib/distorted/modular_technology/pango.rb +20 -5
- data/lib/distorted/modular_technology/triple_counter.rb +45 -0
- data/lib/distorted/modular_technology/ttfunk.rb +48 -0
- data/lib/distorted/modular_technology/vips.rb +17 -0
- data/lib/distorted/modular_technology/vips_load.rb +77 -0
- data/lib/distorted/modular_technology/vips_save.rb +172 -0
- data/lib/distorted/molecule/C18H27NO3.rb +10 -0
- data/lib/distorted/{font.rb → molecule/font.rb} +33 -27
- data/lib/distorted/molecule/image.rb +36 -0
- data/lib/distorted/{pdf.rb → molecule/pdf.rb} +23 -14
- data/lib/distorted/molecule/svg.rb +60 -0
- data/lib/distorted/{text.rb → molecule/text.rb} +70 -86
- data/lib/distorted/{video.rb → molecule/video.rb} +9 -7
- data/lib/distorted/types/README +4 -0
- data/lib/distorted/types/application.yaml +8 -0
- data/lib/distorted/types/font.yaml +29 -0
- data/lib/distorted/version.rb +3 -1
- metadata +33 -8
- data/lib/distorted/image.rb +0 -121
- data/lib/distorted/svg.rb +0 -21
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
# RFC8081 defines the top-level `font` media-type and includes
|
3
|
+
# definitions for font/ttf, font/otf, and font/collection,
|
4
|
+
# but neglects to include the OpenType Collection (.otc)
|
5
|
+
# file extension, meaning the IANA DB's font/collection
|
6
|
+
# only covers TTC and not OTC:
|
7
|
+
#
|
8
|
+
# https://tools.ietf.org/html/rfc8081#section-4.4.4
|
9
|
+
# "Type name: font
|
10
|
+
# Subtype name: collection
|
11
|
+
# Required parameters: None
|
12
|
+
# Optional parameters
|
13
|
+
# Name: outlines
|
14
|
+
# Values: a comma-separated subset of TTF, CFF, and SVG
|
15
|
+
#
|
16
|
+
# https://docs.microsoft.com/en-us/typography/opentype/spec/otff
|
17
|
+
# "OpenType fonts may have the extension .OTF, .TTF, .OTC or .TTC.
|
18
|
+
# The extensions .OTC and .TTC should only be used for font collection files."
|
19
|
+
- !ruby/object:MIME::Type
|
20
|
+
content-type: font/collection
|
21
|
+
encoding: base64
|
22
|
+
extensions:
|
23
|
+
- otc
|
24
|
+
xrefs:
|
25
|
+
template:
|
26
|
+
- font/collection
|
27
|
+
xref_urls:
|
28
|
+
- "https://docs.microsoft.com/en-us/typography/opentype/spec/otff#filenames"
|
29
|
+
registered: false
|
data/lib/distorted/version.rb
CHANGED
@@ -13,8 +13,10 @@
|
|
13
13
|
# `/oooooooooooooo:`-+o+/. `+oo+o++++ooo+oooooo- `-+oo/` :oooooooooooooo/
|
14
14
|
#
|
15
15
|
|
16
|
+
require_relative 'modular_technology/triple_counter'
|
17
|
+
|
16
18
|
module Cooltrainer
|
17
19
|
module DistorteD
|
18
|
-
VERSION =
|
20
|
+
VERSION = TripleCounter.new(0, 6, 0)
|
19
21
|
end
|
20
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distorted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okeeblow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ruby-filemagic
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.7'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: ruby-vips
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,19 +199,30 @@ files:
|
|
185
199
|
- font/850/Profont/readme.txt
|
186
200
|
- font/932/LICENSE/README-ttf.txt
|
187
201
|
- font/932/mona.ttf
|
202
|
+
- lib/distorted/checking_you_out.rb
|
188
203
|
- lib/distorted/error_code.rb
|
189
|
-
- lib/distorted/
|
190
|
-
- lib/distorted/image.rb
|
204
|
+
- lib/distorted/injection_of_love.rb
|
191
205
|
- lib/distorted/modular_technology/pango.rb
|
206
|
+
- lib/distorted/modular_technology/triple_counter.rb
|
207
|
+
- lib/distorted/modular_technology/ttfunk.rb
|
208
|
+
- lib/distorted/modular_technology/vips.rb
|
209
|
+
- lib/distorted/modular_technology/vips_load.rb
|
210
|
+
- lib/distorted/modular_technology/vips_save.rb
|
211
|
+
- lib/distorted/molecule/C18H27NO3.rb
|
212
|
+
- lib/distorted/molecule/font.rb
|
213
|
+
- lib/distorted/molecule/image.rb
|
214
|
+
- lib/distorted/molecule/pdf.rb
|
215
|
+
- lib/distorted/molecule/svg.rb
|
216
|
+
- lib/distorted/molecule/text.rb
|
217
|
+
- lib/distorted/molecule/video.rb
|
192
218
|
- lib/distorted/monkey_business/hash.rb
|
193
219
|
- lib/distorted/monkey_business/mnemoniq.rb
|
194
220
|
- lib/distorted/monkey_business/set.rb
|
195
221
|
- lib/distorted/monkey_business/string.rb
|
196
|
-
- lib/distorted/
|
197
|
-
- lib/distorted/
|
198
|
-
- lib/distorted/
|
222
|
+
- lib/distorted/types/README
|
223
|
+
- lib/distorted/types/application.yaml
|
224
|
+
- lib/distorted/types/font.yaml
|
199
225
|
- lib/distorted/version.rb
|
200
|
-
- lib/distorted/video.rb
|
201
226
|
- test/distorted_test.rb
|
202
227
|
- test/test_helper.rb
|
203
228
|
homepage: https://cooltrainer.org
|
data/lib/distorted/image.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# Requiring libvips 8.8 for HEIC/HEIF (moo) support, `justify` support in the
|
2
|
-
# Vips::Image text operator, animated WebP support, and more:
|
3
|
-
# https://libvips.github.io/libvips/2019/04/22/What's-new-in-8.8.html
|
4
|
-
VIPS_MINIMUM_VER = [8, 8, 0]
|
5
|
-
|
6
|
-
# Tell the user to install the shared library if it's missing.
|
7
|
-
begin
|
8
|
-
require 'vips'
|
9
|
-
|
10
|
-
we_good = false
|
11
|
-
if Vips::version(0) >= VIPS_MINIMUM_VER[0]
|
12
|
-
if Vips::version(1) >= VIPS_MINIMUM_VER[1]
|
13
|
-
if Vips::version(2) >= VIPS_MINIMUM_VER[2]
|
14
|
-
we_good = true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
unless we_good
|
19
|
-
raise LoadError.new("libvips is older than DistorteD's minimum requirement: needed #{VIPS_MINIMUM_VER.join('.'.freeze)} vs available '#{Vips::version_string}'")
|
20
|
-
end
|
21
|
-
|
22
|
-
rescue LoadError => le
|
23
|
-
# Only match libvips.so load failure
|
24
|
-
raise unless le.message =~ /libvips.so/
|
25
|
-
|
26
|
-
# Multiple OS help
|
27
|
-
help = <<~INSTALL
|
28
|
-
|
29
|
-
Please install the libvips image processing library.
|
30
|
-
|
31
|
-
FreeBSD:
|
32
|
-
pkg install graphics/vips
|
33
|
-
|
34
|
-
macOS:
|
35
|
-
brew install vips
|
36
|
-
|
37
|
-
Debian/Ubuntu/Mint:
|
38
|
-
apt install libvips libvips-dev
|
39
|
-
INSTALL
|
40
|
-
|
41
|
-
# Re-raise with install message
|
42
|
-
raise $!, "#{help}\n#{$!}", $!.backtrace
|
43
|
-
end
|
44
|
-
|
45
|
-
require 'set'
|
46
|
-
|
47
|
-
require 'mime/types'
|
48
|
-
|
49
|
-
module Cooltrainer
|
50
|
-
module DistorteD
|
51
|
-
class Image
|
52
|
-
|
53
|
-
MEDIA_TYPE = 'image'.freeze
|
54
|
-
|
55
|
-
# SVG support is a sub-class and not directly supported here:
|
56
|
-
# `write_to_file': No known saver for '/home/okeeblow/Works/cooltrainer/_site/IIDX-turntable.svg'. (Vips::Error)
|
57
|
-
MIME_TYPES = MIME::Types[/^#{MEDIA_TYPE}\/(?!svg)/, :complete => true].to_set
|
58
|
-
|
59
|
-
# Attributes for our <picture>/<img>.
|
60
|
-
# Automatically enabled as attrs for DD Liquid Tag.
|
61
|
-
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture#Attributes
|
62
|
-
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#Attributes
|
63
|
-
# https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading
|
64
|
-
# :crop is a Vips-only attr
|
65
|
-
ATTRS = Set[:alt, :caption, :href, :crop, :loading]
|
66
|
-
|
67
|
-
# Defaults for HTML Element attributes.
|
68
|
-
# Not every attr has to be listed here.
|
69
|
-
# Many need no default and just won't render.
|
70
|
-
ATTRS_DEFAULT = {
|
71
|
-
:crop => :attention,
|
72
|
-
:loading => :eager,
|
73
|
-
}
|
74
|
-
ATTRS_VALUES = {
|
75
|
-
# https://www.rubydoc.info/gems/ruby-vips/Vips/Interesting
|
76
|
-
:crop => Set[:none, :centre, :entropy, :attention],
|
77
|
-
:loading => Set[:eager, :lazy],
|
78
|
-
}
|
79
|
-
|
80
|
-
|
81
|
-
def initialize(src)
|
82
|
-
@image = Vips::Image.new_from_file(src)
|
83
|
-
@src = src
|
84
|
-
end
|
85
|
-
|
86
|
-
def rotate(angle: nil)
|
87
|
-
if angle == :auto
|
88
|
-
@image = @image&.autorot
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def clean
|
93
|
-
# Nuke the entire site from orbit. It's the only way to be sure.
|
94
|
-
@image.get_fields.grep(/exif-ifd/).each {|field| @image.remove field}
|
95
|
-
end
|
96
|
-
|
97
|
-
def save(dest, width: nil, crop: nil)
|
98
|
-
begin
|
99
|
-
if width.nil? or width == :full
|
100
|
-
return @image.write_to_file(dest)
|
101
|
-
elsif width.respond_to?(:to_i)
|
102
|
-
ver = @image.thumbnail_image(
|
103
|
-
width.to_i,
|
104
|
-
# Use `self` namespace for constants so subclasses can redefine
|
105
|
-
**{:crop => crop || self.singleton_class.const_get(:ATTRS_DEFAULT)[:crop]},
|
106
|
-
)
|
107
|
-
return ver.write_to_file(dest)
|
108
|
-
end
|
109
|
-
rescue Vips::Error => v
|
110
|
-
if v.message.include?('No known saver')
|
111
|
-
# TODO: Handle missing output formats. Replacements? Skip it? Die?
|
112
|
-
return nil
|
113
|
-
else
|
114
|
-
raise
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end # save
|
118
|
-
|
119
|
-
end # Image
|
120
|
-
end # DistorteD
|
121
|
-
end # Cooltrainer
|
data/lib/distorted/svg.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
require 'mime/types'
|
4
|
-
require 'svg_optimizer'
|
5
|
-
|
6
|
-
module Cooltrainer
|
7
|
-
module DistorteD
|
8
|
-
class SVG < Image
|
9
|
-
|
10
|
-
SUB_TYPE = 'svg'.freeze
|
11
|
-
|
12
|
-
MIME_TYPES = MIME::Types[/^#{self::MEDIA_TYPE}\/#{self::SUB_TYPE}/, :complete => true].to_set
|
13
|
-
|
14
|
-
def self.optimize(src, dest)
|
15
|
-
# TODO: Make optimizations/plugins configurable
|
16
|
-
SvgOptimizer.optimize_file(src, dest, SvgOptimizer::DEFAULT_PLUGINS)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|