Skip to content

Instantly share code, notes, and snippets.

@ngryman
Created June 24, 2018 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngryman/3ae53313e0667e9307586d105d1d257f to your computer and use it in GitHub Desktop.
Save ngryman/3ae53313e0667e9307586d105d1d257f to your computer and use it in GitHub Desktop.
Keep the aspect ratio of your images using GIFs
function createGif(width, height) {
const b64wh = btoa(
String.fromCharCode(width & 0xFF) +
String.fromCharCode(width >> 8 & 0xFF) +
String.fromCharCode(height & 0xFF) +
String.fromCharCode(height >> 8 & 0xFF) +
String.fromCharCode(0) +
String.fromCharCode(0)
)
return `R0lGODlh${b64wh}ACwAAAAAAQABAAAC`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment