Add text to .jpg/png/gif - image

I heard there is some way, to add additional hidden text inside code of the image file (like jpg/png/gif).
If we open this image in windows, will be shown a picture, but if we open it by some text-editor (like notepad++), we will see our hidden text.
How is this method called? What can you say about it?
Thanks.

Look up steganography. There are lots of tools to add any kind of hidden data you want in there. Usually though, it's not readable by notepad though. you need a companion tool to the one you used to add the data in in the first place. Using this you can even hide a binary file inside.
OR... you could look into using the metadata -- EXIF -- of the JPEG. Lots of tools exist to edit that data too. It ends up stored in the header of the file, so it should be right near the beginning, in other words the file would look something like:
JFIF ..... (GARBAGE) ..... Your Metadata ...... (GARBAGE)
Or finally, I hear that you can just concatenate a RAR onto the end of a JPEG and it will work as a (strangely huge) JPEG but WinRAR will notice the RAR contents when you open it in WinRAR.

This is called steganography.
I think its primary industrial use is watermarking content.
Information Hiding: Steganography & Digital Watermarking is a good resource on the topic.

Use "copy" - copy two files in one.
copy /B img.jpg + some.txt
Thus both file will be merged into the img.jpg file. The text from some.txt is append to the end of the img.jpg file.

Related

convert .nl image file

I have a list of hundreds of hyperlinks that are to image files from my supplier. The problem is they have a .nl file extension. Here's an example:
http://www.netsuite.com/core/media/media.nl?id=66821&c=ACCT120207&h=bad4512e36320e5b2239
I need to use some sort of batch process to find all those image files and convert them to a .png or .jpg link (or batch download all the images then rename them)
Do you have any suggestions?
As you don't show an excerpt from your list of URLs, nor state your Operating System, it is rather hard to help you process the entire list.
However, for the one URL you show, you can retrieve the image and store it locally as "image.jpg" like this:
curl -L "https://system.netsuite.com/core/media/media.nl?id=101065&c=ACCT120207&h=ff667401c82a7dc4c2e1" > image.jpg

Non-deterministic* data in header/beginning of PNG files

I noticed that PNG files created by Gimp from the same RPG data are identical except for the very beginning. This image shows a diff of otherwise identical PNG files created with Gimp:
What is this data which changes each time and how is it encoded? Are there tools to decode it? Can you learn something from this information, e.g. can you find out when a PNG file was (probably) created by this information?
I was under the impression that PNG files are created deterministically* and don't store meta data which isn't necessary to decode the image. (Obviously, the last part is not true, either, as Gimp writes its own name into the files but doesn't ask the user (which is does if you export something as a JPEG file).)
 * I use the word "deterministic" here to refer to things and only such which are the same on each execution/export/whatever given the same input. I'd usually use the word "functional" (i.e. like a mathematical function) but I fear this could be misunderstood by people who don't know what "functional" means in mathematics. Obviously, this is different from the usage of this word in information theory.
See the PNG header definition.
tIME stores the time that the image was last changed, so for me it's the same as the timestamp of the file you create.
bKGD gives the default background color. Possibly the bakcgournd color you are using in Gimp, or the color of the transparent pixels.
tEXT with key Comment and value Created with Gimp is just the default comment. You can change the comment for the image in Image>Properties and you can set a default comment in Edit>Preferences>Default Image
When I export the same PNG twice, I only see a change in tIME. In fact I can't get a bKGD item, even when exporting a PNG with transparent pixels. Are you using any specific options when exporting?

Pictures and picture names to doc?

I have a Windows folder full of pictures. I want to copy them all into a MS Office document, but with the picture filename written above each picture. Is there an easyish way to do this?
Thanks!
The .docx format is simply a main XML wrapped up in a ZIP format with any ancillary required files such as images. It would be pretty simple to do what you need.
I would start by producing an example document, renaming it to .zip, and examining the files within.

How to determine if a photo is corrupted?

I have a requirement where in I have to determine whether a photo is corrupted and accordingly tag it as such.
Another thing, I need is to determine if an Image has got wrong extension. What I mean by wrong extension is that sometimes I have come across a photo that has extension of jpg but when I load this photo into IrfanView it reports that the photo is in different format that the extension.
How can I do this in Delphi.
I have a requirement where in I have to determine whether a photo is corrupted and accordingly tag it as such.
You can try some things, but with certain file formats (example: BMP, JPEG to some extent) only a human can ultimately decide if the file is OK or corrupted. The simplest test is to simply load the file into a corresponding object (TJpegImage, TPngObject, etc). If you get an exception while loading you've surely got a corrupted file. Unfortunately if no exception is raised you can't really say the file is not corrupted. I've seen corrupted JPEG files that load just fine into a Delphi TImage and can be opened with Windows's Image Viewer, but are obviously corrupted to a human observer. With BMP images it's even clearer: open up a bitmap, overwrite some bytes in the middle of the file and then open it in a viewer. How can any automated system tell those wrongly colored bits in the middle of the bitmap are actually wrong?
Another thing, I need is to determine if an Image has got wrong extension. What I mean by wrong extension is that sometimes I have come across a photo that has extension of jpg but when I load this photo into IrfanView it reports that the photo is in different format that the extension.
How about doing some of the same, trying to load the file into the object that corresponds to it's extension, and if you fail, try opening up with some other formats? This should be easy.
Alternatively you can investigate image headers: Most file formats start with a short signature, a few bytes. You can look up the documentation of all image file formats and find the signature, or you can simply open up an large number of files and look for a pattern in the first 4 bytes. I'd go for this second alternative since finding proper documentation for all image file formats might be a challenge.
The only way to check if file is corrupted is to try reading it as it is described in file format, ie. load BMP as BMP with reading BMP header, BMP data etc. There are many web pages that describe graphics file formats. Of course if you transmit files and are afraid that it will be corrupted after transmitting then save such files with some sum like CRC32, or even cryptographic MD5 or SHA1. Then after transmitting check if calculated sum is the same as original.
In Delphi there is unit jpeg and types TJPEGImage and TBitmap. Try loading it with data and check exception. For others formats there are many libraries, just look for required file formats.
To check if file extension is good try reading some first bytes of file and check it with some dictionary of graphics file headers. For example GIF files should start with GIF, BMP files starts with BM, and in JPEG header you will find JFIF. I think unix utility file works this way.
Since you used the term "requirement", I suspect that you're doing a job for someone, possibly as a contract. So make sure that you nail the requirements before worrying about the code.
IMO, you need to get samples of test cases. As others mentioned, failure to load the file as a particular format will be one test. But what about a .jpg that loads ok, but the bottom third is missing? Or a .jpg that loads ok but has green "static" lines in the middle where an error occurred upstream somewhere (on the camera, photoshop, whatever) but then the processing recovered and resumed? In this case, the .jpg may really have green lines in it. Is that considered "corrupt" or not? This is where you need to be careful, especially if it's a contract job.
I have handled this situation by reading the suspicious image and trying to getting its shape. The task is done within try-except block. Following is the code:
import cv2
image = cv2.imread('./image.jpg')
try:
dummy = image.shape # this line will throw the exception
except:
print("[INFO] Image is not available or corrupted.")
This approach should cover all your needs like:
Detecting a corrupted image
Non-image file with an image-type extension detection
Missing image detection etc.

how to convert rtf to image format ( jpg/png..)

i need to convert rtf document that contains images (jpgs/pngs ) to image format
jpgs or pngs programmaticly , do you have any ideas on how to do it ?
on server side (web)
Thanks
You can use a virtual printing device, for example: http://www.joyprinter.com/
If by programmatically, you mean scripts, you could script your RTF program to open files, then export to PDF, then export the PDF to an image. At least, this kind of operation is relatively easy on OS X. You could probably do it entirely in Automator, using TextEdit and Preview. Otherwise, on OS X you could also try accessing the core services that would do the same thing. No clue on Windows though. Hope that helps!
You might want to write a bash script to be executed by a cronjob. So at a defined time, or after a defined period, you will have your rtf files converted into jpgs.
Though I don't know if this might satisfy your "programmatic" need .. here is how to do this conversion:
To convert rtf files contain "advanced" features like images, as in your case, you need unoconv, which requires libreoffice to be installed.
unoconv -f pdf "${input_file}"
Otherwise, just for reference because it's not your case, if the rtf files contain only simply text you can avoid the requirement to have libreoffice installed by using a cascade conversion like
// convert rtf to txt
unrtf --text "input_file.rtf" > "temp.txt"
// convert txt to pdf
enscript "temp.txt" -o - | ps2pdf - "temp.pdf"
// convert pdf to jpg
convert -quality 100 -append "temp.pdf" "output.jpg"
// remove temp files
trash "temp.txt" "temp.pdf" // or rm if you prefer

Resources