Image message is a type of message that includes an image file. It allows users to share visual information with others in a chat. Image messages can be used in a variety of ways, such as sharing photos with friends, sending documents, or any other visual content that needs to be shared quickly and easily. With image messages, users can easily convey information to others in a chat, making it a powerful tool for communication.
When calling this function, you can provide the local image path on the device and the ID of the subchannel where the message will be sent. The SDK will create an image message with the specified image and send it to the subchannel.
For further information regarding a video information please refer to Image Handling page.
Here is a brief explanation of the function parameters:
text/caption
: A string that contains the text message that the user wants to send. This parameter is mandatory as it contains the actual message content.
attachment
: The local image path that the user wants to send on the device
subchannelId
: An identifier for the subchannel where the message will be sent. Subchannels are subdivisions within a channel that represent individual topics or chat threads. Messages and interactions occur within subchannels, not the main channel itself.
tags
- Arbitrary strings that can be used for defining and querying for the messages.
Version 6
Version 5 (Maintained)
Version 6
To send an image in original size, set optional isFullImage()
to true.
Version 5 (Maintained)
Here's a small example on how to create a message with an image attached. The process is pretty simple:
Upload an image.
Create a message with the uploaded image ID.
Refer to #upload-images for the sample code on how to upload a file to get fileId.
Here's a small example on how to create a message with an image attached. The process is pretty simple:
Upload an image.
Create a message with the uploaded image ID.
Refer to #upload-images for the sample code on how to upload a file to get fileId.
Version 6
Beta (v0.0.1)
To send an image in original size, set optional isFullImage()
to true.
The SDK will resize and process the image object before sending it to the server. When an image is uploaded, it is automatically resized into multiple sizing options.
The size of the image is determined by its longest dimension (in pixels) with the aspect ratios being unchanged. The maximum file size of an image cannot exceed 1 GB. Amity will automatically optimize the image and when queried, will return the image in small, medium and large sizes.
If the image is marked as isFull
on upload, the original size of the image can also be returned. Note that this can drastically reduce the speed of message sending, depending on the original image size. If the fullImage
is set to false
, then the uploaded image size will be up to 1500x1500 pixel.
You can also pass an optional caption as part of the message. This caption will be accessible under the data
property in the message model, under the caption
key. You can add up to 1,000 characters of text caption per message.
Supported image formats are JPG, PNG and HEIC and cannot exceed 1GB in size