{"id":15021238,"url":"https://github.com/gregwar/tex2png","last_synced_at":"2026-03-08T04:31:26.459Z","repository":{"id":3608951,"uuid":"4673892","full_name":"Gregwar/Tex2png","owner":"Gregwar","description":"PHP Library to generate PNGs from LaTeX math formula","archived":false,"fork":false,"pushed_at":"2018-09-24T19:57:53.000Z","size":28,"stargazers_count":72,"open_issues_count":1,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-19T06:09:27.610Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Gregwar.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":"2012-06-15T10:25:15.000Z","updated_at":"2024-12-10T13:18:38.000Z","dependencies_parsed_at":"2022-09-01T06:22:19.499Z","dependency_job_id":null,"html_url":"https://github.com/Gregwar/Tex2png","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FTex2png","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FTex2png/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FTex2png/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FTex2png/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gregwar","download_url":"https://codeload.github.com/Gregwar/Tex2png/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230388131,"owners_count":18217755,"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-09-24T19:56:20.226Z","updated_at":"2026-03-08T04:31:26.400Z","avatar_url":"https://github.com/Gregwar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tex2png\n=======\n\nThis class provides a way to create easily LaTeX formulas.\n\nWith it, you can convert raw formulas like:\n\n`\\sum_{i = 0}^{i = n} \\frac{i}{2}`\n\nTo nice images like:\n\n![Sum formula](demo/sum.png)\n\nRequirement\n-----------\n\nTo use this library you'll need :\n\n* **latex** : to compile formulas (with math support)\n* **dvipng** : to convert dvis to png\n* **shell_exec** : you need to be able to call the php `shell_exec()` function\n\nYou'll also need a temporary folder and, of courses, enough permissions to write to the \ntarget directory\n\nUsage\n-----\n\nJust include the `Tex2png.php` file or register this repository directory as the\n`Gregwar\\Tex2png\\` namespace and do the following :\n\n```php\n\u003c?php\n\n// This will create a formula and save it to sum.png\nTex2png::create('\\sum_{i = 0}^{i = n} \\frac{i}{2}')\n    -\u003esaveTo('sum.png')\n    -\u003egenerate();\n```\n\nYou can have a look at the example in `example/` directory.\n\nUsing the cache\n---------------\n\nTex2png library includes a caching system allowing you to generate images only one time.\nTo do so, just don't tell `Tex2png` what is the target file :\n\n```php\n\u003c?php\n\nTex2png::create('\\sum_{i = 0}^{i = n} \\frac{i}{2}')\n    -\u003egenerate();\n\n// The filename will be choosen using an hash of the formula and\n// the image density. (file name will look like cache/tex/3/0/2/e/6/8febefe7aaed9eeb8abf09070d10e02e93e.png)\n```\n\nIf the file already exists, it will not generate anything, else, it will generate it. This results in a \ntiny but powerful caching system avoiding to regenerate a formula PNG twice.\n\nNote that you can change the cache directory calling the `setCacheDirectory()` function\n\nThis is based on the [Gregwar/Cache](https://github.com/Gregwar/Cache/) library.\n\nChanging the density\n--------------------\n\nThe second constructor/create() parameter is the image density :\n\n```php\n\u003c?php\n\nTex2png::create('\\sum_{i = 0}^{i = n} \\frac{i}{2}', 300)\n    -\u003egenerate();\n```\n\nDefault density is **155**, you can choose to generate really big images, this is an example\nof the formula with a density of 1000 :\n\n![Sum formula (density=1000)](demo/sum-big.png)\n\nLicense\n-------\n\nThis class is under MIT license, for more information, please refer to the `LICENSE` file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwar%2Ftex2png","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregwar%2Ftex2png","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwar%2Ftex2png/lists"}