EasyImage Editor
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Editor</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
margin: 20px;
}
#imageInput {
margin-bottom: 20px;
}
#imagePreview {
max-width: 100%;
margin-bottom: 20px;
}
button {
padding: 10px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<input type="file" id="imageInput" accept="image/*" onchange="displayImage()">
<img id="imagePreview" alt="Uploaded Image">
<div>
<button onclick="cropImage()">Crop</button>
<button onclick="rotateImage()">Rotate</button>
<button onclick="resizeImage()">Resize</button>
<button onclick="applyFilter()">Apply Filter</button>
<button onclick="downloadImage()">Download</button>
</div>
<script>
let originalImage;
function displayImage() {
const input = document.getElementById('imageInput');
const preview = document.getElementById('imagePreview');
const file = input.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
preview.src = e.target.result;
originalImage = new Image();
originalImage.src = e.target.result;
};
reader.readAsDataURL(file);
}
}
function cropImage() {
// Implement cropping logic here
alert('Crop feature not implemented in this example.');
}
function rotateImage() {
// Implement rotating logic here
alert('Rotate feature not implemented in this example.');
}
function resizeImage() {
// Implement resizing logic here
alert('Resize feature not implemented in this example.');
}
function applyFilter() {
// Implement filter logic here
alert('Filter feature not implemented in this example.');
}
function downloadImage() {
if (!originalImage) {
alert('Please upload an image before downloading.');
return;
}
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = originalImage.width;
canvas.height = originalImage.height;
ctx.drawImage(originalImage, 0, 0);
const downloadLink = document.createElement('a');
downloadLink.href = canvas.toDataURL();
downloadLink.download = 'edited_image.png';
downloadLink.click();
}
</script>
</body>
</html>