MCPcopy Create free account
hub / github.com/KDE/krita / save

Method save

plugins/python/batch_exporter/Infrastructure.py:285–362  ·  view source on GitHub ↗

Transform Node to a QImage processes the image, names it based on metadata, and saves the image to the disk.

(self, dirname="")

Source from the content-addressed store, hash-verified

283 self.node.setName(newName)
284
285 def save(self, dirname=""):
286 """
287 Transform Node to a QImage
288 processes the image, names it based on metadata, and saves the image to the disk.
289 """
290 img = nodeToImage(self)
291 meta = self.cfg["meta"].copy()
292
293 if self.inherit:
294 meta.update(self.inheritedMetadata())
295
296 meta.update(self.meta)
297
298 margin, scale = meta["m"], meta["s"]
299 extension, path = meta["e"], meta["p"][0]
300 bilinear = meta["b"][0].lower() not in ["no", "false"]
301
302 dirPath = (
303 exportPath(self.cfg, path, dirname, userDefined=True)
304 if path
305 else exportPath(self.cfg, pathFS(self.parent), dirname, userDefined=False)
306 )
307 dirPath.mkdir(parents=True, exist_ok=True)
308
309 def appendName(path, name, scale, margin, extension):
310 """
311 Appends a formatted name to the path argument
312 Returns the full path with the file
313 """
314 meta_s = self.cfg["meta"]["s"][0]
315 out = name
316 out += "_@{}x".format(scale / 100) if scale != meta_s else ""
317 out += "_m{:03d}".format(margin) if margin else ""
318 out += "." + extension
319 out = path / out
320 return out.as_posix()
321
322 it = product(scale, margin, extension)
323 # Below: scale for scale, margin for margin, extension for extension
324 it = starmap(
325 lambda scale, margin, extension: (
326 scale,
327 margin,
328 extension,
329 appendName(dirPath, self.name, scale, margin, extension),
330 ),
331 it,
332 )
333 it = starmap(
334 lambda scale, margin, extension, path: (
335 [int(1e-2 * wh * scale) for wh in self.size],
336 100 - scale != 0,
337 Qt.TransformationMode.SmoothTransformation if bilinear else Qt.TransformationMode.FastTransformation,
338 margin,
339 extension,
340 path,
341 ),
342 it,

Callers 11

paintMethod · 0.45
add_new_pageMethod · 0.45
slot_batch_resizeMethod · 0.45
createStandAloneACBFFunction · 0.45
_exportLayersMethod · 0.45
customPaintEventFunction · 0.45
saveCOAMethod · 0.45
saveCOASpriteSheetMethod · 0.45
paintMethod · 0.45
testDabMethod · 0.45

Calls 10

inheritedMetadataMethod · 0.95
nodeToImageFunction · 0.85
exportPathFunction · 0.85
pathFSFunction · 0.85
expandAndFormatFunction · 0.85
kickstartFunction · 0.85
mkdirMethod · 0.80
scaledMethod · 0.80
copyMethod · 0.45
updateMethod · 0.45

Tested by 1

testDabMethod · 0.36