sibbl / hass-lovelace-kindle-screensaver

This tool generates a png from a Home Assistant Lovelace view, which can be displayed on a Kindle device which has the Online Screensaver plugin installed.
MIT License
333 stars 74 forks source link

Error: Command failed: convert: unrecognized dither method `-background' #112

Closed GoodnessJSON closed 7 months ago

GoodnessJSON commented 7 months ago

Hi there,

Just updated to v1.0.7 and love the new configs. Unfortunately the add-on now crashes with every start with this error:

Converting rendered screenshot of http://192.168.1.50:8123/dashboard-kindle/0?kiosk to grayscale png...
/app/node_modules/gm/lib/command.js:301
          err = new Error('Command failed: ' + stderr);
                ^

Error: Command failed: convert: unrecognized dither method `-background' @ error/convert.c/ConvertImageCommand/1422.

    at ChildProcess.onExit (/app/node_modules/gm/lib/command.js:301:17)
    at ChildProcess.emit (node:events:517:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:517:28)
    at Pipe.<anonymous> (node:net:350:12) {
  code: 1,
  signal: null
}

I've tried toggling the Dither and Gamma settings but it makes no difference. Can this be looked at? Thanks so much for the great project!

andyb2000 commented 7 months ago

Yep, spotted this after testing and talking to @sibbl about another issue with env's so looks like it's due to the line 308 in index.js ( .dither(pageConfig.dither))

I may get time tomorrow to take a quick look.

GoodnessJSON commented 7 months ago

Yep, spotted this after testing and talking to @sibbl about another issue with env's so looks like it's due to the line 308 in index.js ( .dither(pageConfig.dither))

I may get time tomorrow to take a quick look.

That would be amazing, thanks for taking a look!

sibbl commented 7 months ago

The cause of this might be that our Dockerfile uses imagemagick instead of graphicsmagick. While the used npm module gm says to be compatible with both, it doesn't seem to support the differences in the dither parameter. While +dither works for both, the -dither parameter requires the name of the dither algorithm to use in imagemagick, while graphicsmagick only uses it as a toggle.

Maybe it's worth to give Graphicsmagick another try in the Dockerfile but I'm not sure what other incompatibilities will occur. An alternative would be to open an issue in the gm npm package repository. Finally, we could also just use the "custom arguments" feature of the gm npm package to support -dither ALGORITHM and ´+dither` by our own. That's probably what I'd prefer.

GoodnessJSON commented 7 months ago

This only seemed to come with the update to Home Assistant yesterday, as well as the v1.0.7 update today. I'm not sure if that helps at all. Node.js v18.19.1 running HAOS on a RPB4.

sibbl commented 7 months ago

Oh, now I understand. After the update, it doesn't work either way - with and without the toggle? I thought it was just a problem after enabling it.

As a quick fix, I'll remove the option again until we can find out the real cause. Version 1.0.8 will be available in a few minutes.

GoodnessJSON commented 7 months ago

Oh, now I understand. After the update, it doesn't work either way - with and without the toggle? I thought it was just a problem after enabling it.

As a quick fix, I'll remove the option again until we can find out the real cause. Version 1.0.8 will be available in a few minutes.

Yep that's correct! No matter the setting, or after reinstalling it's the same error. Thanks for taking a look! Will let you know about v1.0.8. Thanks for the quick responses!

GoodnessJSON commented 7 months ago

Can confirm this has now fixed it. Great work!

sibbl commented 7 months ago

Thanks for the confirmation and sorry that it happened in the first place!