-
Notifications
You must be signed in to change notification settings - Fork 0
improve generate func, fix support for other file imgs #10
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the image generation functionality by replacing PNG-specific processing with a more flexible image handling approach using Sharp library to support additional image formats.
- Replaced PNG.js with Sharp library for broader image format support
- Updated React Image component to native img element for better compatibility
- Added comprehensive error handling in the upload API route
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| package.json | Added Sharp library dependency for enhanced image processing |
| app/generate/page.tsx | Changed from Next.js Image component to native img element |
| app/api/upload/route.ts | Replaced PNG.js with Sharp for multi-format support and improved error handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const image = sharp(buffer).ensureAlpha(); // ensures RGBA format | ||
| const { width, height } = await image.metadata(); | ||
|
|
||
| if (!width || !height) { | ||
| throw new Error("Unable to read image metadata."); | ||
| } | ||
|
|
||
| const raw = await image.raw().toBuffer(); |
Copilot
AI
Oct 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Sharp instance is created twice - once for metadata extraction and once for raw buffer processing. Consider reusing the same instance or chaining operations to avoid redundant processing.
Co-authored-by: Copilot <[email protected]>
fix support for other file imgs