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;
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