Post by nathanmyersc on Feb 20, 2024 19:07:46 GMT
This project takes an INTENTIONS.txt and inputs it as metadata with several helpful headers into the jpg file itself. it will still be usable and addable as an album cover for mp3s.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <jpeglib.h>
// Function to read lines from a file
std::vector<std::string> readLinesFromFile(const std::string& filename) {
std::vector<std::string> lines;
std::ifstream file(filename);
if (file.is_open()) {
std::string line;
while (std::getline(file, line)) {
lines.push_back(line);
}
file.close();
}
return lines;
}
void insertMetadata(const std::string& inputFilename, const std::string& outputFilename, const std::string& customField) {
// Open input JPEG file
FILE* inputFile = fopen(inputFilename.c_str(), "rb");
if (!inputFile) {
std::cerr << "Error: Failed to open input file '" << inputFilename << "'" << std::endl;
return;
}
// Create output file
FILE* outputFile = fopen(outputFilename.c_str(), "wb");
if (!outputFile) {
std::cerr << "Error: Failed to create output file '" << outputFilename << "'" << std::endl;
fclose(inputFile);
return;
}
// Read input file and write to output file
char buffer[1024];
size_t bytesRead;
while ((bytesRead = fread(buffer, 1, sizeof(buffer), inputFile)) > 0) {
fwrite(buffer, 1, bytesRead, outputFile);
}
// Write custom field metadata to output file
fprintf(outputFile, "CustomField: %s\n", customField.c_str());
// Close files
fclose(inputFile);
fclose(outputFile);
std::cout << "Metadata inserted into JPEG file successfully." << std::endl;
}
std::array<std::string, 26 > customFields =
{
"Affirmations that are instantly transmitted to the viewer upon viewing: ",
"Affirmations that are instantly transmitted to the hearer of any audio file in which this is a cover: ",
"Affirmations that are instantly transmitted to anybody in possession of a physical copy of this image: ",
"",
"Affirmations that are instantly transmitted to anybody who is playing an audio file with this as a cover even if its on mute: ",
"Effects that are instantly transmitted to the viewer upon viewing: ",
"Effects that are instantly transmitted to the hearer of any audio file in which this is a cover: ",
"Effects that are instantly transmitted to anybody in possession of a physical copy of this image: ",
"",
"Effects that are instantly transmitted to anybody who is playing an audio file with this as a cover even if its on mute: ",
"Affirmations that also raise the vibration of whoever has a digital copy of this image on their device: ",
"Affirmations that also cleanse the chakras of whoever has a digital copy of this image on their device: ",
"Affirmations that also repair the body to perfect health of whoever has a digital copy of this image on their device: ",
"Affirmations that also raise the vibration of whoever has a physical copy of this image in their possession: ",
"Affirmations that also cleanse the chakras of whoever has a physical copy of this image in their possession: ",
"Affirmations that also repair the body to perfect health of whoever has a physical copy of this image in their possession: ",
"Affirmations that are unblockable by shaytan and his henchmen: ",
"Affirmations that save the life of the receiver: ",
"Affirmations that restore the reciever to their prime state: ",
"Affirmations that imbue the receiver with immortality: ",
"Affirmations that are instantly effective: ",
"Affirmations that have hyperbolic time chamber like effects: ",
"Affirmations that create financial abundance: ",
"Affirmations that assure best path in life: ",
"Affirmations that make one with source: ",
"Affirmations that instantly work in abundance: "
};
int main() {
std::string inputFilename, outputFilename, customField;
std::cout << "Enter the input JPEG file name: ";
std::getline(std::cin, inputFilename);
outputFilename = inputFilename + "_modified.jpg";
std::string fileNameNoExtension = inputFilename.substr(0,inputFilename.size()-4);
std::cout <<fileNameNoExtension;
customFields[3] = "Affirmations that are instantly transmitted to anybody who says " + fileNameNoExtension + " Activate: ";
customFields[8] = "Effects that are instantly transmitted to anybody who says " + fileNameNoExtension + " Activate: ";
// Read content of INTENTIONS.txt
std::vector<std::string> intentions = readLinesFromFile("INTENTIONS.txt");
if (intentions.empty()) {
std::cerr << "Error: INTENTIONS.txt not found or empty." << std::endl;
return 1;
}
std::cout << "Number Of Intentions Read In: " + intentions.size() << std::endl;
// Concatenate lines from INTENTIONS.txt to form the custom field value
// Prompt user for custom field value
for(std::string customField : customFields)
{
for (const std::string& line : intentions) {
customField += line + " "; // + "\n";
}
insertMetadata(inputFilename, outputFilename, customField);
std::string tempName = inputFilename;
inputFilename = outputFilename;
outputFilename = tempName;
std::cout <<"Inserted Custom Field: " + customField << std::endl;
}
return 0;
}