{"id":31785917,"url":"https://github.com/fostercommerce/imgproxy-php","last_synced_at":"2025-10-10T12:23:36.441Z","repository":{"id":289059725,"uuid":"968584635","full_name":"FosterCommerce/imgproxy-php","owner":"FosterCommerce","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-28T10:12:24.000Z","size":43,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-10T03:43:31.628Z","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/FosterCommerce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2025-04-18T10:52:53.000Z","updated_at":"2025-04-28T10:11:42.000Z","dependencies_parsed_at":"2025-04-21T10:40:55.856Z","dependency_job_id":null,"html_url":"https://github.com/FosterCommerce/imgproxy-php","commit_stats":null,"previous_names":["fostercommerce/imgproxy-php"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FosterCommerce/imgproxy-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterCommerce%2Fimgproxy-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterCommerce%2Fimgproxy-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterCommerce%2Fimgproxy-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterCommerce%2Fimgproxy-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FosterCommerce","download_url":"https://codeload.github.com/FosterCommerce/imgproxy-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FosterCommerce%2Fimgproxy-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003897,"owners_count":26083641,"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-10-10T02:00:06.843Z","response_time":62,"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":[],"created_at":"2025-10-10T12:23:32.093Z","updated_at":"2025-10-10T12:23:36.434Z","avatar_url":"https://github.com/FosterCommerce.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imgproxy-php\n\nA PHP library for working with imgproxy. This package provides a simple way to build URLs with imgproxy processing options.\n\n## Installation\n\n```bash\ncomposer require fostercommerce/imgproxy-php\n```\n\n## Usage\n\n### Creating Processing Options\n\n```php\nuse fostercommerce\\imgproxy\\Options;\n\n// Create a new Options object\n$options = new Options();\n\n// Set options with individual setters\n$options-\u003esetWidth(300)\n    -\u003esetHeight(400)\n    -\u003esetResizingType('fill')\n    -\u003esetGravity('sm');\n\n// Get string representation for URL\necho $options-\u003etoString();\n// Output: \"width:300/height:400/resizing_type:fill/gravity:sm\"\n\n// Options object can also be used directly in a string context\necho $options;\n// Output: \"width:300/height:400/resizing_type:fill/gravity:sm\"\n```\n\n### Alternative Initialization\n\nIt is possible to initialize the Options object with an associative array. The keys of the array are the option names and the values are the option values.\n\nThe values can either be a single value, an array of values, or an associative array of values.\n\n- When a single value is used, it is passed as the first argument to the setter method.\n- When an array of values is used, they are destructured as passed as arguments in order to the setter method.\n- When an associative array is used, the key/value pairs are destructured and passed in as named arguments to the setter method.\n\n```php\n// Create Options object with array of values\n$options = new Options([\n    'width' =\u003e 300,\n    'height' =\u003e 400,\n    'resize' =\u003e [\n        'width' =\u003e 300,\n        'height' =\u003e 400,\n        'enlarge' =\u003e false,\n        'resize_type' =\u003e 'fill',\n    ],\n    'gravity' =\u003e 'sm',\n    'png_options' =\u003e [\n        'interlaced' =\u003e true,\n        'quantize' =\u003e false,\n    ],\n]);\n```\n\n### Building URLs\n\n```php\nuse fostercommerce\\imgproxy\\Options;\nuse fostercommerce\\imgproxy\\UrlBuilder;\n\n// Create options object\n$options = new Options();\n$options-\u003esetPreset('sharp')\n    -\u003esetResize('fill', 300, 400, false)\n    // or\n    -\u003esetResize([\n        'width' =\u003e 300,\n        'height' =\u003e 400,\n        'enlarge' =\u003e false,\n        'resize_type' =\u003e 'fill',\n    ])\n    -\u003esetGravity('sm')\n    -\u003esetQuality(80)\n    -\u003esetFormat('png');\n\n// Create URL builder (without signing, with plain URLs)\n$builder = new UrlBuilder('https://imgproxy.example.com', null, null, false);\n\n// Build URL\n$imageUrl = 'https://example.com/images/image.jpg';\n$url = $builder-\u003ebuildUrl($imageUrl, $options);\n\necho $url;\n// Output: https://imgproxy.example.com/unsafe/preset:sharp/resize:fill:300:400:0/gravity:sm/quality:80/format:png/plain/https://example.com/images/image.jpg\n```\n\n### Encoded URLs\n\n```php\nuse fostercommerce\\imgproxy\\Options;\nuse fostercommerce\\imgproxy\\UrlBuilder;\n\n// Create options object\n$options = new Options();\n$options-\u003esetWidth(300)\n    -\u003esetHeight(400)\n    -\u003esetResizingType('fill');\n\n// Create URL builder with base64 encoding (default behavior)\n$builder = new UrlBuilder('https://imgproxy.example.com', null, null, true);\n\n// Build URL with encoded source\n$imageUrl = 'https://example.com/images/image.jpg';\n$url = $builder-\u003ebuildUrl($imageUrl, $options);\n\necho $url;\n// Output: https://imgproxy.example.com/unsafe/width:300/height:400/resizing_type:fill/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZXMvaW1hZ2UuanBn\n\n// With extension\n$url = $builder-\u003ebuildUrl($imageUrl, $options, 'png');\necho $url;\n// Output: https://imgproxy.example.com/unsafe/width:300/height:400/resizing_type:fill/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZXMvaW1hZ2UuanBn.png\n```\n\n### Signed URLs\n\n```php\n// Create URL builder with signing keys (using plain URLs)\n$key = '0123456789abcdef0123456789abcdef';\n$salt = 'fedcba9876543210fedcba9876543210';\n$builder = new UrlBuilder('https://imgproxy.example.com', $key, $salt, false);\n\n// Build signed URL\n$imageUrl = 'https://example.com/images/image.jpg';\n$url = $builder-\u003ebuildUrl($imageUrl, $options, 'png');\n\necho $url;\n// Output will include a signature: https://imgproxy.example.com/[signature]/preset:sharp/resize:fill:300:400:0/gravity:sm/quality:80/format:png/plain/https://example.com/images/image.jpg@png\n```\n\n### Signed and Encoded URLs\n\n```php\n// Create URL builder with signing keys and base64 encoding\n$key = '0123456789abcdef0123456789abcdef';\n$salt = 'fedcba9876543210fedcba9876543210';\n$builder = new UrlBuilder('https://imgproxy.example.com', $key, $salt, true);\n\n// Build signed URL with encoded source\n$imageUrl = 'https://example.com/images/image.jpg';\n$url = $builder-\u003ebuildUrl($imageUrl, $options);\n\necho $url;\n// Output will include a signature: https://imgproxy.example.com/[signature]/preset:sharp/resize:fill:300:400:0/gravity:sm/quality:80/format:png/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZXMvaW1hZ2UuanBn\n```\n\n## Development\n\n### Testing\n\nThis package uses [Pest PHP](https://pestphp.com/) for testing. To run the tests:\n\n```bash\ncomposer test\n```\n\nor\n\n```bash\nvendor/bin/pest\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffostercommerce%2Fimgproxy-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffostercommerce%2Fimgproxy-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffostercommerce%2Fimgproxy-php/lists"}