View Source Appwrite.Services.Avatars (appwrite v0.2.1)

The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars.

The Avatars service allows you to fetch country flags, browser icons, payment method logos, remote website favicons, generate QR codes, and manipulate remote image URLs.

All endpoints in this service allow you to resize, crop, and change the output image quality for maximum performance and visibility in your app.

Summary

Functions

get_browser(code, width \\ nil, height \\ nil, quality \\ nil)

@spec get_browser(
  String.t(),
  non_neg_integer() | nil,
  non_neg_integer() | nil,
  0..100 | nil
) ::
  {:ok, String.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get a browser icon URL.

Parameters

  • code (String.t()): The browser code (e.g. "chrome", "firefox").
  • width (non_neg_integer() | nil): Desired icon width in pixels.

  • height (non_neg_integer() | nil): Desired icon height in pixels.

  • quality (0..100 | nil): Image quality percentage.

Returns

  • {:ok, String.t()} containing the icon URL on success.
  • {:error, AppwriteException.t()} if code is missing.

get_credit_card(code, width \\ nil, height \\ nil, quality \\ nil)

@spec get_credit_card(
  String.t(),
  non_neg_integer() | nil,
  non_neg_integer() | nil,
  0..100 | nil
) :: {:ok, String.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get a credit card provider icon URL.

Parameters

  • code (String.t()): The credit card code (e.g. "amex", "visa").
  • width (non_neg_integer() | nil): Desired icon width in pixels.

  • height (non_neg_integer() | nil): Desired icon height in pixels.

  • quality (0..100 | nil): Image quality percentage.

Returns

  • {:ok, String.t()} containing the icon URL on success.
  • {:error, AppwriteException.t()} if code is missing.

get_favicon(url)

@spec get_favicon(String.t()) ::
  {:ok, String.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get the favicon URL of a remote website.

Parameters

  • url (String.t()): The URL of the remote website.

Returns

  • {:ok, String.t()} containing the favicon fetch URL on success.
  • {:error, AppwriteException.t()} if url is missing.

get_flag(code, width \\ nil, height \\ nil, quality \\ nil)

@spec get_flag(
  String.t(),
  non_neg_integer() | nil,
  non_neg_integer() | nil,
  0..100 | nil
) :: {:ok, String.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get a country flag icon URL.

Parameters

  • code (String.t()): ISO 3166-1 alpha-2 country code (e.g. "us", "gb").
  • width (non_neg_integer() | nil): Desired icon width in pixels.

  • height (non_neg_integer() | nil): Desired icon height in pixels.

  • quality (0..100 | nil): Image quality percentage.

Returns

  • {:ok, String.t()} containing the flag URL on success.
  • {:error, AppwriteException.t()} if code is missing.

get_image(url, width \\ nil, height \\ nil)

@spec get_image(String.t(), non_neg_integer() | nil, non_neg_integer() | nil) ::
  {:ok, String.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get a remote image URL (cropped/resized).

Parameters

  • url (String.t()): The URL of the remote image.
  • width (non_neg_integer() | nil): Crop width in pixels.

  • height (non_neg_integer() | nil): Crop height in pixels.

Returns

  • {:ok, String.t()} containing the image fetch URL on success.
  • {:error, AppwriteException.t()} if url is missing.

get_initials(name \\ nil, width \\ nil, height \\ nil, background \\ nil)

@spec get_initials(
  String.t() | nil,
  non_neg_integer() | nil,
  non_neg_integer() | nil,
  String.t() | nil
) :: {:ok, String.t()}

Generate a user initials avatar URL.

Parameters

  • name (String.t() | nil): The user's name or initials.

  • width (non_neg_integer() | nil): Avatar width in pixels.

  • height (non_neg_integer() | nil): Avatar height in pixels.

  • background (String.t() | nil): Hex color for the background (without #).

Returns

  • {:ok, String.t()} containing the avatar URL.

get_qr(text, size \\ nil, margin \\ nil, download \\ nil)

@spec get_qr(
  String.t(),
  non_neg_integer() | nil,
  non_neg_integer() | nil,
  boolean() | nil
) :: {:ok, String.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Generate a QR code image URL.

Parameters

  • text (String.t()): The text or URL to encode in the QR code.
  • size (non_neg_integer() | nil): QR code size in pixels.

  • margin (non_neg_integer() | nil): Margin (quiet zone) size around the QR code.

  • download (boolean() | nil): When true, returns a downloadable response.

Returns

  • {:ok, String.t()} containing the QR code URL on success.
  • {:error, AppwriteException.t()} if text is missing.