I want to have a python script that creates a new image from the image data that is already embedded in the script itself
instead of just pasting the image data into my new script file (because it doesn’t work) ive decided to make a certain python script that reads in the data from the image on my desktop and stores it as a variable called “data”, then writes a new python script and incorporates the “data” variable in with it.
define The original image that resides on my desktop
original = “C:\users\joe\desktop\galaxy.png”
Open the original image and set its data as a variable called “data”
pic = open(original, “rb”)
data = pic.read()
set up the code for the new script which includes “data”
line1 = “image = open(‘image.png’, ‘w’)”
line2 = “image.write(” + “’” + data + “’” + “)”
line3 = “image.close()”
write the new code as a .py
newscript = open(“newscript.py”, “w”)
newscript.write(line1 + "
" + line2 + "
" + line3)
so the new script, which contains the binary data as “data” looks like this:
image = open(‘image.png’, ‘w’)
image.write(‘all that binary stuff from the image’)
but when I run the new script that has the image data stored in it I get this error:
“there is an error in your program
EOL while scanning string literal”