<commit_before><?php

namespace Multup;

Use \File;

/*
*	The bulk of this class is pulled from the Resizer bundle I edited it to fit my needs here
*	@author <NAME>(original author <NAME> &  <NAME>)
*	@version 1.0
*/
class Resize{
	
	/*
	*	Original width of the image being resized
	*	@var int
	*/
	private $width;
	
	/*
	*	New width of the image being resized
	*	@var int
	*/
	private $new_width;
	
	/*
	*	Original height of the image being resized
	*	@var int
	*/
	private $height;
	
	/*
	*	New height of the image being resized
	*	@var int
	*/
	private $new_height;
	
	/*
	*	Type of crop being performed
	*	@var str
	*/
	private $option;
	
	/*
	*	The resized image resource
	*	@var resource
	*/
	private $image_resized;
	
	/* 
		Create multiple thumbs/resizes of an image
		Path to the original 
		sizes
			width, height, crop type, path, quality
	*/
	public function create( $path, $filename, $sizes ){
		
		if(is_array($sizes)){
		
			$resized = array();
			
			foreach($sizes as $size){
			
				$this->new_width = $size[0]; //$new_width;
				$this->new_height = $size[1]; //$new_height;
				$this->option = $size[2]; //crop type
				
				$resized[] = $this->resize( $path.$filename, $size[3].$filename, $size[4] );
			}
		}
		
		return $resized;
	}

	/**
	 * Resizes and/or crops an image
	 * @param  mixed   $image resource or filepath 
	 * @param  strung  $save_path where to save the resized image
	 * @param  int (0-100) $quality 
	 * @return bool
	 */
	private function resize( $image, $save_path, $image_quality )
	{
		$image = $this->open_image( $image );
		
		$this->width  = imagesx( $image );
		$this->height = imagesy( $image );
	
		// Get optimal width and height - based on $option.
		$option_array = $this->get_dimensions( $this->new_width , $this->new_height , $this->option );
		
		$optimal_width	= $option_array['optimal_width'];
		$optimal_height	= $option_array['optimal_height'];
		
		// Resample - create image canvas of x, y size.
		$this->image_resized = imagecreatetruecolor( $optimal_width , $optimal_height );
		<commit_msg>Changing resize to do_resize to avoid constructor issues (Closes #1)<commit_after><?php

namespace Multup;

Use \File;

/*
*	The bulk of this class is pulled from the Resizer bundle I edited it to fit my needs here
*	@author <NAME>(original author <NAME> &  <NAME>)
*	@version 1.0
*/
class Resize{
	
	/*
	*	Original width of the image being resized
	*	@var int
	*/
	private $width;
	
	/*
	*	New width of the image being resized
	*	@var int
	*/
	private $new_width;
	
	/*
	*	Original height of the image being resized
	*	@var int
	*/
	private $height;
	
	/*
	*	New height of the image being resized
	*	@var int
	*/
	private $new_height;
	
	/*
	*	Type of crop being performed
	*	@var str
	*/
	private $option;
	
	/*
	*	The resized image resource
	*	@var resource
	*/
	private $image_resized;
	
	/* 
		Create multiple thumbs/resizes of an image
		Path to the original 
		sizes
			width, height, crop type, path, quality
	*/
	public function create( $path, $filename, $sizes ){
		
		if(is_array($sizes)){
		
			$resized = array();
			
			foreach($sizes as $size){
			
				$this->new_width = $size[0]; //$new_width;
				$this->new_height = $size[1]; //$new_height;
				$this->option = $size[2]; //crop type
				

				$resized[] = $this->do_resize( $path.$filename, $size[3].$filename, $size[4] );
			}
		}
		
		return $resized;
	}

	/**
	 * Resizes and/or crops an image
	 * @param  mixed   $image resource or filepath 
	 * @param  strung  $save_path where to save the resized image
	 * @param  int (0-100) $quality 
	 * @return bool
	 */
	private function do_resize( $image, $save_path, $image_quality )
	{
		$image = $this->open_image( $image );
		
		$this->width  = imagesx( $image );
		$this->height = imagesy( $image );
	
		// Get optimal width and height - based on $option.
		$option_array = $this->get_dimensions( $this->new_width , $this->new_height , $this->option );
		
		$optimal_width	= $option_array['optimal_width'];
		$optimal_height	= $option_array['optimal_height'];
		
		// Resample - create image canvas of x, y size.
		$this->image_resized = imagecreatetruecolor( $optimal_width , $optimal_height );
		
{'fraction_non_alphanumeric': 0.1377575467177767, 'fraction_numerical': 0.005510301868711069, 'mean_word_length': 3.105211406096362, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, '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': '4079021', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1446, 'n_words': 429}