Convert jpg to png whit node red

Hello, can you advise how I can convert a local image in jpg format to png format and save it in the same folder using node-red?
I have the imagemagick library installed.
In node red I used the exec node: and in the command entry I put the following:

/usr/bin/convert /homeassistant/esphome/image/forecastmap/weather_map.jpg /homeassistant/esphome/image/forecastmap/weather_map.png 2>&1

if I add debug it says:

"/bin/bash: line 1: /usr/bin/convert: No such file or directory"

If I run this command through the command line, the conversion happens without any problems.
Can you advise where the error is?
Thanks

Is imagemagick installed in the node red container?

I can’t say that, I’m using HA OS. Node-red is installed using addons. imagemagick was installed using command line
apk add --update imagemagick

Where/how did you run the apk command?

A possible sideways question, why in earth do you want to do this? And why in NR? Both formats are pretty universally readable.

I entered the command using the terminal.

And why I want to do it. I need the plugin in esphome to be able to load a png image and the only thing I have available are images in jpg format from the Internet (a weather map image that changes every hour under the same name)

there is another solution for converting jpg to png in home assistant?

Forget node red then. It is an unnecessary complication.

But I think the first problem you will face is that the last time I looked images can’t dynamically be added like that. They are statically compiled in at compile time.

The example given in the docs

image:
  - file: https://esphome.io/_images/logo.png
    id: esphome_logo
    resize: 200x162

Creates the logo image in the firmware as it is at compile time. If the online image changes an hour later, the firmware won’t update.

As I say, that was the situation last time I looked at it. There was a proposal to create a dynamic image component, but I am not sure it has actually been added.

Also I don’t know whether LVGL will change the position when it is merged.

I have tried both LVGL and online_image and it works, I solved it on discord. The only problem is that online_image currently supports png and not jpg, so I’m looking for how to compile the image

Installing in HA’s terminal installs inside the HA container not node red. Nodered also uses npm, you can add npm packages on the configuration page of the addon.

How?
Thanks

1 Like

I just figured it out and trying it it looks like the command will run … but there is some error with the jpg.
thank you, I was solving it all morning :smiley:

and it is. two system packages need to be added

system_packages:
  - imagemagick
  - libjpeg
1 Like

:+1: If you need further image processing you can also use image tools.

does it export png? because I didn’t figure it out

Yes. The function drop down inside the node settings. Use the write option.

Edit: your problem maybe that nodered doesn’t have privileges to access that file path. If possible use the media folder.

Or simply use the shell command integration.