{"id":29142236,"url":"https://github.com/ethanz-code/pngquant-server","last_synced_at":"2026-05-11T10:35:37.515Z","repository":{"id":236047817,"uuid":"790663219","full_name":"ethanz-code/pngquant-server","owner":"ethanz-code","description":"基于 imagemin 构建的图片压缩服务，支持通过 Docker 一键部署，提供可集成的 API 接口。 支持多种格式的图像压缩，JPEG, PNG","archived":false,"fork":false,"pushed_at":"2025-06-06T04:53:14.000Z","size":1776,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T12:53:13.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethanz-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-23T09:46:49.000Z","updated_at":"2025-06-06T04:53:16.000Z","dependencies_parsed_at":"2025-06-24T12:53:16.623Z","dependency_job_id":"a83e5e41-e515-4ac2-be63-6b26631997f7","html_url":"https://github.com/ethanz-code/pngquant-server","commit_stats":null,"previous_names":["yassine-zhang/imagemin-server","yassine-zhang/pngquant-server","ethanz-code/pngquant-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ethanz-code/pngquant-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fpngquant-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fpngquant-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fpngquant-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fpngquant-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethanz-code","download_url":"https://codeload.github.com/ethanz-code/pngquant-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fpngquant-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262834822,"owners_count":23371854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-30T19:10:21.599Z","updated_at":"2026-05-11T10:35:37.463Z","avatar_url":"https://github.com/ethanz-code.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imagemin-server\n\n\u003cp align=\"center\" \u003e\u003cimg src=\"./src/image/test-compresse-size.jpg\" width=\"500\" /\u003e\u003c/p\u003e\n\n开发这么一个项目是因为我需要一个图像压缩服务，而我了解的`imagemin`兼容性是个很大的问题，网上也有对应的API服务，我不觉得这个东西也需要花钱解决。因此选择使用[Bun dev | NodeJS prod] + Express。\n\nTo install dependencies:\n\n```bash\nbun install\n```\n\nTo run:\n\n```bash\nbun run index.ts\n```\n\nThis project was created using `bun init` in bun v1.1.2. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.\n\n## 接口文档\n\n### 压缩图片\n\u003e url: `/compress`\n\u003e method: `POST`\n\n请求参数（接口请求案例：[click here](./src/md/request.md)）：\n\n| 参数名 | 类型 | 描述 |\n| ----------- | ----------- | ----------- |\n| file        | file        | 需要被压缩的图像，请上传一个文件实例 |\n| quality     | string      | 质量参数，例如：`[0.3, 0.6]`，注意参数类型是字符串，请按照指定格式来传参，中间空格无要求 |\n\n响应：\n```json\n{\n  \"status\": 0,\n  \"messgae\": \"success\",\n  \"data\": {\n    \"uncompression\": {\n      \"url\": \"http://192.168.1.16:9093/public/image/png/1713933615_629111.png\",\n      \"size\": \"1.46 MB\"\n    },\n    \"compressed\": {\n      \"url\": \"http://192.168.1.16:9093/public/image/png/1713933615_629111gz.png\",\n      \"size\": \"262.60 KB\"\n    },\n    \"percentage\": \"17.56%\"\n  }\n}\n```\n\n\n\n## 部署\n\n我在项目中加入了dockerfile，你可以使用docker来部署：\n\n```bash\n# 构建镜像\ndocker buildx build --push --platform linux/amd64 -t 31.133.33.333:9000/imagemin-server .\n```\n\n## 注意事项\n本项目未使用数据库，每次请求传的图片文件以及压缩文件都会保存到服务器并在返回结果中提供网络链接，但请勿在生产环境中使用，不保证链接的长久有效。\n\n## Bun的兼容问题\n因为我的新项目使用Bun开发以及部署，而如果要继承imagemin会遇到一个问题：\n```\nTypeError: isNaturalNumber is not a function. (In 'isNaturalNumber(count, !0)', 'isNaturalNumber' is an instance of Module)\n```\n\n但是这个问题用NodeJS就不会出现，它在目前最新Bun v1.1.4版本还没有得到处理：https://github.com/oven-sh/bun/issues/9267\n\n\n/public有惊喜😁\n\n## 联系我\n全栈开发接商单，加QQ: 57878778\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanz-code%2Fpngquant-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethanz-code%2Fpngquant-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanz-code%2Fpngquant-server/lists"}