Skip to content

Commit

Permalink
Merge pull request #40 from j-h-scheufen/endspurt-mvp
Browse files Browse the repository at this point in the history
Fixed image orientation problem from mobile uploads
  • Loading branch information
j-h-scheufen authored Oct 22, 2024
2 parents b53a19d + 59eacf7 commit 7599d0f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions packages/quilombo/components/forms/ImageUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const ImageUpload = ({ value, ownerId, useFileUploadMutation: useDynamicMutation
const [validationError, setValidationError] = useState<string | null>(null);
const fileInputRef = useRef<HTMLInputElement | null>(null);

console.log('value in ImageUpload', value);
console.log('imagePreview;', imagePreview);
const selectImageFile = () => {
fileInputRef.current?.click();
};
Expand Down
2 changes: 1 addition & 1 deletion packages/quilombo/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const IMAGE_FORMATS: Record<ImageType, ResizeOptions> = {
groupBanner: { height: 250, width: 800, fit: 'cover', position: 'attention' },
};

export const MAX_IMAGE_UPLOAD_SIZE_MB = 5;
export const MAX_IMAGE_UPLOAD_SIZE_MB = 4.5; // 4.5 MB is the current limit for Vercel serverless functions! https://vercel.com/docs/concepts/limits/overview#serverless-function-payload-size-limit

export const PINATA_FILE_GROUP = 'd923dfed-5f8d-440b-ae87-e8a43504eaa5'; // quilombo group ID

Expand Down
4 changes: 2 additions & 2 deletions packages/quilombo/utils/pinata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const pinToGroup = async (
return { error: `Invalid input data. Unsupported image mime-type. ${inFileType?.mime}`, errorStatus: 400 };
}

// Image processing
const imageBuffer = await sharp(buffer).resize(resizeOptions).webp({ lossless: true }).toBuffer();
// Image processing (hint: rotate() is used to fix orientation before removing EXIF data)
const imageBuffer = await sharp(buffer).rotate().resize(resizeOptions).webp({ lossless: true }).toBuffer();

const uploadData = new FormData();
uploadData.append('file', new Blob([imageBuffer]));
Expand Down

0 comments on commit 7599d0f

Please sign in to comment.