<commit_before><?php
/**
  * ImageGD model
  *
  * This implements image manipulation functionality as defined by the Image interface.
  * Requires PHP GD library.
	* http://php.net/manual/en/book.image.php
  * The file is not written to disk until explicitly called.
  * @author <NAME> <<EMAIL>>
  */
class ImageGD implements ImageInterface
{
  /**
    * Private instance variable that holds a GD object
    * @access private
    * @var object
    */
  private $image;

	/**
    * Private instance variable that holds mime type, width and height of the image
    * @access private
    * @var string
    */
  private $type;
	private $width;
	private $height;


  /**
    * Constructor which initializes the GD object.
    *
    * @param string $filename Full path to the file which will be manipulated
    * @return void
    */
  public function __construct($filename)
  {
    $this->type = mime_content_type($filename);
    if(preg_match('/png$/', $this->type))
      $this->image = imagecreatefrompng($filename);
    elseif(preg_match('/gif$/', $this->type))
      $this->image = @imagecreatefromgif($filename);
    else
      $this->image = @imagecreatefromjpeg($filename);<commit_msg>Replacing deprecated mime_content_type with finfo_file. Closes #368.<commit_after><?php
/**
  * ImageGD model
  *
  * This implements image manipulation functionality as defined by the Image interface.
  * Requires PHP GD library.
	* http://php.net/manual/en/book.image.php
  * The file is not written to disk until explicitly called.
  * @author <NAME> <<EMAIL>>
  */
class ImageGD implements ImageInterface
{
  /**
    * Private instance variable that holds a GD object
    * @access private
    * @var object
    */
  private $image;

	/**
    * Private instance variable that holds mime type, width and height of the image
    * @access private
    * @var string
    */
  private $type;
	private $width;
	private $height;


  /**
    * Constructor which initializes the GD object.
    *
    * @param string $filename Full path to the file which will be manipulated
    * @return void
    */
  public function __construct($filename)
  {
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $this->type = finfo_file($finfo, $filename);
    if(preg_match('/png$/', $this->type))
      $this->image = imagecreatefrompng($filename);
    elseif(preg_match('/gif$/', $this->type))
      $this->image = @imagecreatefromgif($filename);
    else
      $this->image = @imagecreatefromjpeg($filename);
{'fraction_non_alphanumeric': 0.11949939442874445, 'fraction_numerical': 0.0012111425111021397, 'mean_word_length': 3.178752107925801, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '6591452', 'n_tokens_mistral': 746, 'n_tokens_neox': 727, 'n_words': 226}