npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-image-compress

v0.3.2

Published

Automatically compresses images before sending to AI providers to avoid size limits

Readme

opencode-image-compress

OpenCode plugin that automatically compresses images before sending them to AI providers, preventing "image exceeds maximum" errors.

Problem

High-resolution images (especially @2x Retina screenshots) often exceed provider size limits, making it impossible to use them in conversations:

Without the plugin: "image exceeds 5 MB maximum" error when attaching a large image

Solution

With the plugin installed, images are automatically compressed before being sent. The same image works seamlessly:

With the plugin: the same large image is compressed and described by the AI without errors

Installation

Add to your opencode.json (global or per-project):

{
	"plugin": ["opencode-image-compress@latest"]
}

That's it. OpenCode will automatically install the plugin on next launch.

How It Works

The plugin compresses images in two scenarios:

  1. Images pasted in chat - via the experimental.chat.messages.transform hook
  2. Images read by the agent - via the tool.execute.after hook when the Read tool returns image attachments

In both cases, it detects the provider and model, and compresses images that exceed provider-specific limits.

Provider Limits

Verified as of January 2026. Source URLs are in src/providers.ts.

| Provider | Limit | Target (70%) | Source | | ----------------------- | ------- | ------------ | ----------------------------------------------------------------------------------------------------- | | Anthropic | 5 MB | 3.5 MB | docs | | Amazon Bedrock | 3.75 MB | 2.6 MB | docs | | OpenAI | 20 MB | 14 MB | docs | | Azure OpenAI | 20 MB | 14 MB | docs | | Google (AI Studio) | 100 MB | 70 MB | blog | | Google Vertex AI | 7 MB | 4.9 MB | docs | | Google Vertex Anthropic | 5 MB | 3.5 MB | (follows Anthropic limits) | | Groq | 4 MB | 2.8 MB | docs | | Fireworks AI | 10 MB | 7 MB | docs | | Perplexity | 50 MB | 35 MB | docs | | xAI (Grok) | 20 MB | 14 MB | docs | | DeepSeek | 10 MB | 7 MB | (community consensus) | | Mistral | 10 MB | 7 MB | docs | | Together AI | 20 MB | 14 MB | (not documented) | | Other/Unknown | 5 MB | 3.5 MB | (conservative default) |

Proxy Providers

Providers like github-copilot, opencode, github-models, and openrouter proxy to upstream APIs. The plugin resolves the actual provider from the model ID (e.g., claude-sonnet-4-5 → Anthropic → 5 MB, gpt-4o → OpenAI → 20 MB) to apply the correct limit.

Compression Strategy

  1. Skip if already under target (70% of provider limit)
  2. Scale down if dimensions exceed 2048px
  3. Reduce quality progressively (JPEG/WebP/AVIF)
  4. PNG: increase compression level, then shrink dimensions
  5. Fallback: aggressive resize to 1024px

Supported Formats

JPEG, PNG, WebP, AVIF, GIF (converted to PNG), other formats (converted to JPEG).

Logging

The plugin logs compression activity to OpenCode's app log system (service: "image-compress"). View logs in the TUI or via the API.

Toast Notifications

Set OPENCODE_IMAGE_COMPRESS_PLUGIN_SHOW_TOAST=1 to show TUI toast notifications when images are compressed or when compression fails.

Toast notification showing "Compressed 2 images: 47.54 MB → 3.58 MB (92% smaller)"

Development

git clone https://github.com/kynnyhsap/opencode-image-compress.git
cd opencode-image-compress
bun install

# Run OpenCode with the plugin loaded from source
bun dev

# Run all checks (format, lint, typecheck, unit tests)
bun check

# Individual commands
bun fmt
bun lint
bun typecheck
bun test:unit
E2E_TESTS=1 bun test:e2e

License

MIT