348 }
349 });
350 const optionalProps = "source category enclosure author image".split(" ");
351 optionalProps.forEach((key) => {
352 if (hasProperty(item2, key)) {
3This is a lightweight Blob Admin interface to view and debug your Blob data.
4
5
6
7Use this button to install the val:
1import { textToImageDalle } from "https://esm.town/v/hootz/textToImageDalle";
2import { telegramSendMessage } from "https://esm.town/v/vtdocs/telegramSendMessage?v=5";
3import { telegramSendPhoto } from "https://esm.town/v/vtdocs/telegramSendPhoto?v=1";
20 telegramSendMessage(
21 process.env.telegramDalleBotToken,
22 { chat_id: chatId, text: "send prompt, get an image!" },
23 );
24 return;
25 }
26 // otherwise, generate an image!
27 try {
28 const imageURL = (await textToImageDalle(
29 process.env.openai,
30 text,
36 process.env.telegramDalleBotToken,
37 // caption is limited to 1024 characters
38 { chat_id: chatId, photo: imageURL, caption: text.slice(0, 1024) },
39 );
40 }
1# Telegram DALLE Bot
2
3A personal telegram bot you can message to create images with OpenAI's [DALLE](https://openai.com/dall-e-2) ✨
4
5
6 const { default: Jimp } = await import("npm:jimp@0");
7 const img = await new Jimp(size, size);
8 for (const { x, y, idx, image } of img.scanIterator(0, 0, size, size)) {
9 const dx = x - size / 2 + 0.5;
10 const dy = y - size / 2 + 0.5;
12 if (d <= size / 2) {
13 if (typeof border === "number" && d > (size / 2 - 1)) {
14 image.setPixelColor(border, x, y);
15 }
16 else if (typeof fill === "number") {
17 image.setPixelColor(fill, x, y);
18 }
19 }
8import Jimp from "npm:jimp@0";
9
10export async function createTidbytWorkoutsImage(icons: WorkoutIcon[]) {
11 const headerUrl = "https://art.pixilart.com/sr2c714c74a22aws3.png";
12 const weekdaysUrl = "https://art.pixilart.com/sr22f1df42b42aws3.png";
55}
56export async function getWasm() {
57 const req = await fetch("https://rabbitstream.net/images/loading.png?v=0.6", {
58 "headers": {
59 "Referrer-Policy": "strict-origin-when-cross-origin",
11 let html = `<h1>${valTownInspo.title}</h1>
12 <p>${valTownInspo.description}</p>
13 <a href="https://val.town/${valTownInspo.val}"><img src="${valTownInspo.image}" style="max-width:576px"/></a>
14 <p><a href="https://www.val.town/settings/intervals">Unsubscribe here</a></p>`;
15
11function App() {
12 const [json, setJson] = useState("");
13 const [imageUrl, setImageUrl] = useState("");
14 const [error, setError] = useState("");
15 const [isLoading, setIsLoading] = useState(false);
19 setIsLoading(true);
20 setError("");
21 setImageUrl("");
22
23 try {
32 if (data.error) {
33 setError(data.error);
34 } else if (data.imageUrl) {
35 setImageUrl(data.imageUrl);
36 }
37 } catch (error) {
44 return (
45 <div className="container">
46 <h1>JSON to DALL-E Image Generator</h1>
47 <form onSubmit={handleSubmit}>
48 <textarea
54 >
55 </textarea>
56 <button type="submit" disabled={isLoading}>Generate Image</button>
57 </form>
58 {isLoading && <div id="loadingIndicator">Generating image...</div>}
59 {error && (
60 <div>
62 </div>
63 )}
64 {imageUrl && (
65 <div>
66 <img src={imageUrl} alt="Generated image" />
67 </div>
68 )}
116 font-style: italic;
117 }
118 #imageContainer {
119 margin-top: 20px;
120 }
167 const dallePrompt = completion.choices[0].message.content;
168
169 // Generate DALL-E image
170 const response = await openai.images.generate({
171 model: "dall-e-3",
172 prompt: dallePrompt,
175 });
176
177 return new Response(JSON.stringify({ imageUrl: response.data[0].url, dallePrompt }), {
178 headers: { "Content-Type": "application/json" },
179 });
190 <html>
191 <head>
192 <title>JSON to DALL-E Image Generator</title>
193 <style>${css}</style>
194 </head>
1# ☔️ Umbrella reminder if there's rain today
2
3
4
5## Setup