word/edit: read fractional crop coordinates
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 23 Jan 2022 00:51:12 +0000 (01:51 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 7 Feb 2022 17:42:33 +0000 (18:42 +0100)
commita93c5c61b18192c5f74256e3cb18e7f1cd2034d5
tree8ca1ad3d91448dc7121a7feefbf2e2eaea9132a4
parent8898dfdc93f948c1b1dd90219c8deaa89c57c916
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