Estoy intentando automatizar el marcado de agua de miles de archivos TIFF georreferenciados con un script de Python. Los archivos tienen archivos tfwx world relacionados y archivos aux.xml. Cuando ejecuto el código la referenciación espacial parece estar corrupta. El tamaño de la celda del TIFF de salida parece ser 200 veces mayor. Luego puedo ejecutar arcpy.Rescale_management para recuperar su tamaño adecuado, pero siguen estando mal colocadas. Soy un novato, así que me disculpo si esto es venir a través de vagos o ignorantes. He intentado varias soluciones sin suerte y sólo quiero asegurarme de que no me estoy perdiendo algo fácil.
Esta es una versión reducida del código que estoy utilizando:
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[0]
height = im.size[1]
# 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[0]-1, pos[1]-1)
shadow2 = (pos[0]-2, pos[1]-2)
shadow3 = (pos[0]+1, pos[1]+1)
shadow4 = (pos[0]+2, pos[1]+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)