{"id":16676130,"url":"https://github.com/brendt/responsive-images","last_synced_at":"2025-07-08T23:07:24.414Z","repository":{"id":62496882,"uuid":"74555473","full_name":"brendt/responsive-images","owner":"brendt","description":"Generate responsive images to work with the srcset and sizes spec","archived":false,"fork":false,"pushed_at":"2020-09-06T18:13:00.000Z","size":1244,"stargazers_count":61,"open_issues_count":1,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-19T12:52:17.152Z","etag":null,"topics":["html5","image-processing","php","responsive-images"],"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/brendt.png","metadata":{"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}},"created_at":"2016-11-23T08:17:23.000Z","updated_at":"2025-01-16T14:41:55.000Z","dependencies_parsed_at":"2022-11-02T11:46:15.012Z","dependency_job_id":null,"html_url":"https://github.com/brendt/responsive-images","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/brendt/responsive-images","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendt%2Fresponsive-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendt%2Fresponsive-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendt%2Fresponsive-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendt%2Fresponsive-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brendt","download_url":"https://codeload.github.com/brendt/responsive-images/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brendt%2Fresponsive-images/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264363793,"owners_count":23596507,"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":["html5","image-processing","php","responsive-images"],"created_at":"2024-10-12T13:09:19.553Z","updated_at":"2025-07-08T23:07:24.392Z","avatar_url":"https://github.com/brendt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://scrutinizer-ci.com/g/brendt/responsive-images/badges/build.png?b=master)](https://scrutinizer-ci.com/g/brendt/responsive-images/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/brendt/responsive-images/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/brendt/responsive-images/?branch=master)\n\n# Responsive Images\n\nAutomatically generate responsive images to work with the `srcset` and `sizes` spec. ([http://responsiveimages.org/](http://responsiveimages.org/))\n\n```sh\ncomposer require brendt/responsive-images\n```\n\n## Usage\n\n```php\nuse Brendt\\Image\\ResponsiveFactory;\n\n$factory = new ResponsiveFactory();\n$image = $factory-\u003ecreate('img/image.jpeg');\n```\n\n```html\n\u003cimg src=\"\u003c?= $image-\u003esrc() ?\u003e\" \n     srcset=\"\u003c?= $image-\u003esrcset() ?\u003e\"/\u003e\n```\n\nThis sample would generate something like:\n\n```hmtl\n\u003cimg src=\"/image.jpeg\" \n     srcset=\"/image-384.jpg 384w,\n             /image-768.jpg 768w,\n             /image-1152.jpg 1152w,\n             /image-1536.jpg 1536w,\n             /image.jpg 1920w\" /\u003e\n```\n\n## Configuration\n\nThe `ResponsiveFactory` can take a `ResponsiveFactoryConfigurator` object which will set the needed parameters. \nA default configurator `DefaultConfigurator` is provider out of the box, and uses the following parameters:\n \n```php\n[\n    'driver'           =\u003e 'gd',\n    'includeSource'    =\u003e true,\n    'publicPath'       =\u003e './',\n    'sourcePath'       =\u003e './',\n    'rebase'           =\u003e false,\n    'enableCache'      =\u003e false,\n    'optimize'         =\u003e false,\n    'scaler'           =\u003e 'filesize',\n    'stepModifier'     =\u003e 0.5,\n    'minFileSize'      =\u003e 5000,\n    'maxFileSize'      =\u003e null,\n    'minWidth'         =\u003e 300,\n    'maxWidth'         =\u003e null,\n    'sizes'            =\u003e [ 1920, 840, 300 ],\n    'optimizerOptions' =\u003e [],\n]\n```\n\nYou can override these parameters by providing and array to the `DefaultConfigurator`, \nor create a whole new configurator which implements `ResponsiveFactoryConfigurator`.\n\n```php\n$factory = new ResponsiveFactory(new DefaultConfigurator([\n    'driver'       =\u003e 'imagick',\n    'sourcePath'   =\u003e './src',\n    'publicPath'   =\u003e './public',\n    'enableCache'  =\u003e true,\n]));\n```\n\n### All configuration options\n\n- `driver`: the image driver to use. Defaults to `gd`. Possible options are `gd` or `imagick`.\n- `includeSource`: whether to include the source image in the `srcset`. Defaults to `true`.\n- `sourcePath`: the path to load image source files. Defaults to `./`.\n- `publicPath`: the path to render image files. Defaults to `./`.\n- `rebase`: ignore the path of the requested image when searching in the source directory. Defaults to `false`.\n- `enableCache`: enable or disable image caching. Enabling the cache wont' override existing images. Defaults to `false`.\n- `optimize`: enable or disable the use of different optimizers (if installed on the system). Defaults to `false`.\n- `scaler`: which scaler algorithm to use. Defaults to `filesize`. Possible options are `filesize`, `width` or `sizes`.\n- `stepModifier`: a percentage (between 0 and 1) which is used to create different image sizes. The higher this modifier, the more image variations will be rendered. Defaults to `0.5`.\n- `minFileSize`: the minimum image filesize in bytes. Defaults to `5000`B (5KB).\n- `maxFileSize`: the maximum image filesize in bytes. Defaults to `null`.\n- `minWidth`: the minimum image size in pixels. No images with size smaller than this number will be rendered. Defaults to `300` pixels.\n- `maxWidth`: the maximum image size in pixels. No images with size smaller than this number will be rendered. Defaults to `null`.\n- `sizes`: this parameter is used when the `sizes` scaler is enabled. This scaler will generate a fixed set of sizes, based on this array. \n The expected values are the widths of the generated images. Defaults to `[]` (empty array). \n- `optimizerOptions`: options to pass to the image optimizer library. See [https://github.com/psliwa/image-optimizer](https://github.com/psliwa/image-optimizer) for more information.\n\n### Paths\n\nThe `sourcePath` parameter is used to define where image source files are located. \nIn case of the first example and above configuration, the image file should be saved in `./src/img/image.jpeg`.\n\nThe `publicPath` parameter is used to save rendered images into. This path should be the public directory of your website.\nThe above example would render images into `./public/img/image.jpeg`. \n\n#### Path rebasing\n\nWhen the `rebase` option is enabled, source file lookup will differ: only the filename is used to search the file in the \n source directory. An example would be the following.\n \n```php\n// Without rebase\n\n$options = [\n    'sourcePath' =\u003e './src/images',\n    'publicPath' =\u003e './public',\n];\n\n$image = $factory-\u003ecreate('/img/responsive/image.jpeg');\n\n// Source file is searched in './src/images/img/responsive/image.jpeg' \n// Public files are saved in './public/img/responsive/image-x.jpg'\n``` \n\n```php\n// With rebase\n\n$options = [\n    'sourcePath' =\u003e './src/images',\n    'publicPath' =\u003e './public',\n    'rebase'     =\u003e true,\n];\n\n$image = $factory-\u003ecreate('/img/responsive/image.jpeg');\n\n// Source file is searched in './src/images/image.jpeg'  \n// Public files are saved in './public/img/responsive/image-x.jpg'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrendt%2Fresponsive-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrendt%2Fresponsive-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrendt%2Fresponsive-images/lists"}