Skip to content

Commit 6552c4d

Browse files
committed
feat(webui): allow to specify image size
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent da6f37f commit 6552c4d

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

core/http/static/image.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ async function promptDallE(input) {
1111
document.getElementById("input").disabled = true;
1212

1313
const model = document.getElementById("image-model").value;
14+
const size = document.getElementById("image-size").value;
1415
const response = await fetch("v1/images/generations", {
1516
method: "POST",
1617
headers: {
@@ -21,7 +22,7 @@ async function promptDallE(input) {
2122
steps: 10,
2223
prompt: input,
2324
n: 1,
24-
size: "512x512",
25+
size: size,
2526
}),
2627
});
2728
const json = await response.json();
@@ -48,4 +49,13 @@ async function promptDallE(input) {
4849

4950
document.getElementById("input").focus();
5051
document.getElementById("genimage").addEventListener("submit", genImage);
52+
53+
// Handle Enter key press in the prompt input
54+
document.getElementById("input").addEventListener("keypress", function(event) {
55+
if (event.key === "Enter") {
56+
event.preventDefault();
57+
genImage(event);
58+
}
59+
});
60+
5161
document.getElementById("loader").style.display = "none";

core/http/views/text2image.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ <h2 class="text-2xl font-bold text-white mb-6">Generate an Image</h2>
9191
</svg>
9292
</span>
9393
</div>
94+
95+
<!-- Size Selection -->
96+
<div class="mt-4">
97+
<label for="image-size" class="block text-sm font-medium text-gray-300 mb-2">
98+
<i class="fas fa-expand-arrows-alt mr-2"></i>Image Size:
99+
</label>
100+
<input
101+
type="text"
102+
id="image-size"
103+
value="256x256"
104+
placeholder="e.g., 256x256, 512x512, 1024x1024"
105+
class="bg-gray-900 text-white border border-gray-700 focus:border-blue-500 focus:ring focus:ring-blue-500 focus:ring-opacity-50 rounded-lg shadow-sm p-2.5 w-full max-w-xs transition-colors duration-200"
106+
/>
107+
</div>
108+
109+
<!-- Submit Button -->
110+
<div class="mt-6">
111+
<button
112+
type="submit"
113+
class="w-full bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white font-semibold py-3 px-6 rounded-lg transition duration-300 ease-in-out transform hover:scale-105 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"
114+
>
115+
<i class="fas fa-magic mr-2"></i>Generate Image
116+
</button>
117+
</div>
94118
</form>
95119

96120
<!-- Image Results Container -->

0 commit comments

Comments
 (0)