In an article, I have written about that the original purpose of the "cat" command is to join files together. However, it is not only used to merge two text files, you can also use the "cat" command to embed a message into an image.
I will use the image of Linus Torvalds raising the middle finger as the example. I will embed the message "Nvidia: FUCK YOU!" into this image. Here is the original image, I saved it as "fu.jpg" in my Desktop folder.
To use "cat" to embed a message into this image, the command you can use is:
cat fu.jpg -> fun.png
Just replace "fun.png" with another filename if you want. After you hit enter, you will see the cursor blinking and you can insert your message here. After you are done with the message, hit Ctrl + D to finish the task. Here is how the terminal will look like:
After that, there will be a new image fun.png in my Desktop folder. However, if you use an image viewer like Shotwell to view the image, you wont see the embedded message. To read the message, you need to open the terminal and run this command:
tail fun.png
Here is how the terminal looks with this command, as you can see, there is a line "Nvidia: FUCK YOU!":
Another way to embed the message is to create a text file with the message first then you merge the image and the text file together to create a new image. For example, to create a text file "fu.txt", you can use the "cat" command like this:
cat > fu.txt
The cursor will blink and you can enter the message into the text file then hit Ctrl + D after you are done.
After that, to merge the image and the text file, the command will be similar to that when you merge any two files, just remember the image file must appear before the text file in the command:
cat fu.jpg fu.txt > fun.png
And you will have the same output image as what you got with the first method.
You can also directly append the text file into the fu.jpg image. The command will be:
cat fu.txt >> fun.jpg
And you will have the same output image.
Anyway, this is just a fun way to use the "cat" command. If your girlfriend/ boyfriend is geeky enough, you can use this tip as a way to send a secret love letter. Hope you have fun.
No comments:
Post a Comment