Determine the height and width of an image
Hello everyone,
I would like to determine the height and width of an image.
I am currently at the stage where the image can be selected by the user and can also be saved on the server (server workflow). The image can then also be called up via a URL (png, jpg or tif).
My approach was to use a javascript function to determine the height and width. Unfortunately, for security reasons, it is not possible to create an object with “var img = new Image ()” in the workflow, otherwise it would work.
Does anyone have an idea how to determine the height and width?
The aim is to place the image with the correct aspect ratio on the screen at the end. At the moment it is not placed in the correct aspect ratio, because I am missing the height and width.
Many thanks for any help
Franco
-
I have just found the solution myself.
With a server workflow via “Get Image Metadata Activity” you can get the height and width.…but regardless, does anyone know how to create an object in javascript if the client workflow doesn't allow it (var img = new Image ())?
0 -
Hi Franco Di Bari ,
Thanks for your question. As you discovered, it's not possible to create certain types of JavaScript objects through workflow expressions. There are a few reasons for this.
First of all, for security reasons we took the precaution early on of only allowing a “whitelist” of trusted types and functions to be used. This has increased over time and will increase in future to include other types.
The other reason for limitations is that we want to ensure that everything that the workflow designer suggests to you in the expression editor works in both TypeScript and .NET, so that you can have a workflow that works in Web and also Mobile.
In order to support the Image constructor, we would need to be able to satisfy both of these criteria. I think the security concern is probably not an issue, but it might need a bit of work to translate to .NET. There is an equivalent class there, but the properties and methods may differ.
0 -
Hello Ken,
Thank you for the information. Now I understand the reason better. It would make things easier sometimes, but I do understand that sometimes there are constraints that need to be met.
0
Please sign in to leave a comment.
Comments
3 comments