69°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • Day 3: Resized avatars for comments and other reactions #100DaysOfIndieWeb

    December 23, 2016

    Whenever my website receives a comment, like, repost, or other mention, I display those responses on the post's permalink, along with author information if available. For likes and reposts, I show the profile photo in a list, so there are sometimes lots of photos there.

    For a while now, I've been archiving these profile photos myself in order to avoid various issues caused by hotlinking these images (mixed-content warnings, potential security issues by including remote images, and having avatars disappear when people change their URLs). It's been great because it speeds up the loading of the images since everything is coming from one domain, and I no longer have broken avatars on old posts. However, there was one problem with this plan, which was sometimes peoples' avatars would be huge! Like over 1000 pixels tall, and I was showing it in a 48px square space.

    Today, I updated the code that archives these avatars to resize them to a max of 256 pixels tall.

    This code was written in node.js and running on Amazon Lambda. It was the first (and last) project I've run on Lambda, and I did it as a sort of experiment when Lambda first launched. It wasn't too difficult to figure out the ImageMagick commands in Node.js to do the resizing. But... then I went to go and update the code on Lambda, and that was a nightmare. For starters, they're running a new Node.js version now, so I had to update my system to that to ensure I was bundling the right versions of libraries. Then there were some other changes around permissions and things too, which I didn't totally understand. Then I started getting intermittent errors after I tried launching the new version. Ultimately I got fed up and decided to rewrite the project in Ruby and run it on my own server.

    It turns out I ended up spending about as much time rewriting the app in Ruby as it took to launch and debug the updated version on Lambda. On the plus side, the code is also way easier to understand now, since it's normal synchronous Ruby instead of async Node code that always turns into a mess. It's also only 100 lines now instead of the previous 150 in Node. Here's the new app.

    I didn't change the external facing API, and images are still stored on S3, so my apps that use this project don't have to change at all except for which endpoint they talk to.

    Ultimately, this change is only very slightly visible. The end result is now my posts won't be potentially embedding super large images shrunk down to 48px. This code is also used by webmention.io, so if you're using that to receive Webmentions, then you also have this change now!

    Portland, Oregon
    #100daysofindieweb #100days #indieweb #webmention
    Fri, Dec 23, 2016 12:41pm -08:00
    3 mentions

    Other Mentions

    • Aaron Parecki aaronparecki.com
      Week in Review #100DaysOfIndieWeb
      Fri, Dec 30, 2016 2:18pm -08:00
    • Aaron Parecki aaronparecki.com
      Week in Review #100DaysOfIndieWeb
      Fri, Dec 30, 2016 2:18pm -08:00
    • 100 Days of IndieWeb aaronparecki.com/tag/100daysofindieweb
      Day 3: Resized avatars for comments and other reactions #100DaysOfIndieWeb: aaronparecki.com/2016/12/23/7/d…
      Fri, Dec 23, 2016 8:43pm +00:00 (via brid-gy.appspot.com)
Posted in /articles using quill.p3k.io

Hi, I'm Aaron Parecki, Senior Security Architect at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming and dabble in product design.

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Security Architect at Okta
  • IndieWebCamp Founder
  • OAuth WG Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2023 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv