Added image viewer feature.

This commit is contained in:
Hansly Saw 2022-05-08 20:55:48 +08:00 committed by GitHub
parent 6a668e8203
commit 79a9a774ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,8 +110,8 @@
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mStatus: \t\u001b[0mStarting render of file test.blend…\n",
"src/tcmalloc.cc:283] Attempt to free invalid pointer 0x7fc749c1e040 \n"
@ -149,7 +149,7 @@
" return False\n",
" else: \n",
" if configuration.blend_fileName == None: \n",
" raise ImportError(formatting.font.bold + 'Input Blender file name is missing. ' + formatting.clear + 'It is a required field. ')\n",
" raise ImportError(formatting.font.bold + 'The file name for the Blender file is missing. ' + formatting.clear + 'It is a required field. ')\n",
" else: \n",
" return True\n",
"\n",
@ -200,6 +200,8 @@
" else: \n",
" !blender -b {configuration.blend_fileName} -o ./output_ -E {configuration.renderer} -F {configuration.output_fileFormat} -x 1 -f {configuration.frame} --cycles-device {configuration.device}\n",
"\n",
" info.status('Render of file ' + configuration.blend_fileName + ' has completed.')\n",
"\n",
" if checkInvalidUploadProceed(): \n",
" start_render()\n",
"\n",
@ -212,16 +214,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Hk2D1RK3WqVV"
},
"outputs": [],
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"!blender -b $filename -o ./test_ -E $renderer -x 1"
"<h2>Utilities</h2>"
]
},
{
@ -251,8 +247,44 @@
}
],
"source": [
"from IPython.display import Image\n",
"Image(filename='./test_0001.png')"
"#@title Picture Viewer\n",
"#@title Configuration\n",
"class formatting:\n",
" clear = '\\033[0m'\n",
" class color: \n",
" purple = '\\033[95m'\n",
" cyan = '\\033[96m'\n",
" cyan_dark = '\\033[36m'\n",
" blue = '\\033[94m'\n",
" green = '\\033[92m'\n",
" yellow = '\\033[93m'\n",
" red = '\\033[91m'\n",
" class font:\n",
" bold = '\\033[1m'\n",
" underline = '\\033[4m'\n",
"\n",
"## Define screen functions. \n",
"def clear(): from IPython.display import clear_output; return clear_output()\n",
"\n",
"class fileViewer: \n",
" image_fileName = '' #@param {type: \"string\"}\n",
"\n",
"def fixFormatImage(): \n",
" ## Give file format of png if the user didn't give any. Of course they should put it. \n",
" if getExtension(fileViewer.image_fileName) == None: blend_fileName = (str(blend_fileName) + '.png')\n",
"\n",
"def preview(): \n",
" clear()\n",
" try: \n",
" from IPython.display import Image\n",
" Image(filename=fileViewer.image_fileName)\n",
" except:\n",
" info.err(formatting.font.bold + 'Could not preview the image. ' + formatting.clear + 'Make sure that the file is present and that the file format is correct.')\n",
"\n",
"def main(): \n",
" fixFormatImage(); preview()\n",
"\n",
"main()"
]
},
{
@ -262,9 +294,7 @@
"id": "Kvv_WzdIf1CA"
},
"outputs": [],
"source": [
""
]
"source": []
}
],
"metadata": {
@ -285,4 +315,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}