{"id":91,"date":"2010-04-15T08:32:53","date_gmt":"2010-04-15T15:32:53","guid":{"rendered":"http:\/\/patternweaver.com\/blog\/?p=91"},"modified":"2010-04-15T08:32:53","modified_gmt":"2010-04-15T15:32:53","slug":"imagebooth-multilayered-image-manipulation-in-php","status":"publish","type":"post","link":"http:\/\/patternweaver.com\/blog\/2010\/04\/imagebooth-multilayered-image-manipulation-in-php\/","title":{"rendered":"ImageBooth: Multilayered Image Manipulation in PHP"},"content":{"rendered":"<p>I&#8217;m going to be releasing documentation on my development framework, <a href=\"http:\/\/sourceforge.net\/projects\/datalus\/\">Datalus<\/a>, in the near future&#8230; but before that, I&#8217;ll be releasing a few examples using the utility libraries from it.<\/p>\n<p>My first example uses a stacked imaging framework built on top of GD who&#8217;s goal is to implement the feature set of photoshop 3. It may only be to about 30% of that goal, but it&#8217;s well past useful.<\/p>\n<p>So let&#8217;s take this some images:<br \/>\n<a href=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/captcha.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/captcha-150x70.jpg\" alt=\"\" title=\"Layer 1\" width=\"150\" height=\"70\" class=\"alignnone size-thumbnail wp-image-92\" \/><\/a><br \/>\n<a href=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/captcha2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/captcha2-150x70.png\" alt=\"\" title=\"Layer 2\" width=\"150\" height=\"70\" class=\"alignnone size-thumbnail wp-image-93\" \/><\/a><br \/>\n<a href=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/checks.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/checks-150x150.png\" alt=\"\" title=\"Layer 3\" width=\"150\" height=\"150\" class=\"alignnone size-thumbnail wp-image-94\" \/><\/a><\/p>\n<p>Then we&#8217;ll write a script to combine these images:<\/p>\n<pre><code>require('.\/ImageBooth.php');\n\n    $raw_image = imagecreatefromjpeg('.\/captcha.jpg');\n    $overlay_image = imagecreatefrompng('.\/captcha2.png');\n    $checks = imagecreatefrompng('.\/checks.png');\n    $image = ImageBooth::newImage(70, 200);\n    $image-&gt;newLayer($raw_image, 'base');\n    $image-&gt;newLayer($checks, 'checks');\n    $image-&gt;newLayer($overlay_image, 'overlay');\n    $image-&gt;filter('blur', array('amount'=&gt;'400'));\n    $image-&gt;operate('color_replace', array('origin_color'=&gt;'333388', 'destination_color'=&gt;'CC0000'));\n    $image-&gt;operate('brightness_contrast', array('brightness_adjustment'=&gt;-20, 'contrast_adjustment'=&gt;20));\n    $image-&gt;operate('negative');\n    $image-&gt;selectLayer('checks');\n    $image-&gt;transform('rotate', array('angle'=&gt;15));\n    $image-&gt;resize(400, 200);\n    $image-&gt;resizeCanvas(500, 500);\n    $image-&gt;dumpToBrowser();<\/code><\/pre>\n<p>Now check out the result:<br \/>\n<a href=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/test_output.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/patternweaver.com\/blog\/wp-content\/uploads\/2010\/04\/test_output-150x150.png\" alt=\"\" title=\"test_output\" width=\"150\" height=\"150\" class=\"alignnone size-thumbnail wp-image-95\" \/><\/a><\/p>\n<p>That&#8217;s it. <a href=\"http:\/\/patternwaeaver.com\/Downloads\/ImageBooth.zip\">Download<\/a> it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m going to be releasing documentation on my development framework, Datalus, in the near future&#8230; but before that, I&#8217;ll be releasing a few examples using the utility libraries from it. My first example uses a stacked imaging framework built on top of GD who&#8217;s goal is to implement the feature set of photoshop 3. It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,7],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-datalus","category-php"],"_links":{"self":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":0,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"wp:attachment":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}