snugPinkHummingbirdmain.tsx2 matches
1import { imageToAnsi } from 'https://esm.town/v/g/imageToAnsi';
23export default async function(req: Request): Promise<Response> {
4const url = new URL(req.url);
56const ansi = await imageToAnsi(
7'https://maxm-imggenurl.web.val.run/colorful-picture-of-a-flower',
8{
snugPinkHummingbirdREADME.md4 matches
234
5610```
1112You may use query parameters to modify the generated image:
13- `level` (`0` | `1` | `2` | `3`): Chalk terminal color option
14- `width` (number): Maximum width of the generated image
15- `alphabet` (`full` | `special`): characters to use
1617Projects used:
18- [@g.imageToAnsi](https://www.val.town/v/g/imageToAnsi) for ANSI image generation
19- [@maxm.imggenurl](https://www.val.town/v/maxm/imggenurl) for the ai generated flower
6id: string;
7status: "pending" | "succeeded";
8imageUrl?: string;
9savedUrl?: string;
10}
1112function ImageGenerator() {
13const [promptSuffix, setPromptSuffix] = useState("");
14const [generation, setGeneration] = useState<PendingGeneration | null>(null);
15const [useProModel, setUseProModel] = useState(false);
1617const generateImage = async () => {
18const fullPrompt = `a shirt with a design of ${promptSuffix}`;
19setGeneration({
3233if (!response.ok) {
34throw new Error("Failed to generate image");
35}
3640id: Date.now().toString(),
41status: "succeeded",
42imageUrl: result.imageUrl,
43savedUrl: result.savedUrl,
44});
45} catch (error) {
46console.error("Error generating image:", error);
47setGeneration(null);
48}
60placeholder="Enter your design idea"
61/>
62<button onClick={generateImage}>Generate</button>
63</div>
64<div className="toggle-container">
75<div className="result">
76{generation?.status === "pending" && <p>Generating...</p>}
77{generation?.status === "succeeded" && generation.imageUrl && <img src={generation.imageUrl} alt="Generated" />}
78</div>
79</div>
8283function App() {
84return <ImageGenerator />;
85}
86
val_CQqfNR6svdmain.tsx1 match
4// Execute the code directly and capture its result
5const result = await (async () => {
6const getImageData = async () => { const img = new Image(); img.src = 'https://example.com/path-to-mandelbrot-image.png'; await img.decode(); const canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; const ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); return ctx.getImageData(0, 0, canvas.width, canvas.height).data; }; return await getImageData();
7})();
8
imageToAnsiREADME.md1 match
1Migrated from folder: util/imageToAnsi
stableAzureDragonmain.tsx7 matches
188// const c = async B9 => {
189// try {
190// var BB = await K("https://megacloud.tv/images/loading.png?v=0.0.9");
191// window.bytes = BB;
192// console.log("THis thing is working");
454// Bh(BW).textBaseline = BK(BT, Bl);
455// };
456// BE.wbg.__wbg_drawImage_cb13768a1bdc04bd = function() {
457// return Bg(function(BW, BT, Bl, BC) {
458// Bh(BW).drawImage(Bh(BT), Bl, BC);
459// }, arguments);
460// };
461// BE.wbg.__wbg_getImageData_66269d289f37d3c7 = function() {
462// return Bg(function(BW, BT, Bl, BC, Bj) {
463// return Bf(Bh(BW).getImageData(BT, Bl, BC, Bj));
464// }, arguments);
465// };
556// return Bf(Bh(BW).style);
557// };
558// BE.wbg.__wbg_instanceof_HtmlImageElement_9c82d4e3651a8533 = function(BW) {
559// let BT;
560// try {
561// BT = Bh(BW) instanceof HTMLImageElement;
562// } catch (Bl) {
563// BT = false;
passionateScarletPrawnmain.tsx26 matches
2627if (!response.ok) {
28throw new Error("Failed to generate image");
29}
3040return (
41<div className="container">
42<h1>AI Image Generator</h1>
43<form onSubmit={handleSubmit}>
44<textarea
45value={prompt}
46onChange={(e) => setPrompt(e.target.value)}
47placeholder="Enter your image prompt here..."
48required
49/>
58</div>
59<button type="submit" disabled={isLoading}>
60{isLoading ? "Generating..." : "Generate Image"}
61</button>
62</form>
64{result && (
65<div className="result">
66<img src={result.imageUrl} alt="Generated image" />
67<p>Image saved as: {result.savedUrl}</p>
68</div>
69)}
94<meta charset="UTF-8">
95<meta name="viewport" content="width=device-width, initial-scale=1.0">
96<title>AI Image Generator</title>
97<style>${css}</style>
98</head>
174if (resultData.status === "succeeded") {
175console.log("Generation succeeded!");
176let imageUrl: string | undefined;
177178if (Array.isArray(resultData.output)) {
179imageUrl = resultData.output[0];
180} else if (typeof resultData.output === "string") {
181imageUrl = resultData.output;
182}
183184if (imageUrl) {
185const { blob } = await import("https://esm.town/v/std/blob");
186const timestamp = new Date().getTime();
187const imageName = `generated-image-${timestamp}.jpg`;
188189const imageResponse = await fetch(imageUrl);
190if (!imageResponse.ok) throw new Error("Failed to download image");
191192const imageBlob = await imageResponse.blob();
193await blob.set(imageName, imageBlob);
194195return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
196headers: { "Content-Type": "application/json" },
197});
199}
200} else {
201console.log("Using Val Town's free image generator...");
202const imageUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}`;
203204const { blob } = await import("https://esm.town/v/std/blob");
205const timestamp = new Date().getTime();
206const imageName = `generated-image-${timestamp}.jpg`;
207208const imageResponse = await fetch(imageUrl);
209if (!imageResponse.ok) throw new Error("Failed to generate image");
210211const imageBlob = await imageResponse.blob();
212await blob.set(imageName, imageBlob);
213214return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
215headers: { "Content-Type": "application/json" },
216});
217}
218219return new Response(JSON.stringify({ error: "Failed to generate image" }), {
220status: 500,
221headers: { "Content-Type": "application/json" },
laudableFuchsiaMastodonmain.tsx32 matches
8const [isLoading, setIsLoading] = useState(false);
9const [error, setError] = useState("");
10const [imageUrl, setImageUrl] = useState("");
1112const handleSubmit = async (e: React.FormEvent) => {
14setIsLoading(true);
15setError("");
16setImageUrl("");
1718try {
2425if (!response.ok) {
26throw new Error("Failed to generate image");
27}
2829const data = await response.json();
30setImageUrl(data.imageUrl);
31} catch (err) {
32setError(err.message);
38return (
39<div className="container">
40<h1>AI Image Generator</h1>
41<form onSubmit={handleSubmit}>
42<textarea
43value={prompt}
44onChange={(e) => setPrompt(e.target.value)}
45placeholder="Enter your image prompt here..."
46required
47/>
56</div>
57<button type="submit" disabled={isLoading}>
58{isLoading ? "Generating..." : "Generate Image"}
59</button>
60</form>
61{error && <p className="error">{error}</p>}
62{imageUrl && (
63<div className="image-container">
64<img src={imageUrl} alt="Generated" />
65</div>
66)}
142if (resultData.status === "succeeded") {
143console.log("Generation succeeded!");
144let imageUrl: string | undefined;
145146if (Array.isArray(resultData.output)) {
147imageUrl = resultData.output[0];
148} else if (typeof resultData.output === "string") {
149imageUrl = resultData.output;
150}
151152if (imageUrl) {
153const { blob } = await import("https://esm.town/v/std/blob");
154const timestamp = new Date().getTime();
155const imageName = `generated-image-${timestamp}.jpg`;
156157const imageResponse = await fetch(imageUrl);
158if (!imageResponse.ok) throw new Error("Failed to download image");
159160const imageBlob = await imageResponse.blob();
161await blob.set(imageName, imageBlob);
162163return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
164headers: { "Content-Type": "application/json" },
165});
167}
168} else {
169console.log("Using Val Town's free image generator...");
170const imageUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}`;
171172const { blob } = await import("https://esm.town/v/std/blob");
173const timestamp = new Date().getTime();
174const imageName = `generated-image-${timestamp}.jpg`;
175176const imageResponse = await fetch(imageUrl);
177if (!imageResponse.ok) throw new Error("Failed to generate image");
178179const imageBlob = await imageResponse.blob();
180await blob.set(imageName, imageBlob);
181182return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
183headers: { "Content-Type": "application/json" },
184});
185}
186187return new Response(JSON.stringify({ error: "Failed to generate image" }), {
188status: 500,
189headers: { "Content-Type": "application/json" },
197<meta charset="UTF-8">
198<meta name="viewport" content="width=device-width, initial-scale=1.0">
199<title>AI Image Generator</title>
200<style>${css}</style>
201</head>
280}
281282.image-container {
283margin-top: 20px;
284text-align: center;
285}
286287.image-container img {
288max-width: 100%;
289border-radius: 4px;
shirtGenScriptmain.tsx19 matches
64if (resultData.status === "succeeded") {
65console.log("Generation succeeded!");
66let imageUrl: string | undefined;
6768if (Array.isArray(resultData.output)) {
69imageUrl = resultData.output[0];
70} else if (typeof resultData.output === "string") {
71imageUrl = resultData.output;
72}
7374if (imageUrl) {
75const { blob } = await import("https://esm.town/v/std/blob");
76const timestamp = new Date().getTime();
77const imageName = `generated-image-${timestamp}.jpg`;
7879const imageResponse = await fetch(imageUrl);
80if (!imageResponse.ok) throw new Error("Failed to download image");
8182const imageBlob = await imageResponse.blob();
83await blob.set(imageName, imageBlob);
8485return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
86headers: { "Content-Type": "application/json" },
87});
89}
90} else {
91console.log("Using Val Town's free image generator...");
92const imageUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}`;
9394const { blob } = await import("https://esm.town/v/std/blob");
95const timestamp = new Date().getTime();
96const imageName = `generated-image-${timestamp}.jpg`;
9798const imageResponse = await fetch(imageUrl);
99if (!imageResponse.ok) throw new Error("Failed to generate image");
100101const imageBlob = await imageResponse.blob();
102await blob.set(imageName, imageBlob);
103104return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
105headers: { "Content-Type": "application/json" },
106});
107}
108109return new Response(JSON.stringify({ error: "Failed to generate image" }), {
110status: 500,
111headers: { "Content-Type": "application/json" },
shirtGenScriptmain.tsx19 matches
64if (resultData.status === "succeeded") {
65console.log("Generation succeeded!");
66let imageUrl: string | undefined;
6768if (Array.isArray(resultData.output)) {
69imageUrl = resultData.output[0];
70} else if (typeof resultData.output === "string") {
71imageUrl = resultData.output;
72}
7374if (imageUrl) {
75const { blob } = await import("https://esm.town/v/std/blob");
76const timestamp = new Date().getTime();
77const imageName = `generated-image-${timestamp}.jpg`;
7879const imageResponse = await fetch(imageUrl);
80if (!imageResponse.ok) throw new Error("Failed to download image");
8182const imageBlob = await imageResponse.blob();
83await blob.set(imageName, imageBlob);
8485return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
86headers: { "Content-Type": "application/json" },
87});
89}
90} else {
91console.log("Using Val Town's free image generator...");
92const imageUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}`;
9394const { blob } = await import("https://esm.town/v/std/blob");
95const timestamp = new Date().getTime();
96const imageName = `generated-image-${timestamp}.jpg`;
9798const imageResponse = await fetch(imageUrl);
99if (!imageResponse.ok) throw new Error("Failed to generate image");
100101const imageBlob = await imageResponse.blob();
102await blob.set(imageName, imageBlob);
103104return new Response(JSON.stringify({ imageUrl, savedUrl: imageName }), {
105headers: { "Content-Type": "application/json" },
106});
107}
108109return new Response(JSON.stringify({ error: "Failed to generate image" }), {
110status: 500,
111headers: { "Content-Type": "application/json" },