{"id":19151794,"url":"https://github.com/zhs007/texturepackerjs","last_synced_at":"2026-06-23T07:32:05.699Z","repository":{"id":94329484,"uuid":"47232130","full_name":"zhs007/texturepackerjs","owner":"zhs007","description":null,"archived":false,"fork":false,"pushed_at":"2016-01-14T02:52:55.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T21:14:01.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhs007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-02T02:38:13.000Z","updated_at":"2019-01-15T03:47:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"f878fffc-7dc2-4424-8252-6517cdc0f0eb","html_url":"https://github.com/zhs007/texturepackerjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhs007/texturepackerjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhs007%2Ftexturepackerjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhs007%2Ftexturepackerjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhs007%2Ftexturepackerjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhs007%2Ftexturepackerjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhs007","download_url":"https://codeload.github.com/zhs007/texturepackerjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhs007%2Ftexturepackerjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34680620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-11-09T08:15:43.478Z","updated_at":"2026-06-23T07:32:05.676Z","avatar_url":"https://github.com/zhs007.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TexturePackerJS\nTexturePacker是一个很好用的软件，但我们有一些特殊需求，不太方便用TexturePacker，所以就想自己写一个纯命令行的，需求所限，不会有那么强大的功能，够用就好。\n\n关于NodeJS的图像库\n---\nNodeJS并没有好用而且全的图像库，当然这里说的是能把图像解开到内存中，能操作像素数据的那种。\n\nNodeJS有个gm的库，可以通过gm命令行做很多图形操作，大部分需求其实可以通过这个来实现。\n\n最开始的想法很简单，libpng、libjpeg这些其实都可以很方便的跨平台使用，npm上确实也有这样的库，但现在貌似几乎都编译不了了，github上看起来作者也没有维护来着。\n\n从我们的需求来看，速度不是一个很大的问题，所以就找了一堆原生js的图片读取库，这种一般来说，就算版本升级，大部分也都是可以用的。\n\n关于算法\n---\nTP的算法做得算是不错的了，我们尽可能的接近TP就好了，肯定是要切除纯透明区域，然后有一个间隔，然后有一定的图像旋转，最后拼出来的图片越小越好。图片大小也有一些限制，譬如2的整数次幂这种，有可能会要求高度宽度一样。\n\n具体算法就是在一定规则下，穷举，选一个最优解出来就行。\n\n批量文件重命名\n---\n指望美术出图按命名规范是一件很难的事，所以我们还增加一个批量命名功能。\n\n```\ntexturepackerjs rename **/*.png %d.png\n```\n\n这个命令，会遍历当前目录的所有子目录，按不同目录将文件重命名成``%d.png``，这里可以使用``%03d.png``之类的。\n\n每个目录会重新计数。\n\n目录展开\n---\n因为最终需要拼图，为了底层引擎遍历更高效，我们会希望将目录展开，保证每个文件名不一样。\n\n譬如最开始的目录结构是：\n\n```\nnpc/idle/000.png\nnpc/idle/001.png\nnpc/act/0000.png\nnpc/act/0001.png\n```\n\n我们可以变成\n\n```\nnpc_idle_000.png\nnpc_idle_001.png\nnpc_act_0000.png\nnpc_act_0001.png\n```\n\n这样是不是很方便呢？","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhs007%2Ftexturepackerjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhs007%2Ftexturepackerjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhs007%2Ftexturepackerjs/lists"}