<commit_before><?php

namespace Imagize;

class Image {

    private $resource;
    private $width;
    private $height;
    private $type;
    private $typeString;

    public function __construct($content) {

        $imageInfo = getimagesizefromstring($content);
        $this->width = $imageInfo[0];
        $this->height = $imageInfo[1];
        $this->type = $imageInfo[2];
        $this->typeString = $imageInfo['mime'];

        $this->resource = imagecreatefromstring($content);

    }

    public function getMime() {
        return $this->typeString;
    }

    public function getRessource() {
        return $this->resource;
    }

    public function outputImage() {
        switch ($this->type) {
            case IMAGETYPE_GIF:
                return imagegif($this->resource);
            case IMAGETYPE_JPEG:
                return imagejpeg($this->resource);
            case IMAGETYPE_PNG:
                return imagepng($this->resource);
        }
        return false;
    }

    public function redimensionner($newWidth,$newHeight) {
        if ($newWidth === 0) {
            $ratio = $newHeight / $this->height;
            $newWidth = (int)$this->width * $ratio;

        } else if ($newHeight === 0) {
            $ratio = $newWidth / $this->width;
            $newHeight = (int)$this->height * $ratio;
        }
        $destination = imagecreatetruecolor($newWidth,$newHeight);
        imagecopyresampled($destination,$this->resource,0,0,0,0,$newWidth,$newHeight,$this->width,$this->height);
        $this->resource = $destination;
        $this->height = $newHeight;
        $this->width = $newWidth;
    }

}<commit_msg>preparing to save<commit_after><?php

namespace Imagize;

class Image {

    private $resource;
    private $width;
    private $height;
    private $type;
    private $typeString;

    public function __construct($content) {

        $imageInfo = getimagesizefromstring($content);
        $this->width = $imageInfo[0];
        $this->height = $imageInfo[1];
        $this->type = $imageInfo[2];
        $this->typeString = $imageInfo['mime'];

        $this->resource = imagecreatefromstring($content);

    }

    public function getMime() {
        return $this->typeString;
    }

    public function getRessource() {
        return $this->resource;
    }

    public function outputImage() {
        switch ($this->type) {
            case IMAGETYPE_GIF:
                return imagegif($this->resource);
            case IMAGETYPE_JPEG:
                return imagejpeg($this->resource);
            case IMAGETYPE_PNG:
                return imagepng($this->resource);
        }
        return false;
    }

    public function redimensionner($newWidth, $newHeight) {
        if ($newWidth === 0) {
            $ratio = $newHeight / $this->height;
            $newWidth = (int)$this->width * $ratio;

        } else if ($newHeight === 0) {
            $ratio = $newWidth / $this->width;
            $newHeight = (int)$this->height * $ratio;
        }
        $destination = imagecreatetruecolor($newWidth, $newHeight);
        imagecopyresampled($destination, $this->resource, 0, 0, 0, 0, $newWidth, $newHeight, $this->width, $this->height);
        $this->resource = $destination;
        $this->height = $newHeight;
        $this->width = $newWidth;
    }

    public function sauverVersPath($path) {
        switch ($this->type) {
            case IMAGETYPE_GIF:
                imagegif($this->resource, $path);
                break;
            case IMAGETYPE_JPEG:
                imagejpeg($this->resource, $path);
                break;
            case IMAGETYPE_PNG:
                imagepng($this->resource, $path);
                break;
        }
    }

}
{'fraction_non_alphanumeric': 0.13412017167381973, 'fraction_numerical': 0.004828326180257511, 'mean_word_length': 2.074196207749382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '2522252', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1061, 'n_words': 213}