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/$%7Bart_info.art.src%7D?q=image&page=67&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 8190 results for "image"(1334ms)

TownieProjectsRoute.tsx7 matches

@japhethkingjackson•Updated 1 week ago
43 user: {
44 username: string;
45 profileImageUrl: string | null;
46 };
47 project: any;
49 return (
50 <div className="card">
51 {project.imageUrl ? (
52 <img src={project.imageUrl} className="card-image" />
53 ) : user.profileImageUrl ? (
54 <div className="card-image">
55 <img
56 src={user.profileImageUrl}
57 width="48"
58 height="48"
61 </div>
62 ) : (
63 <div className="card-image placeholder" />
64 )}
65 <div className="card-body">

TownieInputBox.tsx46 matches

@japhethkingjackson•Updated 1 week ago
2import { useRef, useState, useEffect } from "react";
3import { PlusIcon, ArrowUpIcon, Square, XIcon } from "./icons.tsx";
4import { processFiles } from "../utils/images.ts";
5
6export function InputBox ({
11 running,
12 error,
13 images,
14 setImages,
15} : {
16 value: string;
20 running: boolean;
21 error: any;
22 images: (string|null)[];
23 setImages: (images: (string|null)[]) => void;
24}) {
25 const form = useRef(null);
57 autoFocus={true}
58 />
59 <ImageRow images={images} setImages={setImages} />
60 <div className="toolbar">
61 <UploadButton
62 disabled={running}
63 images={images}
64 setImages={setImages}
65 />
66 <div className="spacer" />
88}
89
90export function ImageDropContainer ({
91 images,
92 setImages,
93 running,
94 children,
95}: {
96 images: (string|null)[];
97 setImages: (images: (string|null)[]) => void;
98 running: boolean;
99 children: React.ReactNode;
100}) {
101 const dragging = useImageDrop({ images, setImages, running });
102
103 return (
105 {children}
106 {dragging && (
107 <div className="image-drop-overlay">
108 <div className="image-drop-inner">
109 Drop images here to upload
110 </div>
111 </div>
115}
116
117export function useImageDrop ({ images, setImages, running }: {
118 images: (string|null)[];
119 setImages(images: (string|null)[]) => void;
120 running: boolean;
121}) {
143 setDragging(false);
144 if (e.dataTransfer?.files && !running) {
145 processFiles(Array.from(e.dataTransfer.files), images, setImages);
146 }
147 }
164}
165
166function ImageRow ({ images, setImages }: {
167 images: (string|null)[];
168 setImages: (images: (string|null)[]) => void;
169}) {
170 return (
171 <div className="image-row">
172 {images.map((image, i) => (
173 <Thumbnail
174 key={i}
175 image={image}
176 onRemove={() => {
177 setImages([
178 ...images.slice(0, i),
179 ...images.slice(i + 1),
180 ]);
181 }}
186}
187
188function Thumbnail ({ image, onRemove }: {
189 image: string|null;
190 onRemove: () => void;
191}) {
192 if (!image) return null;
193
194 return (
195 <div className="input-image">
196 <img
197 src={image}
198 alt="User uploaded image"
199 className="image-thumbnail"
200 />
201 <button
202 type="button"
203 title="Remove image"
204 className="remove-image-button"
205 onClick={onRemove}
206 >
212
213function UploadButton ({
214 images,
215 setImages,
216 disabled,
217}: {
218 images: (string|null)[];
219 setImages: (images: (string|null)[]) => void;
220 disabled: boolean;
221}) {
226 <button
227 type="button"
228 title="Upload image"
229 disabled={disabled}
230 onClick={e => {
234 <PlusIcon />
235 <div className="sr-only">
236 Upload image
237 </div>
238 </button>
243 onChange={e => {
244 if (e.target.files) {
245 processFiles(Array.from(e.target.files), images, setImages);
246 }
247 }}

Townieimages.ts12 matches

@japhethkingjackson•Updated 1 week ago
1
2export const PROMPT_IMAGE_LIMIT = 5;
3
4export const processFiles = async (files: File[], images: (string | null)[], setImages: (images: (string | null)[]) => void) => {
5 const imageFiles = files.filter(file => file.type.startsWith('image/'));
6 const filesToProcess = imageFiles.slice(0, PROMPT_IMAGE_LIMIT - images.filter(Boolean).length);
7
8 if (filesToProcess.length === 0) return;
9
10 const newImages = [...images, ...Array(filesToProcess.length).fill(null)];
11 setImages(newImages);
12
13 const processedImages = await Promise.all(
14 filesToProcess.map(async (file) => {
15 return await readFileAsDataURL(file);
17 );
18
19 const updatedImages = [...images];
20 processedImages.forEach((dataUrl, index) => {
21 updatedImages[images.length + index] = dataUrl;
22 });
23
24 setImages(updatedImages.slice(0, PROMPT_IMAGE_LIMIT));
25};
26
30 reader.onload = () => {
31 const result = reader.result as string;
32 console.log("Image loaded, size:", result.length, "bytes");
33 resolve(result);
34 };

TownieHeader.tsx2 matches

@japhethkingjackson•Updated 1 week ago
33 <button className="h6">Log out</button>
34 </form>
35 {user?.profileImageUrl && (
36 <img
37 src={user.profileImageUrl}
38 alt={user.username}
39 width="32"

Towniefavicon.http.tsx1 match

@japhethkingjackson•Updated 1 week ago
10 return new Response(svg, {
11 headers: {
12 "Content-Type": "image/svg+xml",
13 },
14 });

Towniedashboard.ts3 matches

@japhethkingjackson•Updated 1 week ago
11 total_cache_write_tokens: number;
12 total_price: number;
13 total_images: number;
14 used_inference_data?: boolean;
15}
40 <th>Cache Write</th>
41 <th>Total Price</th>
42 <th>Images</th>
43 </tr>
44 </thead>
54 <td>${formatNumber(row.total_cache_write_tokens)} ${row.used_inference_data ? '<span class="badge badge-info" title="Using inference data">I</span>' : ''}</td>
55 <td class="price">${formatPrice(row.total_price)} ${row.used_inference_data ? '<span class="badge badge-info" title="Using inference data">I</span>' : ''}</td>
56 <td>${formatNumber(row.total_images)}</td>
57 </tr>
58 `).join("")}

Townie.cursorrules2 matches

@japhethkingjackson•Updated 1 week ago
178
179- **Redirects:** Use `return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})` instead of `Response.redirect` which is broken
180- **Images:** Avoid external images or base64 images. Use emojis, unicode symbols, or icon fonts/libraries instead
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods

TownieChatRouteSingleColumn.tsx15 matches

@japhethkingjackson•Updated 1 week ago
9import { useUsageStats } from "../hooks/useUsageStats.ts";
10import { Messages } from "./Messages.tsx";
11import { InputBox, ImageDropContainer } from "./InputBox.tsx";
12import { PreviewFrame } from "./PreviewFrame.tsx";
13import { BranchSelect } from "./BranchSelect.tsx";
66 refetch: () => void;
67}) {
68 const [images, setImages] = useState<(string|null)[]>([]);
69 const [selectedFiles, setSelectedFiles] = useState<string[]>([]);
70 const { audio, user } = useContext(AppContext);
84 branchId,
85 selectedFiles,
86 images,
87 soundEnabled: audio,
88 });
108
109 return (
110 <ImageDropContainer
111 running={running}
112 images={images}
113 setImages={setImages}>
114 <div className="single-column-container">
115 <div className="single-sticky-header">
119 rel="norefferer"
120 className="block-link text-link lockup">
121 {project.imageUrl ? (
122 <img src={project.imageUrl} className="image-thumbnail" />
123 ) : user?.profileImageUrl ? (
124 <img
125 src={user.profileImageUrl}
126 className="avatar"
127 alt={user.username}
130 />
131 ) : (
132 <div className="image-placeholder" />
133 )}
134 <div>{project.name}</div>
153 onSubmit={e => {
154 handleSubmit(e);
155 setImages([]);
156 }}
157 onCancel={handleStop}
158 running={running}
159 error={error}
160 images={images}
161 setImages={setImages}
162 />
163 <Footer />
164 </div>
165 </div>
166 </ImageDropContainer>
167 );
168}

mahiindex.ts11 matches

@Mahi7•Updated 1 week ago
20
21/**
22 * Main HTTP handler for the image recognition app
23 */
24export default async function(req: Request): Promise<Response> {
52 }
53
54 // Handle POST requests (image analysis)
55 if (req.method === "POST") {
56 try {
57 // Parse the request body
58 const body = await req.json();
59 const imageUrl = body.imageUrl;
60
61 // Validate the image URL
62 if (!imageUrl) {
63 return jsonResponse({
64 success: false,
65 error: "Image URL is required",
66 }, 400);
67 }
68
69 // Call OpenAI Vision API to analyze the image
70 const response = await openai.chat.completions.create({
71 model: "gpt-4o",
74 role: "user",
75 content: [
76 { type: "text", text: "What's in this image? Provide a detailed description." },
77 { type: "image_url", image_url: { url: imageUrl } }
78 ],
79 },
91 });
92 } catch (error) {
93 console.error("Error analyzing image:", error);
94
95 // Determine if it's an OpenAI API error
100 return jsonResponse({
101 success: false,
102 error: `Failed to analyze image: ${errorMessage}`,
103 }, 500);
104 }

mahiindex.html28 matches

@Mahi7•Updated 1 week ago
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>AI Image Recognition</title>
7 <!-- TailwindCSS -->
8 <script src="https://cdn.twind.style" crossorigin></script>
29 <div class="container mx-auto px-4 py-8 max-w-4xl">
30 <header class="text-center mb-8">
31 <h1 class="text-3xl font-bold text-blue-600 mb-2">AI Image Recognition</h1>
32 <p class="text-gray-600">Enter an image URL to get an AI-powered description</p>
33 </header>
34
35 <main class="bg-white rounded-lg shadow-md p-6">
36 <div class="mb-6">
37 <label for="imageUrl" class="block text-sm font-medium text-gray-700 mb-2">Image URL</label>
38 <div class="flex">
39 <input
40 type="text"
41 id="imageUrl"
42 placeholder="https://example.com/image.jpg"
43 class="flex-1 rounded-l-md border border-gray-300 px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
44 >
50 </button>
51 </div>
52 <p class="mt-1 text-sm text-gray-500">Paste a direct link to an image (JPG, PNG, etc.)</p>
53 </div>
54
55 <div id="previewContainer" class="mb-6 hidden">
56 <h2 class="text-lg font-medium text-gray-800 mb-2">Image Preview</h2>
57 <div class="flex justify-center bg-gray-100 rounded-md p-2">
58 <img id="imagePreview" src="" alt="Preview" class="max-h-64 rounded">
59 </div>
60 </div>
62 <div id="loadingContainer" class="mb-6 hidden text-center py-4">
63 <div class="loading-spinner mr-2"></div>
64 <span class="text-gray-600">Analyzing image...</span>
65 </div>
66
87 <script>
88 // DOM elements
89 const imageUrlInput = document.getElementById('imageUrl');
90 const analyzeBtn = document.getElementById('analyzeBtn');
91 const previewContainer = document.getElementById('previewContainer');
92 const imagePreview = document.getElementById('imagePreview');
93 const loadingContainer = document.getElementById('loadingContainer');
94 const resultContainer = document.getElementById('resultContainer');
98
99 // Event listeners
100 imageUrlInput.addEventListener('input', updatePreview);
101 analyzeBtn.addEventListener('click', analyzeImage);
102
103 // Handle Enter key in the input field
104 imageUrlInput.addEventListener('keydown', (e) => {
105 if (e.key === 'Enter') {
106 analyzeImage();
107 }
108 });
109
110 // Update image preview when URL changes
111 function updatePreview() {
112 const imageUrl = imageUrlInput.value.trim();
113
114 if (imageUrl) {
115 imagePreview.src = imageUrl;
116 previewContainer.classList.remove('hidden');
117
118 // Handle image load errors
119 imagePreview.onerror = () => {
120 previewContainer.classList.add('hidden');
121 };
125 }
126
127 // Analyze the image using the API
128 async function analyzeImage() {
129 const imageUrl = imageUrlInput.value.trim();
130
131 if (!imageUrl) {
132 showError('Please enter an image URL');
133 return;
134 }
146 'Content-Type': 'application/json',
147 },
148 body: JSON.stringify({ imageUrl }),
149 });
150

image_proxy

@oops•Updated 4 days ago

ImageExplorer10 file matches

@carmi•Updated 1 week ago
Chrimage
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