excessPlumFrogREADME.md1 match
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
1112<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>
largeAmaranthCatREADME.md1 match
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
1112<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
1112<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>
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');