{"id":21344448,"url":"https://github.com/freshleafmedia/autofocus","last_synced_at":"2025-08-29T06:16:18.369Z","repository":{"id":62693265,"uuid":"551646108","full_name":"freshleafmedia/autofocus","owner":"freshleafmedia","description":"Automatic image focal point detection","archived":false,"fork":false,"pushed_at":"2023-11-30T14:50:37.000Z","size":766,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-23T23:01:25.346Z","etag":null,"topics":["autofocus","crop","focal-point","image","php"],"latest_commit_sha":null,"homepage":"https://www.freshleafmedia.co.uk/blog/image-focal-point-auto-detection","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/freshleafmedia.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}},"created_at":"2022-10-14T20:09:38.000Z","updated_at":"2025-07-14T13:42:17.000Z","dependencies_parsed_at":"2023-12-15T15:00:50.037Z","dependency_job_id":"66d16971-f5a5-45e0-92e5-a2b2dba214b5","html_url":"https://github.com/freshleafmedia/autofocus","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"70d0b2b5c7bb0218245a23f4f110f6f6a18da77c"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/freshleafmedia/autofocus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Fautofocus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Fautofocus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Fautofocus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Fautofocus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freshleafmedia","download_url":"https://codeload.github.com/freshleafmedia/autofocus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Fautofocus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272640912,"owners_count":24968778,"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","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["autofocus","crop","focal-point","image","php"],"created_at":"2024-11-22T01:19:06.465Z","updated_at":"2025-08-29T06:16:18.318Z","avatar_url":"https://github.com/freshleafmedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Autofocus\n\nAutomatic image focal point detection.\n\n\n## Overview\n\nAutofocus is an image analysis library which attempts to determine where the focal point of an image is.\n\n\n## Installation\n\n```\ncomposer require freshleafmedia/autofocus\n```\n\n\n## Usage\n\n```php\nuse FreshleafMedia\\Autofocus\\FocalPointDetector;\n\n$focalPointDetector = new FocalPointDetector();\n\n$point = $focalPointDetector-\u003egetPoint(new Imagick('/path/to/image'));\n\n$point-\u003ex; // 283\n$point-\u003ey; // 157\n```\n\n\n## How it works\n\nThe algorithm works by picking the busiest area of the image:\n\n1. Detect edges\n2. Apply a vignette. This pushes the focus towards the centre\n3. Split the image into segments\n4. Calculate the average brightness within each segment\n5. Pick the segment with the highest brightness\n\n\u003cp float=\"left\"\u003e\n    \u003cimg src=\"assets/owl.jpg\" width=\"16%\" /\u003e\n    \u003cimg src=\"assets/owl-edges.jpg\" width=\"16%\" /\u003e\n    \u003cimg src=\"assets/owl-vignette.jpg\" width=\"16%\" /\u003e\n    \u003cimg src=\"assets/owl-segment.jpg\" width=\"16%\" /\u003e\n    \u003cimg src=\"assets/owl-average.jpg\" width=\"16%\" /\u003e\n    \u003cimg src=\"assets/owl-select.jpg\" width=\"16%\" /\u003e\n\u003c/p\u003e\n\n\n## Options\n\nThe `FocalPointDetector` constructor takes a number of options:\n\n```php\nnew FocalPointDetector(\n    segmentSize: 20, // The size of the Segments in pixels\n);\n```\n\n\n## Debugging\n\nYou can get access to the processed image to see how the focus was determined:\n\n```php\nuse FreshleafMedia\\Autofocus\\FocalPointDetector;\n\n$focalPointDetector = new FocalPointDetector();\n\n$focalPointDetector\n    -\u003edebug(new Imagick('/path/to/image'))\n    -\u003edrawHeatMap()\n    -\u003edrawGrid()\n    -\u003egetRawImage()\n    -\u003ewriteImage(__DIR__ . '/debug.jpg');\n```\n\n\n## Tests\n\nUnit tests can be run via `composer test`\n\n\n## Credits\n\nThis library is essentially a PHP port of https://github.com/sylvainjule/kirby-autofocus.\n\n\n## License\n\nSee [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshleafmedia%2Fautofocus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreshleafmedia%2Fautofocus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshleafmedia%2Fautofocus/lists"}