Download the PHP package crazko/post-social-image without Composer
On this page you can find all versions of the php package crazko/post-social-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crazko/post-social-image
More information about crazko/post-social-image
Files in crazko/post-social-image
Package post-social-image
Short Description Creates images suitable for social sharing
License MIT
Homepage https://github.com/crazko/post-social-image
Informations about the package post-social-image
A simple command line tool to generate images suitable for sharing on social media sites.
Installation
Usage
API
new Image(int $width, string $background, string $font, int $padding)
Creates new Image
instance.
$width
- width of the image in px, height is calculated proportionaly 16:9$background
- HEX color of the image background, e.g.:ff8800
or#ff8800
$fontPath
- path to the font used in the image$padding
- free space around the image in px
Image::text(string $text, int $size, string $color, ?int $position = null)
Adds 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.
$text
- given text$size
- size of the text in px$color
- HEX color of the text, e.g.:ff8800
or#ff8800
$position
- position of the text in the image, use combination ofPosition::TOP
,Position::BOTTOM
,Position::LEFT
,Position::RIGHT
, e.g.:Position::TOP | Position::RIGHT
Image::save(string $name, string $destination)
Saves generated image to the $destination
with given (webalized) $name
and returns resulting path.
Image::get()
Returns generated image.
CLI
Resulting success message:
Image was created in ./assets/img/my-amazing-post.png
Composer command
You can also define a new command in your composer.json
to avoid constantly typing every option:
and use it to create new images more easily:
Available options
Type vendor/bin/create-image --help
to see all available options.
Development
Fork and clone the repository, install dependencies.
Testing commands:
composer ecs
- checks coding standards with EasyCodingStandard librarycomposer phpstan
- runs static analysis with phpstancomposer tester
- runs tests from./tests
with nette/tester
composer test
- runs all above togethercomposer fix
- fixes coding standard violations automatically
Tips
How to add image to the site
Add following meta tags to the <head>
element of your page:
All recommended tags:
See The Open Graph protocol and Twitter Cards for more info about other meta tags.
Preview
Try 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.