<commit_before><?php

	require_once(realpath(dirname(__FILE__).'/../') . '/class.imagefilter.php');

	Class FilterResize extends ImageFilter{

		public static function run($res, $width=NULL, $height=NULL){

			$dst_w = Image::width($res);
			$dst_h = Image::height($res);

			if(!empty($width) && !empty($height)) {
				$dst_w = $width;
				$dst_h = $height;
			} 

			elseif(empty($height)) {
				$ratio = ($dst_h / $dst_w);
				$dst_w = $width;
				$dst_h = round($dst_w * $ratio);
			} 

			elseif(empty($width)) {
		
				$ratio = ($dst_w / $dst_h);
				$dst_h = $height;
				$dst_w = round($dst_h * $ratio);

			}

			$dst = imagecreatetruecolor($dst_w, $dst_h);
			
			//imagealphablending( $dst, false );
			//imagesavealpha( $dst, true );
			
			self::__fill($dst);

			imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
			
			@imagedestroy($res);
			
			return $dst;
			
		}
	}<commit_msg>Adding support for alpha masked images.<commit_after><?php

	require_once(realpath(dirname(__FILE__).'/../') . '/class.imagefilter.php');

	Class FilterResize extends ImageFilter{

		public static function run($res, $width=NULL, $height=NULL){

			$dst_w = Image::width($res);
			$dst_h = Image::height($res);

			if(!empty($width) && !empty($height)) {
				$dst_w = $width;
				$dst_h = $height;
			} 

			elseif(empty($height)) {
				$ratio = ($dst_h / $dst_w);
				$dst_w = $width;
				$dst_h = round($dst_w * $ratio);
			} 

			elseif(empty($width)) {
		
				$ratio = ($dst_w / $dst_h);
				$dst_h = $height;
				$dst_w = round($dst_h * $ratio);

			}

			$dst = imagecreatetruecolor($dst_w, $dst_h);
			
			/* making the new image transparent */
            $background = imagecolorallocate( $dst, 0, 0, 0 );
            ImageColorTransparent( $dst, $background ); // make the new temp image all transparent			
			imagealphablending( $dst, false );
			imagesavealpha( $dst, true );
			imageAntiAlias( $dst, true );
			
			self::__fill($dst);

			imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
			
			@imagedestroy($res);
			
			return $dst;
			
		}
	}
{'fraction_non_alphanumeric': 0.1876737720111214, 'fraction_numerical': 0.005097312326227989, 'mean_word_length': 3.159922928709056, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3076517', 'n_tokens_mistral': 973, 'n_tokens_neox': 790, 'n_words': 157}