Class ImageFormat
java.lang.Object
net.dv8tion.jda.api.utils.ImageFormat
Represents an image format support by Discord's CDNs.
Format support varies based on the CDN endpoint.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ImageFormatLossy or lossless animated image format.static final ImageFormatLossless animated image format.static final ImageFormatLossy static image format.static final ImageFormatLossless static image format.static final ImageFormatLossy or lossless static image format. -
Method Summary
Modifier and TypeMethodDescriptionReturns the extension of this image format.Returns the query parameters added to URLs by this image format.static ImageFormatCreates anImageFormatusing the provided extension.static ImageFormatCreates anImageFormatusing the provided extension.
-
Field Details
-
JPG
Lossy static image format.
Generally has a smaller size but can have visual artifacts and doesn't support transparency.Requesting an image with this format should always work.
-
PNG
Lossless static image format.
Content is compressed but larger than other lossy image formats.Requesting an image with this format should always work.
-
GIF
Lossless animated image format.
Content is very poorly compressed, and only supports up to 255 colors.
UsingANIMATED_WEBPis recommended instead.Requesting an image with this format may fail with an HTTP 415 (Unsupported Media Type) if the image was originally uploaded as a WebP.
- See Also:
-
STATIC_WEBP
Lossy or lossless static image format.
Sizes can be similar toJPGwith the addition of transparency support.This is the format Discord recommends for static images. Requesting an image with this format should always work.
-
ANIMATED_WEBP
Lossy or lossless animated image format.
Sizes will be considerably smaller thanGIF, however, encoding can also be slower.This is the format Discord recommends for animated images. Requesting an image with this format should always work, including static images.
-
-
Method Details
-
of
Creates anImageFormatusing the provided extension.- Parameters:
extension- The extension of the image- Returns:
- The new
ImageFormat - Throws:
IllegalArgumentException- If the extension isnull
-
of
@Nonnull public static ImageFormat of(@Nonnull String extension, @Nonnull List<String> queryParameters) Creates anImageFormatusing the provided extension.- Parameters:
extension- The extension of the imagequeryParameters- Query parameters to add to URLs, must be a multiple of 2- Returns:
- The new
ImageFormat - Throws:
IllegalArgumentException-- If any argument is
null - If the extension is blank
- If the query parameter list's length is not a multiple of 2
- If any argument is
-
getExtension
Returns the extension of this image format.- Returns:
- The extension
-
getQueryParameters
-