sqip icon indicating copy to clipboard operation
sqip copied to clipboard

Setting background color in primitive causes chained blur to fail

Open sveinugu opened this issue 2 years ago • 4 comments

Interested in making use of the new support for transparent images in sqip-1.0.0.alpha38 through sqip-loader, I created a new fork of "mole-inc/sqip-loader" (which is again a fork of "EmilTholin/sqip-loader") and tried updating the sqip dependencies and adding support for the background option in "sqip-plugin-primitive". Then, I added an example PNG with transparency and set the background option to #ffffff00. As default, sqip-loader adds a blur step with "blur=12".

Expected outcome:

  • A preview sqip image based on the 'sqip-plugin-primitive', and further blurred by the chained 'sqip-plugib-blur'

Actual outcome:

  • Error message: Error: The SVG must have a rect as first shape element which represents the svg background color

The cause of the bug seems to be from lines 177-183 in the file "sqip-plugin-primitive.ts" from commit https://github.com/axe312ger/sqip/commit/9769d4597fdfca877d1caef1c3f2cd68347fd223, which causes a validation check in sqip-plugin-blur to fail.

To see the issue, clone the repo https://github.com/fairtracks/sqip-loader, check out the branch ft_background and run the example. Adding &blur=0 to line 12 in "example/app.js" circumvents the bug (no blur applied).

sveinugu avatar Jun 27 '22 08:06 sveinugu

@sveinugu unfortunately did primitive do some "breaking" changes in their markup.

If the rectangle is missing, there is a chance you use a very old version of primitive.

Can you try with the latest version installed? (Or check IF you have it globally installed why primitive)

axe312ger avatar Aug 09 '22 09:08 axe312ger

Can you try with the latest version installed? (Or check IF you have it globally installed why primitive)

I installed the latest version of primitive from the github repo (https://github.com/fogleman/primitive), however the last update of this repo was 2 years ago. Is there another, more updated version of primitive available somewhere else?

sveinugu avatar Aug 25 '22 08:08 sveinugu

latest version of primitive from the github repo

I have version 1.3.0 installed (on a Mac).

sveinugu avatar Aug 25 '22 08:08 sveinugu

(https://github.com/fogleman/primitive)

After digging a bit I see now that I am not using my globally installed version of primitive at all. Rather, the sqip-plugin-primitive package is building it's own binaries stored within the node_modules directory. This is based on the https://github.com/hashbite/primitive repo, however there are only dependency-related changes compared to the original fogleman repo. I am depending on version 1.0.0-alpha.40 of sqip-plugin-primitive, which builds the latest version of primitive.

I have now removed the globally installed version of primitive, as well as updated and reinstalled the node modules, however the error remains. To be 100% sure that the package-included binary (node_modules/sqip-plugin-primitive/primitive-binaries/primitive-darwin-arm64) was the one used, I renamed it, which caused the example to fail due to missing binary.

TL;DR: I am using the latest version of primitive, automatically installed by npm in the [email protected] package. The error is still present.

sveinugu avatar Aug 25 '22 09:08 sveinugu

I fixed this with 528f600b777c38662e369978d514f4304cc3d7ca, will release a new alpha/canary soon.

axe312ger avatar Jan 25 '24 10:01 axe312ger

Fix available now via:

[email protected], [email protected], [email protected], [email protected]

(All under latest @canary tag)

axe312ger avatar Jan 25 '24 10:01 axe312ger