CleasbyCode/imgprmt

GitHub: CleasbyCode/imgprmt

imgprmt是一个命令行工具,用于将文本提示嵌入JPG图像并创建多语言文件,方便在社交媒体上分享图像及其描述。

Stars: 1 | Forks: 0

# imgprmt ***imgprmt*** 是一个命令行工具,用于存储和分享您喜爱的图像文本提示/描述甚至短篇文章。该工具将您的提示嵌入到一个 ***JPG*** 图像中,并创建一个独特的 ***JPG-HTML*** 多语言文件,将图像、提示文本和 HTML 合并到单个输出文件中。 在兼容的社交媒体平台上分享图像:***X-Twitter***、***Tumblr***、***Mastodon***、***Pixelfed***、***Flickr*** 和 ***Bluesky***,嵌入的提示对任何下载该图像的用户都保持完整。 要在本地查看存储的提示,只需将图像文件扩展名重命名为 "*.htm*",然后在网络浏览器中打开它,即可将其显示为基本网页。 *尝试 [***这里***](https://cleasbycode.co.uk/imgprmt/app/) 的 imgprmt 网页应用,作为下载和编译 CLI 源代码的便捷替代方案。* ![演示图像](https://github.com/CleasbyCode/imgprmt/blob/main/demo_image/imgprmt_12736.jpg) *图像来源:[***Nova Kynth***](https://x.com/_virtualvisions/status/1907586383285301504)* ## 使用示例 (Linux) ``` user1@mx:~/Downloads/imgprmt-main/src$ sudo apt install libturbojpeg0-dev user1@mx:~/Downloads/imgprmt-main/src$ chmod +x compile_imgprmt.sh user1@mx:~/Downloads/imgprmt-main/src$ ./compile_imgprmt.sh user1@mx:~/Downloads/imgprmt-main/src$ Compilation successful. Executable 'imgprmt' created. user1@mx:~/Downloads/imgprmt-main/src$ sudo cp imgprmt /usr/bin user1@mx:~/Desktop$ imgprmt Usage: imgprmt [-b] imgprmt --info user1@mx:~/Desktop$ imgprmt winters_night.jpg *** imgprmt v1.3 *** Enter a complete web address (e.g., image source, your website or social media profile) URL: https://bsky.app/profile/novakynth.bsky.social/post/3m3n3kgenuk2a Default byte limit: 57,084 | X-Twitter byte limit: 1,800. Type or paste in your prompt as one long sentence. If required, add
tags to your text for new lines. Prompt: A serene winter night landscape in a forested area, under a starry dark blue sky... Saved "prompt-embedded" JPG image: imgprmt_32097.jpg (330511 bytes). ``` 使用默认的命令行参数(无选项),嵌入的图像只能发布在: ***Twitter***、***Tumblr***、***Mastodon***、***Pixelfed*** 和 ***Flickr***。 默认提示限制为 **57140** 字节(减去 URL 地址长度)。 ***X-Twitter*** 出于兼容性原因,限制为 **1845** 字节(减去 URL 地址长度)。 这比默认大小小得多,但应该足以满足大多数提示的需求。 \****************** 注意:***Bluesky*** 现在默认将图像保存为 ***WEBP***。 要将图像保存为 ***JPG***,请右键单击您想保存的图像。 从菜单中选择 ***在新标签页中打开图像***。 选择新标签页,在地址栏中,将光标移到地址末尾,添加 ***@jpg***,然后按回车键。 右键单击图像,从菜单中选择 ***图像另存为...*** 您的图像现在应该被下载为 ***JPG***。 \****************** 如果您打算在 ***Bluesky*** 上分享您 *嵌入了提示* 的图像,您***必须***首先在命令行参数中添加 ***-b*** 选项: ``` user1@mx:~/Desktop$ imgprmt -b my_image.jpg ``` 其次,要在 ***Bluesky*** 上发布图像,您需要使用 ***bsky_post.py*** 脚本,*位于仓库的 ***src*** 文件夹中*。要运行此脚本,您需要安装 ***Python3*** 以及 ***'requests'*** 和 ***'bs4' (BeautifulSoup) Python*** 包。 您还需要一个 ***应用密码*** 来配合 ***Python*** 脚本使用,您可以从您的 ***Bluesky*** 账户创建 (*https://bsky.app/settings/app-passwords*)。 以下是 bsky_post.py Python 脚本的一些基本使用示例: 将标准图像发布到您的个人资料/账户。 ``` $ python3 bsky_post.py --handle you.bsky.social --password xxxx-xxxx-xxxx-xxxx --image your_image.jpg --alt-text "alt-text here (optional)" "standard post text here (required)" ``` 如果您想发布多张图像(最多 4 张)。 ``` $ python3 bsky_post.py --handle you.bsky.social --password xxxx-xxxx-xxxx-xxxx --image img1.jpg --image img2.jpg --alt-text "alt_here" "standard post text..." ``` 如果您想将图像作为回复发布到另一个帖子。 ``` $ python3 bsky_post.py --handle you.bsky.social --password xxxx-xxxx-xxxx-xxxx --image your_image.jpg --alt-text "alt_here" --reply-to https://bsky.app/profile/someone.bsky.social/post/8m2tgw6cgi23i "standard post text..." ``` 使用 ***-b*** 选项创建的图像也可以在 ***Tumblr*** 上发布(无需使用 bsky_post 脚本)。 ***Bluesky*** 的图像文件大小限制为 **1MB**。 https://github.com/user-attachments/assets/e27f81f2-9573-4995-8308-f446795af1cf https://github.com/user-attachments/assets/67744e39-6f86-4d64-b199-5838db76d42e https://github.com/user-attachments/assets/805a0b8c-b397-4ba0-b6ca-d978a50e9bfb https://github.com/user-attachments/assets/6942aa0b-4b4e-41ee-b58a-4318148b5952 ## 第三方库 本项目使用了以下第三方库: - libjpeg-turbo (参见 [***LICENSE***](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/LICENSE.md) 文件) - {本软件部分基于 Independent JPEG Group 的工作。} - 版权所有 (C) 2009-2024 D. R. Commander。保留所有权利。 - 版权所有 (C) 2015 Viktor Szathmáry。保留所有权利。
标签:HTML生成, JPG编辑, polyglot文件, 二进制发布, 图像处理, 应用安全, 开源工具, 提示存储, 数据隐藏, 文件合成, 文本嵌入, 社交媒体工具, 逆向工具