userapi-ai 0.2.0 → 0.3.1
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/CHANGELOG.md +3 -1
- data/README.md +33 -1
- data/lib/userapi/tools.rb +13 -0
- data/lib/userapi/version.rb +1 -1
- data/lib/userapi-ai.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91120dbeaa726be94fe09fdce1efa9a6c1202a35b061035e9b5c4a8a7ec474af
|
4
|
+
data.tar.gz: 69cc0065970e41c08e83aad2b7e4dd12e0a484c339fbd3bffa2fc76d47f65ebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b5c5f343de570e8f116256e6db0ece696bc9c280c813e909d3f6daa3e9ca3a49af17d755c832b3a9946d8d2415402e385b4195db93fa5b34666d1c1ca859f9d
|
7
|
+
data.tar.gz: 98fb272867b951cff85f64dc08b62d25537bfd7552527dba2f7df4ba17a3f90b7e3b3613b2e152bead3b5923da8241a6e052f761d1e39f834ffa0b233907275e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -103,7 +103,39 @@ You can use it to generate images of people, animals, objects, and anything else
|
|
103
103
|
webhook_url: "https://example.com/upscale/webhook-url",
|
104
104
|
webhook_type: "result")
|
105
105
|
```
|
106
|
-
See more [here](https://butternut-saffron-e5e.notion.site/Midjourney-userapi-ai-doc-en-119680339b0a47e2ba6ae467eca58142#9abe719bb58948039acb5f0a6aee8947)
|
106
|
+
See more [here](https://butternut-saffron-e5e.notion.site/Midjourney-userapi-ai-doc-en-119680339b0a47e2ba6ae467eca58142#9abe719bb58948039acb5f0a6aee8947).
|
107
|
+
|
108
|
+
#### Tools
|
109
|
+
|
110
|
+
You can split the quad-layout output from Midjourney into 4 separate images.
|
111
|
+
|
112
|
+
Add the gem to your Gemfile:
|
113
|
+
|
114
|
+
```rb
|
115
|
+
gem "mini_magick"
|
116
|
+
```
|
117
|
+
|
118
|
+
Now you can do some magick.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
response = client.status result
|
122
|
+
if response["status"] == "done"
|
123
|
+
local_paths = UserapiAi::Tool.crop result: response["result"]
|
124
|
+
# or UserapiAi::Tool.crop url: "https://example.com/img.png"
|
125
|
+
local_paths.each do |path|
|
126
|
+
f = File.open(path)
|
127
|
+
...
|
128
|
+
end
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
```bash
|
133
|
+
=> local_paths
|
134
|
+
["/var/folders/yb/bjdvl6mn3cx2l7nd08726k500000gn/T/mini_magick20240324-73984-31zmkb-0.png",
|
135
|
+
"/var/folders/yb/bjdvl6mn3cx2l7nd08726k500000gn/T/mini_magick20240324-73984-31zmkb-1.png",
|
136
|
+
"/var/folders/yb/bjdvl6mn3cx2l7nd08726k500000gn/T/mini_magick20240324-73984-31zmkb-2.png",
|
137
|
+
"/var/folders/yb/bjdvl6mn3cx2l7nd08726k500000gn/T/mini_magick20240324-73984-31zmkb-3.png"]
|
138
|
+
```
|
107
139
|
|
108
140
|
## Development
|
109
141
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module UserapiAi
|
2
|
+
class Tool
|
3
|
+
def self.crop url: nil, result: nil
|
4
|
+
url = result["url"] if url.nil?
|
5
|
+
image = MiniMagick::Image.open url
|
6
|
+
image.crop "50%x50%"
|
7
|
+
arr = image.path.split(".")
|
8
|
+
(0..3).map{ |i|
|
9
|
+
arr.dup.insert(-2, "-#{i}.").join("")
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/userapi/version.rb
CHANGED
data/lib/userapi-ai.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userapi-ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Smolev Denis
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/userapi/client.rb
|
58
58
|
- lib/userapi/compatibility.rb
|
59
59
|
- lib/userapi/http.rb
|
60
|
+
- lib/userapi/tools.rb
|
60
61
|
- lib/userapi/version.rb
|
61
62
|
- sig/userapi/ai.rbs
|
62
63
|
homepage: https://userapi.ai.
|