How to use the @expo/image-utils.sharpAsync function in @expo/image-utils

To help you get started, we’ve selected a few @expo/image-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-cli / packages / expo-optimize / src / assets.ts View on Github external
async function optimizeImageAsync(
  projectRoot: string,
  inputPath: string,
  quality: number
): Promise {
  console.log(`\u203A Checking ${chalk.reset.bold(relative(projectRoot, inputPath))}`);

  const outputPath = temporary.directory();
  await sharpAsync({
    input: inputPath,
    output: outputPath,
    quality,
    // https://sharp.pixelplumbing.com/en/stable/api-output/#parameters_4
    adaptiveFiltering: true,
  });
  return join(outputPath, basename(inputPath));
}
github expo / expo-cli / packages / webpack-pwa-manifest-plugin / src / icons.ts View on Github external
inputPath: string,
  mimeType: string,
  width: number,
  height: number,
  fit: ResizeMode = 'contain',
  background: string
): Promise {
  if (!(await isAvailableAsync())) {
    return await jimpResize(inputPath, mimeType, width, height, fit, background);
  }

  const format = ensureValidMimeType(mimeType.split('/')[1]);
  const outputPath = temporary.directory();

  try {
    await sharpAsync(
      {
        input: inputPath,
        output: outputPath,
        format,
      },
      [
        {
          operation: 'flatten',
          background,
        },
        {
          operation: 'resize',
          width,
          height,
          fit,
          background,
github expo / expo-cli / packages / xdl / src / AssetUtils.ts View on Github external
export async function optimizeImageAsync(inputPath: string, quality: number): Promise {
  logger.global.info(`Optimizing ${inputPath}`);
  const outputPath = temporary.directory();
  await sharpAsync({
    input: inputPath,
    output: outputPath,
    quality,
  });
  return path.join(outputPath, path.basename(inputPath));
}

@expo/image-utils

A package used by Expo CLI for processing images

MIT
Latest version published 29 days ago

Package Health Score

89 / 100
Full package analysis