Changes to margins etc should really be done via a css file or placed into <style>
tags.
ie place this at the top of the page
<style>
img {margin:0; padding:0;}
</style>
Alternatively you can add an inline style rule. From the information given you will need to do something like this:
echo '<img src="imgurl" alt="Alt Text" style="margin:0; padding:0;" />'
The likelihood is that this is margin, though could potentially be padding, hence why I have added both rules. You should should use chrome inspect or similar to confirm if it is margin or padding. This will also tell you if it is specifically the image that has margin/padding or another element.