# Class ImagePart

java.lang.Object
com.codename1.ai.MessagePart
com.codename1.ai.ImagePart

public final class ImagePart extends MessagePart
Image content within a multimodal `ChatMessage`. An image is either inline encoded bytes with a MIME type or a provider-accessible URL. Inline bytes are copied on construction and access so later caller mutations cannot change a request that already contains this part.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImagePart(byte[] data, String mimeType)`
  Creates an inline image part.
  `ImagePart(String url)`
  Remote image by URL.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `byte[]`
  `getData()`
  `String`
  `getMimeType()`
  `String`
  `getUrl()`
  `boolean`
  `isUrl()`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ImagePart

    public ImagePart(byte[] data, String mimeType)
    Creates an inline image part. The media type must describe the encoded bytes, for example `image/png` or `image/jpeg`; providers reject inline images without a type.
    Parameters:
      `data` - encoded image bytes, defensively copied
      `mimeType` - media type such as `image/png`

  - ### ImagePart

    public ImagePart(String url)
    Remote image by URL. Only HTTPS is portable across providers. Creates a remotely addressed image part.
    Parameters:
      `url` - provider-accessible HTTPS or data URL

- ## Method Details

  - ### getData

    public byte[] getData()
    Returns:
      a defensive copy of inline bytes, or `null` for a URL image

  - ### getMimeType

    public String getMimeType()
    Returns:
      MIME type of inline bytes, or `null` for a URL image

  - ### getUrl

    public String getUrl()
    Returns:
      provider-accessible URL, or `null` for an inline image

  - ### isUrl

    public boolean isUrl()
    Returns:
      `true` when this part references a URL instead of bytes