axe312ger / sqip

"SQIP" (pronounced \skwɪb\ like the non-magical folk of magical descent) is a SVG-based LQIP technique.

Home Page:http://axe312ger.github.io/sqip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting background color in primitive causes chained blur to fail

sveinugu opened this issue · 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 9769d45, 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 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)

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?

latest version of primitive from the github repo

I have version 1.3.0 installed (on a Mac).

(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 sqip-plugin-primitive@1.0.0-alpha.40 package. The error is still present.

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

Fix available now via:

sqip-cli@1.0.0-alpha.47, sqip-plugin-blur@1.0.0-alpha.43, sqip-plugin-primitive@1.0.0-alpha.44, sqip@1.0.0-alpha.42

(All under latest @canary tag)