How can I convert product media to JPG for black backgrounds?

Hi there, I wanted to make my product backgrounds black instead of the ordinary white background for my Product PNG Images. When I change my theme to black, it leaves the PNG backgrounds to white.

Here is my page - https://rmtperformance.com/

I want it like this page - https://houseofurban.co.uk/collections/defender-2020/products/urban-design-pack-new-defender

This is how I want it

I Saw this thread which said if you convert all product media to JPG it may change the backgrounds to black as it cannot read background transparent data. However I don’t know how to add or write this format code into the liquid file below, any ideas?

- THREAD - https://admin.shopify.com/store/37d205-5/themes/160197771611?key=snippets%2Fproduct-media.liquid

How do I add this line of code to the refresh theme, I have the folder and code, but I don’t see any line of code for format. Any ideas on how I can add this code?