Select to view content in your preferred language

ArcGIS Pro 3.1.2 CIMPictureGraphic PictureURL is null

286
0
06-30-2023 03:20 AM
marco_vertigis
New Contributor III

I am currently trying to detect if a PictureElement contains an image and want to save it temporarily to a file.

The PictureElement owns a "SourceUrl" and has a "ReferenceURI" set. When viewing the Layout in a LayoutView the image is displayed fine. But unfortunately I am currently not able to fetch the Base64String of that image. The PictureURL is just null. I think thats a bug. The code doc says that this property should provide it.

 

var definition = element.GetDefinition();
if (definition is CIMGraphicElement graphicElement && graphicElement.Graphic is CIMPictureGraphic pictureGraphic)
{
   var pictureBase64 = pictureGraphic.PictureURL; // is null
   var picturePath = pictureGraphic.SourceURL; // has a path
   //  pictureGraphic._referenceURI has a path aswell

   byte[] pictureArray = Convert.FromBase64String(pictureBase64);
   var fileExtension = Path.GetExtension(picturePath);
   var tempPicturePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.{fileExtension}");
   File.WriteAllBytes(tempPicturePath, pictureArray);
   return tempPicturePath;
 }

 

 

The layout was originally fetched from a portal and then imported into Pro. So the SourceURL does not exist on the machine and is pointing to the path which was valid when the layout got published.

 

Any help would be appreciated.

0 Kudos
0 Replies