Browse Source

Add placeholder thumbnail to package

This kitten really likes boxes of all kinds: Cardboard and plastic boxes for sure, but also digital boxes such as the UFP.

Contributes to issue CURA-4872.
Ghostkeeper 7 years ago
parent
commit
8bd351c133
2 changed files with 6 additions and 1 deletions
  1. 6 1
      plugins/UFPWriter/UFPWriter.py
  2. BIN
      plugins/UFPWriter/kitten.png

+ 6 - 1
plugins/UFPWriter/UFPWriter.py

@@ -3,6 +3,7 @@
 
 from charon.VirtualFile import VirtualFile #To open UFP files.
 from charon.OpenMode import OpenMode #To indicate that we want to write to UFP files.
+import os.path #To get the placeholder kitty icon.
 
 from UM.Mesh.MeshWriter import MeshWriter #The writer we need to implement.
 from UM.PluginRegistry import PluginRegistry #To get the g-code writer.
@@ -19,4 +20,8 @@ class UFPWriter(MeshWriter):
         archive.addRelation(target = "/3D/model.gcode", file_type = "http://schemas.ultimaker.org/package/2018/relationships/gcode")
 
         #Store the thumbnail.
-        #TODO
+        #TODO: Generate the thumbnail image. Below is just a placeholder.
+        archive.addContentType(extension = "png", mime_type = "image/png")
+        thumbnail = archive.getStream("/Metadata/thumbnail.png")
+        thumbnail.write(os.path.join(os.path.basename(__file__), "kitten.png"))
+        archive.addRelation(target = "/Metadata/thumbnail.png", file_type = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail")

BIN
plugins/UFPWriter/kitten.png