Book a Demo

Author Topic: Image asset details  (Read 5420 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Image asset details
« on: August 09, 2019, 04:19:47 pm »
I'm trying to figure out how image assets are stored in EA. I found in t_document that it has the image name and extension, and is associated with the main element GUID via the ElementID.
I'm looking for the image width and height if this is stored somewhere.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Image asset details
« Reply #1 on: August 09, 2019, 04:57:21 pm »
Can you enlighten me what you mean with image assets with some short example?

q.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Image asset details
« Reply #2 on: August 09, 2019, 05:38:45 pm »
Image asset is an alternative to the Image Library since version 13. It lets you manage images as model elements (image stereotyped artifacts) which can be very useful.
When you create a boundary, you can set an image asset as the alternative image.

Nizam wrote an article on the community site here: https://community.sparxsystems.com/tutorials/1280-prolaborate-architecture-using-ea15-image-assets
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Image asset details
« Reply #3 on: August 09, 2019, 06:31:36 pm »
Thanks. I never have used that. Probably because using images is something I expect to be used in Powerpoint thingies.

q.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Image asset details
« Reply #4 on: September 25, 2019, 04:43:20 pm »
To expand on this topic: I created via the API a boundary element + diagram object with an image asset set as the alt. image.
It works fine except I can't get the right dimensions to apply. I made an attempt to create the diagram object with unset top/bottom/right/left values (0). I was expecting the image asset default dimensions to apply, but this is not the case.
If I have the image asset using EA in the diagram, the appropriate T/B/R/L position values are populated.

Hence my initial question on finding the image asset dimensions which must be stored somewhere.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Image asset details
« Reply #5 on: September 25, 2019, 06:21:10 pm »
I don't think EA stores the image dimensions. I think they rather unmarshal the bincontent into an image in memory and get the dimensions like that.
I guess you'll have to replicate that process somehow.

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Image asset details
« Reply #6 on: October 08, 2019, 04:26:25 pm »
Hi Geert,

I tried to achieve what you suggested with the following C# code but I'm getting an incorrect parameter error

Code: [Select]
byte[] b64Img = Convert.FromBase64String(binContentNodes[j].SelectSingleNode("BinContent").InnerText);   
                                    Image image;
                                    using (MemoryStream ms = new MemoryStream(b64Img))
                                    {
                                        image = Image.FromStream(ms);
                                        // use -> image.Height & and image.Width
                                    }

Note: the bin content comes from t_document table.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Image asset details
« Reply #7 on: October 08, 2019, 04:35:52 pm »
I have no idea how to solve that, sorry.

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Image asset details
« Reply #8 on: October 09, 2019, 04:58:39 pm »
Hi Geert,
I found the issue that I had come across before: the base64 content is a zipped file with the image file.
Investigations continue to get the image dimensions.
Guillaume
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Image asset details
« Reply #9 on: October 09, 2019, 05:54:23 pm »
Hi Geert,
I found the issue that I had come across before: the base64 content is a zipped file with the image file.
Investigations continue to get the image dimensions.
Guillaume
That I have dealt with before.
Here's vbscript code that does the decoding, and unzipping:

Code: [Select]
'returns the string encoded int he base64 zipped contents of the given xml string
public function decodeBase64zippedXML(xmlString,nodeName)
Dim xDoc
Set xDoc = CreateObject( "MSXML2.DOMDocument" )
decodeBase64zippedXML = ""
'get the stereotype
'load the resultset in the xml document
If xDoc.LoadXML(xmlString) Then   
dim contentsNode
set contentsNode = xDoc.SelectSingleNode("//" & nodeName)
if not contentsNode is nothing then
dim contentsDecoded
contentsDecoded = contentsNode.nodeTypedValue
'save as temp zip file
dim tempZipFile
set tempZipFile = new BinaryFile
tempZipFile.FullPath = replace(getTempFilename, ".tmp",".zip")
tempZipFile.Contents = contentsDecoded
tempZipFile.Save
'unzip
dim tempFolderPath
tempfolderPath = unzip(tempZipFile.FullPath)
'get the text file
dim tempFolder
set tempFolder = new FileSystemFolder
tempFolder.FullPath = tempfolderPath
dim contentsFile
For each contentsFile in tempfolder.TextFiles
decodeBase64zippedXML = contentsFile.Contents
'there should be only one file
exit for
next
'delete the temp folder and temp file name
tempfolder.Delete
tempZipFile.Delete
end if
end if
end function
The unzip function:
Code: [Select]
function unzip (zipfile)
'The folder the contents should be extracted to.
dim extractTo, fso, filename, foldername
Set fso = CreateObject("Scripting.FileSystemObject")
filename = fso.GetFileName(zipfile)
foldername = Replace(FileName, ".zip", "")
extractTo = fso.GetParentFolderName(zipfile) & "\" & foldername

'If the extraction location does not exist create it.
If NOT fso.FolderExists(extractTo) Then
   fso.CreateFolder(extractTo)
End If

'Extract the contents of the zip file.
set objShell = CreateObject("Shell.Application")
dim filesInZip
set FilesInZip = objShell.NameSpace(zipfile).items
objShell.NameSpace(extractTo).CopyHere(filesInZip)

'clear objects
Set fso = Nothing
Set objShell = Nothing

'return folder name
unzip = extractTo
end function
In this case it unzips a txt file, which I load, but I guess you can replace that bit with loading an image file instead.

Geert