Checking if an image is empty in Make

Hello!

I’m working on a scenario in which I’m making requests to an API to get an image with an HTTP module (“Make a request”), and I’ve encountered a challenge I can’t seem to resolve.

My goal is to validate whether the file returned is genuinely empty based on the returned data.
The API returns an URL with additional info but sometimes, it gives a status code and a file size that may not necessarily reflect whether the file is blank.

Since the HTTP module “Get a file” returns the data and file size it gets from the URL, I was wondering if there was a reliable way to stop my scenario, perhaps even return an error if that module detects that the image is empty.

I’m interested in any advice on how to approach this, or a solution that could help in those cases. Thanks in advance!

Hi @bryanf ,

Can you post the image or json of thee output you get in both cases - when it’s empty or populated ?

Hello @kudracha, thanks for your reply!

In both cases, I’m getting a JSON with the following data:

{
  "file_name": "JAIIO_036060182-1.jpg",
  "original_size": 115543,
  "kraked_size": 52130,
  "saved_bytes": 63413,
  "kraked_url": "https://dl.kraken.io/api/f2/35/ff/2d7e1f41e53751230de84f94d2/JAIIO_036060182-1.jpg",
  "original_width": 800,
  "original_height": 1200,
  "kraked_width": 800,
  "kraked_height": 1200,
  "success": true
}

(this example comes from an execution that was 2 days ago)

This is what I’m getting whether the image is actually empty or not, which is why I was leaning towards the HTTP “Get a file” module to test the data that comes directly from the URL.

@bryanf , Where does this image come from? Can you manually check if there’s a photo or not? It’s weird that you get ANY of those parameters on output if the object is not an image…

@kudracha I’m sending a valid image that comes from an AWS S3 bucket (with public read perms) to the Kraken.io API so they can compress it, then they return their own URL with the compressed image and the additional data.

I checked one of those links manually a few days ago and got redirected to a blank page, but unfortunately, Kraken.io links expire after some time so now they return a 404.

I also think it doesn’t make sense for them to return this kind of data if it’s not actually valid…

Managed to solve my issue by using:

  1. an HTTP “Get a file” module with the URL I got from that API
  2. a filter after the module that checks if there’s data, if the statusCode is 200 and if the fileSize is greater than 0

In my case I was using an array aggregator to make an array of photos after the compression, so invalid ones wouldn’t be included in the aggregator, which is good enough for me!

3 Likes