<commit_before>#!/bin/bash

op="$1"
shift 1
case "$op" in
	degrade|downgrade)
		for file; do
			[ -f "$file" ] || continue
			echo $file
			mv "$file" "$file~"
			new=${file%.*}.jpg
			convert "$file~[0]" -quality 80 "jpg:$new"
		done
		;;
	fix-anamorphic)
		for file; do
			[ -f "$file" ] || continue
			w=$(identify -format "%w" "$file")
			h=$(identify -format "%h" "$file")
			nw=$(( $h * 16 / 9 ))
			nh=$h
			echo "$file: ${w}x${h} -> ${nw}x${nh}"
			mv "$file" "$file~"
			convert "$file~" -resize "${nw}x${nh}!" "$file"
		done
		;;
	fix-png)
		for file; do
			[ -f "$file" ] || continue
			if [[ "$file" = *.png ]]; then
				fmt=$(identify -format "%r" "$file");
				if [[ "$fmt" == "PseudoClassGrayMatte" ]]; then
					echo "$file"
					convert "$file" -alpha off "$file"
				fi
			fi
		done
		;;
	base64)
		for file; do
			[ -f "$file" ] ||continue
			if [[ "$file" = *.png ]]; then
				echo -n data:image/png\;base64,
			elif [[ "$file" = *.gif ]]; then
				echo -n data:image/png\;base64,
			fi
			base64 -w0 <"$file"
			echo
		done
		;;
	stitch)<commit_msg>Fixed encoding GIFs to base64<commit_after>#!/bin/bash

op="$1"
shift 1
case "$op" in
	degrade|downgrade)
		for file; do
			[ -f "$file" ] || continue
			echo $file
			mv "$file" "$file~"
			new=${file%.*}.jpg
			convert "$file~[0]" -quality 80 "jpg:$new"
		done
		;;
	fix-anamorphic)
		for file; do
			[ -f "$file" ] || continue
			w=$(identify -format "%w" "$file")
			h=$(identify -format "%h" "$file")
			nw=$(( $h * 16 / 9 ))
			nh=$h
			echo "$file: ${w}x${h} -> ${nw}x${nh}"
			mv "$file" "$file~"
			convert "$file~" -resize "${nw}x${nh}!" "$file"
		done
		;;
	fix-png)
		for file; do
			[ -f "$file" ] || continue
			if [[ "$file" = *.png ]]; then
				fmt=$(identify -format "%r" "$file");
				if [[ "$fmt" == "PseudoClassGrayMatte" ]]; then
					echo "$file"
					convert "$file" -alpha off "$file"
				fi
			fi
		done
		;;
	base64)
		for file; do
			[ -f "$file" ] ||continue
			if [[ "$file" = *.png ]]; then
				echo -n data:image/png\;base64,
			elif [[ "$file" = *.gif ]]; then
				echo -n data:image/gif\;base64,
			fi
			base64 -w0 <"$file"
			echo
		done
		;;
	stitch)
{'fraction_non_alphanumeric': 0.23376623376623376, 'fraction_numerical': 0.016697588126159554, 'mean_word_length': 2.565289256198347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1280849', 'n_tokens_mistral': 1077, 'n_tokens_neox': 868, 'n_words': 235}