예제 #1
0
    def _exportLayers(self, parentNode, fileFormat, parentDir):
        """ This method get all sub-nodes from the current node and export then in
            the defined format."""

        for node in parentNode.childNodes():
            newDir = ''
            if node.type() == 'grouplayer':
                newDir = os.path.join(parentDir, node.name())
                self.mkdir(newDir)
            elif (not self.exportFilterLayersCheckBox.isChecked()
                  and 'filter' in node.type()):
                continue
            elif (self.ignoreInvisibleLayersCheckBox.isChecked()
                  and not node.visible()):
                continue
            else:
                nodeName = node.name()
                _fileFormat = self.formatsComboBox.currentText()
                if '[jpeg]' in nodeName:
                    _fileFormat = 'jpeg'
                elif '[png]' in nodeName:
                    _fileFormat = 'png'

                layerFileName = '{0}{1}/{2}.{3}'.format(
                    self.directoryTextField.text(), parentDir, node.name(),
                    _fileFormat)
                node.save(layerFileName, self.xResSpinBox.value(),
                          self.yResSpinBox.value(), krita.InfoObject())

            if node.childNodes():
                self._exportLayers(node, fileFormat, newDir)
예제 #2
0
    def exportDocument(document, fileName, timeOut=10000):
        """Attempts to export the document for timeOut milliseconds"""

        succeed = False

        currentTime = 0
        while currentTime < timeOut:
            succeed = document.exportImage(fileName, krita.InfoObject())
            if succeed:
                break
            time.sleep(0.5)
            currentTime = currentTime + 500

        return succeed
예제 #3
0
    def _exportNodeFrame(self, document, node, fileFormat, frameNumber,
                         parentDir):

        DuKRIF_animation.setCurrentFrame(document, frameNumber)

        if node.bounds().width() == 0:
            frameInfo = DuKRIF_json.createKeyframeInfo("_blank", "",
                                                       frameNumber)
            return frameInfo

        imageName = '{0}_{1}'.format(node.name(),
                                     DuKRIF_utils.intToStr(frameNumber))
        imagePath = '{0}/{1}.{2}'.format(parentDir, imageName, fileFormat)
        imageFileName = imageFileName = self.getAbsolutePath(imagePath)

        if self.cropToImageBounds.isChecked():
            bounds = QRect()
        else:
            bounds = QRect(0, 0, self.rectWidthSpinBox.value(),
                           self.rectHeightSpinBox.value())

        opacity = node.opacity()
        node.setOpacity(255)

        node.save(imageFileName,
                  self.resSpinBox.value() / 72.,
                  self.resSpinBox.value() / 72., krita.InfoObject(), bounds)

        node.setOpacity(opacity)

        # TODO check if the file was correctly exported. The Node.save() method always reports False :/

        frameInfo = DuKRIF_json.getKeyframeInfo(
            document, node, frameNumber,
            not self.cropToImageBounds.isChecked())
        frameInfo['fileName'] = imagePath

        return frameInfo