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

glm4v-cli

v1.0.1

Published

GLM-4V 视觉模型 CLI 工具 - 支持本地图片分析

Downloads

199

Readme

GLM-4V CLI

GLM-4V 视觉模型命令行工具 - 支持本地图片分析

功能特性

  • 本地图片分析(支持 jpg/png/gif/webp/bmp)
  • 配置文件管理 API 地址和 Key
  • 自定义提示词
  • JSON 格式输出
  • 自动 base64 编码
  • 跨平台支持(Windows/macOS/Linux)

安装

全局安装(推荐)

npm install -g glm4v-cli

本地安装

# 克隆或下载项目
cd glm4v-cli

# 安装依赖
npm install

# 链接到全局(可选)
npm link

系统要求

  • Node.js: >= 18.0.0
  • 操作系统: Windows 10/11, macOS, Linux

快速开始

1. 初始化配置

glm4v init

2. 设置 API Key

glm4v config --api-key your-api-key-here

3. 分析图片

# macOS/Linux
glm4v analyze /path/to/image.jpg

# Windows
glm4v analyze C:\Users\YourName\Pictures\image.jpg
# 或
glm4v analyze "C:\Users\YourName\Pictures\image.jpg"

命令详解

init - 初始化配置

创建配置文件:

  • Windows: %APPDATA%\glm4v\config.json
  • macOS/Linux: ~/.config/glm4v/config.json
glm4v init

config - 管理配置

# 显示当前配置
glm4v config --show

# 设置 API Key
glm4v config --api-key sk-xxxxxxxx

# 设置自定义 API 地址
glm4v config --api-url https://api.example.com/v1

# 同时设置多个配置
glm4v config --api-url https://api.example.com/v1 --api-key sk-xxxxxxxx

analyze - 分析图片

# 基本用法
glm4v analyze ./photo.jpg

# 自定义提示词
glm4v analyze ./photo.jpg -p "这张图片里有什么文字?"

# 使用不同模型
glm4v analyze ./photo.jpg -m glm-4v-flash

# 限制输出长度
glm4v analyze ./photo.jpg -t 500

# JSON 格式输出
glm4v analyze ./photo.jpg --json

# 组合选项
glm4v analyze ./photo.png -p "描述图片风格" -t 800 --json

跨平台使用示例

Windows

# PowerShell
glm4v analyze C:\Users\pan\Downloads\image.png
glm4v analyze "C:\Users\pan\Downloads\image.png" -p "描述这个图片"

# CMD
glm4v analyze C:\Users\pan\Downloads\image.png

macOS

glm4v analyze ~/Downloads/image.png
glm4v analyze /Users/pan/Downloads/image.png -p "这张图片里有什么?"

Linux

glm4v analyze ~/Pictures/image.jpg
glm4v analyze /home/user/pictures/image.jpg --json

配置说明

配置文件位置:

| 系统 | 路径 | |-----|------| | Windows | %APPDATA%\glm4v\config.json | | macOS | ~/.config/glm4v/config.json | | Linux | ~/.config/glm4v/config.json |

配置内容:

{
  "apiUrl": "https://ai.bytenote.net/v1",
  "apiKey": "your-api-key-here"
}

使用示例

# 示例 1: 分析图标
$ glm4v analyze ./icon.png
📷 正在分析图片...
   文件: /Users/pan/Downloads/icon.png
   大小: 12.70 KB
   类型: image/png
   模型: glm-4v

✅ 分析完成

🤖 GLM-4V 回答:
这是一张应用图标,显示一个剪贴板图案...

📊 Token 使用:
   - Prompt: 1674
   - Completion: 92
   - Total: 1766

# 示例 2: JSON 输出
$ glm4v analyze ./chart.png -p "分析这个图表的数据趋势" --json
{
  "content": "该图表显示了...",
  "usage": {
    "prompt_tokens": 2156,
    "completion_tokens": 156,
    "total_tokens": 2312
  }
}

支持的图片格式

  • .jpg / .jpeg
  • .png
  • .gif
  • .webp
  • .bmp

限制

  • 单张图片最大 10MB
  • 支持的图片格式见上表
  • Node.js 版本 >= 18.0.0

常见问题

Windows 上路径问题

如果路径包含空格,请使用引号包裹:

glm4v analyze "C:\Users\My Name\Pictures\my image.png"

配置文件找不到

运行 glm4v init 创建配置文件,然后使用 glm4v config --show 查看配置路径。

权限问题(Linux/macOS)

如果全局安装后找不到命令,可能需要添加 npm 全局目录到 PATH:

# 查看 npm 全局目录
npm config get prefix

# 添加到 PATH(根据 shell 选择)
# Bash
echo 'export PATH="$PATH:$(npm config get prefix)/bin"' >> ~/.bashrc

# Zsh
echo 'export PATH="$PATH:$(npm config get prefix)/bin"' >> ~/.zshrc

License

MIT