convert method

void convert(
  1. Format format
)

The format function lets you converts a given image from one format to another. The formats that the source image can be converted to are gif, png, jpg (for JPEG), pjpg (for Progressive JPEG), webp, webpll (Lossless), and webply (Lossy).

for more details read documentation: For more details, Read documentation: https://www.contentstack.com/docs/developers/apis/image-delivery-api/#convert-formats

Example:

final stack = contentstack.Stack(apiKey, deliveryToken, environment);
final imageTransformation = stack.imageTransform(imageUrl);
final response = await imageTransformation.convert(Format.pjpg).fetch();

Implementation

void convert(Format format) {
  format.when(gif: (formatResult) {
    query.append('format', 'gif');
  }, png: (formatResult) {
    query.append('format', 'png');
  }, jpg: (formatResult) {
    query.append('format', 'jpg');
  }, pjpg: (formatResult) {
    query.append('format', 'pjpg');
  }, webp: (formatResult) {
    query.append('format', 'webp');
  }, webplossy: (formatResult) {
    query.append('format', 'webply');
  }, webplossless: (formatResult) {
    query.append('format', 'webpll');
  });
}