Skip to content

Please allow promise for transforms #88

Closed
@cxa

Description

As the title, e.g. I need to extend transforms:

const extendTransforms = (builtins) => {
  const getBase64 = async (image) => {
    const img = image.resize({ width: 10 });
    const buf = await img.toBuffer();
    const mt = await img.metadata();
    return `data:image/${mt.format};base64,${buf.toString("base64")}`;
  };

  function base64(config, ctx) {
    if (config.width != "10") return;
    return async (image) => {
      setMetadata(image, "base64", await getBase64(image));
      return image;
    };
  }

  return [base64, ...builtins];
};
imagetools({ extendTransforms })

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions