{"id":1404,"date":"2025-03-23T12:05:24","date_gmt":"2025-03-23T12:05:24","guid":{"rendered":"https:\/\/jackburton.eu\/?p=1404"},"modified":"2025-03-23T12:10:59","modified_gmt":"2025-03-23T12:10:59","slug":"pixel-sorting-and-image-manipulation-using-python-scripts","status":"publish","type":"post","link":"https:\/\/jackburton.eu\/index.php\/2025\/03\/23\/pixel-sorting-and-image-manipulation-using-python-scripts\/","title":{"rendered":"Pixel sorting and image manipulation using Python scripts"},"content":{"rendered":"\n<p>I had this idea about five years ago to write my own pixel sorting scripts. What&#8217;s pixel sorting I hear you say? In it&#8217;s most basic form, it&#8217;s taking the pixels in an image and resorting them according to values such as brightness, saturation, colour etc.. <\/p>\n\n\n\n<p>If you think of pixels in an image existing in columns and rows, a simple script would say: go from column to column, top to bottom, when you hit a pixel that has a brightness value of 150 (pixels have a brightness value of 1-255), take the next 10 pixels, and put them in an ascending order according to their brightness. This creates cool glitchy trailing pixel effects. There are lots of pixel sorting scripts that people have shared out there on the web, so it&#8217;s not like you need to know how to code to do it. But I wanted more control and I could see how I could add layers of complication if I could just fucking code. So I started learning Python; quickly gave up. <\/p>\n\n\n\n<p>It&#8217;s super interesting, coding. Using logic in that way scratches a lot of itches for me in terms of problem solving, but I just don&#8217;t have the brain for it. Sometimes you have to admit defeat, move on with your life. Fast forward to 2025.<\/p>\n\n\n\n<p>I still don&#8217;t know how I feel about AI (you can see where this is going). I found the initial wave of generative image stuff fascinating, like completely enthralling. Not just because of its eerie weirdness, the horrible fingers, the faces of horror; it just blew me a way. I had a lot of fun running a fake instagram account that was a parody of myself using generated images. But what was fun about it was the captions I was writing, it gave me an outlet for some creative writing, the images themselves quite quickly lost their appeal, their sense of wonder. Then the internet became flooded with AI dross, and I didn&#8217;t feel like contributing more to it, so I put it on pause. Now I feel like I can&#8217;t walk down the street without an AI generated human with extenuated features maniacally grinning at me from every poster. I hate the fuckers. <\/p>\n\n\n\n<p>There are of course lots of concerns around AI, copyright, energy use, job losses. I actually lost a small illustration gig I had with a microbrewery to AI generated versions of what i was doing. So yeah, it&#8217;s real. But it&#8217;s also here for good, and I think it&#8217;s worth trying to understand what we are dealing with through, er, indulging in a bit of AI implementation ourselves.<\/p>\n\n\n\n<p>SO, armed with the latest ChatGPT model, I was finally able to write the python scripts I dreamed about five years ago. And wow, as a tool, it is very very useful and powerful. <\/p>\n\n\n\n<ul>\n<li>Ok quick note, my biggest insight through using AI is that it is incapable of producing something in and of itself that has cultural meaning and value beyond being in some manner &#8216;strange&#8217; or &#8216;pretty&#8217;, it&#8217;s always surface level. AI has no consciousness or subjectivity, it can only give us poor reflections. However, it is amazing at language, that&#8217;s all it is, so any task that is based around structuring meaning, such as coding, it is very very good at.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>I started with basic scripts, I don&#8217;t think it has ever given me a script that worked perfectly off the bat, but with my very basic knowledge of Python I was able to either spot the problem and correct it, or tell it what was wrong and get it to correct it. Through using ChatGPT to write these scripts I&#8217;ve grown to understand Python on a level I couldn&#8217;t before, even though I&#8217;m not sure I&#8217;ve learned any extra code, which is interesting. I&#8217;ve been able to build up the layers of complexity and, well, here are some of the results. These are still just experiments, but I get very engrossed in making them, the element of chance that is introduced into the composition is somehow like taking photos, you&#8217;re never sure of the results until they&#8217;ve been processed but you&#8217;re ever-present as you&#8217;re hunting for that image.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-1-1024x683.jpg\" alt=\"\" class=\"wp-image-1410\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-1-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-1-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-1-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-1-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-1-2048x1366.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">-select pixels based on brightness, left to right, sort the following pixels in descending brightness order<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output13-1-1024x683.jpg\" alt=\"\" class=\"wp-image-1413\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output13-1-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output13-1-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output13-1-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output13-1-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output13-1-2048x1366.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">-same script but with a nice glitch from uploading and downloading the image, sometimes you get lucky<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output53-1024x683.jpg\" alt=\"\" class=\"wp-image-1420\" width=\"840\" height=\"560\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output53-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output53-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output53-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output53-1536x1024.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output53-2048x1366.jpg 2048w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><figcaption class=\"wp-element-caption\">&#8211; select pixels by brightness, copy the pixel up, down, left, right, increase saturation<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output46-1024x683.jpg\" alt=\"\" class=\"wp-image-1419\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output46-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output46-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output46-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output46.jpg 1050w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">&#8211; tried to create spirals from selected pixels, didn&#8217;t work but got this<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"683\" height=\"1024\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1-683x1024.jpg\" alt=\"\" class=\"wp-image-1418\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1-683x1024.jpg 683w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1-200x300.jpg 200w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1-768x1151.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1-1025x1536.jpg 1025w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1-1366x2048.jpg 1366w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output30-1.jpg 1668w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><figcaption class=\"wp-element-caption\">-use edge detect to select pixels, switch pixel blocks of a defined size with random pixel blacks in the rest of the image<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output26-1-1024x683.jpg\" alt=\"\" class=\"wp-image-1417\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output26-1-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output26-1-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output26-1-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output26-1-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output26-1-2048x1366.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">-same as above<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-2-1024x683.jpg\" alt=\"\" class=\"wp-image-1411\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-2-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-2-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-2-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-2-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output11-2.jpg 1800w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">&#8211; same I think, I really like this one<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"683\" height=\"1024\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009-683x1024.jpg\" alt=\"\" class=\"wp-image-1425\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009-683x1024.jpg 683w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009-200x300.jpg 200w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009-768x1151.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009-1025x1536.jpg 1025w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009-1366x2048.jpg 1366w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_009.jpg 1668w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><figcaption class=\"wp-element-caption\">&#8211; edge detect, insert text along edge, use the colour of the selected pixel for text colour, increase saturation<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_001-3-1024x683.jpg\" alt=\"\" class=\"wp-image-1421\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_001-3-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_001-3-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_001-3-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_001-3.jpg 1050w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">&#8211; insert images along edge detect<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_004-3-1024x683.jpg\" alt=\"\" class=\"wp-image-1423\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_004-3-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_004-3-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_004-3-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_004-3-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_004-3-2048x1366.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">-same<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_002-3-1024x683.jpg\" alt=\"\" class=\"wp-image-1422\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_002-3-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_002-3-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_002-3-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_002-3-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_002-3-2048x1366.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">-same<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_007-1-1024x683.jpg\" alt=\"\" class=\"wp-image-1424\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_007-1-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_007-1-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_007-1-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_007-1-1536x1025.jpg 1536w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/processed_007-1-2048x1366.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">&#8211; same<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"682\" height=\"1024\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output10-2-682x1024.jpg\" alt=\"\" class=\"wp-image-1409\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output10-2-682x1024.jpg 682w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output10-2-200x300.jpg 200w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output10-2-768x1152.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output10-2-1024x1536.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output10-2.jpg 1333w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><figcaption class=\"wp-element-caption\">&#8211; the scripts generally convert the image to grayscale to do the processing and parse the image in different ways before putting it back together, when the putting back together goes wrong you get these guys<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output9-3-1024x683.jpg\" alt=\"\" class=\"wp-image-1408\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output9-3-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output9-3-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output9-3-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output9-3.jpg 1050w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"683\" src=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output7-2-1024x683.jpg\" alt=\"\" class=\"wp-image-1407\" srcset=\"https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output7-2-1024x683.jpg 1024w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output7-2-300x200.jpg 300w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output7-2-768x512.jpg 768w, https:\/\/jackburton.eu\/wp-content\/uploads\/2025\/03\/output7-2.jpg 1050w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I had this idea about five years ago to write my own pixel sorting scripts. What&#8217;s pixel sorting I hear you say? In it&#8217;s most basic form, it&#8217;s taking the pixels in an image and resorting them according to values such as brightness, saturation, colour etc.. If you think of pixels in an image existing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[1],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/posts\/1404"}],"collection":[{"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/comments?post=1404"}],"version-history":[{"count":8,"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/posts\/1404\/revisions"}],"predecessor-version":[{"id":1437,"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/posts\/1404\/revisions\/1437"}],"wp:attachment":[{"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/media?parent=1404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/categories?post=1404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jackburton.eu\/index.php\/wp-json\/wp\/v2\/tags?post=1404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}