sharedMagentaChameleonmain.tsx4 matches
36<meta charset="UTF-8">
37<meta name="viewport" content="width=device-width, initial-scale=1.0">
38<title>Image Generation Form</title>
39<style>
40body {
72<body>
73<div class="form-container">
74<input id="description" type="text" placeholder="Image description">
75<input id="exclude" type="text" placeholder="Things to exclude in the image">
76<select id="aspect-ratio">
77<option value="1:1">1:1</option>
85<option value="5:12">5:12</option>
86</select>
87<button onclick="submitForm()">Generate Image</button>
88</div>
89<script>
dataUriGenAppmain.tsx2 matches
3* - File upload through input and drag-and-drop
4* - Automatic MIME type detection
5* - Preview of the uploaded file (image, video, audio, or text)
6* - Copy button to easily copy the generated data URI
7*
144
145preview.innerHTML = '';
146if (file.type.startsWith('image/')) {
147const img = document.createElement('img');
148img.src = dataUri;
webdavServerREADME.md1 match
3Manage your vals from a webdav client (ex: https://cyberduck.io/)
45
67> ⚠️ some webdav operations are not supported, so support can vary between clients.
placeholderKittenImagesmain.tsx28 matches
1// This val creates a publicly accessible kitten image generator using the Val Town image generation API.
2// It supports generating square images with a single dimension parameter or rectangular images with two dimension parameters.
34export default async function server(request: Request): Promise<Response> {
13<meta charset="UTF-8">
14<meta name="viewport" content="width=device-width, initial-scale=1.0">
15<title>Kitten Image Generator</title>
16<style>
17body {
31margin-bottom: 20px;
32}
33.example-image {
34display: block;
35max-width: 100%;
75</head>
76<body>
77<h1>Welcome to the Kitten Image Generator!</h1>
78<div class="instructions">
79<p>Use this service to generate cute kitten images of various sizes:</p>
80<p>For square images: <code>/width</code> (e.g., <code>/400</code> for a 400x400 image)</p>
81<p>For rectangular images: <code>/width/height</code> (e.g., <code>/400/300</code> for a 400x300 image)</p>
82</div>
83<div class="form-container">
84<h2>Generate a Kitten Image</h2>
85<form id="kittenForm">
86<label for="width">Width (64-1024):</label>
91</form>
92</div>
93<p>Here's an example of a generated 400x400 kitten image:</p>
94<img src="/400" alt="Example 400x400 kitten" class="example-image">
95<p>Start generating your own kitten images by using the form above or modifying the URL!</p>
96<script>
97document.getElementById('kittenForm').addEventListener('submit', function(e) {
111112if (parts.length === 1) {
113// Square image
114width = height = parseInt(parts[0]);
115} else if (parts.length === 2) {
116// Rectangular image
117width = parseInt(parts[0]);
118height = parseInt(parts[1]);
119} else {
120return new Response('Invalid URL format. Use /width for square images or /width/height for rectangular images.',
121{ status: 400, headers: { 'Content-Type': 'text/plain' } });
122}
132133const prompt = `A cute kitten, high quality, detailed`;
134const imageGenerationUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}?width=${width}&height=${height}`;
135136try {
137console.log(`Generating image with dimensions: ${width}x${height}`);
138const imageResponse = await fetch(imageGenerationUrl);
139console.log(`Response status: ${imageResponse.status}`);
140141if (!imageResponse.ok) {
142throw new Error(`Failed to generate image: ${imageResponse.status} ${imageResponse.statusText}`);
143}
144145const imageBlob = await imageResponse.blob();
146console.log(`Successfully generated image, size: ${imageBlob.size} bytes`);
147148// Return the image as-is, without any processing
149return new Response(imageBlob, {
150headers: {
151'Content-Type': 'image/png',
152'Cache-Control': 'public, max-age=86400',
153},
154});
155} catch (error) {
156console.error('Error generating image:', error.message);
157return new Response(`Failed to generate image: ${error.message}`, { status: 500, headers: { 'Content-Type': 'text/plain' } });
158}
159}
resizeImageErrormain.tsx29 matches
1// This val creates an image resizing service using the Cloudinary API.
2// It provides a form for users to input the image URL and size, and displays the resized image.
34/** @jsxImportSource https://esm.sh/react */
78function App() {
9const [imageUrl, setImageUrl] = useState("");
10const [size, setSize] = useState("");
11const [resizedImageUrl, setResizedImageUrl] = useState("");
1213const handleSubmit = async (e: React.FormEvent) => {
14e.preventDefault();
15const response = await fetch(`?link=${encodeURIComponent(imageUrl)}&size=${size}`);
16try {
17if (response.ok) {
18const blob = await response.blob();
19setResizedImageUrl(URL.createObjectURL(blob));
20} else {
21const errorText = await response.text();
23}
24} catch (error) {
25alert(`Error resizing image: ${error.message}`);
26console.error("Error details:", error);
27}
30return (
31<div className="container">
32<h1>Image Resizer</h1>
33<form onSubmit={handleSubmit}>
34<div className="form-group">
35<label htmlFor="imageUrl">Image URL:</label>
36<input
37type="url"
38id="imageUrl"
39value={imageUrl}
40onChange={(e) => setImageUrl(e.target.value)}
41required
42/>
53/>
54</div>
55<button type="submit">Resize Image</button>
56</form>
57{resizedImageUrl && (
58<div className="result">
59<h2>Resized Image:</h2>
60<img src={resizedImageUrl} alt="Resized" />
61</div>
62)}
7374async function testEndpoint() {
75const testImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png";
76const testSize = "100x100";
77const cloudinaryUrl = `https://res.cloudinary.com/demo/image/fetch/c_fill,w_100,h_100/${encodeURIComponent(testImageUrl)}`;
78
79try {
83return "Test successful";
84} else {
85throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);
86}
87} catch (error) {
104<html>
105<head>
106<title>Image Resizer</title>
107<style>${css}</style>
108</head>
123}
124125const cloudinaryUrl = `https://res.cloudinary.com/demo/image/fetch/c_fill,w_${width},h_${height}/${encodeURIComponent(link)}`;
126127try {
128const imageResponse = await fetch(cloudinaryUrl);
129
130if (!imageResponse.ok) {
131throw new Error(`Failed to fetch image: ${imageResponse.status} ${imageResponse.statusText}`);
132}
133134const contentType = imageResponse.headers.get("content-type");
135return new Response(imageResponse.body, {
136headers: {
137"Content-Type": contentType || "image/jpeg",
138"Cache-Control": "public, max-age=31536000",
139},
140});
141} catch (error) {
142console.error("Error fetching or processing image:", error.message, error.stack);
143return new Response(`Error processing image: ${error.message}. Please ensure the image URL is correct and publicly accessible.`, { status: 500 });
144}
145}
placeholderImagesmain.tsx27 matches
1// This val creates a kitten image generator using the Val Town image generation API.
2// It supports generating square images with a single dimension parameter or rectangular images with two dimension parameters.
34export default async function server(request: Request): Promise<Response> {
13<meta charset="UTF-8">
14<meta name="viewport" content="width=device-width, initial-scale=1.0">
15<title>Kitten Image Generator</title>
16<style>
17body {
31margin-bottom: 20px;
32}
33.example-image {
34display: block;
35max-width: 100%;
54</head>
55<body>
56<h1>Welcome to the Kitten Image Generator!</h1>
57<div class="instructions">
58<p>Use this service to generate cute kitten images of various sizes:</p>
59<p>For square images: <code>/width</code> (e.g., <code>/400</code> for a 400x400 image)</p>
60<p>For rectangular images: <code>/width/height</code> (e.g., <code>/400/300</code> for a 400x300 image)</p>
61</div>
62<p>Here's an example of a generated 400x400 kitten image:</p>
63<img src="/400" alt="Example 400x400 kitten" class="example-image">
64<p>Start generating your own kitten images by modifying the URL!</p>
65</body>
66</html>
7273if (parts.length === 1) {
74// Square image
75width = height = parseInt(parts[0]);
76} else if (parts.length === 2) {
77// Rectangular image
78width = parseInt(parts[0]);
79height = parseInt(parts[1]);
80} else {
81return new Response('Invalid URL format. Use /width for square images or /width/height for rectangular images.',
82{ status: 400, headers: { 'Content-Type': 'text/plain' } });
83}
9394const prompt = `A cute kitten, high quality, detailed`;
95const imageGenerationUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}?width=${width}&height=${height}`;
9697try {
98console.log(`Generating image with dimensions: ${width}x${height}`);
99const imageResponse = await fetch(imageGenerationUrl);
100console.log(`Response status: ${imageResponse.status}`);
101102if (!imageResponse.ok) {
103throw new Error(`Failed to generate image: ${imageResponse.status} ${imageResponse.statusText}`);
104}
105106const imageBlob = await imageResponse.blob();
107console.log(`Successfully generated image, size: ${imageBlob.size} bytes`);
108109// Return the image as-is, without any processing
110return new Response(imageBlob, {
111headers: {
112'Content-Type': 'image/png',
113'Cache-Control': 'public, max-age=86400',
114},
115});
116} catch (error) {
117console.error('Error generating image:', error.message);
118return new Response(`Failed to generate image: ${error.message}`, { status: 500, headers: { 'Content-Type': 'text/plain' } });
119}
120}
SocialMediaDashboardV1main.tsx15 matches
11const [profiles, setProfiles] = useState([]);
12const [currentIndex, setCurrentIndex] = useState(0);
13const [newProfile, setNewProfile] = useState({ username: '', image_url: '', link: '', followers: '' });
14const [message, setMessage] = useState('');
1552if (response.ok) {
53setMessage('New profile added');
54setNewProfile({ username: '', image_url: '', link: '', followers: '' });
55fetchProfiles();
56} else {
97<div className="profile-card-content">
98<img
99src={currentProfile.image_url}
100alt={currentProfile.username}
101onError={(e) => {
126/>
127<input
128type="url" name="image_url" placeholder="Image URL"
129value={newProfile.image_url} onChange={handleInputChange} required
130/>
131<input
160CREATE TABLE IF NOT EXISTS ${KEY}_profiles_${SCHEMA_VERSION} (
161id INTEGER PRIMARY KEY AUTOINCREMENT,
162image_url TEXT NOT NULL,
163username TEXT NOT NULL,
164link TEXT NOT NULL,
192if (url.pathname === '/add-sample-profiles' && request.method === 'POST') {
193const sampleProfiles = [
194{ image_url: 'http://placehold.co/250', username: 'user1', link: 'https://example.com/user1', followers: 1000 },
195{ image_url: 'http://placehold.co/250', username: 'user2', link: 'https://example.com/user2', followers: 2000 },
196{ image_url: 'http://placehold.co/250', username: 'user3', link: 'https://example.com/user3', followers: 3000 },
197];
198199for (const profile of sampleProfiles) {
200await sqlite.execute(
201`INSERT INTO ${KEY}_profiles_${SCHEMA_VERSION} (image_url, username, link, followers) VALUES (?, ?, ?, ?)`,
202[profile.image_url, profile.username, profile.link, profile.followers]
203);
204}
213214if (url.pathname === '/add-profile' && request.method === 'POST') {
215const { username, image_url, link, followers } = await request.json();
216if (!username || !image_url || !link || !followers) {
217return new Response('Missing required fields', { status: 400 });
218}
219try {
220await sqlite.execute(
221`INSERT INTO ${KEY}_profiles_${SCHEMA_VERSION} (image_url, username, link, followers) VALUES (?, ?, ?, ?)`,
222[image_url, username, link, parseInt(followers)]
223);
224return new Response('Profile added successfully');
iangac_validatormain.tsx5 matches
56function analyzeJSON(jsonData) {
7const images = jsonData.images;
8const allIds = new Set(images.map(img => img.id));
9const referencedIds = new Set();
10const errors = [];
1213// Check all references and track referenced IDs
14images.forEach(image => {
15image.related.forEach(ref => {
16if (!allIds.has(ref)) {
17errors.push(`Error: '${ref}' in '${image.id}' related list doesn't have a matching ID`);
18}
19referencedIds.add(ref);
1// This program creates an image generation service using the maxm-imggenurl API.
2// It provides a simple HTML interface for users to enter a prompt and generate an image.
3// The generated images are displayed in a grid, and clicking on an image shows a popup with the image and prompt.
45/** @jsxImportSource https://esm.sh/react */
7import { createRoot } from "https://esm.sh/react-dom/client";
89// Define a type for our generated images
10type GeneratedImage = { imageUrl: string; prompt: string };
1112function App() {
13const [prompt, setPrompt] = useState("");
14const [imageUrl, setImageUrl] = useState("");
15const [loading, setLoading] = useState(false);
1617const generateImage = async () => {
18setLoading(true);
19try {
20const response = await fetch(`/generate?prompt=${encodeURIComponent(prompt)}`, { method: 'POST' });
21const data = await response.json();
22setImageUrl(data.imageUrl);
23// After generating, fetch the updated list of images
24fetchImages();
25} catch (error) {
26console.error("Error generating image:", error);
27}
28setPrompt(""); // Clear the prompt after generating
30};
3132const [images, setImages] = useState<GeneratedImage[]>([]);
33const [selectedImage, setSelectedImage] = useState<GeneratedImage | null>(null);
3435const fetchImages = async () => {
36try {
37const response = await fetch('/images');
38const data = await response.json();
39setImages(data);
40} catch (error) {
41console.error("Error fetching images:", error);
42}
43};
4445React.useEffect(() => {
46fetchImages();
47}, []);
4849const openPopup = (image: GeneratedImage) => {
50setSelectedImage(image);
51};
5253const closePopup = () => {
54setSelectedImage(null);
55};
5657return (
58<div className="container">
59<h1>AI Image Generator</h1>
60<div className="input-container">
61<input
63value={prompt}
64onChange={(e) => setPrompt(e.target.value)}
65placeholder="Enter your image prompt"
66/>
67<button onClick={generateImage} disabled={loading || !prompt}>
68{loading ? "Generating..." : "Generate Image"}
69</button>
70</div>
71<div className="image-grid">
72{images.map((image, index) => (
73<div key={index} className="image-item" onClick={() => openPopup(image)}>
74<img src={image.imageUrl} alt={image.prompt} />
75</div>
76))}
77</div>
78{selectedImage && (
79<div className="popup-overlay" onClick={closePopup}>
80<div className="popup-content" onClick={(e) => e.stopPropagation()}>
81<img src={selectedImage.imageUrl} alt={selectedImage.prompt} />
82<p>{selectedImage.prompt}</p>
83<button onClick={closePopup}>Close</button>
84</div>
103const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
104const url = new URL(request.url);
105const KEY = "genimage";
106107// Create table if it doesn't exist
108await sqlite.execute(`
109CREATE TABLE IF NOT EXISTS ${KEY}_images (
110id INTEGER PRIMARY KEY AUTOINCREMENT,
111imageUrl TEXT NOT NULL,
112prompt TEXT NOT NULL
113)
123}
124
125const imageUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}`;
126
127// Store the generated image in the database
128await sqlite.execute(`
129INSERT INTO ${KEY}_images (imageUrl, prompt) VALUES (?, ?)
130`, [imageUrl, prompt]);
131132return new Response(JSON.stringify({ imageUrl }), {
133headers: { "Content-Type": "application/json" },
134});
135}
136137if (url.pathname === "/images") {
138const result = await sqlite.execute(`SELECT * FROM ${KEY}_images ORDER BY id DESC`);
139return new Response(JSON.stringify(result.rows), {
140headers: { "Content-Type": "application/json" },
148<meta charset="UTF-8">
149<meta name="viewport" content="width=device-width, initial-scale=1.0">
150<title>AI Image Generator</title>
151<style>${css}</style>
152</head>
204cursor: not-allowed;
205}
206.image-grid {
207display: grid;
208grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
210margin-top: 20px;
211}
212.image-item {
213cursor: pointer;
214transition: transform 0.3s ease;
215}
216.image-item:hover {
217transform: scale(1.05);
218}
219.image-item img {
220width: 100%;
221height: 150px;
261return (
262<div className="container">
263<h1>AI Image Generator</h1>
264<div className="input-container">
265<input
267value={prompt}
268onChange={(e) => setPrompt(e.target.value)}
269placeholder="Enter your image prompt"
270/>
271<button onClick={generateImage} disabled={loading || !prompt}>
272{loading ? "Generating..." : "Generate Image"}
273</button>
274</div>
275<div className="image-grid">
276{images.map((image, index) => (
277padding: 20px;
278background-color: #fff;
307cursor: not-allowed;
308}
309.image-container {
310text-align: center;
311}
7* Type text prompts, select it, press "Q". Select a previous generation with a new text prompt to keep iterating. Selecting shapes doesn't work yet. Have fun!
89<a href="https://x.com/JanPaul123/status/1815502582015754657"><img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/5893dfbf-c2de-4be0-049e-d8fdd1970a00/public"/></a>
10