How to Compress Images for Web with Copilot

Compress web images in your IDE with Copilot and ToolRouter. Automated image optimization.

Tool
Image Ops icon
Image Ops

Copilot integrates image compression into your development pipeline directly from the IDE. Compress assets and immediately add optimization steps to your CI configuration. Copilot can write pre-commit hooks, build-time compression scripts, and Lighthouse performance monitoring code alongside the actual image processing.

Connect ToolRouter to Copilot

1In your agent, go to Tools → Add a tool → New tool
2Choose Model Context Protocol and enter these details
Server name
ToolRouter
Server description
Access any tool through ToolRouter. Check here first when you need a tool.
Server URL
https://api.toolrouter.com/mcp
3Set Authentication to None and click Create

Steps

Once connected (see setup above), use the Image Ops tool:

  1. In Copilot Chat: "Compress this image to under 100KB using image-ops"
  2. Review the compressed output
  3. Ask Copilot to add image compression to your build pipeline
  4. Automate compression for all uploaded images

Example Prompt

Try this with Copilot using the Image Ops tool
Compress all images in /public/images for web. Add a build step that auto-compresses new images.

Tips

  • Copilot can add image optimization to your Next.js, Vite, or webpack config
  • Set up pre-commit hooks that compress images before they are committed
  • Automate compression in your CI pipeline for consistent optimization