How to Resize Email Image Attachments in Power Automate

Cloudmersive
5 min read2 days ago

--

Resizing image attachments is one of the many email automation workflows we can accomplish in Power Automate.

Using the Office 365 Outlook connector in conjunction with the Cloudmersive Image Processing connector, we can pull image attachments directly from specific inbound (or outbound) emails and conform them to pre-set height and width specifications.

Potential hangups with image resizing workflows

In some cases, resizing images can add bulk to the original file, and that’s worth keeping in mind if we’re planning to use the resulting images on web pages or other landing pages with optimized load times.

Additionally, if the image files we’re processing are too large (> 3.5 mb), our flow might fail from the get-go.

Barring those issues, if we’re regularly getting reasonably sized JPG and PNG images as part of seme repetitive business process, we can save ourselves time by automating the image resizing process.

Walkthrough: resize email image attachments

Below, we’ll walk through a quick example Automated cloud flow in Power Automate that 1) retrieves attachments from emails sent by a specific sender, 2) checks if the images are PNG or JPG format, 3) resizes the images, and 4) saves the resized images in a SharePoint folder.

We’ll start by creating an Automated cloud flow using the When a new email arrives (V3) trigger action from the Office 365 Outlook connector.

We’ll configure our trigger action to only run when emails come from a specific sender AND contain attachments. We’ll also elect to include the attachments in our workflow.

Next, we’ll add a Condition control to our flow.

We’ll configure our Condition to check if the attachment name value (adjusted to lowercase letters using the toLower function in this example) contains a .png, .jpg, or .jpeg extension.

Selecting the attachment name value places our Condition in a For each control, as we can see above.

In the True branch of our condition, we’ll add our image resizing action.

To find this action, we’ll search for Cloudmersive connectors in the Power Automate connector library, and we’ll locate the Image Processing connector with the yellow logo.

From the actions list, we’ll select the Resize an image action.

We’ll then create our Image Processing connection using a free Cloudmersive API key. We can get a free API key by visiting the Cloudmersive website and creating a free account (free API keys allow up to 800 API calls each month with no additional commitments).

Once our connection is saved, we’ll configure the following parameters for our Resize Image request:

  1. New Image Width
  2. New Image Height
  3. Image File Content
  4. Image File Name

In this example, we’ll convert all image attachments to 800 x 800 width and height specifications. We’ll get the file content & file name values as dynamic content as from our trigger action.

To wrap up our flow, we’ll use a Create file action to save our image(s) on a SharePoint team site.

As shown in the above example, we can reuse the Attachments Name value from our trigger action to dynamically rename each resized image file. In this case, we’ve added the string “resized” prior to the name to distinguish the resized image as a different version of the original.

We’ll now save our flow and run a test, which means sending ourselves an email with one (or multiple) .png or .jpg attachments.

When our flow finishes running, we’ll find the resized images in our target SharePoint folder.

We can open one of our images to check that it’s conformed to our exact height and width specifications (in this example, we picked 800 x 800).

And that’s all there is to it! We can now automatically resize image attachments after first validating the file type via extension.

Conclusion

In this article, we learned how to set up an automated flow in Power Automate that takes image attachments from an email, checks the extension to verify the file type, and resizes the images to new height and width dimensions.

Be sure to check back in on our blog for more quick & easy Power Automate walkthroughs!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Responses (1)