{"id":36992717,"url":"https://github.com/sbolch/gd-image","last_synced_at":"2026-01-13T23:44:52.982Z","repository":{"id":49113615,"uuid":"109691251","full_name":"sbolch/gd-image","owner":"sbolch","description":"An image editing package using PHP's GD library.","archived":true,"fork":false,"pushed_at":"2023-10-02T20:17:29.000Z","size":123,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-23T04:44:48.536Z","etag":null,"topics":["gd","image","php","picture"],"latest_commit_sha":null,"homepage":"","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/sbolch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-11-06T12:16:54.000Z","updated_at":"2025-10-04T22:47:15.000Z","dependencies_parsed_at":"2022-09-24T02:43:06.712Z","dependency_job_id":null,"html_url":"https://github.com/sbolch/gd-image","commit_stats":null,"previous_names":["sbolch/gd-image","shadesoft/gdimage"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/sbolch/gd-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbolch%2Fgd-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbolch%2Fgd-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbolch%2Fgd-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbolch%2Fgd-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbolch","download_url":"https://codeload.github.com/sbolch/gd-image/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbolch%2Fgd-image/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["gd","image","php","picture"],"created_at":"2026-01-13T23:44:52.858Z","updated_at":"2026-01-13T23:44:52.933Z","avatar_url":"https://github.com/sbolch.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDImage\n\n\u003e An image editing package using PHP's GD library.\n\n[![Latest Stable Version](https://poser.pugx.org/sbolch/gd-image/version)](https://packagist.org/packages/sbolch/gd-image)\n[![StyleCI](https://styleci.io/repos/109691251/shield?branch=main\u0026style=flat)](https://styleci.io/repos/109691251?branch=main)\n[![Total Downloads](https://poser.pugx.org/sbolch/gd-image/downloads)](https://packagist.org/packages/sbolch/gd-image)\n[![License](https://poser.pugx.org/sbolch/gd-image/license)](https://packagist.org/packages/sbolch/gd-image)\n\n## Installation\n\nOpen a command console, enter your project directory and execute the following command to download the latest stable\nversion of this bundle:\n\n```console\n$ composer require sbolch/gd-image\n```\n\nThis command requires you to have Composer installed globally, as explained in\nthe [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\n## Usage\n\n### Image Converter\n\n```php\n\u003c?php\n  // ...\n  use sbolch\\GDImage\\Converter;\n  // ...\n  class Demo {\n    public function demo() {\n      $img = 'path/to/image.png';\n\n      $converter = new Converter();\n      $converter\n        -\u003eimage($img)\n        -\u003etoJpg()\n        -\u003etarget('path/to/converted-image.jpg')\n        -\u003esave();\n    }\n  }\n```\n\n#### Available functions\n\n- `image ( string | GdImage $image ) : self`\n\n  Set source image from file path or image resource\n\n- `target ( string $path ) : self`\n\n  Set target path\n\n- `quality ( int quality ) : self`\n\n  Set output quality - accepted value is a percentage\n\n- `background ( int red, int green, int blue ) : self`\n\n  Set background color instead of transparency - accepted values are integers between 0 and 255\n\n- `toAvif() | toBmp() | toGif() | toJpg() | toJpeg() | toPng() | toWebp() : self`\n\n  Set output format\n\n- `save() : string`\n\n  Save generated image\n\n- `output() : void`\n\n  Print image to PHP output\n\n### Image Sizer\n\n```php\n\u003c?php\n  // ...\n  use sbolch\\GDImage\\Sizer;\n  // ...\n  class Demo {\n    public function demo() {\n      $img = 'path/to/image.jpg';\n\n      $sizer = new Sizer();\n      $sizer\n        -\u003eimage($img)\n        -\u003ethumbnail(400, 300)\n        -\u003esave();\n    }\n  }\n```\n\n#### Available functions\n\n**See available functions at Converter, all of them are available here, too**\n\n- `image ( string | GdImage $image ) : self`\n\n  Set source image from file path or image resource\n\n- `instance(): GdImage`\n\n  Return current image resource\n\n- `widen ( int $width ) : self`\n\n  Set the image to the given width while preserving its ratio\n\n- `heighten ( int $height ) : self`\n\n  Set the image to the given height while preserving its ratio\n\n- `maximize ( int $width, int $height ) : self`\n\n  Maximize image's size by its longer dimension while preserving its ratio\n\n- `crop ( int $width, int $height [, int $x [, int $y]] ) : self`\n\n  Crop picture to given dimensions starting at the given position\n\n- `thumbnail ( int $width, int $height ) : self`\n\n  Make a thumbnail by cropping the image by its shorter dimension (centered crop)\n\n## Cached Image Sizer\n\nSame as Image Sizer but it uses cache.\n\n```php\n\u003c?php\n  // ...\n  use sbolch\\GDImage\\CachedSizer;\n  // ...\n  class Demo {\n    public function demo() {\n      $img = 'path/to/image.jpg';\n\n      $sizer = new CachedSizer();\n      $sizer\n        -\u003eimage($img)\n        -\u003ethumbnail(400, 300)\n        -\u003esave();\n    }\n  }\n```\n\n## Twig integration\n\nIf you use Twig, you can include the extensions\n- `sbolch\\GDImage\\Twig\\ConverterExtension([string $docroot])`\n- `sbolch\\GDImage\\Twig\\SizerExtension([string $docroot [, string $cacheDir]])`\n\n\u003e You can override the default PHP document root with the optional $docroot parameter for both extensions.\n\u003e \n\u003e You can use the cache mechanism in SizerExtension by using the optional $cacheDir parameter with your desired cache folder.  \n\nThen you can use the below filters (question mark marks optional parameters)\n\n```twig\n{# Converting image and returning its new path via sbolch\\GDImage\\Twig\\ConverterExtension #}\n{{ 'path/to/image'|convert_to_avif(?targetPath, ?quality) }}\n{{ 'path/to/image'|convert_to_bmp(?targetPath, ?quality) }}\n{{ 'path/to/image'|convert_to_gif(?targetPath, ?quality) }}\n{{ 'path/to/image'|convert_to_jpg(?targetPath, ?quality) }}\n{{ 'path/to/image'|convert_to_jpeg(?targetPath, ?quality) }}\n{{ 'path/to/image'|convert_to_png(?targetPath, ?quality) }}\n{{ 'path/to/image'|convert_to_webp(?targetPath, ?quality) }}\n\n{# Resizing image and returning its new path via sbolch\\GDImage\\Twig\\SizerExtension #}\n{{ 'path/to/image'|widen(width, ?outputFormat, ?targetPath) }}\n{{ 'path/to/image'|heighten(height, ?outputFormat, ?targetPath) }}\n{{ 'path/to/image'|maximize(width, height, ?outputFormat, ?targetPath) }}\n{{ 'path/to/image'|thumbnail(width, height, ?outputFormat, ?targetPath) }}\n```\n\n## Phar mode (only Converter yet)\n\nYou can download the phar file on the [releases](https://github.com/sbolch/GDImage/releases) page and use it as below:\n\n```sh\nphp converter.phar -i /path/to/image -f jpg\n```\n\n- -i (--input) : Input file\n- -o (--output) : Output file (optional - you must use -o or -f)\n- -f (--format) : Output format (optional - you must use -o or -f)\n- -q (--quality): Encoding quality as percentage (optional)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbolch%2Fgd-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbolch%2Fgd-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbolch%2Fgd-image/lists"}