Skip to content

Conversation

@Shitanshukumar607
Copy link
Owner

fix support for other file imgs

Copilot AI review requested due to automatic review settings October 5, 2025 17:44
@vercel
Copy link

vercel bot commented Oct 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
img-to-svg Ready Ready Preview Comment Oct 5, 2025 6:16pm

Copy link

Copilot AI left a 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.

Comment on lines +20 to +27
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();
Copy link

Copilot AI Oct 5, 2025

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.

Copilot uses AI. Check for mistakes.
@Shitanshukumar607 Shitanshukumar607 merged commit a1581be into main Oct 6, 2025
5 of 6 checks passed
@Shitanshukumar607 Shitanshukumar607 deleted the improve-generate branch October 10, 2025 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants