feat: photo quality improvements
- webcam capture resolution/quality configurable in admin settings (defaults 640x480 / 0.92) - enhance photo modal in journal: original vs preview with sliders (brightness, contrast, saturation, sharpen) and auto-levels button - new endpoint PUT /api/entries/:id/photo/enhance replaces photo, cleans old file and thumb - sharper HEIC conversion (0.92) and webp thumbnails (85) - worker: fail explicitly on empty AI response
This commit is contained in:
+11
-2
@@ -21,6 +21,9 @@ const sentText = document.getElementById('sentText');
|
||||
const sentTimer = document.getElementById('sentTimer');
|
||||
const SENT_KEY = 'whatido_entry_sent_at';
|
||||
let entryCooldownMin = 30;
|
||||
let captureWidth = 640;
|
||||
let captureHeight = 480;
|
||||
let captureQuality = 0.92;
|
||||
let sentTimerId = null;
|
||||
|
||||
function unlockForm() {
|
||||
@@ -156,6 +159,12 @@ if (params.get('nameInput')) {
|
||||
if (f.footer_right) document.getElementById('footerRight').textContent = f.footer_right;
|
||||
const c = parseInt(f.spam_interval_min, 10);
|
||||
if (Number.isFinite(c) && c >= 1) entryCooldownMin = c;
|
||||
const w = parseInt(f.photo_capture_width, 10);
|
||||
const h = parseInt(f.photo_capture_height, 10);
|
||||
if (Number.isFinite(w) && w >= 160 && w <= 4096) captureWidth = w;
|
||||
if (Number.isFinite(h) && h >= 120 && h <= 4096) captureHeight = h;
|
||||
const q = parseFloat(f.photo_capture_quality);
|
||||
if (Number.isFinite(q) && q >= 0.5 && q <= 1) captureQuality = q;
|
||||
} catch (e) { /* ignore */ }
|
||||
checkPreviousSend();
|
||||
})();
|
||||
@@ -175,7 +184,7 @@ function removePhoto() {
|
||||
|
||||
async function openCam() {
|
||||
try {
|
||||
stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'user', width: { ideal: 640 }, height: { ideal: 480 } } });
|
||||
stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'user', width: { ideal: captureWidth }, height: { ideal: captureHeight } } });
|
||||
camVideo.srcObject = stream;
|
||||
camModal.classList.add('open');
|
||||
} catch (e) {
|
||||
@@ -199,7 +208,7 @@ function capture() {
|
||||
capturedBlob = blob;
|
||||
showPreview(URL.createObjectURL(blob));
|
||||
closeCam();
|
||||
}, 'image/jpeg', 0.85);
|
||||
}, 'image/jpeg', captureQuality);
|
||||
}
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
|
||||
Reference in New Issue
Block a user