Thin the stroke of PNG in JS

Is there a way to take a black png image with a transparent background and shrink down the stroke of the line by a few pixels while maintains image size?

I would need to to be able to overlay on top of the original without covering the whole thing

I have tried converting to SVG so I can adjust the stroke but when converting to SVG stroke is set to none and it’s just the path data

I have tried thinning algorithms with bitmap but they seem to do nothing.

What I am trying to do is exactly what photoshops contract method does but I cannot find any way to automate this in JS