Get image width - Node, Handlebars, js

Hello, I’d like to automate the process of applying width to srcset. I’m using Node an handlebars. I can do it manually but prefer to apply a function + condition if 2x/3x exist. Could anyone help?

this is from the server:

 file: '22_16_CF005663.jpg',
'2x': '64.jpg',
 '3x': null,

this is html:

<img src="/images/{{file}}"
       srcset="/images/{{file}},
               /images/{{2x}},
               /images/{{3x}}"
     alt="{{alt}}">