Skip to content
Advertisement

How do I convert Python scripts files to images files representing the code with highlighting?

In short, how do I get this:

enter image description here

From this:

JavaScript

With all the indentation guide and code highlighting.

I have written hundreds of Python scripts and I need to convert all of them to images…

I have seen this:

JavaScript

from here

But it does not do code highlighting and I want either a numpy or cv2 based solution.

How can I do it?

Advertisement

Answer

You can use pygments library to convert to HTML with highlighting and then convert the HTML to an image.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement