[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1235] branches/ io_import_gimp_to_3d_layers.py: Changed name from Premultiply Images to Premultiply Alpha

Daniel Salazar zanqdo at gmail.com
Sun Dec 5 18:52:00 CET 2010


Revision: 1235
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1235
Author:   zanqdo
Date:     2010-12-05 18:52:00 +0100 (Sun, 05 Dec 2010)

Log Message:
-----------
Changed name from Premultiply Images to Premultiply Alpha
Added asset handling

Docs here http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/File_I-O/GIMPto3DLayers

Modified Paths:
--------------
    branches/io_import_gimp_to_3d_layers.py

Modified: branches/io_import_gimp_to_3d_layers.py
===================================================================
--- branches/io_import_gimp_to_3d_layers.py	2010-12-05 15:36:53 UTC (rev 1234)
+++ branches/io_import_gimp_to_3d_layers.py	2010-12-05 17:52:00 UTC (rev 1235)
@@ -36,7 +36,7 @@
 """
 
 def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
-	LayerScale, OpacityMode, PremulImages, ShadelessMats,\
+	LayerScale, OpacityMode, PremulAlpha, ShadelessMats,\
 	SetCamera, SetupCompo, GroupUntagged):
 	
 	#-------------------------------------------------
@@ -44,7 +44,24 @@
 	XCFInfo = 'xcfinfo'
 	XCF2PNG = 'xcf2png'
 	#-------------------------------------------------
-	PathRaw = Path
+	
+	#Folder = '['+File.rstrip('.xcf')+']'+'_images/'
+	Folder = 'images_'+'['+File.rstrip('.xcf')+']/'
+	
+	if bpy.data.is_dirty:
+		PathSaveRaw = Path+Folder
+		PathSave = PathSaveRaw.replace(' ', '\ ')
+		print ('SaveRaw: ', PathSaveRaw)
+		print ('Save: ', PathSave)
+		os.system('mkdir %s' % PathSave)
+	else:
+		PathSave = bpy.data.filepath
+		RSlash = PathSave.rfind('/')
+		PathSaveRaw = PathSave[:RSlash+1]+Folder
+		PathSave = PathSaveRaw.replace(' ', '\ ')
+		os.system('mkdir %s' % PathSave)
+		PathSaveRaw = bpy.path.relpath(PathSaveRaw)+'/'
+		
 	Path = Path.replace(' ', '\ ')
 	#-------------------------------------------------
 	# INFO
@@ -105,7 +122,7 @@
 		Opacity = ' --percent 100'
 	for Layer in PNGs:
 		CMD = '%s -C %s%s -o %s%s.png "%s"%s' %\
-		(XCF2PNG, Path, File, Path, Layer['LayerName'].replace(' ', '_'), Layer['LayerName'], Opacity)
+		(XCF2PNG, Path, File, PathSave, Layer['LayerName'].replace(' ', '_'), Layer['LayerName'], Opacity)
 		os.system(CMD)
 	
 	#-------------------------------------------------
@@ -130,7 +147,7 @@
 		Render.resolution_x = ResX
 		Render.resolution_y = ResY
 		Render.resolution_percentage = 100
-	if PremulImages: Render.alpha_mode = 'PREMUL'
+	if PremulAlpha: Render.alpha_mode = 'PREMUL'
 	
 	#-------------------------------------------------
 	# 3D VIEW SETTINGS
@@ -236,8 +253,8 @@
 		
 		Img = bpy.data.images.new(NameShort)
 		Img.source = 'FILE'
-		if PremulImages: Img.use_premultiply = True
-		Img.filepath = '%s%s.png' % (PathRaw, Name)
+		if PremulAlpha: Img.use_premultiply = True
+		Img.filepath = '%s%s.png' % (PathSaveRaw, Name)
 		
 		Tex.image = Img
 		
@@ -405,7 +422,7 @@
 		description="Add Viewer nodes to each Mix node",
 		default=True)
 	
-	PremulImages = BoolProperty(name="Premuliply Image",
+	PremulAlpha = BoolProperty(name="Premuliply Alpha",
 		description="Set Image and Render settings to premultiplied alpha",
 		default=True)
 
@@ -452,7 +469,7 @@
 		box.prop(self, 'OpacityMode', icon='GHOST')
 		if self.OpacityMode == 'COMPO' and self.SetupCompo == False:
 			box.label('Tip: Enable Node Compositing', icon='INFO')
-		box.prop(self, 'PremulImages', icon='IMAGE_RGB_ALPHA')
+		box.prop(self, 'PremulAlpha', icon='IMAGE_RGB_ALPHA')
 		box.prop(self, 'ShadelessMats', icon='SOLID')
 		box.prop(self, 'LayerOffset')
 		box.prop(self, 'LayerScale')
@@ -473,7 +490,7 @@
 		LayerViewers = self.LayerViewers
 		MixerViewers = self.MixerViewers
 		OpacityMode = self.OpacityMode
-		PremulImages = self.PremulImages
+		PremulAlpha = self.PremulAlpha
 		ShadelessMats = self.ShadelessMats
 		SetCamera = self.SetCamera
 		SetupCompo = self.SetupCompo
@@ -484,7 +501,7 @@
 		# Call Main Function
 		if filename.endswith('.xcf'):
 			main(filename, directory, LayerViewers, MixerViewers, LayerOffset,\
-				LayerScale, OpacityMode, PremulImages, ShadelessMats,\
+				LayerScale, OpacityMode, PremulAlpha, ShadelessMats,\
 				SetCamera, SetupCompo, GroupUntagged)
 		else:
 			self.report({'ERROR'},"Selected file wasn't an .XCF")




More information about the Bf-extensions-cvs mailing list