{"id":21418437,"url":"https://github.com/nightflyza/pixelcraft","last_synced_at":"2025-07-29T02:04:19.381Z","repository":{"id":216136610,"uuid":"740524475","full_name":"nightflyza/PixelCraft","owner":"nightflyza","description":"PixelCraft is a lightweight PHP library designed for easy image processing using the GD lib","archived":false,"fork":false,"pushed_at":"2025-07-02T12:01:20.000Z","size":959,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-29T02:02:36.530Z","etag":null,"topics":["crop","gd","graphics","image-conversion","image-filters","image-generation","image-manipulation","image-processing","images2ascii","php","php-image-processor","php-image-resizer","php-library","pixel-art","thumbnail","watermarks"],"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/nightflyza.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-08T14:19:49.000Z","updated_at":"2025-07-02T09:53:35.000Z","dependencies_parsed_at":"2024-01-22T12:46:13.352Z","dependency_job_id":"db377de7-c2ca-45eb-8f0b-b540faaafb89","html_url":"https://github.com/nightflyza/PixelCraft","commit_stats":null,"previous_names":["nightflyza/pixelcraft"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/nightflyza/PixelCraft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightflyza%2FPixelCraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightflyza%2FPixelCraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightflyza%2FPixelCraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightflyza%2FPixelCraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nightflyza","download_url":"https://codeload.github.com/nightflyza/PixelCraft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightflyza%2FPixelCraft/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267617636,"owners_count":24116207,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["crop","gd","graphics","image-conversion","image-filters","image-generation","image-manipulation","image-processing","images2ascii","php","php-image-processor","php-image-resizer","php-library","pixel-art","thumbnail","watermarks"],"created_at":"2024-11-22T19:21:24.461Z","updated_at":"2025-07-29T02:04:19.363Z","avatar_url":"https://github.com/nightflyza.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![pcraftlogo](https://github.com/nightflyza/PixelCraft/assets/1496954/42c91406-dfc4-47dc-8eea-db3106edb009)\n\n# PixelCraft\n\nPixelCraft is a lightweight PHP library designed for easy image processing using the GD lib. \nWith PixelCraft, you can perform basic image operations such as resizing, cropping, drawing of watermarks, and format conversion.\nThe library is characterized by its user-friendly interface and minimal code footprint, \nallowing for quick and efficient image processing in PHP projects.\n\n## Requirements\n\n- PHP \u003e=5.3 (PHP 7.4, 8.2, 8.3, 8.4 also compatible)\n- GD Library\n- Mbstring extension\n\n## Few usage examples\n\n### Minimal example / drawing from scratch\n\n```php\n\n$pc=new PixelCraft();\n\n$pc-\u003ecreateImage(640, 480);\n$pc-\u003efill('yellow');\n\n$pc-\u003eaddColor('sky', 34, 61, 216);\n$pc-\u003edrawRectangle(0, 0, 640, 240, 'sky');\n\n$pc-\u003erenderImage('png');\n```\n\n![drawfromscratch](https://github.com/user-attachments/assets/56974d6a-8107-4982-8a45-736f59aac92a)\n\n\n\n### Image downscale and convertation from PNG to JPEG\n\n```php\n$pc=new PixelCraft();\n\n$pc-\u003eloadImage('someimage.png');\n$pc-\u003escale(0.5);\n\n$pc-\u003esaveImage('resizedimage.jpg','jpeg');\n```\n\n![downscale](https://github.com/user-attachments/assets/dd06f439-a795-43ce-8e1e-544e7533f980)\n\n\n### Adding watermarks to images\n\n```php\n$pixelCraft = new PixelCraft();\n\n$pixelCraft-\u003eloadImage('yourimage.jpg');\n$pixelCraft-\u003eloadWatermark('watermark.png');\n\n$watermarkX=$pixelCraft-\u003egetImageWidth()-150;\n$watermarkY=20;\n\n$pixelCraft-\u003edrawWatermark(false,$watermarkX,$watermarkY);\n\n$originalFileType=$pixelCraft-\u003egetImageType();\n$pixelCraft-\u003erenderImage($originalFileType);\n```\n\n![watermark](https://github.com/user-attachments/assets/7c66903a-1554-46f3-ac40-2cb908c28284)\n\n### Instagram-like filters\n\n```php\n$pixelCraft = new PixelCraft();\n\n$pixelCraft-\u003eloadImage('yourimage.jpg');\n\n$filtersSet = array();\n$filtersSet[] = array(IMG_FILTER_BRIGHTNESS =\u003e -15);\n$filtersSet[] = array(IMG_FILTER_GRAYSCALE =\u003e -5);\n$filtersSet[] = array(IMG_FILTER_COLORIZE =\u003e array(80, 0, 60));\n$filtersSet[] = array(IMG_FILTER_GAUSSIAN_BLUR =\u003e '');\n\n$pixelCraft-\u003eimageFilters($filtersSet);\n\n$pixelCraft-\u003erenderImage('jpeg');\n\n```\n\n![instafilters](https://github.com/user-attachments/assets/6b4c4a21-c2f8-4b2a-ad61-9d164c96bdb9)\n\n\n### Adding text to image\n\n```php\n$pixelCraft = new PixelCraft();\n\n$pixelCraft-\u003eloadImage('yourimage.jpg');\n\n$labelPosition = ($pixelCraft-\u003egetImageHeight()) - 10;\n$pixelCraft-\u003edrawTextAutoSize($labelPosition, 10, 'Text at image bottom', 'white', 'black');\n\n$pixelCraft-\u003erenderImage('jpeg');\n```\n\n![textatbottom](https://github.com/user-attachments/assets/2116e0c1-6972-4959-9ae1-7224e9f04b00)\n\n### Drawing pixel-art\n\n```php\n$pixelCraft = new PixelCraft();\n\n$pixelMap = '\n1111111111111111111111111\n1000000000000000000000001\n1000000000001000000000001\n1000000000011100000000001\n1001000000011100000001001\n1001100000011100000011001\n1001110000011100000111001\n1001111000011100001111001\n1001101100011100011011001\n1001101100011100011011001\n1001100110011100110011001\n1001100110011100110011001\n1001100110011100110011001\n1001100110011100110011001\n1001100110011100110011001\n1001100110011100110011001\n1001100110011100110011001\n1001111100010100011111001\n1001111000110110001111001\n1001101101100011011011001\n1001100111110111110011001\n1001100011011101100011001\n1001100011001001100011001\n1001111111111111111111001\n1001111111111111111111001\n1000000011001001100000001\n1000000001101011000000001\n1000000000111110000000001\n1000000000001000000000001\n1000000000000000000000001\n1111111111111111111111111\n';\n\n$pixelCraft-\u003ecreateImage(25,31);\n$pixelCraft-\u003eaddColor('foreground', 227, 209, 54);\n$pixelCraft-\u003eaddColor('background', 73, 140, 204);\n\n$pixelMap=trim($pixelMap);\n$pixelMap=explode(PHP_EOL,$pixelMap);\nforeach ($pixelMap as $y=\u003e$xAxis) {\n    $xAxis=str_split($xAxis);\n    foreach ($xAxis as $x=\u003e$pixel) {\n        if ($pixel) {\n            $pixelCraft-\u003edrawPixel($x,$y,'foreground');\n        } else {\n            $pixelCraft-\u003edrawPixel($x,$y,'background');\n        }\n    }\n}\n\n$pixelCraft-\u003escale(16);\n\n\n$pixelCraft-\u003erenderImage();\n\n```\n\n![pixelart](https://github.com/user-attachments/assets/df72f378-4eef-4c28-bb81-5c3fcbc53cb9)\n\n\n### Random values visualization\n\n```php\n$pixelCraft = new PixelCraft();\n\n$width=100;\n$height=100;\n$pixelCraft-\u003ecreateImage($width,$height);\n\nfor ($x=0;$x\u003c$width;$x++) {\n    for ($y=0;$y\u003c$height;$y++) {\n        $randomR=rand(0,255);\n        $randomG=rand(0,255);\n        $randomB=rand(0,255);\n        $colorName='C_'.$randomR.$randomG.$randomB;\n        $pixelCraft-\u003eaddColor($colorName,$randomR,$randomG,$randomB);\n        $pixelCraft-\u003edrawPixel($x,$y,$colorName);\n    }\n}\n\n$pixelCraft-\u003escale(8);\n$pixelCraft-\u003erenderImage();\n```\n\n![drawrandom](https://github.com/user-attachments/assets/3d970496-f286-4c10-be1c-961aeb85d9f5)\n\n### Image region crop\n\n```php\n$pixelCraft = new PixelCraft();\n\n$pixelCraft-\u003eloadImage('../assets/fox.jpg');\n\n$pixelCraft-\u003ecropRegion(80, 20, 220, 220);\n$pixelCraft-\u003edrawString(180,20,$pixelCraft-\u003egetImageWidth().'x'.$pixelCraft-\u003egetImageHeight(),'black');\n\n//saving original image type\n$originalFileType=$pixelCraft-\u003egetImageType();\n\n$pixelCraft-\u003erenderImage($originalFileType);\n\n```\n\n![regioncrop](https://github.com/user-attachments/assets/7b30f3c5-8c56-497d-8611-72d7505ccc67)\n\n### Image resize and region crop\n```php\n$pixelCraft = new PixelCraft();\n\n$pixelCraft-\u003eloadImage('../assets/fox.jpg');\n\n$pixelCraft-\u003ecrop(256, 256);\n$pixelCraft-\u003eresize(128, 128);\n\n//saving original image type\n$originalFileType=$pixelCraft-\u003egetImageType();\n\n$pixelCraft-\u003erenderImage($originalFileType);\n```\n\n![resizeandcrop](https://github.com/user-attachments/assets/4b525b75-63e6-4b2e-83dc-6845926f8ff4)\n\n### Converting an image to ASCII-art based on pixel brightness\n\n```php\n$pixelCraft = new PixelCraft();\n\n$charMap = '@#W$9876543210?!abc;:+=-,._       ';\n$len = strlen($charMap);\n\n$result = '';\n$pixelCraft-\u003eloadImage('../assets/horse.png');\n\n$filterSet = array();\n$filterSet []= array(IMG_FILTER_NEGATE =\u003e'');\n$pixelCraft-\u003eimageFilters($filterSet);\n$pixelCraft-\u003epixelate(3, true);\n$pixelCraft-\u003eresize(64, 64);\n\n\n$colorMap = $pixelCraft-\u003egetColorMap(false);\n\nforeach ($colorMap as $x =\u003e $ys) {\n    foreach ($ys as $y =\u003e $color) {\n        $brightness = $pixelCraft-\u003ergbToBrightness($color);\n        $charIndex = floor(($brightness * $len) / 255);\n        $result .= $charMap[$charIndex].' ';\n    }\n    $result .= PHP_EOL;\n}\n\nprint($result);\n\n```\n\n![pcimg2ascii](https://github.com/user-attachments/assets/a1a1ef1e-4550-4b72-a7b5-94c38d5d229b)\n\n[Full PixelCraft class documentation](https://ubilling.net.ua/api_doc/classes/PixelCraft.xhtml)\n\n\n## Installation with [composer](https://getcomposer.org)\n\nThe recommended method of installing this library is via [Composer](https://packagist.org/packages/pixelcraft/pixelcraft)\n\n### Terminal\n\n```bash\ncomposer require pixelcraft/pixelcraft\n```\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightflyza%2Fpixelcraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightflyza%2Fpixelcraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightflyza%2Fpixelcraft/lists"}