From a93c5c61b18192c5f74256e3cb18e7f1cd2034d5 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 23 Jan 2022 01:51:12 +0100 Subject: [PATCH] word/edit: read fractional crop coordinates Clean up various separators (,-x;:/) from manual input into common comma, and allow dot for possible future fractions in large numbers: UPDATE word SET image = jsonb_set(image, '{crop32}', regexp_replace(image->>'crop32', '[^0-9,]', ',', 'g') ) WHERE image->>'crop32' IS NOT NULL; Decided against dividing by 1000 to simplify code, but this would do that: UPDATE word SET image = jsonb_set(image, '{crop32}', to_jsonb(array_to_string(array( SELECT unnest(string_to_array(image->>'crop32', ','))::float / 1000 ), ',')) ) WHERE image->>'crop32' IS NOT NULL; --- word/editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/word/editor.js b/word/editor.js index 461bab0..4eb2382 100644 --- a/word/editor.js +++ b/word/editor.js @@ -126,7 +126,7 @@ document.addEventListener('DOMContentLoaded', () => { const canvas = [thumbpreview.clientWidth, thumbpreview.clientHeight]; const border = [canvas[0], canvas[0] * imgpreview.height / imgpreview.width]; const minscale = Math.max(1, canvas[1] / border[1]); // 100% or fit width - let crop = cropinput.value.split(/[^0-9]/).map(pos => pos / 1000); + let crop = cropinput.value.split(/[^0-9.]/).map(pos => pos / 1000); let scale = 1 / (crop[2] - crop[0]) || minscale; crop.push(0); // defined y dimension crop.splice(2); // end coordinates applied to zoom -- 2.30.0