Crushing PNGs in .NET

Updated on Thursday, May 13, 2021

Crushing PNGs in .NET

I'm working on page speed and Google PageSpeed Insights is telling me that my PNGs are just way too large. Sadly .NET does not provide any way to optimize PNG images so there is no easy fix - just unmanaged libraries and command line tools.

I have an allergy to manual processes so I've lashed up some code to automatically find and optimize PNGs in my App_Data folder using PNGCRUSH. I can call CrushAllImages() to fix up everything or CrushImage() when I need to fix up a specific PNG. Code below:

(Related: Long term solar powered time lapse camera using Arduino; Capture DropCam (Nest Cam) frames to Google Drive; Style Transfer for Time Lapse Photography)

(You might also like: Sugarloaf Stars; Mt. Livermore on Angel Island; Farallones)

(All Code Posts)

LEGO Management

Updated on Wednesday, February 22, 2017

LEGO Management

Good HBR article on LEGO and girls: LEGO’s Girl Problem Starts with Management, depressing conclusion:

"Don’t hold your breath, though. Despite its first-day sold-out success, LEGO has decided not to continue the Research Institute line. It was only a “limited edition.” So girls, back to the pool. The guys in this boardroom don’t seem to want to give you any ideas… let alone seats at the table."

(previously, previously)

(Related: Go-arounds: LEGO and Legislative Service; Got It; LEGO, now for Girls)

(You might also like: Vernal Equinox 2016; News: Facebook defends its simple 2 question survey on the trustworthiness of news publishers; ISS over Wales)

(All Marketing Posts)

Autumnal Equinox 2014

Updated on Wednesday, February 22, 2017

Autumnal Equinox 2014

Autumn starts now in the northern hemisphere, Spring in the southern. Rendered in Catfood Earth (Windows, Android).

(Previously)

(Related: Autumnal Equinox 2015; Autumnal Equinox 2021; Autumnal Equinox 2016)

(You might also like: Merced; New Scientist on Immigration; Leaving the Nest)

(All Code Posts)

Sunset sunset

Updated on Saturday, February 19, 2022

Sunset sunset

Sunset over the Sunset district in San Francisco. There is also the start of moonset at the start of the video and then clouds roll in and, unusually, out before the sun goes down.

(Related: Sunset sunset 4k; Sunset #8; Sunset #10)

(You might also like: Think before you print?; What is the San Francisco Rent Board Fee?; Summer Solstice 2021)

(More Timelapses)

Cable Car Museum

Updated on Thursday, November 12, 2015

Cable Car Museum

Worth a visit. When I first moved to San Francisco I assumed that the cable cars were the type that go up mountains rather than a cunning way to drag trolleys up hills.

(Related: Golden Gate Park - Stow Lake, Strawberry Hill and Museum Concourse; Sawmill Flats; San Francisco Shoreline Timelapse)

(You might also like: Coronavirus Hikes: March 2020; We can’t fix politics without fixing 24-hour news; Google Inbox Account Switching)

(Recent Photos)

Please Stay

Updated on Wednesday, February 22, 2017

Please Stay

My Scottish Grandmother would always tell me off if I said I was English instead of British. She also said it was better to be moving in the wrong direction rather than standing still in the right one. That mostly applied to navigating traffic, but I think it's true for Scotland as well. Help make the UK better and don't become small and stagnant and some sort of irrelevant bland euro-region.

And if you do go then this.

(Related: What do you get when you multiply six by nine? Brexit.; The real reason Americans don't have passports; Scott Adams)

(You might also like: Diary of a Living Room; Agua; Ordoñez Gun)

(All Politics Posts)

San Francisco from Hill 88

Updated on Monday, September 6, 2021

Minify and inline CSS for ASP.NET MVC

Updated on Wednesday, April 28, 2021

ASP.NET has a CssMinify class (and a JavaScript variant as well) designed for use in the bundling pipeline. But what if you want to have your CSS minified and inline? Here is an action that is working for me (rendered into a style tag on my _Layout.cshtml using @Html.Action("InlineCss", "Home")).

Note that I'm using this to inline CSS for this blog. The pages are cached so I'm not worried about how well this action performs. My blog is also basically all landing pages so I'm also not worried about caching a non-inline version for later use, I just drop all the CSS on every page.

(Related: Monitor page index status with Google Sheets, Apps Script and the Google Search Console API; Automate Google PageSpeed Insights and Core Web Vitals Logging with Apps Script; Reading and Writing Office 365 Excel from a Console app using the Microsoft.Graph C# Client API)

(You might also like: ITHCWY Redesign; Treasure Island; Timelapse, Week of Jan 31 2022)

(All Code Posts)

Book reviews for July 2014

Updated on Friday, February 24, 2017
Web Analytics 2.0: The Art of Online Accountability & Science of Customer Centricity [With CDROM] by Avinash Kaushik

Web Analytics 2.0: The Art of Online Accountability & Science of Customer Centricity [With CDROM] by Avinash Kaushik

5/5

Deep, evergreen advice on web analytics. This book is grounded in the trenches and is full of practical advice and reality. Works well to read all the way through and to dip into for specific topics.

 

The Divide: American Injustice in the Age of the Wealth Gap by Matt Taibbi

The Divide: American Injustice in the Age of the Wealth Gap by Matt Taibbi

5/5

Barnstorming tirade against injustice in the US law enforcement and legal systems. Nothing in here was news to me, but laid out story after story it's breathtaking. Minor welfare infractions leading to jail time, institutionalized fraud ignored. Banks get away with money laundering and theft while in some places standing on the street is a crime. Once you've worked up a full head of rage you realize that Obama is as bad as Bush is nearly as bad as Clinton. The failure is in politics and this book is a depressing catalog of the symptoms.

 

(Related: Carr is Wrong: Costolo is Wrong: Wikipedia’s SOPA Blackout is a Great Idea; The Trust Project, Fake News and a Partial Facebook Uninstall; HBR on the Wrong Patent Reform)

(You might also like: News: Google, Microsoft, Mozilla And Others Team Up To Launch WebAssembly, A New Binary Format For The Web; Crissy Field; California November 2020 Propositions)

(All Book Reviews)

Tedious Feed Update

Updated on Wednesday, February 22, 2017

Tedious Feed Update

If you subscribe to I Thought He Came With You via RSS please switch to this new feed and delete the old one.

Longer version... this blog has used FeedBurner for ever but I managed to get locked out a couple of years ago. I upgraded to Google Apps for Domains and part of the process was transitioning various services over to a temporary account and then back to the new one. Most of them made it over but FeedBurner got orphaned somehow.

I've emailed, left forum posts etc but no luck. Google doesn't really do customer service so despite actually paying them I seem to be out of luck. Also, Google hates RSS so FeedBurner probably isn't the right long term tool even if I could get back into my account.

I've been meaning to do something about this for a while but as it was working it wasn't a top priority. This changed when my blog got hacked a couple of times in a row - I'm not sure if it was the software (I'd been using BlogEngine.net) or my hosting provider but it's painful to fix and I decided I needed a change. I Thought I Came From You is now running on a home grown platform. It should be more stable, faster (some quick benchmarking suggests twice as fast so far) and not get hacked quite so often.

So switch to http://ithoughthecamewithyou.com/syndication.axd for updates (I can't recommend Feedly highly enough) and delete the old feed. If you have any problems leave a comment below or send me an email.

(Related: Migrating from Blogger to BlogEngine.NET; Twitter's API has got too painful for me; Export Google Fit Daily Steps, Weight and Distance to a Google Sheet)

(You might also like: Ordoñez Gun; How to fix software patents; HOWTO: Punish Banks)

(All Etc Posts)