Howdy!
As the title states, I have been working on a way to embed image data into the python code for portability reasons.
There have been methods in the past for me without maya using pyside, wxpython...etc
Along with base64 encodeing the file data into a string variable.
Considering the end user shouldn't need to install any theird party libraries, base64 encoding seemed a good fit.
Given a small png image, encoding with the following: (yeilding a string you can then copy/paste)
import base64
imageFile = "some image file path.extension"
imageData = '\\\n"""' + base64.encodestring(open(imageFile,"rb").read()) + '"""'
print imageData\
"""iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAA
BGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VG
AAAEGElEQVR42mJkYGBgBmJWIOaA0iA+JeAvEP8G4h8gGiCAWKCGCgCxJJTmIMIQRij9H4scyOAP
QPwcRAMEEAvUQEnPPY/OycvIMDAxEjadFaro9z9U82Hch0+eMGx3kTMCWQYQQCAL2EAuZ2JiYpiu
zsjw+Q8poYHqGpC93MAA9nnGxAANDTaAAGKBhjknSOTPPwaGO9/JD3wWoAWaXHAuyExmgABiQfEi
EH/9S74FbEwQM5ABQAChWPAXGIZf0FTs3H+YYevu/WC2t6sjg7ujLU4L2LFEOUAAsaALIPvg////
DJt37mOIKY0H85d0L2SwtrVhYGTEnhL+MUEciQwAAghvEP39+4/h3oOHDIz/FMB8EPvz738MzMzY
s8o/LD4ACCAWdAUfkFLR718Qztcvv+Bi737+YWBlw27Bb2bMOAAIIBZozgOnHV4gT58HIfn9+z8U
i0CgNCMTTPu7OTJs3LUfTBekxEKSDRMkmcK0g8wGCCCQBSDnffj37x9D2s3/DKxIwfsLasHP3xAL
RGWkGHIntIDZkwtqGJrWzGOoC0kCW6Rt68hgFx7DMPvZfwaQWdDc/AsggFigWfs5NOcJMFoFFjNw
C3hDwubDTiDb/cev3wxffvxlkFJRY7h06BVYCsS+d+otg4i0FENKVwtDR3QSw5X6BG+G//++IxUV
PwACiAVaMH0AW8TCxg4yPG/OPLAhk1KS3MGFy89fDK/e/2KQM49jePXsIVgOxH725jGDS3YLw4NT
z6HplPMyw4+vP5ALO4AAYgImxb9A/AOIPzBo2rwDqXt09gnD1cP3GJInQyz6+uMXw8cv3xke3boB
pmHsl+++Mlw/fYPh+8/fEAtUzd8CzXkNMgtq5l+AAGJCi3RmYAAu3DC9joFTRIzh+sm7DB718xge
vfrM8P3HT+wYaPgPRlaEfjQAEEDoFjD8f/W4muHvn3VbevMYeOSUGe5eesDw4fNfhh/ff2Lgn7/+
Mvz6x8LwE2EBRg4ECCAmLJXFj/+vnzYALdn36M5xBg5ZBYbfPGIMv1h5GH4CHfgTmFXB+B8jkA8y
nIXhKxMbzuIDIICwWfAViN8y/Py+7Maq2QwsskB/S0ky/OaVYvjNJcbwm1OY4Re7IMNvDiEwzSgo
xvCNjRenBQABhGLB/0t7/0Hzxcf/n97tY/jze9P50iQGFiVQlSTA8JtfFogVGf4IKgFpoM/4ZBlY
lPkZrvYlA7Pw3+XYajiAAGIEFWgYgnrOoOQLcpYko4hUNwMLqxdf9zxEgYUMfjIwfKpLYvj/4iHI
GS+BjvyGLA0QQCx4Km6Qwjf/3zyrBlrC+Kk0yRN3Nf9nDTRof6NLAQQQVh9AfcEEq06BWAyKedEc
BcpM74H4KcgxIEugwQwHAAGE0wJqAYAAAwBJB7SMBNomvQAAAABJRU5ErkJggg==
"""
I've used a few methods to decode this data in order to display in an image object, the closest idea as of right now is to use the tempfile module. Writing the image data to disk (with a known file path), then feeding said images path to cmds.image( image=filePath )
To no avail as of right now.
the data does no appear in my temp directory
Has any one else tried something similar?