Skip to content

Instantly share code, notes, and snippets.

View joujiahe's full-sized avatar

Johnson Chou joujiahe

View GitHub Profile
@joujiahe
joujiahe / bash
Created February 23, 2019 06:04
Replace DOS line endings to Unix style in MacOS
// to get ^M, type CTRL-V and CTRL-M
find . -type f -name '*.ts' -exec perl -p -i -e "s/^M//g" {} \;
@joujiahe
joujiahe / pdfimage
Created October 12, 2020 15:46 — forked from innermond/pdfimage
Extract images from pdf but, surprise! The images that contain alpha channels are extracted as two images. The source and the mask, as they are stored inside pdf file. This script recombine them into an one png file with given transparency
#/usr/bin/bash
# extract images from pdf at first-hand
#prefix=pict
#echo extract images from "$1"
#pdfimages -j "$1" $prefix
# IMAGES ARE SAVED SECVENTIALLY AS IMAGE AND THE NEXT IS A MASK IMAGE !!!!
declare -a files=($(ls *.ppm *.pbm))
mask=
image=
for (( i = 0; i < ${#files[*]}; i = i + 2 ))