Commits

Anonymous committed 519ae78

Add carteisan generator

Comments (0)

Files changed (1)

Gimp/watermarkBatchTools.py

 '''
 import os, glob, re
 import gettext
+import itertools
 from gimpfu import *
 from random import randint
 from math import radians
 	num_images=0
 		
 	if len(gimp.image_list()) > 0 :
-		imglayer= gimp.image_list()[0]
+		imglayer = gimp.image_list()[0]
 		imgwidth = pdb.gimp_image_width(imglayer)
 		imgheight = pdb.gimp_image_height(imglayer)
 		
 		pdb.gimp_image_add_layer(imglayer,texture_layer, 0)
 		pdb.gimp_drawable_fill(texture_layer, 3)
 		
-		for w in range(0,int(gridx)):
-			for h in range(0,int(gridy)):
-				if imgwidth > imgheight:
-					font_size = round(imgwidth * font_s / 1000)
-				else:
-					font_size = round(imgheight * font_s / 1000)
+		for w,h in itertools.product(range(0,int(gridx)), range(0,int(gridy))):
+			if imgwidth > imgheight:
+				font_size = round(imgwidth * font_s / 1000)
+			else:
+				font_size = round(imgheight * font_s / 1000)
 
-				textBoxWidth,textBoxHeight,fontAscent,fontDescent = pdb.gimp_text_get_extents_fontname(copyright, font_size, PIXELS, fontname)
-				
-				x_cord = round((w * imgwidth) / gridx)
-				x_cord_1 =  round(((w + 1) * imgwidth) / gridx) #Next Element 
-				y_cord =  round((h * (imgheight - textBoxHeight)) / gridy)
-				y_cord_1 =  round(((h + 1) * (imgheight - textBoxHeight)) / gridy) #Next Element
-				
-				x =  round(((x_cord + x_cord_1) / 2)) - font_size
-				y =  round((y_cord + y_cord_1) / 2)
-				
-				texture = pdb.gimp_text_fontname( imglayer,texture_layer,x,y,copyright,-1,True,font_size,PIXELS,fontname)
-				pdb.gimp_text_layer_set_color(texture, fontcolor)
-				texture_layer = pdb.gimp_rotate(texture, True, radians(angle*-1))
+			textBoxWidth,textBoxHeight,fontAscent,fontDescent = pdb.gimp_text_get_extents_fontname(copyright, font_size, PIXELS, fontname)
+			
+			x_cord = round((w * imgwidth) / gridx)
+			x_cord_1 =  round(((w + 1) * imgwidth) / gridx) #Next Element 
+			y_cord =  round((h * (imgheight - textBoxHeight)) / gridy)
+			y_cord_1 =  round(((h + 1) * (imgheight - textBoxHeight)) / gridy) #Next Element
+			
+			x =  round(((x_cord + x_cord_1) / 2)) - font_size
+			y =  round((y_cord + y_cord_1) / 2)
+			
+			texture = pdb.gimp_text_fontname( imglayer,texture_layer,x,y,copyright,-1,True,font_size,PIXELS,fontname)
+			pdb.gimp_text_layer_set_color(texture, fontcolor)
+			texture_layer = pdb.gimp_rotate(texture, True, radians(angle*-1))
 	else:
 		pdb.gimp_message( _("There is no layer to start") )
 
 				imgwidth = pdb.gimp_image_width(img)
 				imgheight = pdb.gimp_image_height(img)
 				
-				for w in range(0,int(gridx)):
-					for h in range(0,int(gridy)):
-						texture_layer = gimp.Layer(img, _("Texture"), imgwidth,imgheight,RGBA_IMAGE,opacity,NORMAL_MODE)
-						pdb.gimp_image_undo_disable(img)
-						pdb.gimp_image_add_layer(img,texture_layer, 0)
-						pdb.gimp_drawable_fill(texture_layer, 3)
-						
-						if imgwidth > imgheight:
-							font_size = round(imgwidth * font_s / 1000)
-						else:
-							font_size = round(imgheight * font_s / 1000)
+				for w,h in itertools.product(range(0,int(gridx)), range(0,int(gridy))):
+					texture_layer = gimp.Layer(img, _("Texture"), imgwidth,imgheight,RGBA_IMAGE,opacity,NORMAL_MODE)
+					pdb.gimp_image_undo_disable(img)
+					pdb.gimp_image_add_layer(img,texture_layer, 0)
+					pdb.gimp_drawable_fill(texture_layer, 3)
+					
+					if imgwidth > imgheight:
+						font_size = round(imgwidth * font_s / 1000)
+					else:
+						font_size = round(imgheight * font_s / 1000)
 
-						textBoxWidth,textBoxHeight,fontAscent,fontDescent = pdb.gimp_text_get_extents_fontname(copyright, font_size, PIXELS, fontname)
-						
-						x_cord = round((w * imgwidth) / gridx)
-						x_cord_1 =  round(((w + 1) * imgwidth) / gridx) #Next Element 
-						y_cord =  round((h * (imgheight - textBoxHeight)) / gridy)
-						y_cord_1 =  round(((h + 1) * (imgheight - textBoxHeight)) / gridy) #Next Element
-						
-						x =  round(((x_cord + x_cord_1) / 2)) - font_size
-						y =  round((y_cord + y_cord_1) / 2)
-						
-						texture_layer = pdb.gimp_text_fontname( img,texture_layer,x,y,copyright,0,True,font_size,PIXELS,fontname)
-						pdb.gimp_text_layer_set_color(texture_layer, fontcolor)
-						texture_layer = pdb.gimp_rotate(texture_layer, True, radians(angle*-1))
-						texture_layer = pdb.gimp_image_merge_visible_layers(img,CLIP_TO_IMAGE)	
+					textBoxWidth,textBoxHeight,fontAscent,fontDescent = pdb.gimp_text_get_extents_fontname(copyright, font_size, PIXELS, fontname)
+					
+					x_cord = round((w * imgwidth) / gridx)
+					x_cord_1 =  round(((w + 1) * imgwidth) / gridx) #Next Element 
+					y_cord =  round((h * (imgheight - textBoxHeight)) / gridy)
+					y_cord_1 =  round(((h + 1) * (imgheight - textBoxHeight)) / gridy) #Next Element
+					
+					x =  round(((x_cord + x_cord_1) / 2)) - font_size
+					y =  round((y_cord + y_cord_1) / 2)
+					
+					texture_layer = pdb.gimp_text_fontname( img,texture_layer,x,y,copyright,0,True,font_size,PIXELS,fontname)
+					pdb.gimp_text_layer_set_color(texture_layer, fontcolor)
+					texture_layer = pdb.gimp_rotate(texture_layer, True, radians(angle*-1))
+					texture_layer = pdb.gimp_image_merge_visible_layers(img,CLIP_TO_IMAGE)	
 						
 				outfilepathname = outdirectory +os.sep + os.path.basename(infilepathname)
 				pdb.gimp_file_save(img,img.layers[0],outfilepathname,outfilepathname)