-4

I am currently trying to write an application which allows me to get the code of an image just like when you open an image in a text editor. I thought about changing the extension of the file and setting up a bufferedreader?

I have no idea how to accomplish this. The best would be having the code from the image in a String or an array.

Any ideas?

Thanks in advance.

user2410644
  • 3,861
  • 6
  • 39
  • 59
  • 2
    what's the code of an image? – lelloman Sep 30 '13 at 15:26
  • An image contains a code. Try to open an image with your text editor and you'll see some encrypted code. I want to have these lines. Every file is contains a code, you can try it out with almost every text editor. – user2410644 Sep 30 '13 at 15:27
  • Maybe you mean that you want the pixels from an image? In that case see http://stackoverflow.com/questions/6524196/java-get-pixel-array-from-image – Vegard Sep 30 '13 at 15:35
  • There are no "Lines" in binary files. – Grim Sep 30 '13 at 15:43
  • *"Any ideas?"* Don't do exactly what you are attempting. Binary files were neither meant to be viewed or edited in a 'text editor'. – Andrew Thompson Sep 30 '13 at 15:58
  • I know they are not meant to be viewed or edited. The result would be a "glitched" image, because the core code would be manipulated. Colours would be disturbed and pixels would be shifted. That's exactly my attempt. I want to somehow get the code to be able to manipulate it, to have for result a glitched image. That's what I wanted to know by "Any ideas", I am sorry that my question was that vague. – user2410644 Sep 30 '13 at 20:30

2 Answers2

3

I don't know exactly what you mean by "code", but I suggest you use any kind of image library. Maybe this can help you. In the library you can then call methods such as getSize() and more.

EDIT: Is this the code you are looking for?

<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:creator><rdf:Seq xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li>Corbis</rdf:li></rdf:Seq>
        </dc:creator><dc:rights><rdf:Alt xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li xml:lang="x-default">© Corbis.  All Rights Reserved.</rdf:li></rdf:Alt>
        </dc:rights></rdf:Description><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:tiff="http://ns.adobe.com/tiff/1.0/"><tiff:artist>Corbis</tiff:artist></rdf:Description><rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/"><xmp:Rating>3</xmp:Rating><xmp:CreateDate>2008-03-14T13:59:26.540</xmp:CreateDate></rdf:Description><rdf:Description xmlns:MicrosoftPhoto="http://ns.microsoft.com/photo/1.0/"><MicrosoftPhoto:Rating>50</MicrosoftPhoto:Rating></rdf:Description></rdf:RDF></x:xmpmeta>

Try regex and read the file as you suggested. Otherwise a JaxB parser might help if you manage to set it up right.

Joe Eifert
  • 1,306
  • 14
  • 29
1

Text-Files != Binary-Files

First line from BufferedReader-Docu sais: "reads text ..."

Ok, we know images are not text. So you need to use any InputStream, so you have a File, you need the FileInputStream. Be warned: If you print those binary-data to console, it is automatically converted into text, some special binary-data may be skipped. You can not paste it into notepad and save the output as image again.

Grim
  • 1,938
  • 10
  • 56
  • 123
  • The thing I would like to accomplish is, to read the "code" out of the image file, and manipulate it by, for example, deleting some characters, modifying them etc. This would have the effect, that the image appears glitched, colours are swapped in some places, pixels are in a wrong order etc. This would be my goal – user2410644 Sep 30 '13 at 20:27
  • There are no Characters in a Code. So you can not delete Characters. There are only Bytes in a Code, you can delete Bytes - Is this what you want? **Delete Bytes**? – Grim Oct 02 '13 at 11:17