{"id":15917464,"url":"https://github.com/takuya/php-imagick-cmd-wrapper","last_synced_at":"2025-04-30T09:25:22.625Z","repository":{"id":57064716,"uuid":"397630143","full_name":"takuya/php-imagick-cmd-wrapper","owner":"takuya","description":"image magick command wrapper for php","archived":false,"fork":false,"pushed_at":"2025-03-31T10:38:16.000Z","size":2153,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T03:04:41.906Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takuya.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-18T14:28:24.000Z","updated_at":"2025-03-31T10:38:20.000Z","dependencies_parsed_at":"2025-02-18T09:24:51.419Z","dependency_job_id":"0d579dc0-75a0-4dce-8834-61514220851c","html_url":"https://github.com/takuya/php-imagick-cmd-wrapper","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-imagick-cmd-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-imagick-cmd-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-imagick-cmd-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-imagick-cmd-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takuya","download_url":"https://codeload.github.com/takuya/php-imagick-cmd-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251675631,"owners_count":21625850,"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-10-06T18:10:47.523Z","updated_at":"2025-04-30T09:25:22.602Z","avatar_url":"https://github.com/takuya.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-imagick-cmd-wrapper\n![](https://github.com/takuya/php-imagick-cmd-wrapper//workflows/main/badge.svg)\n\nImage magick shell command wrapper for php\n\n\n## requirements\n```\napt install imagemagick\n```\n\n## Why using magick shell command from php?\n\n#### Occasionally, a php-imagick (ext-imagick) is not available. \n\n  Some mod-php server are not supporting ext-imagck. but convert command is easy to install.\n\n#### Imagick class ( in ext-imagick) is not documented in precisely.\n\n  Think, Can you tell how to use 'png:compression-filter' in ext-imagick ?. Perhaps you can't. \n  But, there are very many 'convert' samples in web. and we are trying to `system('convert a.jpg b.png')` calling with escaping shell arguments. What's a irritated.\n\n\nSo, we need `convert` command wrapper. \n\n## Installing from GitHub\n```\nrepo=git@github.com:takuya/php-imagick-cmd-wrapper.git\ncomposer config repositories.takuya/php-imagick-cmd-wrapper vcs $repo\ncomposer require takuya/php-imagick-cmd-wrapper\n```\n\n## Usage Sample \n\n```php\n$f_in = 'DkzpJ1lUUAA84KP.jpg';\n$width = 500;\n// convert\n$convert = new Convert();\n$ret = $convert\n      -\u003esetInputFile( $f_in )\n      -\u003eunsharp('10x5+0.7+0')\n      -\u003esample($width)\n      -\u003epointsize(30)\n      -\u003efill('blue')\n      -\u003estrokewidth(1)\n      -\u003estroke('gray80')\n      -\u003efont('DejaVu-Sans')\n      -\u003eannotate('+10+100','unsharp_sample')\n      -\u003esetOutputFile( 'jpeg:-' )\n      -\u003eexecute();\n$image_bin = $ret[1];\nfile_put_contents('out.jpg',$image_bin)    \n```\n\n## Important Notice! Call Method Ordering.\n\nBefore Use, You should know that OPTIONS Ordering is VERY IMPORTANT.\n\nThe `convert` command is Very NAIVE for option order.\n\nWe must care about Arguments Ordering.\n\n#### Sample1 ( vain , not working. )\n```php\n(new Identify())\n    -\u003esetInputFile('a.jpg')\n    -\u003eformat('[%w,%h]')\n-\u003eexecute();\n```\n\nThis result in ` identify a.jpg -format '[%w,%h]'` , but no work.\n#### Sample2 ( works fine. )\n```php\n(new Identify())\n    -\u003esetInputFile('a.jpg')\n    -\u003eformat('[%w,%h]')\n-\u003eexecute();\n```\nThis result in ` identify  -format '[%w,%h]' a.jpg ` , it will work fine.\n\n### More Sample Usage\n\n#### Convert JPEG to PNG.\n```php\n$convert = ;\n(new Convert())\n      -\u003esetInputile( 'a.jpg' )\n      -\u003esetOutputFile( 'b.png' )\n      -\u003eexecute();\n```\n#### Using STDOUT - converting jpeg to png\n```php\n$convert = ;\n$result = (new Convert())\n      -\u003esetInputile( 'a.jpg' )\n      -\u003esetOutputFile( 'png:-' )\n      -\u003eexecute();\n$png_binary = $result[1];\n```\n#### Using STDIN - converting jpeg to png\n```php\n$convert = ;\n$result = (new Convert())\n      -\u003esetInputile( '-', file_get_contents('a.jpg') )\n      -\u003esetOutputFile( 'png:-' )\n      -\u003eexecute();\n$png_binary = $result[1];\n```\n####  Structure of return value \ncommand result is array of 3 entries\n```php\n$result = [\n  '0' =\u003e ' int / exit status code' ,\n  '1' =\u003e ' string / stdout from command' ,\n  '2' =\u003e ' string / stderr from command' ,\n];\n ```\n### Resize(sampling Algorithm) and UnSharp and Normalization\n```php\n$ret = $convert\n      -\u003esetInputFile( $f_in )\n      -\u003esample('50%')\n      -\u003eunsharp('10x5+0.7+0')\n      -\u003enormalize()\n      -\u003esetOutputFile( 'jpeg:-' )\n      -\u003eexecute();\n```\n\n### IDE Auto Completion.\n\nOptions(methods) are auto generated from Help doc from 'convert -h'.\n\nSo, in Some IDE, Auto completions will not work fine.\n\nIf it happens then add a path `src/generated/` to your Project search PATH.\n\n## Developing notice.\n\nThis project uses auto generated php code, parsing `converet -h`.\n\nIf you want to re-generate class, execute these command in CLI.\n```\ncomposer run generate-class convert\ncomposer run generate-class montage\ncomposer run generate-class identify\ncomposer run generate-class mogrify\n ```\n\nI used these environment. wsl1 debian. \n```\nwsl --list -v\n  NAME      STATE           VERSION\n* Debian    Running         1\n```\n```\ncat /etc/debian_version\n10.10\n```\nimagemagick from debian(wsl)\n```\nconvert -version\nVersion: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org\nCopyright: © 1999-2019 ImageMagick Studio LLC\nLicense: https://imagemagick.org/script/license.php\nFeatures: Cipher DPC Modules OpenMP\nDelegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib\n```\n\n## \n## test results.\n![](https://github.com/takuya/php-imagick-cmd-wrapper//workflows/main/badge.svg)\n## testing\n```\ncomposer install \n./vendor/bin/phpunit\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-imagick-cmd-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakuya%2Fphp-imagick-cmd-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-imagick-cmd-wrapper/lists"}