<commit_before>/////////////
// Imports //
#include <iostream>

#include "image.hpp"
#include "pixel.hpp"

//////////
// Code //

// Loading an image from the filesystem.
Image* loadImage(char* path) {
    std::cout << "Loading image " << path << ".\n";
    Image* img = new Image(std::string(path));
    if (img->error) {
        std::cerr << "Failed to load image " << path << ".\n";
        delete img;
        return nullptr;
    }

    return img;
}

// Loading a set of images.
Image** loadImages(char** argv) {
    Image** imgs = new Image*[3];

    Image* img1 = loadImage(argv[1]);
    if (img1 == nullptr) {
        delete[] imgs;
        return nullptr;
    }

    Image* img2 = loadImage(argv[2]);
    if (img2 == nullptr) {
        delete[] imgs;
        delete img1;
        return nullptr;
    }

    Image* img3 = loadImage(argv[3]);
    if (img3 == nullptr) {
        delete[] imgs;
        delete img1;
        delete img2;
        return nullptr;
    }

    imgs[0] = img1;
    imgs[1] = img2;
    imgs[2] = img3;

    return imgs;
}

// Placeholder main.
int main(int argc, char** argv) {
    // Checking for argument validity.
    if (argc != 5) {
        std::cout << "Proper usage: tentons <input image 1> <input image 2> "
                  << "<input image 3> <output image>\n";

        return 1;
    }

    // Loading each Image.
    Image** imgs = loadImages(argv);
    if (imgs == nullptr)
        return 2;

    // Processing the output image.
    std::cout << "Processing output image...\n";
    Image* out = processImages(imgs[0], imgs[1], imgs[2]);

    // Writing the output image.
    if (out != nullptr) {
        std::cout << "Writing output image...\n";
        out->save(std::string(argv[4]));
    } else {
        std::cout << "Cannot write out null output image!\n";
    }

    // Cleaning up memory.
    std::cout << "Cleaning up memory...\n";
    for (int i = 0; i < 3; i++)
        if (imgs[i] != nullptr)
            delete imgs[i];

    delete[] imgs;

    if (out != nullptr)<commit_msg>Made loading more than just 3 images.<commit_after>/////////////
// Imports //
#include <iostream>

#include "image.hpp"
#include "pixel.hpp"

//////////
// Code //

// Loading an image from the filesystem.
Image* loadImage(char* path) {
    std::cout << "Loading image " << path << ".\n";
    Image* img = new Image(std::string(path));
    if (img->error) {
        std::cerr << "Failed to load image " << path << ".\n";
        delete img;
        return nullptr;
    }

    return img;
}

// Loading a set of images.
Image** loadImages(int argc, char** argv) {
    Image** imgs = new Image*[argc - 2];

    for (int i = 1; i < argc - 1; i++) {
        imgs[i - 1] = loadImage(argv[i]);
        if (imgs[i - 1] == nullptr) {
            std::cerr << "Could not load image " << argv[i] << "!\n";
            for (int j = 1; j < i; i++)
                delete imgs[j];
            delete[] imgs;

            return nullptr;
        }
    }

    return imgs;
}

// Placeholder main.
int main(int argc, char** argv) {
    // Checking for argument validity.
    if (argc == 1) {
        std::cout << "Proper usage: tentons <img 1> <img 2> ... "
                  << "<output image>\n";
        return 1;
    }

    // Loading each Image.
    Image** imgs = loadImages(argc, argv);
    if (imgs == nullptr)
        return 2;

    // Processing the output image.
    std::cout << "Processing output image...\n";
    Image* out = processImages(imgs[0], imgs[1], imgs[2]);

    // Writing the output image.
    if (out != nullptr) {
        std::cout << "Writing output image...\n";
        out->save(std::string(argv[4]));
    } else {
        std::cout << "Cannot write out null output image!\n";
    }

    // Cleaning up memory.
    std::cout << "Cleaning up memory...\n";
    for (int i = 0; i < 3; i++)
        if (imgs[i] != nullptr)
            delete imgs[i];

    delete[] imgs;

    if (out != nullptr)
{'fraction_non_alphanumeric': 0.17660492260847502, 'fraction_numerical': 0.012433392539964476, 'mean_word_length': 1.896399706098457, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 16, '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': '1489880', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1268, 'n_words': 393}