Skip to content

Instantly share code, notes, and snippets.

@orodley
Created July 24, 2014 09:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save orodley/c3adb0bd7cacd4491ad1 to your computer and use it in GitHub Desktop.
Save orodley/c3adb0bd7cacd4491ad1 to your computer and use it in GitHub Desktop.
Extract base64-encoded images from an HTML file.
for image in `grep --color=never -Po 'data:image/[^;]*;base64,\K[a-zA-Z0-9+/]*' foo.html`; do echo -n "$image" | base64 -di > `mktemp image_XXXX`; done
@MattWenham
Copy link

I think your matching group should read [a-zA-Z0-9+/=] to catch padding characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment