my website banner

script can now find picture in full path, fixed README.txt master
authorDavid Polakovic <email@dpolakovic.space>
Fri, 18 Jul 2025 23:47:41 +0000 (01:47 +0200)
committerDavid Polakovic <email@dpolakovic.space>
Fri, 18 Jul 2025 23:47:41 +0000 (01:47 +0200)
README.txt
tti.pl

index a3151b325eb07074ef9fa96d232167d9c7dc6b8a..4fa7e39d81fe7f4731f070bdfd481c775dad87c9 100644 (file)
@@ -1,4 +1,4 @@
-SHMÚ fetch
+Text-to-image (tti) writer
 The least significant bit writer.
 copyright 2024, David Polakovic, licensed under GPLv3
 
@@ -6,12 +6,17 @@ ABOUT:
 This script encodes message into a pictures. It utilizes very
 common approach of writing information in the least significant
 bits of the image pixels. You can check your message by performing
-a hexdump on the image.
+a hexdump on the image or by opening the image in a text editor.
 
 HOW TO RUN:
 Navigate to the directory where you downloaded the script and
 then use:
      perl tti.pl [file] <your> <message> <goes> <here> ...
+example:
+     perl tti.pl flower.png This is the secret message.
+
+New file will be saved in the same directory as the original file,
+with "-processed" handle.
 
 
 LICENSE:
diff --git a/tti.pl b/tti.pl
index 4f2e06a05cc60320ce48e229700c92469fcb2195..64e84c5359cecb55844f94e3a3a934a3365411f1 100644 (file)
--- a/tti.pl
+++ b/tti.pl
@@ -8,25 +8,37 @@ if (@ARGV < 2) {
 }
 
 # save the filename
-my $filename = $ARGV[0];
+my $file_name = $ARGV[0];
+my $file_extension;
+
+if ($file_name =~ /^(.+)(\.[^.]+)$/) {
+    $file_extension = $2;  # ".jpg"
+    $file_name = $1;       # "flower"
+} else {
+    # Handle case where there's no extension
+    $file_extension = "";
+}
 
 # save the message 
 shift(@ARGV);
 my $message = join(" ", @ARGV);
 
 # create name for output file
-my $new_filename = "processed_" . $filename;
+my $new_file_name = $file_name . "-processed" . $file_extension;
+
+# revert back to original name once new name is created
+$file_name = $file_name . $file_extension;
 
 # copy the file
 if ($^O eq 'MSWin32' or $^O eq 'MSWin64') {
     # for Windows
-    system("copy", $filename, $new_filename);
+    system("copy", $file_name, $new_file_name);
 } else {
     # for every other system
-    system("cp", $filename, $new_filename);
+    system("cp", $file_name, $new_file_name);
 }
 
 # write the message into new file
-open my $fh, '>>:raw', $new_filename or die "Cannot open file: $!";
+open my $fh, '>>:raw', $new_file_name or die "Cannot open file: $!";
 print $fh $message;
 close $fh;