# Embedding icons in GhPython code

**URL:** <https://discourse.mcneel.com/t/embedding-icons-in-ghpython-code/67604>\
**Category:** Grasshopper Developer\
**Created:** [July 25, 2018, 1:51pm UTC](https://discourse.mcneel.com/t/embedding-icons-in-ghpython-code/67604 "2018-07-25T13:51:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![piac](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/piac/32/673006_2.png) [@piac](https://discourse.mcneel.com/u/piac)\
**Post date:** [July 25, 2018, 1:51pm UTC](https://discourse.mcneel.com/t/embedding-icons-in-ghpython-code/67604/1 "2018-07-25T13:51:09Z")

</div>

Sometimes, when developing GHPY files, you might need to embed icons in the Python file. There are a few alternatives, but a simple one is to just create the picture from a string, if the picture is small by itself.

For example, this base-64 string:

```nohighlight
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAAAlwSFlz
AAAOwgAADsIBFShKgAAAAUpJREFUSEvtlL0rRWEAh4+vQRhsVtmsGNj8DRKLFWWQQSll8QeIUkrZ
DAYbq0WUksGuLAaLUcjX89z3fXW77j2cmzuo+9TT+zvvqfd3Pt5zsib10hPHRGccKymf74pjLsP4
hB+4in34HI/fcAjF45c4bqHnzHuYywIuhviNOVwJsbTYYIjZA46EmN1ia4jV8ZZ38QxHnQCv8BFd
dM0JMCdu4ihX2B1iPjN4ghO46QTMYip4j6MUKthGr07ncQDT83XRandQmX+8g15sC/GLWrvo/zEW
x4axg+MhNoY/K/CLdpv6Vbt71lHKCzbQHeb5KSeKYMFdiCXSVkwFk3jhBPheTkP8PRYchljiEvsx
FSyjpdd4jsdYCAv8ryRcrAVTwTT6iOrGgnt8RRdfQil/BwfoOfVdFMKCI2xHr7wWHeiXXxgL9kNs
0lCy7BP8OEoIkC0vEAAAAABJRU5ErkJggg==

```

can be parsed to this image:

* * *

![sample](https://global.discourse-cdn.com/mcneel/original/3X/c/c/cc118bcd02f34737fb743a91ca1e5c1e695ea902.png) , a 24x24 pixel png icon.

* * *

This definition translates the bitmap representation to the text representation, and back.

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/9/2/928531a208da93dbc64a84862dd817c21927aca6.png)

This definition was made [by request here](https://discourse.mcneel.com/t/how-to-add-grasshopper-library-icon-in-ghpython-compiled-ghpys/67427/9).

[icon-to-text-for-python.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/d/a/daabcfe8c53c1ace00d66417093234c08cce2c9c.gh) (12.2 KB)

Giulio

–  
Giulio Piacentino  
for Robert McNeel & Associates  
[giulio@mcneel.com](mailto:giulio@mcneel.com)
