<commit_before><commit_msg>PHP converter added (alpha)<commit_after><?php
	header('Content-Type: application/json');
	header('Access-Control-Allow-Origin: *');  
    
    $inputimages = ($_REQUEST["svgsources"]);
    $urlprefix = ($_REQUEST["secure"] == 'false') ? 'http://' : 'https://';
	$result = array('error' => '1', 'errormsg' => 'No images given');	
    
	if(isset($inputimages) && is_array($inputimages)){
   
		// Create empty array with images to return
		$imageurls = array();
	
		// Loop through given image urls
		foreach($inputimages as $input){
				
			// Get the file name
			$filename = explode('/',$input);
			$filename = array_pop($filename);
            $filename = str_replace('.svg' ,'' , $filename);
            
			// Check the domain and create a folder if needed
			$url = parse_url($input);
			$domain = $url['host'];
			if(!file_exists("images/results/" . $domain)){
				 mkdir("images/results/" . $domain, 0777);
			}
			$imagefolder = "images/results/" . $domain;
		
			// Check if the file already exists
			if(!file_exists($imagefolder . '/'.$filename.'.png')){
				// Get the image
				$inputimage = file_get_contents($input);
				
				// Convert the given image to PNG and store it in the custom directory
				$image = new Imagick();
                $image->setBackgroundColor(new ImagickPixel('transparent'));
				$image->readImageBlob(($inputimage));
				$image->setImageFormat("png32");
                $image->setImageCompressionQuality(100);
				$image->writeImage($imagefolder . '/'.$filename.'.png');
			}
			
			$imageurls[] = array('url'	=> $urlprefix."bitlabs.nl/svgmagic/" . $imagefolder . '/'.$filename.'.png');
		}
		
		$result = array('results' => $imageurls, 'error' => '0');	
	}
	echo $_GET['callback'] . '('. json_encode($result) . ')';
?>
{'fraction_non_alphanumeric': 0.18994413407821228, 'fraction_numerical': 0.006145251396648044, 'mean_word_length': 3.1943793911007026, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 14, 'https://': 1, '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': '4180757', 'n_tokens_mistral': 636, 'n_tokens_neox': 554, 'n_words': 121}