{"id":21678348,"url":"https://github.com/ifyun/file2img","last_synced_at":"2026-05-20T02:32:11.293Z","repository":{"id":191072967,"uuid":"639701450","full_name":"ifyun/file2img","owner":"ifyun","description":"Save file to image","archived":false,"fork":false,"pushed_at":"2023-05-12T06:35:04.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T10:28:12.798Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/ifyun.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}},"created_at":"2023-05-12T03:16:13.000Z","updated_at":"2023-05-12T03:40:55.000Z","dependencies_parsed_at":"2023-08-28T02:23:14.049Z","dependency_job_id":null,"html_url":"https://github.com/ifyun/file2img","commit_stats":null,"previous_names":["ifyun/file2img"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifyun%2Ffile2img","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifyun%2Ffile2img/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifyun%2Ffile2img/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifyun%2Ffile2img/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ifyun","download_url":"https://codeload.github.com/ifyun/file2img/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244591480,"owners_count":20477707,"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":"2024-11-25T14:28:15.404Z","updated_at":"2026-05-20T02:32:11.245Z","avatar_url":"https://github.com/ifyun.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FILE2IMG\n\n将任意文件储存到图片的像素中，保存为 BMP 图片，储存文件后的图片肉眼看不出区别。\n\n## 原理\n\n用图片 RGB 数值的奇偶表示二进制，达到储存文件的目的，奇数表示 1，偶数表示 0\n\n- RGB 第 0 ~ 15 位表示文件名的长度\n- RGB 第 16 ~ 48 位表示文件长度\n- RGB 第 48 位之后存储文件名 + 文件内容\n\n文件最大长度限制：2\u003csup\u003e32\u003c/sup\u003e bits = 524288 KiB\n\n一张图片可存储的文件长度：height * width * 3 - 48 bits\n\n一张 1920 x 1080 的图片可存储长度为：\n\n```\n1920 * 1080 * 3 - 48 bits = 777594 Bytes ≈ 759 KiB\n```\n\n\u003e 原图片不会被修改，不支持 PNG 图片\n\n## 环境要求\n\n- Python 3.11\n- numpy\n- PIL(pillow)\n\n```bash\npip install numpy\npip install pillow\n```\n\n## 使用\n\n### 将文件写入图片\n\n```bash\npython file2img.py -w --file D:\\\\archive.zip --img D:\\\\image.jpg --dest D:\\\\archive.bmp\n```\n\n`D:\\archive.zip` 文件内容将会写入到 `D:\\image.jpg`，带有数据的图片会保存到 `D:\\archive.bmp`。\n\n### 从图片中提取文件\n\n```bash\npython file2img.py -r --img D:\\\\archive.bmp --dest D:\\\\\n```\n\n`D:\\archive.bmp` 中的文件将被读取并写入到 `D:` 目录，文件名从图片中读取。\n\n### 完整选项\n\n```\noptions:\n  -h, --help            show this help message and exit\n  -r, --read            读取\n  -w, --write           写入\n  -f FILE, --file FILE  文件路径\n  -i IMG, --img IMG     图片路径\n  -d DEST, --dest DEST  保存路径(读取时为目录)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifyun%2Ffile2img","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fifyun%2Ffile2img","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifyun%2Ffile2img/lists"}