Skip to content

Instantly share code, notes, and snippets.

@almond-bongbong
Created October 27, 2020 07:47
Show Gist options
  • Save almond-bongbong/7ee93b56ef705569a032de4c47b342c2 to your computer and use it in GitHub Desktop.
Save almond-bongbong/7ee93b56ef705569a032de4c47b342c2 to your computer and use it in GitHub Desktop.
Transform orientation file object
export const transformOrientationFile = (file: File): Promise<File> => (
new Promise<File>(((resolve) => {
loadImage(file, (img) => {
(img as HTMLCanvasElement).toBlob((blob) => {
if (blob) {
const newFile = new File([blob], file.name, { ...file });
resolve(newFile);
}
}, file.type);
},
{
canvas: true,
orientation: true,
maxWidth: 2000,
});
}))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment