Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=image&page=511&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=image

Returns an array of strings in format "username" or "username/projectName"

Found 6019 results for "image"(1822ms)

getJsonAndRenderAsImageREADME.md13 matches

@ashryanio•Updated 7 months ago
1# getJsonAndRenderAsImage
2
3Shows how to get a JSON object containing a base64 imaged stored in Val Town blob storage and render it as an image in the DOM with React.
4
5## Setup
6
7Make sure you have a JSON object named `image-test` in your Val Town blob storage (alternatively, you can change the key name in the blob getter in the script).
8
9The object should look like this:
11```json
12{
13 "image": "base64stringgoeshere"
14}
15```
16
17To easily upload an image to your blob storage, [fork this val](
18getBlobAndRenderAsImage), run it, and enter your API key in the password input.
19
20## How it works
221. Fetching the JSON:
23
24 - The client-side React component makes a fetch request to "/image".
25 - This request is handled by our server function.
26
282. Server-side handling:
29
30 - The server function calls `blob.getJSON("image-test")`.
31 - This `blob.getJSON()` method makes an HTTP request to the Val Town API.
32 - The API returns a Response object containing the JSON data.
546. Creating a data URL:
55
56 - We extract the image data from the JSON object at `data.image`.
57 - We prepend the data URL prefix to the image data.
58 - This data URL is a base64-encoded string representing the image.
59
60
64
65
668. Rendering the image:
67
68 - We use the data URL as the src attribute of an `<img>` tag.
69 - The browser decodes the base64 data and renders the image.
70
71## Further reading on Val Town blobs

hackerNewsDigestREADME.md1 match

@workingpleasewait•Updated 7 months ago
4
5
6<img width="400px" src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/2661d748-d7a7-4d1e-85a4-f60fae262000/public" />
7

uptimeREADME.md1 match

@cjpais•Updated 7 months ago
10
11<div align="center">
12<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="500px"/>
13</div>

statusREADME.md1 match

@cjpais•Updated 7 months ago
4
5<div align="center">
6<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="700px"/>
7</div>

placeholderKittenImagesmain.tsx28 matches

@ashryanio•Updated 7 months ago
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.
3
4export 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>
17 body {
31 margin-bottom: 20px;
32 }
33 .example-image {
34 display: block;
35 max-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>
97 document.getElementById('kittenForm').addEventListener('submit', function(e) {
111
112 if (parts.length === 1) {
113 // Square image
114 width = height = parseInt(parts[0]);
115 } else if (parts.length === 2) {
116 // Rectangular image
117 width = parseInt(parts[0]);
118 height = parseInt(parts[1]);
119 } else {
120 return 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 }
132
133 const prompt = `A cute kitten, high quality, detailed`;
134 const imageGenerationUrl = `https://maxm-imggenurl.web.val.run/${encodeURIComponent(prompt)}?width=${width}&height=${height}`;
135
136 try {
137 console.log(`Generating image with dimensions: ${width}x${height}`);
138 const imageResponse = await fetch(imageGenerationUrl);
139 console.log(`Response status: ${imageResponse.status}`);
140
141 if (!imageResponse.ok) {
142 throw new Error(`Failed to generate image: ${imageResponse.status} ${imageResponse.statusText}`);
143 }
144
145 const imageBlob = await imageResponse.blob();
146 console.log(`Successfully generated image, size: ${imageBlob.size} bytes`);
147
148 // Return the image as-is, without any processing
149 return new Response(imageBlob, {
150 headers: {
151 'Content-Type': 'image/png',
152 'Cache-Control': 'public, max-age=86400',
153 },
154 });
155 } catch (error) {
156 console.error('Error generating image:', error.message);
157 return new Response(`Failed to generate image: ${error.message}`, { status: 500, headers: { 'Content-Type': 'text/plain' } });
158 }
159}

getBlobAndRenderAsImageREADME.md11 matches

@ashryanio•Updated 7 months ago
1# getBlobAndRenderAsImage
2
3Shows how to get a Val Town blob and render it as an image in the DOM with React.
4
5## Setup
6
7Make sure you have an image named `test.png` in your Val Town blob storage (alternatively, you can change the key name in the blob getter in the script).
8
9To easily upload an image to your blob storage, [fork this val](
10getBlobAndRenderAsImage), run it, and enter your API key in the password input.
11
12## How it works
141. Fetching the blob:
15
16 - The client-side React component makes a fetch request to "/image".
17 - This request is handled by our server function.
18
22 - The server function calls `blob.get("test.png")`.
23 - This `blob.get()` method makes an HTTP request to the Val Town API.
24 - The API returns a Response object containing the image data.
25
26
344. Sending the response to the client:
35
36 - We set the appropriate "Content-Type" header (e.g., "image/png").
37 - We return the Response object to the client.
38
48 - We create a FileReader object.
49 - We use FileReader to read the Blob as a data URL.
50 - This data URL is a base64-encoded string representing the image.
51
52
56
57
588. Rendering the image:
59
60 - We use the data URL as the src attribute of an `<img>` tag.
61 - The browser decodes the base64 data and renders the image.
62
63## Further reading on Val Town blobs

blob_adminREADME.md1 match

@ashryanio•Updated 7 months ago
3This is a lightweight Blob Admin interface to view and debug your Blob data.
4
5![b7321ca2cd80899250589b9aa08bc3cae9c7cea276282561194e7fc537259b46.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/311a81bb-18d8-4583-b7e3-64bac326f700/public)
6
7Use this button to install the val:

ablePinkDogREADME.md1 match

@nicosql•Updated 7 months ago
3Protect your vals behind a password. Use session cookies to persist authentication.
4
5![6ed0648ae8813e958dbe79468572cb52f578239c0fae55857a13660beebdc5fd.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/36c1dc4f-4e19-457b-ad89-0bf139754e00/public)
6
7## Demo

renewedAmethystRattlesnakeREADME.md1 match

@pperi•Updated 7 months ago
3This is a lightweight Blob Admin interface to view and debug your Blob data.
4
5![b7321ca2cd80899250589b9aa08bc3cae9c7cea276282561194e7fc537259b46.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/311a81bb-18d8-4583-b7e3-64bac326f700/public)
6
7Use this button to install the val:

compactAmberMongooseREADME.md1 match

@pperi•Updated 7 months ago
3This is a lightweight Blob Admin interface to view and debug your Blob data.
4
5![b7321ca2cd80899250589b9aa08bc3cae9c7cea276282561194e7fc537259b46.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/311a81bb-18d8-4583-b7e3-64bac326f700/public)
6
7Use this button to install the val:

brainrot_image_gen1 file match

@dcm31•Updated 6 days ago
Generate images for Italian Brainrot characters using FAL AI

modifyImage2 file matches

@stevekrouse•Updated 6 days ago
Atiq
"Focal Lens with Atig Wazir" "Welcome to my photography journey! I'm Atiq Wazir, a passionate photographer capturing life's beauty one frame at a time. Explore my gallery for stunning images, behind-the-scenes stories, and tips & tricks to enhance your own