Skip to main content

Hi,

Does anybody have any experience writing GDB metadata images into SDE?

I can update just about anything but inserting an image to the item description needs to be in a specific ESRI binary format (EsriPropertyType="PictureX") and the AttributeFileReader transformer does not support this encoding type.

 

Cheers,

 

Itay

Have you tried converting the binary image file (jpg, probably) contents to Base64 with the BinaryEncoder? 

Not tested, but inspired by the following code found on an Esri forum post.

import xml.etree.ElementTree as ET
import base64
...
with open(jpgFile, "rb") as img_file:
  strEncoded = base64.b64encode(img_file.read()) # Create the needed thumbnail xml element 
  attrib = {'EsriPropertyType':'PictureX'} 
  subEl = ET.SubElement(root,'Binary') 
  subEl = ET.SubElement(subEl,'Thumbnail') 
  subEl = ET.SubElement(subEl,'Data', attrib) 
  subEl.text = strEncoded

 


Have you tried converting the binary image file (jpg, probably) contents to Base64 with the BinaryEncoder? 

Not tested, but inspired by the following code found on an Esri forum post.

import xml.etree.ElementTree as ET
import base64
...
with open(jpgFile, "rb") as img_file:
  strEncoded = base64.b64encode(img_file.read()) # Create the needed thumbnail xml element 
  attrib = {'EsriPropertyType':'PictureX'} 
  subEl = ET.SubElement(root,'Binary') 
  subEl = ET.SubElement(subEl,'Thumbnail') 
  subEl = ET.SubElement(subEl,'Data', attrib) 
  subEl.text = strEncoded

 

Hi @david_r​ ,

Thanks for the tip, unfortunatly the BinaryEncoder does 'something' but the image is not displayed correctly in AcrCatalog: 

imageand using python is not an option.


Hi @david_r​ ,

Thanks for the tip, unfortunatly the BinaryEncoder does 'something' but the image is not displayed correctly in AcrCatalog:

imageand using python is not an option.

The Python code was mostly to show the context.

Are you able to fix the thumbnail in ArcCatalog and export the XML as a template? How does that compare to what you're generating?


Hi @david_r​ ,

Thanks for the tip, unfortunatly the BinaryEncoder does 'something' but the image is not displayed correctly in AcrCatalog:

imageand using python is not an option.

Hi @david_r​ ,

I have done some more investigating and managed to insert the image correctly into the SDE metadata as opposed to previous attempts of replacing the image.


Hi @david_r​ ,

Thanks for the tip, unfortunatly the BinaryEncoder does 'something' but the image is not displayed correctly in AcrCatalog:

imageand using python is not an option.

Hi itay,

 

I am trying to do the same thing, do you have any information on how you achieved it?

 

Thanks, :)


Hi @david_r​ ,

Thanks for the tip, unfortunatly the BinaryEncoder does 'something' but the image is not displayed correctly in AcrCatalog:

imageand using python is not an option.

As mentioned converting the image into base64 with the BinaryEncoder.


Hi @david_r​ ,

Thanks for the tip, unfortunatly the BinaryEncoder does 'something' but the image is not displayed correctly in AcrCatalog:

imageand using python is not an option.

Hmm ok, I've tried that and my blob comes out exactly the same as before no matter what I do. Was there anything else I might be missing?

 

Update: Just figured it out 🙂 thanks!!


Reply