Hi everyone,
Trying to assign thumbnail images to existing FGCD metadata of feature classes in a geodatabase. The thumbnail images are in .jpg format and are on a local drive with a prefix matching the name of the feature class (the gdb is also on the local drive).
Example: feature class is Zip_Code_Tabulation_Areas and corresponding thumbnail image is Zip_Code_Tabulation_Areas_thumbnail.jpg
Trying to follow the documentation from https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm
import arcpy
import os
arcpy.env.overwriteOutput = True
from arcpy import metadata as md
# set the workspace
arcpy.env.workspace = r"D:\gisdata\rigis_download\rigis_services_SPF_2023.gdb"
# create the list of feature classes within the local geodatabase
fc_list = arcpy.ListFeatureClasses()
# iterate through each feature class to assign a thumbnail to the metadata
for each in fc_list:
try:
print('the feature class is ' + each)
thumbnailImage = r"D:\gisdata\rigis_download\thumbnails" + "\\" + each + "_thumbnail.jpg"
print('the thumbnail is ' + thumbnailImage)
tgt_item_md = md.Metadata(each)
tgt_item_md.thumbnailUri(thumbnailImage)
tgt_item_md.save()
except:
print('this did not work')
print('done')
It never works for any of the feature classes and sometimes actually deletes the jpgs from the directory all together. Error is:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
TypeError: 'NoneType' object is not callable
Tried multiple variations of what I ~think~ is the critical piece to no avail:
tgt_item_md.thumbnailUri(thumbnailImage)
tgt_item_md.thumbnailUri = thumbnailImage
I "think" it may be because the variable thumbnailImage is just a string, and not the image itself? I am not proficient enough in python to figure out how to create a variable of the actual image?
Although the documentation implies it can be a path as a string:
| thumbnailUri (Read and Write) | A local or network path, or a URL, to a graphic file that describes and helps to identify the item. Derived from the Thumbnail that is extracted from the item's metadata. When setting this value, if a URL is provided, the identified file will be downloaded and incorporated into the item’s metadata. | String |
tgt_item_md.isReadOnly returns False so the metadata should be writeable.
Thank you for any help. I am probably missing something easy.