I needed this and I found online few tools but I wasn't pleased with any of them. So I made my own. My tool is based on fastboot and adb commands (they must be installed in your PC, and added to PATH). I have consulted the batch script of HikariCalyx to check partitions names and match them with those from my phone. Get a ROM like these from here, extract it to a folder and place this tool in that folder, then connect your phone to PC and execute the tool. The author of those stock ROMs, Raghu Varma has a tool like this too and I liked that, but it hangs in execution (main thread in interface).