Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed image orientation problem from mobile uploads #40

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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