It was this workflow by @ipazin from this discussion.
It should be possible to adapt that to your needs