<commit_before><?php

/*****

Simple GD based Image Class
<NAME> 2015

Usage Example:
$img = new Image("C:\image.png");
$img->resize(400, 400);
$img->save(); //or $img->save("C:\image-resized.png");

******/

class Image
{
	private $path;
	private $pathinfo;
	private $name;
	private $img;

	//Open the image
	function __construct($path)
	{
		$this->path = $path;
		$this->pathinfo = pathinfo($path);
		$this->name = isset($this->pathinfo['basename']) ? $this->pathinfo['basename'] : '';

		if(!file_exists($path))
			throw(new Exception("Image file not found: \"$this->name\""));

		$this->gdInit();
		$this->img = call_user_func($this->gdLoad, $path);

		if (!$this->img)
			throw(new Exception("\"$this->name\" does not appear to be a valid image."));
	}

	//Resize the image
	function resize($maxwidth, $maxheight = null)
	{
		if (!is_int($maxwidth) || !is_int($maxheight))<commit_msg>Fixed bug found in unit test<commit_after><?php

/*****

Simple GD based Image Class
<NAME> 2015

Usage Example:
$img = new Image("C:\image.png");
$img->resize(400, 400);
$img->save(); //or $img->save("C:\image-resized.png");

******/

class Image
{
	private $path;
	private $pathinfo;
	private $name;
	private $img;

	//Open the image
	function __construct($path)
	{
		$this->path = $path;
		$this->pathinfo = pathinfo($path);
		$this->name = isset($this->pathinfo['basename']) ? $this->pathinfo['basename'] : '';

		if(!file_exists($path))
			throw(new Exception("Image file not found: \"$this->name\""));

		$this->gdInit();
		$this->img = call_user_func($this->gdLoad, $path);

		if (!$this->img)
			throw(new Exception("\"$this->name\" does not appear to be a valid image."));
	}

	//Resize the image
	function resize($maxwidth, $maxheight = null)
	{
		if (!is_int($maxwidth) && !is_int($maxheight))
{'fraction_non_alphanumeric': 0.21639709983268265, 'fraction_numerical': 0.011154489682097044, 'mean_word_length': 4.403614457831325, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3970313', 'n_tokens_mistral': 690, 'n_tokens_neox': 641, 'n_words': 150}