https://shkspr.mobi/blog/2021/12/quick-and-dirty-way-to-rip-an-ebook-from-android/ Terence Eden's Blog Quick and dirty way to rip an eBook from Android 2021-12-27 by @edent | drm, ebook, msc | 1 comment | 450 words --------------------------------------------------------------------- I recently purchased a book for my MSC which was only available via a crappy Android app. There was no obvious way to decrypt it to read on a more sensible device, so I resorted to the ancient art of screenscraping. This is a quick-and-dirty way to grab images of the pages and convert them to a standard PDF using Linux. There's a lot more you can do to make the end book more useful, but this'll get you started Lots of Screen Shots With a USB cable plugged into my phone and laptop, I wrote a horrible little bash script: #!/bin/bash for i in {00001..00555}; do adb exec-out screencap -p > $i.png adb shell input tap 1000 2000 sleep 1s done echo All done This runs a loop 555 times. Takes a screenshot, names it for the loop number with padded zeros, taps the bottom right of the screen, then waits for a second to ensure the page has refreshed. Slow and dull, but works reliably. Images range from 200KB to 2MB depending on complexity. Back them up before doing the next bit. Cropping The screenshots are all 1080x2160. But the page only takes up part of that. The top left corner is at 50x432 and the bottom right is at 1028x1726. This command crops all the images. It is destructive, so make sure you have a backup. mogrify -crop 978x1294+50+432 +repage *.png It's also useful to trim the images to remove any whitespace from the borders. That makes a smaller file size. mogrify -trim *.png Images can be shrunk with: pngquant *.png PDF and OCR Sticking all the images together into a single PDF is pretty easy: convert *.png +repage output.pdf The +repage option keeps the aspect ratio of the trimmed image. But there's no text to search. There are a bunch of OCR programs on Linux, I like PDF Sandwich: pdfsandwich -rgb -nopreproc output.pdf That'll get you a colour PDF with OCR'd text embedded in it. The text is "sandwiched" behind the image of the page, so you can't see it but can search for it. You can also use OCRmyPDF which may result in a smaller file: ocrmypdf -l eng output.pdf output_ocr.pdf And that's it. I now have a searchable PDF which I can read on any device. What have we learned? DRM on textbooks is an annoyance. For computer science books, it's little more than a fig-leaf. --------------------------------------------------------------------- Share the love: * Twitter * Facebook * LinkedIn * Reddit * HackerNews * Lobsters * Email * Pocket * WhatsApp * Telegram * Like this: Like Loading... --------------------------------------------------------------------- More posts from around the site: One thought on "Quick and dirty way to rip an eBook from Android" 1. [1d08a308] Hacker News says: 2021-12-27 at 20:10 Quick and dirty way to rip an eBook from Android: shkspr.mobi/ blog/2021/12/q... Comments: news.ycombinator.com/item?id=297048... Reply 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] [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] 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!] Support This Site 1-Click Payment of PS5 Donate via Cash.App My wishlist Buy me a coffee Regular giving on Flattr 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,753 other subscribers. Email Address [ ] Free Sign Up Search Blog Posts 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 30 posts October 31 posts November 30 posts December 27 posts 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 Send to Email Address [ ] Your Name [ ]Your Email Address [ ] [ ] loading [Send Email] Cancel Post was not sent - check your email addresses! Email check failed, please try again Sorry, your blog cannot share posts by email. %d bloggers like this: