Skip to content

Commit

Permalink
[BulkEditPhotos] Fix performance and crop preview bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhatib committed Dec 13, 2022
1 parent c0a1326 commit 5ec2b32
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/BulkEditPhotos/BulkEditPhotos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import JSZip from 'jszip';
import { doc } from 'prettier';
import { useCallback, useEffect, useRef, useState } from 'react';
import UploadButton from '../components/UploadButton';
import Rotator from '../CreatePhotosSlideshow/Rotator';
import { readImageSizing } from '../images/helpers';
import {
CanvasEditorRef,
Expand Down Expand Up @@ -43,8 +42,10 @@ const BulkEditPhotos = (): JSX.Element => {
setFiles((oldFiles) => [...oldFiles, ...newFiles]);
const newImages = [...images];
for (const file of newFiles) {
const blob = await Rotator.createRotatedImage(file);
const url = URL.createObjectURL(blob);
// Dropping fixing rotation of images because it is slow.
// Instead leave that to the user to fix with the rotation tool.
// const blob = await Rotator.createRotatedImage(file);
const url = URL.createObjectURL(file);
const { width, height } = await readImageSizing(url);
newImages.push({
// TODO: Add a uid for finding the correct image.
Expand Down Expand Up @@ -182,6 +183,8 @@ const BulkEditPhotos = (): JSX.Element => {
<button
className="h-10 self-end bg-green-500 text-white px-3 py-2 hover:bg-green-700 mr-2"
onClick={() => {
// Update crops before switching to another tool.
onCrop();
setActiveTool('frame');
}}
>
Expand Down

0 comments on commit 5ec2b32

Please sign in to comment.