Export JPEG Files with each LayerSet (Photoshop Python with PyQt)


/ Published in: Python
Save to your folder(s)

Photoshop python script
export multiple files with each layerSet


Copy this code and paste it in your HTML
  1. import sys
  2. from PyQt4.QtGui import *
  3. import comtypes.client
  4.  
  5. class LayerSetsExporter(QWidget):
  6.  
  7. def __init__(self, parent = None):
  8. super(LayerSetsExporter, self).__init__(parent)
  9. self.createLayout()
  10. self.createConnection()
  11.  
  12. def setLayerSetsVisible(self, layerSets, state):
  13. for layerSet in layerSets:
  14. layerSet.visible = False
  15.  
  16. def processRun(self):
  17. outputPath = 'D:/Python/Temp/'
  18.  
  19. app = comtypes.client.CreateObject('Photoshop.Application')
  20. doc = app.activeDocument
  21.  
  22. optionJpg = comtypes.client.CreateObject('Photoshop.JPEGSaveOptions')
  23. optionJpg.quality = 8
  24.  
  25. count = 0
  26. layerSets = doc.layerSets
  27. for layerSet in layerSets:
  28. self.setLayerSetsVisible(layerSets, False)
  29. layerSet.visible = True
  30. doc.saveAs(outputPath + str(count) + '.jpg', optionJpg, True)
  31. count += 1
  32.  
  33. def createLayout(self):
  34. self.btnRun = QPushButton('&Run')
  35. layout = QVBoxLayout()
  36. layout.addWidget(self.btnRun)
  37.  
  38. self.resize(200,100)
  39. self.setWindowTitle('PS LayerSets Exporter')
  40. self.setLayout(layout)
  41.  
  42. def createConnection(self):
  43. self.btnRun.clicked.connect(self.processRun)
  44.  
  45. qApp = QApplication(sys.argv)
  46.  
  47. exporter = LayerSetsExporter()
  48. exporter.show()
  49.  
  50. qApp.exec_()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.