From 79a9a774ad12d1c905e8ebbfbc9b295cca767585 Mon Sep 17 00:00:00 2001 From: Hansly Saw <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 8 May 2022 20:55:48 +0800 Subject: [PATCH] Added image viewer feature. --- BlenderRender.ipynb | 64 +++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/BlenderRender.ipynb b/BlenderRender.ipynb index 662be24..9318224 100644 --- a/BlenderRender.ipynb +++ b/BlenderRender.ipynb @@ -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" + "

Utilities

" ] }, { @@ -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 -} \ No newline at end of file +}