Skip to main content
Biswa
Gold ⭐️
Dec 13, 2019 6:18 AM UTC
Solved

Select attribute with wildcard character

Hi,

I am extracting image width and image height using ExtractImageMetadata processor and comparing the Image Width and Image Height with threshold value. If it is greater than the threshold value than I will resize the image. Attribute names, Image Width and Image Height is different for different image formats.

 

e.g. For .png

PNG-IHDR.Image Height
PNG-IHDR.Image Width

 

For .jpg

JPEG.Image Height 

JPEG.Image Width

I want to have a regular expression something like below. So that irrespective of image format, I will be able to compare the Image Width and Image Height.

${"*Image Width":ge(1000):and(${"*Image Height":ge(1000)})}

 

Above regular expression is not working as expected. Any input will be helpful.

 

Thanks and Regards,

Biswa

 

 

MattWho
MattWhoAnswer
Titanium ⭐️⭐️
Dec 13, 2019 2:37 PM UTC

@Biswa 

 

NiFi's Expression Language (EL) will not support wildcard in attribute subject names.

I suggest you pull height and width in to a set of standardized attribute names:

Use the UpdateAttribute processor advanced UI to create some rules.  Fore example:
if "PNG-IHDR.Image Height" attribute exists, create new attribute "image height" with value from "PNG-IHDR.Image Height"

Do the same for the other 3 unique attribute names, thus resulting in a static attribute subject names for height and width for use later in your flow for comparison/routing decisions.

Hope this helps,

Matt

3 replies

MattWho
Titanium ⭐️⭐️
MattWhoAnswer
Titanium ⭐️⭐️
Dec 13, 2019 2:37 PM UTC

@Biswa 

 

NiFi's Expression Language (EL) will not support wildcard in attribute subject names.

I suggest you pull height and width in to a set of standardized attribute names:

Use the UpdateAttribute processor advanced UI to create some rules.  Fore example:
if "PNG-IHDR.Image Height" attribute exists, create new attribute "image height" with value from "PNG-IHDR.Image Height"

Do the same for the other 3 unique attribute names, thus resulting in a static attribute subject names for height and width for use later in your flow for comparison/routing decisions.

Hope this helps,

Matt

Translate
mfolco
Silver ⭐️⭐️
Jun 1, 2021 1:12 AM UTC

@MattWho 
would it be possible to share this configuration inside the advanced UI?
I'm having the same problem and I haven't found any way to check if the "Image Height" exists.
Not even a way to get the value.

Translate
mfolco
Silver ⭐️⭐️
Jun 1, 2021 3:13 AM UTC

I managed to solve the problem.
Below is an example of what I used to get the value of the attributes using the advanced part of the "UpdateAttribute".

mfolco_1-1622517208748.png

 

Hope this helps.

Translate