I am trying to automate the watermarking of thousands of georeferenced TIFF files with a Python script. The files have related tfwx world files and aux.xml files. When I run the code the spatial referencing seems to be corrupted. The cell size of the output TIFF seems to be 200x larger. I can then run arcpy.Rescale_management to recover their proper size, but they are still incorrectly placed. I am a noob, so I apologize if this is coming across as vague or ignorant. I have tried several workarounds without luck and I just want to make sure I'm not missing something easy.
Here is a stripped down version of the code I am using:
from PIL import Image, ImageDraw, ImageFont import os, sys, arcpy from arcpy import env env.workspace = r'D:\mbrush\scratch\tools\CalTrans\testing' workspace = env.workspace env.overwriteOutput = True # copywrite logo and name text = u'\u00a9' + ' Company Name' # iterate through tiffs and watermark for file in os.listdir(workspace): if file.endswith('.tif'): # open image im = Image.open(workspace + '\\' + file) # open image for drawing drawing = ImageDraw.Draw(im) # determine height and width of image width = im.size height = im.size # determine where to place the text posx = width - (500) posy = height - (80) pos = (posx, posy) # set font size fontsize = 33 # define outfile to overwrite original img_out = workspace + '\\' + file # choose font font = ImageFont.truetype(r'C:/Windows/Fonts/Arial/arial.ttf', fontsize) # create text shadow shadow = (pos-1, pos-1) shadow2 = (pos-2, pos-2) shadow3 = (pos+1, pos+1) shadow4 = (pos+2, pos+2) drawing.text(shadow, text, fill=(200,200,200), font=font) drawing.text(shadow2, text, fill=(255,255,255), font=font) drawing.text(shadow3, text, fill=(200,200,200), font=font) drawing.text(shadow4, text, fill=(255,255,255), font=font) # draw watermark drawing.text(pos, text, fill=(3, 8, 12), font=font) # save image im.save(img_out)