1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* This application creates a thumbnail maker using Hono for server-side routing and client-side JavaScript for image processing.
* It allows users to upload images, specify output options, and generate a composite thumbnail image.
* The app uses the HTML5 Canvas API for image manipulation and supports drag-and-drop functionality.
*
* The process is divided into two steps:
* 1. Generating thumbnails: Users choose thumbnail size options and create individual thumbnails.
* 2. Rendering: Users can create and export the final composite image with options for format and quality.
* This two-step process allows changing format or quality without re-rendering the entire canvas.
*
* Additional features:
* - Users can go back from the second step to the first one to regenerate thumbnails.
* - Dropping new files takes the user back to the first step.
* - A "Download Metadata" button is added to download a JSON file with thumbnail information.
*/
import { serve } from 'https://esm.town/v/g/serveUtils';
import { Hono } from 'npm:hono';
function html() {
/*
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thumbnail Maker</title>
<link rel="stylesheet" href="/styles.css">
<script type="module" src="/main.js" defer></script>
</head>
<body>
<div id="app">
<h1>Thumbnail Maker</h1>
<div id="dropZone">
<p>📷 Drag & drop images here or click to select</p>
<input type="file" id="fileInput" multiple accept="image/*">
</div>
<div id="thumbnailOptions">
<h2>Step 1: Generate Thumbnails</h2>
<label>
Thumbnail Height:
<input type="number" id="thumbHeight" min="50" max="1000" value="300">
</label><br>
<label>
<input type="checkbox" id="keepAspectRatio" checked>
Keep Aspect Ratio
</label><br>
<label>
Thumbnail Width:
<input type="number" id="thumbWidth" min="50" max="1000" value="300" disabled>
</label><br>
<button id="generateBtn">Generate Thumbnails</button>
</div>
<div id="renderOptions" style="display: none;">
<h2>Step 2: Render and Export</h2>
<label>
Output Format:
<select id="outputFormat">
<option value="image/png">PNG</option>
<option value="image/jpeg">JPEG</option>
<option value="image/webp">WebP</option>
</select>
</label><br>
<label>
Quality (JPEG/WebP):
<input type="number" id="outputQuality" min="0" max="1" step="0.1" value="0.8">
</label><br>
<button id="renderBtn">Render and Export</button>
<button id="backBtn">Back to Step 1</button>
</div>
<progress id="progressBar" value="0" max="100" style="display: none;"></progress>
<div id="downloadSection" style="display: none;">
<a id="downloadLink">Download Thumbnails</a>
<button id="downloadMetadataBtn">Download Metadata</button>
</div>
<div id="imagePreview"></div>
</div>
</body>
</html>
*/
}
function css() {
/*
body {
font-family: Arial, sans-serif;
font-size: 16px;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f0f0f0;
}
#app {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
color: #333;
}