Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

384
Vistas
Resize an image to aspect ratio 16:9

I'm trying to resize the uploaded image to 16:9. I've been trying all day and this is the best I've done so far.

const resizeResult = await manipulateAsync(
  uploadResult.uri,
  [
    {
      resize:
        uploadResult.width > uploadResult.height
          ? { height: 900 }
          : { width: 1600 },
    },
    {
      crop: {
        width: 1600,
        height: 900,
        originX:
          uploadResult.width > uploadResult.height
            ? (uploadResult.height - uploadResult.width) / 2
            : (uploadResult.width - uploadResult.height) / 2,
        originY: 0,
      },
    },
  ],
  { compress: 0.7, format: SaveFormat.JPEG }
);

Unfortunately, this resizes/crops the 1800x1200 image to 1350x900, not 1600x900.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you just have to calculate and cap the size of the image using its aspect ratio.

const ratio = uploadResult.width / uploadResult.height;

let newWidth = ratio * 900;
let newHeight = 900;

if (ratio > 0) {
    newWidth = 1600;
    newHeight = 1600 / ratio;
}

const resizeResult = await manipulateAsync(
  uploadResult.uri,
  [
    {
      resize: { height: newHeight, width: newWidth }
    }
  ],
  { compress: 0.7, format: SaveFormat.JPEG }
);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda