Bikas0's picture
Card Cropping
8df2f3a
raw
history blame
7.27 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Card cropping</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
position: relative;
background-image: url('static/depositphotos_489854724-stock-illustration-light-multicolor-rainbow-vector-abstract.jpg');
background-size: 2300px;
background-repeat: no-repeat;
background-position: center;
background-color: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(7px);
min-height: 100vh; /* Ensure page takes at least viewport height */
}
form {
margin-bottom: 20px;
}
/* File uploader and predict button styles */
.file-upload-label {
padding: 10px;
}
#predictBtn {
padding: 10px 20px;
margin-top: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
#predictBtn:hover {
background-color: #0056b3;
}
#predictBtn:active {
background-color: #004f9f;
}
#predictBtn:focus {
outline: none;
}
.file-upload-input {
display: none;
}
.file-upload-icon {
font-size: 30px;
margin-right: 1px;
}
.image-container {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20px;
position: relative;
}
.image-wrapper {
position: relative;
margin: 0 50px; /* Increased space between the images */
}
.image-label {
text-align: center;
background-color: #ffffff;
padding: 5px 10px;
border-radius: 5px;
font-weight: bold;
margin-top: 10px;
display: none; /* Initially hide labels */
}
.image-container img {
height: auto;
display: none; /* Initially hide images */
}
#uploadedImage {
max-width: 200px; /* Smaller size for uploaded image */
}
#croppedImage {
max-width: 250px;
}
#result {
margin-top: 20px;
position: relative;
}
#loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
}
#logo {
position: absolute;
bottom: 5px;
right: 5px;
max-width: 100px; /* Increase logo size */
height: auto;
}
.footprint {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
text-align: center;
background-color: rgba(255, 255, 255, 0.2);
padding: 10px 0;
z-index: 1;
}
.footprint img {
max-width: 100px;
height: auto;
margin-left: auto; /* Push the logo to the right */
display: inline-block;
vertical-align: middle; /* Align the logo vertically with the text */
}
</style>
</head>
<body>
<br>
<br>
<h1>Visiting Card/Id Card Cropping System</h1>
<form id="uploadForm" enctype="multipart/form-data">
<label for="file-upload" class="file-upload-label">
<input type="file" name="image" id="file-upload" class="file-upload-input" accept="image/*" required>
<span class="file-upload-icon">📤</span> Choose an image
</label>
<button id="predictBtn" type="submit">Predict</button>
</form>
<div id="result">
<div id="loading">
<img src="path_to_loader_icon.gif" alt="Loader">
</div>
<p id="message"></p>
<div class="image-container">
<div class="image-wrapper">
<img id="uploadedImage" src="" alt="Uploaded Image">
<div class="image-label" id="uploadedLabel">Uploaded Image</div>
</div>
<div class="image-wrapper">
<img id="croppedImage" src="" alt="Cropped Image">
<div class="image-label" id="croppedLabel">Output</div>
</div>
</div>
</div>
<!-- Footprint -->
<div class="footprint">
<p>Copyright © XYZ It Ltd. 2024</p>
<img src="static/360_F_517815080_tD3cmJRmhhztVmeHrnJd3DA4HT1Zkks7 (1).jpg" alt="Company Logo">
</div>
<script>
document.getElementById('uploadForm').addEventListener('submit', async function(event) {
event.preventDefault();
const formData = new FormData(this);
// Show loading icon when form is submitted
document.getElementById('loading').style.display = 'block';
const fileInput = document.getElementById('file-upload');
const file = fileInput.files[0];
let uploadedImageSrc = '';
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
uploadedImageSrc = e.target.result;
}
reader.readAsDataURL(file);
}
const response = await fetch('/detect-and-crop', {
method: 'POST',
body: formData
});
const result = await response.json();
document.getElementById('message').textContent = result.message;
if (uploadedImageSrc) {
const uploadedImage = document.getElementById('uploadedImage');
const uploadedLabel = document.getElementById('uploadedLabel');
uploadedImage.src = uploadedImageSrc;
uploadedImage.style.display = 'block';
uploadedLabel.style.display = 'block';
}
if (result.output_filename) {
const imageUrl = `/output/${result.output_filename}?${Date.now()}`;
const croppedImage = document.getElementById('croppedImage');
const croppedLabel = document.getElementById('croppedLabel');
croppedImage.src = imageUrl;
croppedImage.style.display = 'block';
croppedLabel.style.display = 'block';
} else {
// Clear the src attribute when no output image available
const croppedImage = document.getElementById('croppedImage');
const croppedLabel = document.getElementById('croppedLabel');
croppedImage.src = '';
croppedImage.style.display = 'none';
croppedLabel.style.display = 'none';
}
document.getElementById('loading').style.display = 'none';
});
</script>
</body>
</html>