https://shkspr.mobi/blog/2021/09/turning-an-eink-screen-into-a-monochrome-art-gallery/ Terence Eden's Blog Turning an eInk screen into a monochrome art gallery 2021-09-26 by @edent | art, eink, images, nook, php, tutorial --------------------------------------------------------------------- Previously on Terence Eden's Blog: I turned an old eReader into an Information Screen. This time, I'm taking a different Nook, and turning it into a magic gallery. Here's what it looks like in action: Upcycled an old eReader into an art frame. Displays a new black & white piece of art from Flickr every few minutes. Full write-up this weekend, but pretty straightforward to do. pic.twitter.com/TtVRbhz3Ee -- Terence Eden (@edent) September 22, 2021 Video With the front light off: https://shkspr.mobi/blog/wp-content/uploads/2021/09/offweb.mp4 With the front light on: https://shkspr.mobi/blog/wp-content/uploads/2021/09/onweb.mp4 How it works Every few minutes, it finds a black and white artistic image from Flickr and displays it. Simple! Inspiration Ambient home cinema by Tom Whitwell Build I've previously replaced the battery on an eInk Nook, so I know how easy they are to disassemble. But for this I wanted to keep the plastic frame on, so that I'd be able to attach a more aesthetically pleasing wooden picture frame. Finding a picture frame of the right size was a little tricky. The physical dimension of the unit are ~170mm x ~140mm. But the screen is only ~125mm x ~93mm . I used eFrame - they have a really handy website for custom sized frames and inserts. I ordered a mount for an 135mm x 103mm picture (they cut them slightly smaller but I didn't want any overhang) with 20mm top and bottom borders, and 35mm left and right borders. That gave me enough space to fit the Nook. But, as long as the aperture lets you see the eInk, and masks off the plastic frame, you should be OK. I was also able to buy a frame without a glass front. As this is my first attempt, I went for simple and cheap wood - rather than something more ornate and artistic. Total cost including shipping was PS25. Attaching the frame It is useful to be able to get to the main "N" button - and there needs to be a gap for the charging cable. I thought about cutting out a little bit of the frame but, in the end, it was easier to attach the Nook to the frame using velcro and blu-tak. Because of the weight of the Nook, I used some sturdy hooks for the wall mount. Power There wasn't enough room in the frame for a normal USB cable, so I used a right-angled micro-USB cable. With the page refreshing every 5 minutes between 0600-2300, it got about 3 days of battery life - less if it used the Glow-Light. So a permanent wired connection seemed sensible. Background On the surface this seems quite simple - get a bunch of images and display them. But there are some limitations. The original Nook Simple Touch is, bless it, an old and slow device. I want to do the minimum amount of processing on it as possible. The screen resolution is only 600x800. I don't want to convert colour artwork to black and white - that will just look messy. I also want the image size to roughly match the screen - so things aren't shrunk down. So, I want a list of art which meets the following criteria: * Intended for monochrome display^1 * Roughly 4:3 aspect ratio * Proper art^2 by real artists^3 I started by looking at the Open Data produced by various museums and art galleries. Unfortunately, none of them indicated whether an artwork was greyscale. So, I turned to Flickr! Using the Flickr API Sadly, the Flickr API has been neglected for the best part of a decade. So the documentation is grossly out of date. Two of the undocumented Search API calls are styles and orientation. I use them to search for black and white images in landscape orientation. You can discover more by using the Flickr search website and opening the "Advanced" panel. The rest of the API call is quite standard. A keyword to search for ("art") - or whatever you want. Sorted by "interestingness" - although popularity is also a good metric. With safe_search turned off - no prudes in our house. And an image size no wider that 800px - because serving a correctly scaled image means less work for the eReader. The Code It is almost embarrassing in its simplicity. It uses Sam Wilson's PHP library for Flickr. It grabs 100 images, and then picks a random one to serve. It is resized to fit in a bounding box of 800x600 and repaginated to centre the image. The image is rotated it 90 degrees and served over HTTP with an appropriate caching policy. Nothing else. Here it is^4. require_once 'vendor/autoload.php'; $flickr = new \Samwilson\PhpFlickr\PhpFlickr("123465789"); $search_terms = ["art", "artistic", "painting", "drawing"]; $search_rand = array_rand($search_terms, 1); $sort_terms = ["date-posted-asc", "date-posted-desc", "date-taken-asc", "date-taken-desc", "interestingness-desc", "interestingness-asc", "relevance"]; $sort_rand = array_rand($sort_terms, 1); $s = $flickr->photos()->search(["text" => $search_terms[$search_rand], "per_page" => "100", "styles" => "blackandwhite", "orientation" => "landscape", "sort" => $sort_terms[$sort_rand], "safe_search" =>"3" ]); $number_of_photos = count($s["photo"]); $random_photo = random_int(0, $number_of_photos - 1); $p = $s["photo"][$random_photo]; $farm = $p["farm"]; $server = $p["server"]; $id = $p["id"]; $secret = $p["secret"]; $title = $p["title"]; $image_url = "https://live.staticflickr.com/{$server}/{$id}_{$secret}_c.jpg"; $image = imagecreatefromjpeg( $image_url ); $cropped = imagecropauto( $image, IMG_CROP_DEFAULT ); if ( $cropped !== false ) { imagedestroy($image); $image = $cropped; } $x = imagesx( $image ); $y = imagesy( $image ); $width_ratio = $x / 800; $height_ratio = $y / 600; // Scale if ( $height_ratio >= $width_ratio ) { $new_height = ( 600 / $y ) * $x; $scaled = imagescale( $image, $new_height, 600 ); } else { $scaled = imagescale( $image, 800, -1 ); } $x = imagesx( $scaled ); $y = imagesy( $scaled ); // Make a background canvas $canvas = imagecreatetruecolor( 800, 600 ); $black = imagecolorallocate( $canvas, 0, 0, 0 ); imagefilledrectangle( $canvas, 0, 0, 800, 600, $black ); $dst_x = ( ( 800 - $x ) / 2 ); $dst_y = ( ( 600 - $y ) / 2 ); imagecopy( $canvas, $scaled, $dst_x, $dst_y, 0, 0, $x, $y ); $rotated = imagerotate( $canvas, 90, 0 ); header('Content-type: image/jpeg'); header("Expires: on, 01 Jan 1970 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); imagejpeg( $rotated ); // Tidy Up imagedestroy( $image ); imagedestroy( $scaled ); imagedestroy( $rotated ); Displaying As I mentioned in my previous post about displaying web pages on the Nook - the browser is slow, old, and can't handle https connections. So I used ElectricSign which is an old Android app. Give it a URL and it will display the contents on screen. It can be set to periodically refresh. I've had it running for months on a different screen and it hasn't crashed. That's it! TODO * Buy more cheap, 2nd hand eInk screens on eBay. Preferably larger and with higher DPI. * Get some fancy frames. * Start a pirate art museum. * Monetise it by tracking how long people stare at a particular artwork. * BitCoin?^5 Thanks for reading If you've enjoyed this blog post, you can buy me something from my wishlist or sponsor my GitHub. Find out more way to support this blog . --------------------------------------------------------------------- 1. OK, bit more complicated than that. eInk Pearl can display 16 shades of grey. - 2. Whatever that is... - 3. Whoever they are... - 4. Licenced as MIT - but it is so basic that I won't be annoyed if you do something else with it. - 5. LOL! Nope! - --------------------------------------------------------------------- More posts from around the site: Leave a Reply Cancel reply Your email address will not be published. Required fields are marked * [ ] [ ] [ ] [ ] [ ] [ ] [ ] Comment[ ] Name * [ ] Email * [ ] Website [ ] [ ] Notify me of follow-up comments by email. [ ] Notify me of new posts by email. [Post Comment] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More) [ ] [Ping me!] Claim your FREE email subscription Enter your email address to subscribe to this blog and receive brand new posts by email. (Or subscribe to this [rss]Atom Feed.) Join 12,407 other subscribers. Email Address [ ] Free Sign Up Search This Site Search for: [ ] [Search] Explore The Archives 2021 January 31 posts February 28 posts March 31 posts April 30 posts May 31 posts June 30 posts July 31 posts August 31 posts September 26 posts October November December 2020 January 31 posts February 29 posts March 31 posts April 30 posts May 31 posts June 30 posts July 31 posts August 31 posts September 30 posts October 31 posts November 30 posts December 31 posts 2019 January 31 posts February 12 posts March 17 posts April 12 posts May 12 posts June 10 posts July 7 posts August 5 posts September 6 posts October 14 posts November 30 posts December 17 posts 2018 January 8 posts February 4 posts March 6 posts April 14 posts May 5 posts June 6 posts July 6 posts August 13 posts September 14 posts October 8 posts November 30 posts December 4 posts 2017 January 12 posts February 9 posts March 8 posts April 4 posts May 10 posts June 5 posts July 5 posts August 6 posts September 3 posts October 4 posts November 30 posts December 2016 January 10 posts February 10 posts March 11 posts April 9 posts May 8 posts June 9 posts July 6 posts August 9 posts September 4 posts October 2 posts November 30 posts December 14 posts 2015 January 8 posts February 11 posts March 10 posts April 4 posts May 9 posts June 3 posts July 7 posts August 9 posts September 10 posts October 2 posts November 30 posts December 4 posts 2014 January 13 posts February 13 posts March 14 posts April 14 posts May 8 posts June 7 posts July 9 posts August 5 posts September 5 posts October 1 post November 30 posts December 20 posts 2013 January 25 posts February 17 posts March 15 posts April 18 posts May 11 posts June 14 posts July 6 posts August 14 posts September 6 posts October 4 posts November 30 posts December 14 posts 2012 January 14 posts February 8 posts March 13 posts April 15 posts May 10 posts June 16 posts July 8 posts August 8 posts September 6 posts October 6 posts November 30 posts December 31 posts 2011 January 13 posts February 11 posts March 11 posts April 12 posts May 8 posts June 8 posts July 6 posts August 5 posts September 11 posts October 7 posts November 30 posts December 17 posts 2010 January 6 posts February 15 posts March 12 posts April 13 posts May 4 posts June 3 posts July 15 posts August 8 posts September 11 posts October 9 posts November 30 posts December 9 posts 2009 January 1 post February 5 posts March 3 posts April 7 posts May 12 posts June 8 posts July 10 posts August 10 posts September 12 posts October 22 posts November 31 posts December 15 posts 2008 January 2 posts February March 2 posts April 3 posts May 2 posts June July 1 post August 3 posts September 1 post October 3 posts November 2 posts December 1 post 2007 January February March April May June July August September October November 4 posts December 5 posts 2006 January February March April 1 post May June July August September October November 1 post December 2005 January February March 1 post April May June July August September 1 post October November December 2004 January February March April May 5 posts June 3 posts July 1 post August September October November December 2003 January February March 2 posts April May June July August September October November December 2002 January February 1 post March April 3 posts May June July August September October November December 2001 January February March April May June July 1 post August September October 1 post November December 2000 January February March 1 post April May June July August September October November 1 post December 1999 January February March April May June July August September 1 post October November December 1 post 1995 January February March 1 post April May June July August September October November December 1987 January February March April May June July August September October November December 1 post * (c) Terence Eden * Contact Me * Subscribe * Citations * Support My Blog * About Me ISSN 2753-1570