Update index.html
Browse files- index.html +58 -106
index.html
CHANGED
@@ -5,120 +5,72 @@
|
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Image Format Converter</title>
|
7 |
<style>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
<label for="imageInput">Select an Image:</label>
|
16 |
-
<input type="file" id="imageInput" accept="image/*" required onchange="detectImageProperties()">
|
17 |
-
|
18 |
-
<p id="formatInfo">Detected Format: <span id="formatDisplay"></span></p>
|
19 |
-
<p id="sizeInfo">Image Size: <span id="sizeDisplay"></span></p>
|
20 |
-
|
21 |
-
<label for="targetFormat">Choose Target Format:</label>
|
22 |
-
<select id="targetFormat" required>
|
23 |
-
<option value="image/bmp">BMP</option>
|
24 |
-
<option value="image/eps">EPS</option>
|
25 |
-
<option value="image/gif">GIF</option>
|
26 |
-
<option value="image/ico">ICO</option>
|
27 |
-
<option value="image/jpeg">JPG</option>
|
28 |
-
<option value="image/png">PNG</option>
|
29 |
-
<option value="image/psd">PSD</option>
|
30 |
-
<option value="image/svg+xml">SVG</option>
|
31 |
-
<option value="image/tga">TGA</option>
|
32 |
-
<option value="image/tiff">TIFF</option>
|
33 |
-
<option value="image/webp">WebP</option>
|
34 |
-
</select>
|
35 |
-
|
36 |
-
<label for="customWidth">Custom Width (leave empty for original):</label>
|
37 |
-
<input type="text" id="customWidth">
|
38 |
-
|
39 |
-
<label for="customHeight">Custom Height (leave empty for original):</label>
|
40 |
-
<input type="text" id="customHeight">
|
41 |
-
|
42 |
-
<input type="checkbox" id="keepAspectRatio">
|
43 |
-
<label for="keepAspectRatio">Keep Aspect Ratio</label>
|
44 |
-
|
45 |
-
<input type="checkbox" id="compressImage">
|
46 |
-
<label for="compressImage">Compress Image</label>
|
47 |
-
|
48 |
-
<button type="button" onclick="convertImage()">Convert</button>
|
49 |
-
|
50 |
-
<a id="downloadLink" style="display: none" download="converted_image">Download Converted Image</a>
|
51 |
-
</form>
|
52 |
-
|
53 |
-
<script>
|
54 |
-
function detectImageProperties() {
|
55 |
-
const input = document.getElementById('imageInput');
|
56 |
-
const formatDisplay = document.getElementById('formatDisplay');
|
57 |
-
const sizeDisplay = document.getElementById('sizeDisplay');
|
58 |
-
|
59 |
-
if (input.files.length > 0) {
|
60 |
-
const file = input.files[0];
|
61 |
-
formatDisplay.textContent = file.type;
|
62 |
-
sizeDisplay.textContent = `${file.size} bytes`;
|
63 |
-
}
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
const customHeight = document.getElementById('customHeight').value;
|
71 |
-
const keepAspectRatio = document.getElementById('keepAspectRatio').checked;
|
72 |
-
const compressImage = document.getElementById('compressImage').checked;
|
73 |
-
const formatDisplay = document.getElementById('formatDisplay');
|
74 |
-
const downloadLink = document.getElementById('downloadLink');
|
75 |
-
|
76 |
-
if (input.files.length > 0) {
|
77 |
-
const file = input.files[0];
|
78 |
-
|
79 |
-
// Display detected format
|
80 |
-
formatDisplay.textContent = file.type;
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
87 |
|
88 |
-
|
89 |
-
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
}
|
99 |
-
} else {
|
100 |
-
// If custom dimensions are not provided, use original dimensions
|
101 |
-
newWidth = img.width;
|
102 |
-
newHeight = img.height;
|
103 |
-
}
|
104 |
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
|
109 |
-
|
|
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
};
|
118 |
|
119 |
-
|
120 |
-
|
121 |
}
|
122 |
-
</
|
123 |
-
</
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Image Format Converter</title>
|
7 |
<style>
|
8 |
+
body {
|
9 |
+
font-family: 'Arial', sans-serif;
|
10 |
+
max-width: 600px;
|
11 |
+
margin: 20px auto;
|
12 |
+
padding: 20px;
|
13 |
+
background-color: #f4f4f4;
|
14 |
+
border-radius: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
+
h1 {
|
18 |
+
text-align: center;
|
19 |
+
color: #333;
|
20 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
form {
|
23 |
+
background-color: #fff;
|
24 |
+
padding: 20px;
|
25 |
+
border-radius: 8px;
|
26 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
27 |
+
}
|
28 |
|
29 |
+
label, select, button, input {
|
30 |
+
display: block;
|
31 |
+
margin-bottom: 15px;
|
32 |
+
}
|
33 |
|
34 |
+
select, input {
|
35 |
+
width: 100%;
|
36 |
+
padding: 10px;
|
37 |
+
border: 1px solid #ccc;
|
38 |
+
border-radius: 4px;
|
39 |
+
}
|
40 |
|
41 |
+
input[type="checkbox"] {
|
42 |
+
margin-right: 5px;
|
43 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
button {
|
46 |
+
background-color: #4caf50;
|
47 |
+
color: #fff;
|
48 |
+
padding: 10px;
|
49 |
+
border: none;
|
50 |
+
border-radius: 4px;
|
51 |
+
cursor: pointer;
|
52 |
+
transition: background-color 0.3s ease;
|
53 |
+
}
|
54 |
|
55 |
+
button:hover {
|
56 |
+
background-color: #45a049;
|
57 |
+
}
|
58 |
|
59 |
+
a {
|
60 |
+
color: #2196F3;
|
61 |
+
text-decoration: none;
|
62 |
+
display: block;
|
63 |
+
margin-top: 10px;
|
64 |
+
}
|
|
|
65 |
|
66 |
+
a:hover {
|
67 |
+
text-decoration: underline;
|
68 |
}
|
69 |
+
</style>
|
70 |
+
</head>
|
71 |
+
<body>
|
72 |
+
<h1>Image Format Converter</h1>
|
73 |
+
|
74 |
+
<form id="imageForm">
|
75 |
+
<label for="imageInput">Select an Image:</label>
|
76 |
+
<input type="file" id="imageInput" accept="image/*"
|