{"id":18929374,"url":"https://github.com/thecodingmachine/utils.graphics.image-preset-displayer","last_synced_at":"2025-08-24T19:36:34.619Z","repository":{"id":6032229,"uuid":"7256416","full_name":"thecodingmachine/utils.graphics.image-preset-displayer","owner":"thecodingmachine","description":"Images handler that will generate image thumbs and serve them when displayed (like the drupal image styles services)","archived":false,"fork":false,"pushed_at":"2018-02-28T11:33:26.000Z","size":439,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"3.0","last_synced_at":"2025-02-16T12:30:30.774Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2012-12-20T11:03:57.000Z","updated_at":"2016-10-05T07:37:57.000Z","dependencies_parsed_at":"2022-08-30T15:40:09.135Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/utils.graphics.image-preset-displayer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.graphics.image-preset-displayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.graphics.image-preset-displayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.graphics.image-preset-displayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.graphics.image-preset-displayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/utils.graphics.image-preset-displayer/tar.gz/refs/heads/3.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927823,"owners_count":19719835,"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":[],"created_at":"2024-11-08T11:32:15.034Z","updated_at":"2025-02-20T22:41:55.140Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Graphics image preset displayer\n===============================\n\nWhat is this package\n--------------------\n\nThis package is used to resize/modify images dynamically on a website.\nIt requires [Mouf](http://mouf-php.com) and Apache as a web-server.\n\nHow does it work?\n-----------------\n\nYou store the images to be resized/transformed in a directory. For instance: `images/original`.\nYou would normally access those images like this: `http://[myserver]/[myapp]/images/original/test.png`.\nInstead, using this package, you can access `http://[myserver]/[myapp]/images/small/test.png`.\n\nIf the `test.png` image does not exist in the `small` directory, it will be automatically resized,\nand stored in that directory (thanks to a `.htaccess` file stored in the `small` directory).\nOnce the image has been generated, the image will be served statically.\nTherefore, the cost of resizing the image is only paid once, the first time the image is accessed.\n\nThis package is very similar to the way the *image_cache* module works in Drupal.\n\n\nHow to use it\n-------------\n\nFirst, start by creating an instance of the `StaticImageDisplayer` class.\n\nThe most important properties are:\n\n- *initialImageFilter*: this is a pointer to an object representing the source image.\n- *imageSource*: this is a pointer to an object representing the transformed image.\n- *savePath*: the directory where the resized images will be saved.\n- *basePath*: the directory where the original images are stored.\n\n![sample StaticImageDisplayer instance](doc/images/StaticImageDisplayer.png)\n\n**Compulsory**\nThe *initialImageFilter* property must be filled with an instance of `MoufImageFromFile`. For your convenience,\nyou might name this instance `sourceImage`. The `path` property of the `sourceImage` should remain empty.\nIt will be filled on runtime, when an image is requested.\n\n![sourceImage instance](doc/images/sourceImage.png)\n\nFinally, the most important part. The *imageSource* property points to an instance of a class implementing\nthe `MoufImageInterface`. In our case, we are looking to reduce the image size. We will therefore use the\n`MoufImageResize` class that resizes an image. Here, we could put any valid transformation provided\nby the *mouf.image* package.\n\n![MoufImageResize](doc/images/MoufImageResize.png)\n\nEverything is set up. We just need one additional thing. We need to write the `.htaccess` that will\nautomatically call the `StaticImageDisplayer` if an image is not found.\nHopefully, the `StaticImageDisplayer` class provides a utility function for this, directly accessible from the Mouf UI.\n\nIn your `StaticImageDisplayer` instance, just click on the \"Generate .htaccess\" button.\n\n![Generate .htaccess](doc/images/generateHtAccess.png)\n\nThe .htaccess should be generated. You are now ready to test image resizing.\nPut an image in your `basePath` folder and try to access it from the `savePath` URL. You should see the image resized. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Futils.graphics.image-preset-displayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Futils.graphics.image-preset-displayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Futils.graphics.image-preset-displayer/lists"}