{"id":36976301,"url":"https://github.com/silencesoft/slim-image-resize","last_synced_at":"2026-01-13T22:12:14.216Z","repository":{"id":57050649,"uuid":"165163477","full_name":"silencesoft/slim-image-resize","owner":"silencesoft","description":"Image Resize Middleware for Slim Framework","archived":false,"fork":true,"pushed_at":"2019-01-12T23:28:09.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T20:53:39.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"tuupola/slim-image-resize","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silencesoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-11T02:13:39.000Z","updated_at":"2019-01-12T23:22:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/silencesoft/slim-image-resize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/silencesoft/slim-image-resize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silencesoft%2Fslim-image-resize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silencesoft%2Fslim-image-resize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silencesoft%2Fslim-image-resize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silencesoft%2Fslim-image-resize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silencesoft","download_url":"https://codeload.github.com/silencesoft/slim-image-resize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silencesoft%2Fslim-image-resize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-13T22:12:13.359Z","updated_at":"2026-01-13T22:12:14.207Z","avatar_url":"https://github.com/silencesoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image Resize Middleware for Slim 3\n\n### Note\n*This is an update to original project tuupola/slim-image-resize to work with slim 3.*\n\nThis middleware implements automatic image resizing based on image filename.\n\n[![Author](http://img.shields.io/badge/author-@tuupola-blue.svg?style=flat-square)](https://twitter.com/tuupola)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)\n[![Build Status](https://img.shields.io/travis/tuupola/slim-image-resize/master.svg?style=flat-square)](https://travis-ci.org/tuupola/slim-image-resize)\n[![HHVM Status](https://img.shields.io/hhvm/tuupola/slim-image-resize.svg?style=flat-square)](http://hhvm.h4cc.de/package/tuupola/slim-image-resize)\n[![Coverage](http://img.shields.io/codecov/c/github/tuupola/slim-image-resize.svg?style=flat-square)](https://codecov.io/github/tuupola/slim-image-resize)\n\n## Install\n\nYou can install latest version using [composer](https://getcomposer.org/).\n\n```\n$ composer require tuupola/slim-image-resize @dev\n```\n\n## Configuration\n\nConfiguration options are passed as an array. There are no mandatory parameters.\n\n```php\n$app = new \\Slim\\Slim();\n$app-\u003eadd(new Slim\\Middleware\\ImageResize());\n```\n\nYou can configure the allowed image extensions and cache folder. Cache folder must be writable by webserver process. Image quality applies only for jpg images. Example options shown below are also the default options used by the middleware.\n\n```php\n$app = new \\Slim\\Slim();\n$app-\u003eadd(new Slim\\Middleware\\ImageResize([\n    \"extensions\" =\u003e [\"jpg\", \"jpeg\", \"png\", \"gif\"],\n    \"cache\" =\u003e \"cache\",\n    \"quality\" =\u003e 90\n]));\n```\n\n## Caching\n\nFor caching to work you also must add the following to your [.htaccess](https://github.com/tuupola/slim-image-resize/blob/master/example/.htaccess) file. These rules should be added before Slim rewrite rules. Folder name must be the same you passed in as middleware configuration option. With caching rewrite rules in place only first request is served by PHP. All subsequent requests are served with static file from cache folder.\n\n```\n# Check for cached image in cache folder.\nRewriteCond %{REQUEST_METHOD} ^GET$\nRewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_URI} -f\nRewriteRule ^(.*)$ /cache/$1 [L,QSA]\n```\n\nIf your Slim application is installed in to a subfolder use the following rewrite rule instead. This example assumes the subfolder is called `example`.\n\n```\nRewriteBase /example\n\n# Check for cached image in cache folder.\nRewriteCond %{REQUEST_METHOD} ^GET$\nRewriteCond %{DOCUMENT_ROOT}/example/cache/%{REQUEST_URI} -f\nRewriteRule ^(.*)$ /example/cache/example/$1 [L,QSA]\n\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^ index.php [QSA,L]\n```\n\n## Usage\n\nWith middleware configured you can create different sizes of images by altering the filename.\n\n```html\n\u003c!-- This is the original image --\u003e\n\u003cimg src=\"images/viper.jpg\"\u003e\n\u003c!-- Images below will be resized --\u003e\n\u003cimg src=\"images/viper-400x200.jpg\"\u003e\n\u003cimg src=\"images/viper-x200.jpg\"\u003e\n\u003cimg src=\"images/viper-200x.jpg\"\u003e\n\u003cimg src=\"images/viper-100x100.jpg\"\u003e\n```\n\nHTML above will produce the following images.\n\n![Original](http://www.appelsiini.net/img/viper.jpg)\n![400x200](http://www.appelsiini.net/img/viper-400x200.jpg)\n![x200](http://www.appelsiini.net/img/viper-x200.jpg)\n![200x](http://www.appelsiini.net/img/viper-200x.jpg)\n![100x100](http://www.appelsiini.net/img/viper-100x100.jpg)\n\n## Security\n\nBy default it is possible to create any size image. If images are also cached you should restrict which sizes middleware is allowed to create. Otherwise it is possible to make requests arbitary number of different sizes of images.\n\n```php\n$app = new \\Slim\\Slim();\n$app-\u003eadd(new Slim\\Middleware\\ImageResize([\n    \"sizes\" =\u003e [\"400x200\", \"x200\", \"200x\", \"100x100\"]\n]));\n```\n\nIf you have arbitary number of different sizes it is also possible to sign images with secret key.\n\n```php\n$app-\u003eadd(new Slim\\Middleware\\ImageResize([\n    \"secret\" =\u003e \"s11kr3t\"\n]));\n```\n\nYou must include the signature in the image name.\n\n```html\n\u003cimg src=\"images/viper-400x200-175ecbf97b7faebb.jpg\"\u003e\n```\n\nSignature for above image was generated with following code.\n\n```php\n$sha1 = sha1(\"400x200:s11kr3t\");\n$signature = substr($sha1, 0, 16);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilencesoft%2Fslim-image-resize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilencesoft%2Fslim-image-resize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilencesoft%2Fslim-image-resize/lists"}