Excluding Image from Attachment if Content is Empty

I am trying to dynamically include an image in an email attachment, while ensuring that the image is excluded from the attachment if its content is empty, without excluding the entire attachment.

Here is the JSON format I am using for the attachment:

“Attachments”: [
“Name”: “<file_name>”,
“Content”: “<file_content>”,
“ContentType”: “application/vnd.ms-excel”
“Name”: “image.jpg”,
“<image_4> ? "Content": "<image_4>",”: “”,
“ContentType”: “image/jpeg”

I have tried to implement the above logic, but I encountered the following issue:

"There was an issue setting up your call.

Raw response for the API
Status code 422
{“ErrorCode”:300,“Message”:“Zero-sized attachments not allowed.”}"

I would appreciate assistance in resolving this issue and achieving the desired functionality. I need to exclude only the image from the attachment if the image content is empty, while still including the rest of the attachment.