I do not believe how easy it was.
The simples solution is using phx
The ditto tpl looks like
...
<img src="[+image+]" alt="" width="[+image:width+]" height="[+image:height+]" />
...
And the php custom modifier is:
1. create a snippet called phx:width
2. paste this code
<?php
list($width, $height, $type, $attr) = getimagesize($output);
return $width;
?>
3. Do the same for height and change the return value.
Amazing