resizo 0.1.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 +7 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +161 -0
- data/exe/resizo +7 -0
- data/lib/resizo/cli.rb +106 -0
- data/lib/resizo/file_size.rb +48 -0
- data/lib/resizo/geometry.rb +118 -0
- data/lib/resizo/presets.rb +92 -0
- data/lib/resizo/tools.rb +124 -0
- data/lib/resizo/version.rb +5 -0
- data/lib/resizo.rb +42 -0
- metadata +65 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d2a3b35a72b9c91c57c33cb2c499fe81a72abbe1bde950958e46627d4aacf46b
|
|
4
|
+
data.tar.gz: 27221e27b75d3701bb49b843950d0fe64d1529fd8dc37d5bc2b23ee3bd81c45e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a102938b6ff197a68791d2ab3ff189e1265b4f7aeb75366de36096d85176ee553976d26c828638c5afd7000a8e80f1dd69039272b9b9f038307c1909f20499ca
|
|
7
|
+
data.tar.gz: a1b92158458abd52542612f50a2577b15d8e3270baaa9cda5301bb3a9bd247e362cc443bb6f8988029d95000b1df74d055872190da2deb7118d9049dd714a27b
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eldho Paulose
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# resizo
|
|
2
|
+
|
|
3
|
+
Image size presets and resize/crop maths for Ruby, from the team behind
|
|
4
|
+
[Resizo](https://www.resizo.in/), a free image resizer that runs in the
|
|
5
|
+
browser with no upload and no sign-up.
|
|
6
|
+
|
|
7
|
+
- Size presets for Pinterest, Twitch and passport photos, each linked to the
|
|
8
|
+
tool that produces it
|
|
9
|
+
- `contain` / `cover` fit geometry, crop boxes with a focal point, aspect ratios
|
|
10
|
+
- mm/inch → px at any DPI
|
|
11
|
+
- File-size parsing that treats `100 KB` as 100,000 bytes, like upload forms do
|
|
12
|
+
- A `resizo` command-line tool
|
|
13
|
+
- No dependencies. Works with MiniMagick, ruby-vips, ImageProcessing or anything
|
|
14
|
+
else that takes numbers.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
gem install resizo
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
or in a Gemfile:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
gem "resizo"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
require "resizo"
|
|
32
|
+
|
|
33
|
+
# Where a 4000x3000 photo lands in a 1080x1080 square
|
|
34
|
+
p = Resizo::Geometry.fit(4000, 3000, 1080, 1080, mode: :cover)
|
|
35
|
+
p.width, p.height, p.x, p.y #=> 1440, 1080, -180, 0
|
|
36
|
+
|
|
37
|
+
# Crop box for a 4:5 portrait, focused on the top third
|
|
38
|
+
Resizo::Geometry.crop_box(4000, 3000, 4, 5, focus: [0.5, 0.33])
|
|
39
|
+
#=> [800, 0, 2400, 3000]
|
|
40
|
+
|
|
41
|
+
Resizo::Geometry.aspect_ratio(1920, 1080) #=> "16:9"
|
|
42
|
+
Resizo::Geometry.mm_to_px(35, dpi: 300) #=> 413
|
|
43
|
+
|
|
44
|
+
# Presets
|
|
45
|
+
pin = Resizo::Presets.find(:pinterest, :standard_pin)
|
|
46
|
+
pin.size #=> "1000x1500"
|
|
47
|
+
pin.tool #=> "https://www.resizo.in/resize-image-for-pinterest/"
|
|
48
|
+
|
|
49
|
+
Resizo::Presets.twitch_set(:emote) #=> [112, 56, 28]
|
|
50
|
+
|
|
51
|
+
# File sizes
|
|
52
|
+
Resizo::FileSize.parse("100 KB") #=> 100000
|
|
53
|
+
Resizo::FileSize.parse("100 KB", binary: true) #=> 102400
|
|
54
|
+
Resizo::FileSize.within?(239_000, "240 KB") #=> true
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### With ImageProcessing / ruby-vips
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
require "image_processing/vips"
|
|
61
|
+
require "resizo"
|
|
62
|
+
|
|
63
|
+
preset = Resizo::Presets.find(:pinterest, :standard_pin)
|
|
64
|
+
ImageProcessing::Vips
|
|
65
|
+
.source("photo.jpg")
|
|
66
|
+
.resize_to_fill(preset.width, preset.height)
|
|
67
|
+
.call(destination: "pin.jpg")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Command line
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
$ resizo presets pinterest
|
|
74
|
+
Pinterest - https://www.resizo.in/resize-image-for-pinterest/
|
|
75
|
+
Standard Pin 1000x1500 2:3
|
|
76
|
+
Square Pin 1000x1000 1:1
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
$ resizo fit 4000x3000 1080x1080 --cover
|
|
80
|
+
cover: draw 1440x1080 at (-180, 0), scale 0.36
|
|
81
|
+
|
|
82
|
+
$ resizo crop 4000x3000 4:5
|
|
83
|
+
crop 2400x3000 at (800, 0)
|
|
84
|
+
|
|
85
|
+
$ resizo bytes "1.5 MB"
|
|
86
|
+
1500000
|
|
87
|
+
|
|
88
|
+
$ resizo tools social
|
|
89
|
+
$ resizo url heic-to-jpg
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Presets
|
|
93
|
+
|
|
94
|
+
| Platform | Preset | Size |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| Pinterest | Standard Pin (2:3) | 1000×1500 |
|
|
97
|
+
| Pinterest | Square / 4:5 / 3:4 / 1:2 Pin | 1000×1000 · 1000×1250 · 1000×1333 · 1000×2000 |
|
|
98
|
+
| Pinterest | Full-screen Pin (9:16) | 1080×1920 |
|
|
99
|
+
| Pinterest | Profile cover (16:9) | 1920×1080 |
|
|
100
|
+
| Twitch | Emote set | 112 · 56 · 28 px |
|
|
101
|
+
| Twitch | Subscriber badge set | 72 · 36 · 18 px (25 KB max) |
|
|
102
|
+
| Twitch | Profile picture / banner / player banner | 256×256 · 1200×480 · 1920×1080 |
|
|
103
|
+
| Twitch | Panel | 320 px wide, up to 300 px tall |
|
|
104
|
+
| Passport | US (2×2 in) | 600×600 |
|
|
105
|
+
| Passport | UK / EU / Schengen (35×45 mm) | 413×531 |
|
|
106
|
+
|
|
107
|
+
Pinterest and Twitch figures come from those platforms' own help pages. Where
|
|
108
|
+
Pinterest gives only a ratio, the preset uses that ratio at 1000 px wide.
|
|
109
|
+
|
|
110
|
+
## Free online tools
|
|
111
|
+
|
|
112
|
+
The same presets, in a browser, with nothing uploaded:
|
|
113
|
+
|
|
114
|
+
**Images**
|
|
115
|
+
- [Free Image Resizer](https://www.resizo.in/): resize, compress and convert
|
|
116
|
+
- [Compress to Target Size](https://www.resizo.in/compress-to-target-size/): hit an exact KB/MB limit
|
|
117
|
+
- [HEIC to JPG Converter](https://www.resizo.in/heic-to-jpg/)
|
|
118
|
+
- [JPG to WebP Converter](https://www.resizo.in/jpg-to-webp-converter/)
|
|
119
|
+
- [Passport Photo Resizer](https://www.resizo.in/passport-photo-resizer/)
|
|
120
|
+
- [Circle Crop](https://www.resizo.in/circle-crop/)
|
|
121
|
+
- [Image Watermark](https://www.resizo.in/image-watermark/)
|
|
122
|
+
- [Meme Generator](https://www.resizo.in/meme-generator/)
|
|
123
|
+
- [Feature Graphic Maker](https://www.resizo.in/feature-graphic-maker/)
|
|
124
|
+
- [WiFi QR Code Generator](https://www.resizo.in/wifi-qr-generator/)
|
|
125
|
+
|
|
126
|
+
**Batch**
|
|
127
|
+
- [Batch Image Toolkit](https://www.resizo.in/batch-toolkit/): resize, convert, crop, watermark and rename many files into one ZIP
|
|
128
|
+
|
|
129
|
+
**Social media**
|
|
130
|
+
- [Social Media Image Resizer](https://www.resizo.in/social-media-image-resizer/)
|
|
131
|
+
- [Instagram](https://www.resizo.in/resize-image-for-instagram/) ·
|
|
132
|
+
[Facebook](https://www.resizo.in/resize-image-for-facebook/) ·
|
|
133
|
+
[X / Twitter](https://www.resizo.in/resize-image-for-twitter/) ·
|
|
134
|
+
[LinkedIn](https://www.resizo.in/resize-image-for-linkedin/) ·
|
|
135
|
+
[YouTube](https://www.resizo.in/resize-image-for-youtube/) ·
|
|
136
|
+
[WhatsApp](https://www.resizo.in/resize-image-for-whatsapp/) ·
|
|
137
|
+
[TikTok](https://www.resizo.in/resize-image-for-tiktok/) ·
|
|
138
|
+
[Pinterest](https://www.resizo.in/resize-image-for-pinterest/) ·
|
|
139
|
+
[Twitch](https://www.resizo.in/resize-image-for-twitch/)
|
|
140
|
+
- [eCommerce Image Resizer](https://www.resizo.in/ecommerce-image-resizer/)
|
|
141
|
+
|
|
142
|
+
**Video**
|
|
143
|
+
- [Video Studio](https://www.resizo.in/video-studio/) ·
|
|
144
|
+
[Video Watermark](https://www.resizo.in/video-watermark/) ·
|
|
145
|
+
[Video Resizer](https://www.resizo.in/video-resizer/) ·
|
|
146
|
+
[Video Compressor](https://www.resizo.in/video-compressor/) ·
|
|
147
|
+
[Video to GIF](https://www.resizo.in/video-to-gif/)
|
|
148
|
+
|
|
149
|
+
The site is also in Español, Français, Deutsch, Português, 日本語, العربية and
|
|
150
|
+
한국어: `Resizo.home_url(:es)` and so on.
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
ruby -Ilib -Itest test/test_resizo.rb
|
|
156
|
+
gem build resizo.gemspec
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT. See [LICENSE.txt](LICENSE.txt).
|
data/exe/resizo
ADDED
data/lib/resizo/cli.rb
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Resizo
|
|
6
|
+
# `resizo` command-line tool. Kept dependency-free (no Thor/OptionParser
|
|
7
|
+
# subcommands) so the gem installs anywhere.
|
|
8
|
+
class CLI
|
|
9
|
+
USAGE = <<~TXT
|
|
10
|
+
Usage: resizo <command> [args]
|
|
11
|
+
|
|
12
|
+
Commands:
|
|
13
|
+
tools [CATEGORY] List free Resizo tools (image, batch, social, video)
|
|
14
|
+
url TOOL Print a tool's URL, e.g. `resizo url heic-to-jpg`
|
|
15
|
+
presets [PLATFORM] [--json] Size presets (pinterest, twitch, passport)
|
|
16
|
+
fit SRC DST [--cover|--contain] Where SRC lands in DST, e.g. `resizo fit 4000x3000 1080x1080 --cover`
|
|
17
|
+
crop SRC RATIO Crop box for a ratio, e.g. `resizo crop 4000x3000 4:5`
|
|
18
|
+
ratio SIZE Reduced aspect ratio, e.g. `resizo ratio 1920x1080`
|
|
19
|
+
bytes SIZE [--binary] Parse a file size, e.g. `resizo bytes "100 KB"`
|
|
20
|
+
version Print the gem version
|
|
21
|
+
|
|
22
|
+
Every tool runs in your browser at https://www.resizo.in/ - no upload, no sign-up.
|
|
23
|
+
TXT
|
|
24
|
+
|
|
25
|
+
def initialize(out = $stdout, err = $stderr)
|
|
26
|
+
@out = out
|
|
27
|
+
@err = err
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run(argv)
|
|
31
|
+
args = argv.dup
|
|
32
|
+
command = args.shift
|
|
33
|
+
case command
|
|
34
|
+
when nil, "help", "-h", "--help" then @out.puts(USAGE)
|
|
35
|
+
when "version", "-v", "--version" then @out.puts(Resizo::VERSION)
|
|
36
|
+
when "tools" then tools(args)
|
|
37
|
+
when "url" then @out.puts(Resizo.tool_url(required(args, "TOOL")))
|
|
38
|
+
when "presets" then presets(args)
|
|
39
|
+
when "fit" then fit(args)
|
|
40
|
+
when "crop" then crop(args)
|
|
41
|
+
when "ratio" then @out.puts(Geometry.aspect_ratio(*Geometry.parse_size(required(args, "SIZE"))))
|
|
42
|
+
when "bytes" then @out.puts(FileSize.parse(required(args, "SIZE"), binary: args.include?("--binary")))
|
|
43
|
+
else
|
|
44
|
+
@err.puts("resizo: unknown command #{command.inspect}\n\n#{USAGE}")
|
|
45
|
+
return 1
|
|
46
|
+
end
|
|
47
|
+
0
|
|
48
|
+
rescue Resizo::Error => e
|
|
49
|
+
@err.puts("resizo: #{e.message}")
|
|
50
|
+
1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def required(args, name)
|
|
56
|
+
args.reject { |a| a.start_with?("--") }.first || raise(Resizo::Error, "missing #{name}")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def tools(args)
|
|
60
|
+
cats = args.empty? ? Tools::CATEGORIES : [args.first.to_sym]
|
|
61
|
+
unknown = cats - Tools::CATEGORIES
|
|
62
|
+
raise Resizo::Error, "unknown category #{unknown.first} (#{Tools::CATEGORIES.join(', ')})" unless unknown.empty?
|
|
63
|
+
|
|
64
|
+
cats.each do |cat|
|
|
65
|
+
@out.puts("#{cat.to_s.capitalize} tools")
|
|
66
|
+
Tools.by_category(cat).each { |t| @out.puts(format(" %-34s %s", t.name, t.url)) }
|
|
67
|
+
@out.puts
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def presets(args)
|
|
72
|
+
json = args.delete("--json")
|
|
73
|
+
list = args.empty? ? Presets.all : Presets.for(args.first)
|
|
74
|
+
raise Resizo::Error, "unknown platform #{args.first} (#{Presets.platforms.join(', ')})" if list.empty?
|
|
75
|
+
|
|
76
|
+
if json
|
|
77
|
+
@out.puts(JSON.pretty_generate(list.map(&:to_h)))
|
|
78
|
+
else
|
|
79
|
+
list.group_by(&:platform).each do |platform, items|
|
|
80
|
+
@out.puts("#{platform.to_s.capitalize} - #{items.first.tool}")
|
|
81
|
+
items.each { |p| @out.puts(format(" %-30s %-10s %s", p.name, p.size, p.ratio)) }
|
|
82
|
+
@out.puts
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def fit(args)
|
|
88
|
+
sizes = args.reject { |a| a.start_with?("--") }
|
|
89
|
+
raise Resizo::Error, "usage: resizo fit SRC DST [--cover|--contain]" unless sizes.size == 2
|
|
90
|
+
|
|
91
|
+
mode = args.include?("--cover") ? :cover : :contain
|
|
92
|
+
p = Geometry.fit(*Geometry.parse_size(sizes[0]), *Geometry.parse_size(sizes[1]), mode: mode)
|
|
93
|
+
@out.puts("#{mode}: draw #{p.width}x#{p.height} at (#{p.x}, #{p.y}), scale #{p.scale.round(4)}")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def crop(args)
|
|
97
|
+
raise Resizo::Error, "usage: resizo crop SRC RATIO" unless args.size == 2
|
|
98
|
+
|
|
99
|
+
rw, rh = args[1].split(":").map(&:to_f)
|
|
100
|
+
raise Resizo::Error, "invalid ratio #{args[1].inspect} (expected W:H)" unless rw&.positive? && rh&.positive?
|
|
101
|
+
|
|
102
|
+
x, y, w, h = Geometry.crop_box(*Geometry.parse_size(args[0]), rw, rh)
|
|
103
|
+
@out.puts("crop #{w}x#{h} at (#{x}, #{y})")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Resizo
|
|
4
|
+
# File-size parsing and formatting.
|
|
5
|
+
#
|
|
6
|
+
# Upload forms disagree about whether "100 KB" means 100,000 or 102,400
|
|
7
|
+
# bytes. Resizo's Compress to Target Size tool reads it as the decimal
|
|
8
|
+
# 100,000, the only reading that passes both kinds of form, and this module
|
|
9
|
+
# does the same by default. Pass binary: true for 1 KB = 1,024 bytes.
|
|
10
|
+
module FileSize
|
|
11
|
+
UNITS = %w[B KB MB GB].freeze
|
|
12
|
+
|
|
13
|
+
module_function
|
|
14
|
+
|
|
15
|
+
# Resizo::FileSize.parse("100 KB") #=> 100_000
|
|
16
|
+
# Resizo::FileSize.parse("1.5MB") #=> 1_500_000
|
|
17
|
+
# Resizo::FileSize.parse("100 KB", binary: true) #=> 102_400
|
|
18
|
+
def parse(str, binary: false)
|
|
19
|
+
m = str.to_s.strip.match(/\A(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|KiB|MiB|GiB)?\z/i)
|
|
20
|
+
raise Resizo::Error, "invalid file size #{str.inspect}" unless m
|
|
21
|
+
|
|
22
|
+
unit = (m[2] || "B").upcase
|
|
23
|
+
base = binary || unit.include?("I") ? 1024 : 1000 # KiB/MiB/GiB are always binary
|
|
24
|
+
power = { "B" => 0, "KB" => 1, "KIB" => 1, "MB" => 2, "MIB" => 2, "GB" => 3, "GIB" => 3 }.fetch(unit)
|
|
25
|
+
(m[1].to_f * (base**power)).round
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Resizo::FileSize.format(245_000) #=> "245 KB"
|
|
29
|
+
def format(bytes, binary: false, precision: 1)
|
|
30
|
+
raise Resizo::Error, "expected a non-negative number, got #{bytes.inspect}" unless bytes.is_a?(Numeric) && bytes >= 0
|
|
31
|
+
|
|
32
|
+
base = binary ? 1024 : 1000
|
|
33
|
+
i = 0
|
|
34
|
+
value = bytes.to_f
|
|
35
|
+
while value >= base && i < UNITS.size - 1
|
|
36
|
+
value /= base
|
|
37
|
+
i += 1
|
|
38
|
+
end
|
|
39
|
+
num = i.zero? ? value.round.to_s : value.round(precision).to_s.sub(/\.0\z/, "")
|
|
40
|
+
"#{num} #{UNITS[i]}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# True when a file of `bytes` fits under a limit such as "240 KB".
|
|
44
|
+
def within?(bytes, limit, binary: false)
|
|
45
|
+
bytes <= parse(limit, binary: binary)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Resizo
|
|
4
|
+
# Pure resize/crop maths. No image library required: feed the numbers to
|
|
5
|
+
# MiniMagick, ruby-vips, ImageProcessing or a <canvas>.
|
|
6
|
+
module Geometry
|
|
7
|
+
# Where a source image lands inside a target frame.
|
|
8
|
+
# width/height - the drawn size of the source
|
|
9
|
+
# x/y - its top-left corner in the frame (negative = cropped)
|
|
10
|
+
Placement = Struct.new(:x, :y, :width, :height, :scale, keyword_init: true)
|
|
11
|
+
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
# Fit a source into a target frame.
|
|
15
|
+
#
|
|
16
|
+
# mode:
|
|
17
|
+
# :contain - whole image visible, padded (letterbox)
|
|
18
|
+
# :cover - frame filled, overflow cropped
|
|
19
|
+
# :stretch - ignore aspect ratio
|
|
20
|
+
# focus: [fx, fy] in 0..1, where the crop is centred in :cover mode.
|
|
21
|
+
#
|
|
22
|
+
# Resizo::Geometry.fit(4000, 3000, 1080, 1080, mode: :cover)
|
|
23
|
+
# #=> #<struct x=-180, y=0, width=1440, height=1080, scale=0.36>
|
|
24
|
+
def fit(src_w, src_h, dst_w, dst_h, mode: :contain, focus: [0.5, 0.5])
|
|
25
|
+
[src_w, src_h, dst_w, dst_h].each { |v| positive!(v) }
|
|
26
|
+
|
|
27
|
+
if mode.to_sym == :stretch
|
|
28
|
+
return Placement.new(x: 0, y: 0, width: dst_w, height: dst_h, scale: dst_w.fdiv(src_w))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
scale =
|
|
32
|
+
case mode.to_sym
|
|
33
|
+
when :contain then [dst_w.fdiv(src_w), dst_h.fdiv(src_h)].min
|
|
34
|
+
when :cover then [dst_w.fdiv(src_w), dst_h.fdiv(src_h)].max
|
|
35
|
+
else raise Resizo::Error, "unknown mode #{mode.inspect} (expected :contain, :cover or :stretch)"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
w = (src_w * scale).round
|
|
39
|
+
h = (src_h * scale).round
|
|
40
|
+
fx, fy = focus.map { |f| f.to_f.clamp(0.0, 1.0) }
|
|
41
|
+
Placement.new(x: ((dst_w - w) * fx).round, y: ((dst_h - h) * fy).round, width: w, height: h, scale: scale)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The source rectangle to crop so it fills the target ratio.
|
|
45
|
+
# Returns [x, y, width, height] in source pixels.
|
|
46
|
+
#
|
|
47
|
+
# Resizo::Geometry.crop_box(4000, 3000, 1, 1) #=> [500, 0, 3000, 3000]
|
|
48
|
+
def crop_box(src_w, src_h, ratio_w, ratio_h, focus: [0.5, 0.5])
|
|
49
|
+
[src_w, src_h, ratio_w, ratio_h].each { |v| positive!(v) }
|
|
50
|
+
target = ratio_w.fdiv(ratio_h)
|
|
51
|
+
if src_w.fdiv(src_h) > target
|
|
52
|
+
w = (src_h * target).round
|
|
53
|
+
h = src_h
|
|
54
|
+
else
|
|
55
|
+
w = src_w
|
|
56
|
+
h = (src_w / target).round
|
|
57
|
+
end
|
|
58
|
+
fx, fy = focus.map { |f| f.to_f.clamp(0.0, 1.0) }
|
|
59
|
+
[((src_w - w) * fx).round, ((src_h - h) * fy).round, w, h]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Scale to a width, keeping the aspect ratio. Returns [width, height].
|
|
63
|
+
def scale_to_width(src_w, src_h, width)
|
|
64
|
+
[src_w, src_h, width].each { |v| positive!(v) }
|
|
65
|
+
[width, (src_h * width.fdiv(src_w)).round]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Scale to a height, keeping the aspect ratio. Returns [width, height].
|
|
69
|
+
def scale_to_height(src_w, src_h, height)
|
|
70
|
+
[src_w, src_h, height].each { |v| positive!(v) }
|
|
71
|
+
[(src_w * height.fdiv(src_h)).round, height]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Largest size that fits inside a bounding box without upscaling.
|
|
75
|
+
def fit_within(src_w, src_h, max_w, max_h, upscale: false)
|
|
76
|
+
[src_w, src_h, max_w, max_h].each { |v| positive!(v) }
|
|
77
|
+
scale = [max_w.fdiv(src_w), max_h.fdiv(src_h)].min
|
|
78
|
+
scale = [scale, 1.0].min unless upscale
|
|
79
|
+
[(src_w * scale).round, (src_h * scale).round]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Reduced aspect ratio as a string.
|
|
83
|
+
#
|
|
84
|
+
# Resizo::Geometry.aspect_ratio(1920, 1080) #=> "16:9"
|
|
85
|
+
def aspect_ratio(width, height)
|
|
86
|
+
positive!(width)
|
|
87
|
+
positive!(height)
|
|
88
|
+
g = width.to_i.gcd(height.to_i)
|
|
89
|
+
"#{width.to_i / g}:#{height.to_i / g}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Pixels for a physical size at a DPI.
|
|
93
|
+
#
|
|
94
|
+
# Resizo::Geometry.mm_to_px(35, dpi: 300) #=> 413
|
|
95
|
+
def mm_to_px(mm, dpi: 300)
|
|
96
|
+
(mm.to_f / 25.4 * dpi).round
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def inches_to_px(inches, dpi: 300)
|
|
100
|
+
(inches.to_f * dpi).round
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Parse "1080x1920", "1080×1920" or "1080 x 1920" into [1080, 1920].
|
|
104
|
+
def parse_size(str)
|
|
105
|
+
m = str.to_s.strip.match(/\A(\d+)\s*[x×*]\s*(\d+)\z/i)
|
|
106
|
+
raise Resizo::Error, "invalid size #{str.inspect} (expected WIDTHxHEIGHT)" unless m
|
|
107
|
+
|
|
108
|
+
[m[1].to_i, m[2].to_i]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def positive!(value)
|
|
112
|
+
return if value.is_a?(Numeric) && value.positive?
|
|
113
|
+
|
|
114
|
+
raise Resizo::Error, "expected a positive number, got #{value.inspect}"
|
|
115
|
+
end
|
|
116
|
+
private_class_method :positive!
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Resizo
|
|
4
|
+
# Image size presets. Figures are the ones used by the matching tool on
|
|
5
|
+
# https://www.resizo.in/, which only ships numbers taken from the platform's
|
|
6
|
+
# own documentation (or, where noted, a ratio the platform states at a width
|
|
7
|
+
# we chose).
|
|
8
|
+
module Presets
|
|
9
|
+
Preset = Struct.new(:platform, :id, :name, :width, :height, :ratio, :note, :tool, keyword_init: true) do
|
|
10
|
+
def size
|
|
11
|
+
"#{width}x#{height}"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_h
|
|
15
|
+
super.merge(size: size)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
PINTEREST = [
|
|
20
|
+
Preset.new(platform: :pinterest, id: :standard_pin, name: "Standard Pin", width: 1000, height: 1500, ratio: "2:3",
|
|
21
|
+
note: "Pinterest's recommended Pin size."),
|
|
22
|
+
Preset.new(platform: :pinterest, id: :square_pin, name: "Square Pin", width: 1000, height: 1000, ratio: "1:1",
|
|
23
|
+
note: "In-app crop ratio at 1000 px wide."),
|
|
24
|
+
Preset.new(platform: :pinterest, id: :portrait_4x5_pin, name: "Portrait 4:5 Pin", width: 1000, height: 1250, ratio: "4:5",
|
|
25
|
+
note: "In-app crop ratio at 1000 px wide."),
|
|
26
|
+
Preset.new(platform: :pinterest, id: :portrait_3x4_pin, name: "Portrait 3:4 Pin", width: 1000, height: 1333, ratio: "3:4",
|
|
27
|
+
note: "In-app crop ratio at 1000 px wide."),
|
|
28
|
+
Preset.new(platform: :pinterest, id: :tall_pin, name: "Tall Pin", width: 1000, height: 2000, ratio: "1:2",
|
|
29
|
+
note: "Inside Pinterest's 1:2.1 truncation limit."),
|
|
30
|
+
Preset.new(platform: :pinterest, id: :full_screen_pin, name: "Full-screen Pin", width: 1080, height: 1920, ratio: "9:16",
|
|
31
|
+
note: "Keep content inside the safe zone: 270 px top, 790 px bottom, 65 px left, 195 px right."),
|
|
32
|
+
Preset.new(platform: :pinterest, id: :profile_cover, name: "Profile cover", width: 1920, height: 1080, ratio: "16:9",
|
|
33
|
+
note: "16:9, minimum 800x450.")
|
|
34
|
+
].freeze
|
|
35
|
+
|
|
36
|
+
TWITCH = [
|
|
37
|
+
Preset.new(platform: :twitch, id: :emote, name: "Emote", width: 112, height: 112, ratio: "1:1",
|
|
38
|
+
note: "Upload as a set: 112, 56 and 28 px, transparent PNG."),
|
|
39
|
+
Preset.new(platform: :twitch, id: :sub_badge, name: "Subscriber badge", width: 72, height: 72, ratio: "1:1",
|
|
40
|
+
note: "Upload as a set: 72, 36 and 18 px, transparent PNG, 25 KB max each."),
|
|
41
|
+
Preset.new(platform: :twitch, id: :profile_picture, name: "Profile picture", width: 256, height: 256, ratio: "1:1",
|
|
42
|
+
note: "Shown as a circle."),
|
|
43
|
+
Preset.new(platform: :twitch, id: :profile_banner, name: "Profile banner", width: 1200, height: 480, ratio: "5:2"),
|
|
44
|
+
Preset.new(platform: :twitch, id: :video_player_banner, name: "Video player banner", width: 1920, height: 1080, ratio: "16:9"),
|
|
45
|
+
Preset.new(platform: :twitch, id: :panel, name: "Panel", width: 320, height: 300, ratio: nil,
|
|
46
|
+
note: "320 px wide; height follows the image, kept at or under 300 px.")
|
|
47
|
+
].freeze
|
|
48
|
+
|
|
49
|
+
PASSPORT = [
|
|
50
|
+
Preset.new(platform: :passport, id: :us, name: "US passport (2x2 in)", width: 600, height: 600, ratio: "1:1",
|
|
51
|
+
note: "2x2 inches at 300 DPI."),
|
|
52
|
+
Preset.new(platform: :passport, id: :uk_eu_schengen, name: "UK / EU / Schengen (35x45 mm)", width: 413, height: 531, ratio: "7:9",
|
|
53
|
+
note: "35x45 mm at 300 DPI.")
|
|
54
|
+
].freeze
|
|
55
|
+
|
|
56
|
+
TOOL_SLUGS = {
|
|
57
|
+
pinterest: "resize-image-for-pinterest",
|
|
58
|
+
twitch: "resize-image-for-twitch",
|
|
59
|
+
passport: "passport-photo-resizer"
|
|
60
|
+
}.freeze
|
|
61
|
+
|
|
62
|
+
ALL = (PINTEREST + TWITCH + PASSPORT).each { |p| p.tool = "#{Resizo::BASE_URL}/#{TOOL_SLUGS[p.platform]}/" }.freeze
|
|
63
|
+
|
|
64
|
+
module_function
|
|
65
|
+
|
|
66
|
+
def all
|
|
67
|
+
ALL
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def platforms
|
|
71
|
+
TOOL_SLUGS.keys
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def for(platform)
|
|
75
|
+
ALL.select { |p| p.platform == platform.to_sym }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Resizo::Presets.find(:pinterest, :standard_pin)
|
|
79
|
+
def find(platform, id)
|
|
80
|
+
ALL.find { |p| p.platform == platform.to_sym && p.id == id.to_sym }
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# The emote and badge sizes Twitch asks for, largest first.
|
|
84
|
+
def twitch_set(kind)
|
|
85
|
+
case kind.to_sym
|
|
86
|
+
when :emote then [112, 56, 28]
|
|
87
|
+
when :badge, :sub_badge then [72, 36, 18]
|
|
88
|
+
else raise Resizo::Error, "unknown Twitch set #{kind.inspect} (expected :emote or :badge)"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/resizo/tools.rb
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Resizo
|
|
4
|
+
# Catalog of the free tools on https://www.resizo.in/.
|
|
5
|
+
module Tools
|
|
6
|
+
Tool = Struct.new(:slug, :name, :category, :description, keyword_init: true) do
|
|
7
|
+
def url
|
|
8
|
+
slug.empty? ? "#{Resizo::BASE_URL}/" : "#{Resizo::BASE_URL}/#{slug}/"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def key
|
|
12
|
+
(slug.empty? ? "image-resizer" : slug).tr("-", "_").to_sym
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
ALL = [
|
|
17
|
+
# Image
|
|
18
|
+
Tool.new(slug: "", name: "Free Image Resizer", category: :image,
|
|
19
|
+
description: "Resize, compress and convert images in the browser with no upload or sign-up."),
|
|
20
|
+
Tool.new(slug: "compress-to-target-size", name: "Compress to Target Size", category: :image,
|
|
21
|
+
description: "Hit an exact KB/MB budget in JPG, WebP, AVIF, PNG or PDF."),
|
|
22
|
+
Tool.new(slug: "heic-to-jpg", name: "HEIC to JPG Converter", category: :image,
|
|
23
|
+
description: "Convert iPhone HEIC/HEIF photos to JPG, PNG, WebP or AVIF."),
|
|
24
|
+
Tool.new(slug: "jpg-to-webp-converter", name: "JPG to WebP Converter", category: :image,
|
|
25
|
+
description: "Convert JPG and PNG images to WebP."),
|
|
26
|
+
Tool.new(slug: "passport-photo-resizer", name: "Passport Photo Resizer", category: :image,
|
|
27
|
+
description: "Passport, visa and ID photos for the US, UK, India, EU, Canada and more."),
|
|
28
|
+
Tool.new(slug: "circle-crop", name: "Circle Crop", category: :image,
|
|
29
|
+
description: "Crop any image to a circle for profile pictures."),
|
|
30
|
+
Tool.new(slug: "image-watermark", name: "Image Watermark", category: :image,
|
|
31
|
+
description: "Hand-placed text or logo watermarks on a batch of photos."),
|
|
32
|
+
Tool.new(slug: "meme-generator", name: "Meme Generator", category: :image,
|
|
33
|
+
description: "Make memes with text, stickers and layouts."),
|
|
34
|
+
Tool.new(slug: "feature-graphic-maker", name: "Feature Graphic Maker", category: :image,
|
|
35
|
+
description: "Design a 1024x500 Google Play feature graphic."),
|
|
36
|
+
Tool.new(slug: "wifi-qr-generator", name: "WiFi QR Code Generator & Scanner", category: :image,
|
|
37
|
+
description: "Make or scan a WiFi QR code; the password never leaves the browser."),
|
|
38
|
+
|
|
39
|
+
# Batch
|
|
40
|
+
Tool.new(slug: "batch-toolkit", name: "Batch Image Toolkit", category: :batch,
|
|
41
|
+
description: "Bulk resize, convert, crop, watermark and rename, downloaded as one ZIP."),
|
|
42
|
+
Tool.new(slug: "batch-resize", name: "Batch Resize", category: :batch,
|
|
43
|
+
description: "Resize many images at once."),
|
|
44
|
+
Tool.new(slug: "batch-convert", name: "Batch Convert", category: :batch,
|
|
45
|
+
description: "Convert many images between formats at once."),
|
|
46
|
+
Tool.new(slug: "batch-crop", name: "Batch Crop", category: :batch,
|
|
47
|
+
description: "Crop many images to one aspect ratio."),
|
|
48
|
+
Tool.new(slug: "batch-watermark", name: "Batch Watermark", category: :batch,
|
|
49
|
+
description: "Stamp a corner watermark on many images."),
|
|
50
|
+
Tool.new(slug: "batch-rename", name: "Batch Rename", category: :batch,
|
|
51
|
+
description: "Rename many image files with a pattern."),
|
|
52
|
+
|
|
53
|
+
# Social
|
|
54
|
+
Tool.new(slug: "social-media-image-resizer", name: "Social Media Image Resizer", category: :social,
|
|
55
|
+
description: "One image to 40+ presets across 11 platforms in one ZIP."),
|
|
56
|
+
Tool.new(slug: "resize-image-for-instagram", name: "Instagram Image Resizer", category: :social,
|
|
57
|
+
description: "Posts, stories, reels covers and profile pictures."),
|
|
58
|
+
Tool.new(slug: "resize-image-for-facebook", name: "Facebook Image Resizer", category: :social,
|
|
59
|
+
description: "Covers, posts, events and ads."),
|
|
60
|
+
Tool.new(slug: "resize-image-for-twitter", name: "X / Twitter Image Resizer", category: :social,
|
|
61
|
+
description: "Header/banner, posts and card images."),
|
|
62
|
+
Tool.new(slug: "resize-image-for-linkedin", name: "LinkedIn Image Resizer", category: :social,
|
|
63
|
+
description: "Banners, posts and company pages."),
|
|
64
|
+
Tool.new(slug: "resize-image-for-youtube", name: "YouTube Image Resizer", category: :social,
|
|
65
|
+
description: "Thumbnails, channel banners and profile pictures."),
|
|
66
|
+
Tool.new(slug: "resize-image-for-whatsapp", name: "WhatsApp Image Resizer", category: :social,
|
|
67
|
+
description: "DP, status and sticker sizes."),
|
|
68
|
+
Tool.new(slug: "resize-image-for-tiktok", name: "TikTok Image Resizer", category: :social,
|
|
69
|
+
description: "Profile pictures, photo posts and video covers."),
|
|
70
|
+
Tool.new(slug: "resize-image-for-pinterest", name: "Pinterest Image Resizer", category: :social,
|
|
71
|
+
description: "2:3 Pins, square, 9:16 full-screen with safe zone and 16:9 profile cover."),
|
|
72
|
+
Tool.new(slug: "resize-image-for-twitch", name: "Twitch Image Resizer", category: :social,
|
|
73
|
+
description: "Emotes and sub badges as transparent PNGs, banners and panels."),
|
|
74
|
+
Tool.new(slug: "ecommerce-image-resizer", name: "eCommerce Image Resizer", category: :social,
|
|
75
|
+
description: "Marketplace presets for Amazon, Etsy, Shopify, eBay, Flipkart and more."),
|
|
76
|
+
|
|
77
|
+
# Video
|
|
78
|
+
Tool.new(slug: "video-studio", name: "Video Studio", category: :video,
|
|
79
|
+
description: "Browser video editor: trim, crop, resize, add text, export MP4/WebM."),
|
|
80
|
+
Tool.new(slug: "video-watermark", name: "Video Watermark", category: :video,
|
|
81
|
+
description: "Add a text or logo watermark to a video without uploading it."),
|
|
82
|
+
Tool.new(slug: "video-resizer", name: "Video Resizer", category: :video,
|
|
83
|
+
description: "Resize a video for any platform."),
|
|
84
|
+
Tool.new(slug: "video-compressor", name: "Video Compressor", category: :video,
|
|
85
|
+
description: "Make a video file smaller."),
|
|
86
|
+
Tool.new(slug: "video-converter", name: "Video Converter", category: :video,
|
|
87
|
+
description: "Convert between MP4 and WebM."),
|
|
88
|
+
Tool.new(slug: "video-cutter", name: "Video Cutter", category: :video,
|
|
89
|
+
description: "Trim the start and end of a video."),
|
|
90
|
+
Tool.new(slug: "video-cropper", name: "Video Cropper", category: :video,
|
|
91
|
+
description: "Crop a video frame."),
|
|
92
|
+
Tool.new(slug: "video-to-gif", name: "Video to GIF", category: :video,
|
|
93
|
+
description: "Turn a video clip into a GIF."),
|
|
94
|
+
Tool.new(slug: "video-to-mp3", name: "Video to MP3", category: :video,
|
|
95
|
+
description: "Extract the audio track from a video."),
|
|
96
|
+
Tool.new(slug: "add-text-to-video", name: "Add Text to Video", category: :video,
|
|
97
|
+
description: "Put titles and captions on a video.")
|
|
98
|
+
].freeze
|
|
99
|
+
|
|
100
|
+
CATEGORIES = %i[image batch social video].freeze
|
|
101
|
+
|
|
102
|
+
module_function
|
|
103
|
+
|
|
104
|
+
def all
|
|
105
|
+
ALL
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def by_category(category)
|
|
109
|
+
ALL.select { |t| t.category == category.to_sym }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Find a tool by slug ("heic-to-jpg"), key (:heic_to_jpg) or URL.
|
|
113
|
+
def find(query)
|
|
114
|
+
q = query.to_s.sub(%r{\Ahttps?://(www\.)?resizo\.in}, "")
|
|
115
|
+
q = q.sub(%r{\A/+}, "").sub(%r{/+\z}, "").tr("_", "-")
|
|
116
|
+
q = "" if q == "image-resizer"
|
|
117
|
+
ALL.find { |t| t.slug == q }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def find!(query)
|
|
121
|
+
find(query) || raise(Resizo::Error, "unknown tool #{query.inspect}")
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
data/lib/resizo.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "resizo/version"
|
|
4
|
+
|
|
5
|
+
# Image-dimension helpers and a catalog of the free browser tools at
|
|
6
|
+
# https://www.resizo.in/. Every Resizo tool runs client-side: images are
|
|
7
|
+
# processed in the browser and never uploaded.
|
|
8
|
+
module Resizo
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
|
|
11
|
+
BASE_URL = "https://www.resizo.in"
|
|
12
|
+
|
|
13
|
+
# Locales the site is published in. English lives at the root.
|
|
14
|
+
LOCALES = %w[en es fr de pt ja ar ko].freeze
|
|
15
|
+
|
|
16
|
+
module_function
|
|
17
|
+
|
|
18
|
+
# Home page URL for a locale.
|
|
19
|
+
#
|
|
20
|
+
# Resizo.home_url #=> "https://www.resizo.in/"
|
|
21
|
+
# Resizo.home_url("de") #=> "https://www.resizo.in/de/"
|
|
22
|
+
def home_url(locale = "en")
|
|
23
|
+
locale = locale.to_s
|
|
24
|
+
unless LOCALES.include?(locale)
|
|
25
|
+
raise Error, "unknown locale #{locale.inspect} (expected one of #{LOCALES.join(', ')})"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
locale == "en" ? "#{BASE_URL}/" : "#{BASE_URL}/#{locale}/"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# URL of a tool page, by slug, symbol or URL.
|
|
32
|
+
#
|
|
33
|
+
# Resizo.tool_url(:heic_to_jpg) #=> "https://www.resizo.in/heic-to-jpg/"
|
|
34
|
+
def tool_url(query)
|
|
35
|
+
Tools.find!(query).url
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
require_relative "resizo/tools"
|
|
40
|
+
require_relative "resizo/presets"
|
|
41
|
+
require_relative "resizo/geometry"
|
|
42
|
+
require_relative "resizo/file_size"
|
metadata
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: resizo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Eldho Paulose
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-12-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: |
|
|
14
|
+
Resizo is a dependency-free Ruby toolkit for image dimensions: verified size
|
|
15
|
+
presets for Pinterest, Twitch and passport photos, contain/cover fit geometry,
|
|
16
|
+
aspect-ratio maths, decimal KB/MB file-size parsing, and a catalog of the free
|
|
17
|
+
in-browser tools at https://www.resizo.in/ (image resizer, compress to target
|
|
18
|
+
size, HEIC to JPG, passport photo resizer, watermark and video tools).
|
|
19
|
+
Ships a small `resizo` command-line tool.
|
|
20
|
+
email:
|
|
21
|
+
executables:
|
|
22
|
+
- resizo
|
|
23
|
+
extensions: []
|
|
24
|
+
extra_rdoc_files: []
|
|
25
|
+
files:
|
|
26
|
+
- CHANGELOG.md
|
|
27
|
+
- LICENSE.txt
|
|
28
|
+
- README.md
|
|
29
|
+
- exe/resizo
|
|
30
|
+
- lib/resizo.rb
|
|
31
|
+
- lib/resizo/cli.rb
|
|
32
|
+
- lib/resizo/file_size.rb
|
|
33
|
+
- lib/resizo/geometry.rb
|
|
34
|
+
- lib/resizo/presets.rb
|
|
35
|
+
- lib/resizo/tools.rb
|
|
36
|
+
- lib/resizo/version.rb
|
|
37
|
+
homepage: https://www.resizo.in/
|
|
38
|
+
licenses:
|
|
39
|
+
- MIT
|
|
40
|
+
metadata:
|
|
41
|
+
homepage_uri: https://www.resizo.in/
|
|
42
|
+
documentation_uri: https://www.resizo.in/docs/
|
|
43
|
+
bug_tracker_uri: https://www.resizo.in/contact/
|
|
44
|
+
rubygems_mfa_required: 'true'
|
|
45
|
+
post_install_message:
|
|
46
|
+
rdoc_options: []
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.7'
|
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '0'
|
|
59
|
+
requirements: []
|
|
60
|
+
rubygems_version: 3.5.22
|
|
61
|
+
signing_key:
|
|
62
|
+
specification_version: 4
|
|
63
|
+
summary: Image size presets (Pinterest, Twitch, passport photos) and resize/crop geometry
|
|
64
|
+
helpers.
|
|
65
|
+
test_files: []
|