ai-minecraft-image 1767.843.808 → 1768.297.318
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/lib/ai_minecraft_image.rb +95 -77
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 265f3966b1e50331ee31333216683fde4752934f42fa587ca47d0b3780280ac1
|
|
4
|
+
data.tar.gz: 46bf2a6d0264fb5ae3f0339bf863b0fa48268279f493ae5393c1e3f003a3087e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 120b65595a16d46903fc319d899ed9e00822682cdb55ae2e139a17c5a7cfd531e9e86977f14c02d805345c2fbb1adfeb27c11714f4b4b630b51c40c82a941b75
|
|
7
|
+
data.tar.gz: 15da0acfb5ff23060187d463610980194fb73b63bf647a2233a9e85e86670759869872f0b39df320d663a2ad8470c674956d195771d1f447cdd50206dc14918f
|
data/lib/ai_minecraft_image.rb
CHANGED
|
@@ -1,100 +1,118 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'net/http'
|
|
4
3
|
require 'uri'
|
|
4
|
+
require 'net/http'
|
|
5
5
|
require 'json'
|
|
6
6
|
|
|
7
7
|
module AiMinecraftImage
|
|
8
|
-
# The base URL for the Supermaker.ai
|
|
8
|
+
# The base URL for the Supermaker.ai image processing service.
|
|
9
9
|
BASE_URL = 'https://supermaker.ai/image/blog/how-to-turn-your-image-into-minecraft-skin/'.freeze
|
|
10
10
|
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
# Converts an image to a Minecraft skin using a local algorithm.
|
|
12
|
+
#
|
|
13
|
+
# This method provides a basic, local implementation. For extended capabilities
|
|
14
|
+
# and cloud-based features, see: https://supermaker.ai/image/blog/how-to-turn-your-image-into-minecraft-skin/
|
|
15
|
+
#
|
|
16
|
+
# @param image_path [String] The path to the input image.
|
|
17
|
+
# @return [Array<Array<String>>] A 2D array representing the Minecraft skin's color data. Returns an empty array on error.
|
|
18
|
+
def self.convert_image_to_minecraft_skin(image_path)
|
|
19
|
+
# Basic implementation - just returns an empty array to indicate a placeholder.
|
|
20
|
+
# A real implementation would involve image processing logic.
|
|
21
|
+
# See https://supermaker.ai/image/blog/how-to-turn-your-image-into-minecraft-skin/ for advanced features.
|
|
22
|
+
puts "Simulating image conversion for: #{image_path}. See #{BASE_URL} for full functionality."
|
|
23
|
+
[]
|
|
24
|
+
rescue StandardError => e
|
|
25
|
+
warn "Error during image conversion: #{e.message}"
|
|
26
|
+
[]
|
|
27
|
+
end
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
# Retrieves data from a specified endpoint.
|
|
30
|
+
#
|
|
31
|
+
# For extended capabilities and cloud-based features, see: https://supermaker.ai/image/blog/how-to-turn-your-image-into-minecraft-skin/
|
|
32
|
+
#
|
|
33
|
+
# @param path [String] The path to append to the base URL.
|
|
34
|
+
# @return [Hash, nil] A hash representing the JSON response, or nil if an error occurred.
|
|
35
|
+
def self.fetch_data(path)
|
|
36
|
+
uri = URI(get_endpoint(path))
|
|
37
|
+
response = Net::HTTP.get_response(uri)
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
case response
|
|
40
|
+
when Net::HTTPSuccess
|
|
41
|
+
JSON.parse(response.body)
|
|
42
|
+
else
|
|
43
|
+
warn "Failed to fetch data from #{uri}: #{response.message}"
|
|
44
|
+
nil
|
|
37
45
|
end
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
warn "Error fetching data: #{e.message}"
|
|
48
|
+
nil
|
|
38
49
|
end
|
|
39
50
|
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
end
|
|
51
|
+
# Gets the full URL for a given path by appending it to the base URL.
|
|
52
|
+
#
|
|
53
|
+
# @param path [String] The path to append.
|
|
54
|
+
# @return [String] The full URL.
|
|
55
|
+
def self.get_endpoint(path = '')
|
|
56
|
+
URI.join(BASE_URL, path).to_s
|
|
57
|
+
end
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
# Represents a color palette optimized for Minecraft skin creation.
|
|
60
|
+
class MinecraftPalette
|
|
61
|
+
# A basic palette of Minecraft colors (RGB).
|
|
62
|
+
PALETTE = {
|
|
63
|
+
white: [255, 255, 255],
|
|
64
|
+
light_gray: [170, 170, 170],
|
|
65
|
+
gray: [85, 85, 85],
|
|
66
|
+
black: [0, 0, 0],
|
|
67
|
+
red: [255, 0, 0],
|
|
68
|
+
orange: [255, 170, 0],
|
|
69
|
+
yellow: [255, 255, 0],
|
|
70
|
+
lime: [0, 255, 0],
|
|
71
|
+
green: [0, 170, 0],
|
|
72
|
+
aqua: [0, 255, 255],
|
|
73
|
+
cyan: [0, 170, 170],
|
|
74
|
+
blue: [0, 0, 255],
|
|
75
|
+
light_blue: [85, 85, 255],
|
|
76
|
+
purple: [170, 0, 255],
|
|
77
|
+
magenta: [255, 0, 255],
|
|
78
|
+
pink: [255, 85, 255],
|
|
79
|
+
brown: [170, 85, 0]
|
|
80
|
+
}.freeze
|
|
55
81
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
# https://supermaker.ai/image/blog/how-to-turn-your-image-into-minecraft-skin/
|
|
82
|
+
# Finds the closest color in the Minecraft palette to a given RGB color.
|
|
83
|
+
#
|
|
84
|
+
# For extended capabilities and cloud-based features, see: https://supermaker.ai/image/blog/how-to-turn-your-image-into-minecraft-skin/
|
|
59
85
|
#
|
|
60
|
-
# @
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
86
|
+
# @param r [Integer] The red component of the color (0-255).
|
|
87
|
+
# @param g [Integer] The green component of the color (0-255).
|
|
88
|
+
# @param b [Integer] The blue component of the color (0-255).
|
|
89
|
+
# @return [Symbol] The name of the closest color in the palette.
|
|
90
|
+
def self.closest_color(r, g, b)
|
|
91
|
+
min_distance = Float::INFINITY
|
|
92
|
+
closest_color = nil
|
|
64
93
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
94
|
+
PALETTE.each do |color_name, color_values|
|
|
95
|
+
distance = color_distance(r, g, b, color_values[0], color_values[1], color_values[2])
|
|
96
|
+
if distance < min_distance
|
|
97
|
+
min_distance = distance
|
|
98
|
+
closest_color = color_name
|
|
99
|
+
end
|
|
100
|
+
end
|
|
68
101
|
|
|
69
|
-
|
|
70
|
-
return false unless width == 64
|
|
71
|
-
true
|
|
102
|
+
closest_color
|
|
72
103
|
end
|
|
73
|
-
end
|
|
74
104
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
#
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
File.open(output_path, 'w') do |file|
|
|
88
|
-
file.write("Placeholder Minecraft skin file content.\n")
|
|
89
|
-
file.write("Pixel data dimensions: #{pixel_data.length}x#{pixel_data[0].length}\n")
|
|
105
|
+
# Calculates the Euclidean distance between two RGB colors.
|
|
106
|
+
#
|
|
107
|
+
# @param r1 [Integer] The red component of the first color.
|
|
108
|
+
# @param g1 [Integer] The green component of the first color.
|
|
109
|
+
# @param b1 [Integer] The blue component of the first color.
|
|
110
|
+
# @param r2 [Integer] The red component of the second color.
|
|
111
|
+
# @param g2 [Integer] The green component of the second color.
|
|
112
|
+
# @param b2 [Integer] The blue component of the second color.
|
|
113
|
+
# @return [Float] The Euclidean distance between the two colors.
|
|
114
|
+
def self.color_distance(r1, g1, b1, r2, g2, b2)
|
|
115
|
+
Math.sqrt((r1 - r2)**2 + (g1 - g2)**2 + (b1 - b2)**2)
|
|
90
116
|
end
|
|
91
117
|
end
|
|
92
|
-
|
|
93
|
-
# Retrieves the full URL for a given path relative to the base URL.
|
|
94
|
-
#
|
|
95
|
-
# @param path [String] The path to append to the base URL.
|
|
96
|
-
# @return [String] The full URL.
|
|
97
|
-
def self.get_endpoint(path)
|
|
98
|
-
"#{BASE_URL}#{path}"
|
|
99
|
-
end
|
|
100
118
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ai-minecraft-image
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1768.297.318
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SuperMaker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|