{"id":14036793,"url":"https://github.com/crazko/post-social-image","last_synced_at":"2026-02-06T21:34:52.402Z","repository":{"id":62502536,"uuid":"170199769","full_name":"crazko/post-social-image","owner":"crazko","description":"Creates images suitable for social sharing","archived":false,"fork":false,"pushed_at":"2019-08-03T07:29:21.000Z","size":311,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-02T16:36:09.834Z","etag":null,"topics":["command","image","open-graph","social"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/crazko.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":"2019-02-11T20:47:17.000Z","updated_at":"2024-01-16T14:58:03.000Z","dependencies_parsed_at":"2022-11-02T12:15:32.735Z","dependency_job_id":null,"html_url":"https://github.com/crazko/post-social-image","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/crazko/post-social-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazko%2Fpost-social-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazko%2Fpost-social-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazko%2Fpost-social-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazko%2Fpost-social-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crazko","download_url":"https://codeload.github.com/crazko/post-social-image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazko%2Fpost-social-image/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29177554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T20:14:21.878Z","status":"ssl_error","status_checked_at":"2026-02-06T20:14:21.443Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["command","image","open-graph","social"],"created_at":"2024-08-12T03:02:14.061Z","updated_at":"2026-02-06T21:34:52.382Z","avatar_url":"https://github.com/crazko.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"![Example Image](./docs/post-social-image.png)\n\nA simple command line tool to generate images suitable for sharing on social media sites.\n\n[![Travis (.org)](https://img.shields.io/travis/crazko/post-social-image.svg)](https://travis-ci.org/crazko/post-social-image)\n\n## Installation\n\n```\ncomposer require crazko/post-social-images\n```\n\n## Usage\n\n```php\n\u003c?php\n\nuse Crazko\\PostSocialImage\\Image;\nuse Crazko\\PostSocialImage\\Position;\n\n$title = 'My amazing post';\n\n$image = new Image(1600, '#1E9682', '/ubuntu.ttf', 80);\n$image-\u003etext($title, 120, '#E6FAFF'); // First text is always wrapped and centered\n$image-\u003etext('example.com', 25, '#33F88A', Position::BOTTOM | Position::RIGHT);\n\n// More texts can be placed into image\n$image-\u003etext('John Doe', 50, '#660012', Position::TOP | Position::LEFT);\n\n$path = $image-\u003esave($title, './assests/img'); // ./assets/img/my-amazing-post.png\n```\n\n![Example Image](./docs/my-amazing-post.png)\n\n### API\n\n#### `new Image(int $width, string $background, string $font, int $padding)`\n\nCreates new `Image` instance.\n\n- `$width` - width of the image in px, height is calculated proportionaly 16:9\n- `$background` - HEX color of the image background, e.g.: `ff8800` or `#ff8800`\n- `$fontPath` - path to the font used in the image\n- `$padding` - free space around the image in px\n\n#### `Image::text(string $text, int $size, string $color, ?int $position = null)`\n\nAdds text to the image. Can be used multiple times. First one is always centered, wrapped when the text is too long and resized to always fit the image - considered as a main title.\n\n- `$text` - given text\n- `$size` - size of the text in px\n- `$color` - HEX color of the text, e.g.: `ff8800` or `#ff8800`\n- `$position` - position of the text in the image, use combination of `Position::TOP`, `Position::BOTTOM`, `Position::LEFT`, `Position::RIGHT`, e.g.: `Position::TOP | Position::RIGHT`\n\n#### `Image::save(string $name, string $destination)`\n\nSaves generated image to the `$destination` with given ([webalized](https://doc.nette.org/en/2.4/strings#toc-webalize)) `$name` and returns resulting path.\n\n#### `Image::get()`\n\nReturns generated image.\n\n### CLI\n\n```\nvendor/bin/create-image -o example.com ./assets/img \"My amazing post\"\n```\n\nResulting success message:\n\n\u003e Image was created in ./assets/img/my-amazing-post.png\n\n#### Composer command\n\nYou can also [define a new command](https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands) in your `composer.json` to avoid constantly typing every option:\n\n```json\n{\n    \"scripts\": {\n        \"image\": \"vendor/bin/create-image --ansi -b E6FAFF -f 1E9682 -c E1738A -o example.com ./assets/img\"\n    },\n}\n```\n\nand use it to create new images more easily:\n\n```\ncomposer image \"My amazing post\"\n```\n\n#### Available options\n\nType `vendor/bin/create-image --help` to see all available options.\n\n```\nDescription:\n  Creates a new social image.\n\nUsage:\n  create [options] [--] \u003cdestination\u003e \u003ctitle\u003e\n\nArguments:\n  destination                            Where to save the image?\n  title                                  Title of the post the image should be generated for.\n\nOptions:\n  -w, --width=WIDTH                      The width of the image in px. Height is calculated proportionaly 16:9. [default: 1200]\n  -p, --padding=PADDING                  The padding of the image in px. [default: 50]\n  -s, --size=SIZE                        The size of the image title in px. [default: 100]\n  -b, --colorBackground=COLORBACKGROUND  HEX color of the title. [default: \"ffffff\"]\n  -f, --colorForeground=COLORFOREGROUND  HEX color of the image background. [default: \"000000\"]\n  -o, --origin=ORIGIN                    E.g. your name or the name of your blog.\n  -c, --colorOrigin=COLORORIGIN          HEX color of the origin. [default: \"000000\"]\n  -h, --help                             Display this help message\n  -q, --quiet                            Do not output any message\n  -V, --version                          Display this application version\n      --ansi                             Force ANSI output\n      --no-ansi                          Disable ANSI output\n  -n, --no-interaction                   Do not ask any interactive question\n  -v|vv|vvv, --verbose                   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\nHelp:\n  Creates a new social image with a defined title and optional signature.\n```\n\n## Development\n\nFork and clone the repository, install dependencies.\n\n```\ngit clone git@github.com:\u003cyour-name\u003e/post-social-images.git\ncd post-social-images\ncomposer install\n```\n\nTesting commands:\n\n- `composer ecs` - checks coding standards with [EasyCodingStandard](https://github.com/Symplify/EasyCodingStandard) library\n- `composer phpstan` - runs static analysis with [phpstan](https://github.com/phpstan/phpstan)\n- `composer tester` - runs tests from `./tests` with [nette/tester](https://tester.nette.org/)\n\n\u003c!-- separator --\u003e\n\n- `composer test` - runs all above together\n- `composer fix` - fixes coding standard violations automatically\n\n## Tips\n\n### How to add image to the site\n\nAdd following meta tags to the `\u003chead\u003e` element of your page:\n\n```html\n\u003cmeta name=\"twitter:image\" content=\"/assets/img/my-amazing-post.png\"\u003e\n\u003cmeta property=\"og:image\" content=\"/assets/img/my-amazing-post.png\"\u003e\n```\n\nAll recommended tags:\n\n```html\n\u003cmeta name=\"twitter:card\" content=\"summary_large_image\"\u003e\n\u003cmeta name=\"twitter:creator\" content=\"@twitter_handle\"\u003e\n\u003cmeta name=\"twitter:title\" content=\"My amazing post\"\u003e\n\u003cmeta name=\"twitter:description\" content=\"My amazing post introduction for visitors and crawlers.\"\u003e\n\u003cmeta name=\"twitter:image\" content=\"/assets/img/my-amazing-post.png\"\u003e\n\n\u003cmeta property=\"og:type\" content=\"article\"\u003e\n\u003cmeta property=\"og:title\" content=\"My amazing post\"\u003e\n\u003cmeta property=\"og:description\" content=\"My amazing post introduction for visitors and crawlers.\"\u003e\n\u003cmeta property=\"og:url\" content=\"https://example.com/my-amazing-post\"\u003e\n\u003cmeta property=\"og:image\" content=\"/assets/img/my-amazing-post.png\"\u003e\n```\n\nSee [The Open Graph protocol](http://ogp.me/) and [Twitter Cards](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards) for more info about other meta tags.\n\n#### Preview\n\nTry to add your page to the https://metatags.io/ to see how would it look like with your amazing new social image when shared on Facebook, Twitter, Linkedin and others.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazko%2Fpost-social-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazko%2Fpost-social-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazko%2Fpost-social-image/lists"}