{"id":28625272,"url":"https://github.com/contao/image","last_synced_at":"2025-06-12T08:09:10.672Z","repository":{"id":40439976,"uuid":"52284505","full_name":"contao/image","owner":"contao","description":"Contao Image Library","archived":false,"fork":false,"pushed_at":"2025-02-25T14:42:07.000Z","size":408,"stargazers_count":13,"open_issues_count":6,"forks_count":5,"subscribers_count":8,"default_branch":"1.x","last_synced_at":"2025-05-26T04:48:47.842Z","etag":null,"topics":["cms","contao","image","php","resizer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contao.png","metadata":{"funding":{"custom":"https://to.contao.org/donate"},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2016-02-22T15:46:58.000Z","updated_at":"2025-02-26T01:50:57.000Z","dependencies_parsed_at":"2023-02-16T01:10:18.188Z","dependency_job_id":"e492ae78-967a-45eb-9a26-e3cb90e87977","html_url":"https://github.com/contao/image","commit_stats":{"total_commits":257,"total_committers":7,"mean_commits":"36.714285714285715","dds":0.2684824902723736,"last_synced_commit":"059ec45803bb358bbac3d87af7e707e7d0d5deda"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/contao/image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contao%2Fimage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contao%2Fimage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contao%2Fimage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contao%2Fimage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contao","download_url":"https://codeload.github.com/contao/image/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contao%2Fimage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259427060,"owners_count":22855562,"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":["cms","contao","image","php","resizer"],"created_at":"2025-06-12T08:08:57.226Z","updated_at":"2025-06-12T08:09:10.656Z","avatar_url":"https://github.com/contao.png","language":"PHP","funding_links":["https://to.contao.org/donate"],"categories":[],"sub_categories":[],"readme":"Contao image library\n====================\n\n[![](https://img.shields.io/github/actions/workflow/status/contao/image/ci.yml?branch=1.x\u0026style=flat-square)](https://github.com/contao/image/actions?query=branch%3A1.x)\n[![](https://img.shields.io/codecov/c/github/contao/image/1.x.svg?style=flat-square)](https://codecov.io/gh/contao/image)\n[![](https://img.shields.io/packagist/v/contao/image.svg?style=flat-square)](https://packagist.org/packages/contao/image)\n[![](https://img.shields.io/packagist/dt/contao/image.svg?style=flat-square)](https://packagist.org/packages/contao/image)\n\nThis library provides methods to resize images based on resize configurations\nand generates responsive images to be used with `\u003cpicture\u003e` and `srcset`. It is\nused in [Contao][1] to handle on-the-fly resizing of images.\n\nInstallation\n------------\n\n```sh\nphp composer.phar require contao/image\n```\n\nUsage\n-----\n\n### Simple resize:\n\n```php\n$imagine = new \\Imagine\\Gd\\Imagine();\n$resizer = new Resizer('/path/to/cache/dir');\n$image = new Image('/path/to/image.jpg', $imagine);\n\n$config = (new ResizeConfiguration())\n    -\u003esetWidth(100)\n    -\u003esetHeight(100)\n    -\u003esetMode(ResizeConfiguration::MODE_CROP)\n;\n\n$options = (new ResizeOptions())\n    -\u003esetImagineOptions([\n        'jpeg_quality' =\u003e 95,\n        'interlace' =\u003e \\Imagine\\Image\\ImageInterface::INTERLACE_PLANE,\n    ])\n    -\u003esetBypassCache(true)\n    -\u003esetTargetPath('/custom/target/path.jpg')\n;\n\n$resizedImage = $resizer-\u003eresize($image, $config, $options);\n\n$resizedImage-\u003egetPath(); // /custom/target/path.jpg\n$resizedImage-\u003egetUrl('/custom/target'); // path.jpg\n$resizedImage-\u003egetUrl('/custom/target', 'https://example.com/'); // https://example.com/path.jpg\n```\n\n### Responsive image:\n\n```php\n$imagine = new \\Imagine\\Gd\\Imagine();\n\n$resizer = new Resizer('/path/to/cache/dir');\n$pictureGenerator = new PictureGenerator($resizer);\n$image = new Image('/path/to/image.jpg', $imagine);\n\n$config = (new PictureConfiguration())\n    -\u003esetSize((new PictureConfigurationItem())\n        -\u003esetResizeConfig((new ResizeConfiguration())\n            -\u003esetWidth(100)\n            -\u003esetHeight(100)\n            -\u003esetMode(ResizeConfiguration::MODE_CROP)\n        )\n        -\u003esetDensities('1x, 2x')\n        -\u003esetSizes('100vw')\n    )\n    -\u003esetSizeItems([\n        (new PictureConfigurationItem())\n            -\u003esetResizeConfig((new ResizeConfiguration())\n                -\u003esetWidth(400)\n                -\u003esetHeight(200)\n                -\u003esetMode(ResizeConfiguration::MODE_CROP)\n            )\n            -\u003esetDensities('1x, 2x')\n            -\u003esetSizes('100vw')\n            -\u003esetMedia('(min-width: 900px)')\n    ])\n;\n\n$options = (new ResizeOptions());\n$picture = $pictureGenerator-\u003egenerate($image, $config, $options);\n\n$picture-\u003egetImg('/path/to');\n/* [\n    'src' =\u003e 'cache/dir/4/image-de332f09.jpg',\n    'width' =\u003e 100,\n    'height' =\u003e 100,\n    'srcset' =\u003e 'cache/dir/4/image-de332f09.jpg 100w, cache/dir/4/image-9e0829dd.jpg 200w',\n    'sizes' =\u003e '100vw',\n] */\n\n$picture-\u003egetSources('/path/to', 'https://example.com/');\n/* [\n    [\n        'src' =\u003e 'https://example.com/cache/dir/c/image-996db4cf.jpg',\n        'width' =\u003e 400,\n        'height' =\u003e 200,\n        'srcset' =\u003e 'https://example.com/cache/dir/c/image-996db4cf.jpg 400w, https://example.com/cache/dir/2/image-457dc5e0.jpg 800w',\n        'sizes' =\u003e '100vw',\n        'media' =\u003e '(min-width: 900px)',\n    ],\n] */\n```\n\n[1]: https://contao.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontao%2Fimage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontao%2Fimage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontao%2Fimage/lists"}