Skip to content

Instantly share code, notes, and snippets.

View patlecat's full-sized avatar

patlecat

  • Winterthur, Switzerland
View GitHub Profile
@patlecat
patlecat / gist:59f8372248f599c2ef7009a457819862
Created June 13, 2016 12:19
How to correctly resize a GIF with GraphicsMagick >1.3.18
## Commandline for GM, a GIF resize in 3 steps
# Analyze the GIF frames
gm identify -format "File_size: %b, Unique_colors: %k, Bit_depth: %q, Orig Dimensions: %hx%wpx\n" original.gif
# Apply a coalesce with correct colors and depth (from identify) and no dither (has to come in front to work)
gm convert original.gif +dither -depth 8 -colors 135 -coalesce gm_resize_new_big.gif
# Okay resize now and make sure it won't try to dither again!
gm convert gm_resize_new_big.gif +dither -resize 100x100 gm_resize_new_small.gif
@patlecat
patlecat / gist:3983364
Created October 30, 2012 22:03 — forked from paulirish/gist:3910471
Javascript: Page visibility API
// this is the least sucky way i could think of to
// detect and deal with a cross-browser impl of the page visibility api
// forks welcome.
function getHiddenProp(){
var prefixes = ['webkit','moz','ms','o'];
if ('hidden' in document) return 'hidden';
@patlecat
patlecat / gist:3983224
Created October 30, 2012 21:34 — forked from padolsey/gist:527683
Javascript: IE version detector
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}