Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image!!

Status
Not open for further replies.

vbkris

Programmer
Joined
Jan 20, 2003
Messages
5,994
Location
IN
ok guys heres one:

i have a gif file which opens normally in IE, i opened the file using notepad and added a character 'a' to the first line. i saved the file.. the fie did not open in IE...

but now is the problem.. i deleted the character i added.. still the file doesnt open in IE...

what have i done wrong?

Known is handfull, Unknown is worldfull
 
I am guessing it is because the browser may be picking up on 'a' as a special character(a href=...). Could you send me the code you have?
 
hi beirti,
i found out why it is happening:
this happens even if u change the cursor in the notepad file (where the gif is open). it seems even the moving of a cursor needs code which gets inserted into the text file!!! (this is true also for a mouse click)...

ie open the .gif in notepad and simply browse the file using front and back keys. the file gets corrupted!!!


try this and help me if u can overcome this... :)

Known is handfull, Unknown is worldfull
 
1 question:
Why would you want to open a gif in notepad?
 
vbkris:
The problem, I think, is that Notepad edits 7-bit text data, but a GIF is 8-bit data.

By saving the file from Notepad, the most significant bit of every byte has probably been lost. And since a GIF has a specific internal structure, that structure, or at least its delimiter tags, have been damaged, too.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Yes, opening a binary graphics file in an ascii text editor will definitely screw things up.

Apparently vbkris is trying to hide secret messages in his web graphics for his Al Quaeda cronies. Although I prefer not to participate in this terrorist action, vbkris can find freeware utilities to add GIF comments to the files. Other utilities can embed other data in the file.

webattack.com may list some of these apps. I think I used a program called GIF Cleaner to add copyright text comments to GIF files. It has been a while though and I may be forgetful.

- - picklefish - -
 
:)

guys let me assure u that i aint Al-Quaeda.. i did this just because i face this problem when i tried to upload a file using raw upload (ASP)...
another advantage is that if i add a special character and only i know how to remove it then i have a good soln for safe gaurding my images on the web...


thanks...



Known is handfull, Unknown is worldfull
 
What, you aren't Vareem Bin Krisaddam, the 4 of hearts? Now I feel so silly. [bigsmile]

Just curious, how will adding a character safe-guard images? There has also been some interesting debate in the HTML forum here about protecting assets online.

It is possible for PHP (with the right libraries on your server) to visibly stamp copyrights or whatever text you want on images. Some examples are found on phpclasses.org

- - picklefish - -
 
jimbolak by adding an extra character the file gets 'corrupted' ie IE will not open it as a gif...

sleipnir214:
if i open the file using fopen will i still have the 7 or 8 byte problem?

Known is handfull, Unknown is worldfull
 
>> if i open the file using fopen will i still have the 7 or 8 byte problem?

A little correction: Notepad DOES work with an 8-bit character set. That is not the problem.

The problem is that the files notepad works with are in DOS format--i.e., every newline is represented by two bytes: CR (hex 0D) and LF (hex 0A).

There is a great possibility that notepad replaced every 0A in the GIF file with an 0D/0A pair.

I REALLY hope that helps.
Will
 
so how about fopen?

Known is handfull, Unknown is worldfull
 
PHP reads binary data fine, on Windows, you have to supply the [tt]b[/tt] option to [tt]fopen[/tt].

//Daniel
 
so adding an "a" using fopen(in binary) will corrupt the file?

Known is handfull, Unknown is worldfull
 
Opening and writing file with binary will never ever corupt the file.
But doing that in text mode as many editors does will corupt the file.


________
George, M
 
o.k shadow what i meant by "corrupt" is that a normal browser like IE cannot open it... as u have seen in my postings before my objective is to "corrupt" it in such a way that only i can view it (using PHP remove the "a" character)... :)

Known is handfull, Unknown is worldfull
 
Yes i knw but what i'm saying is that if you modify the image content of an gif file not headers of it, using binary, you will see the image but some pixels are bad. either way using binary you only have to modify some information after GIF header wich is the gif header and then you will corupt the file or make for example all colors the same from the gif header palette.

But if you use text mode you will lose the file even if you just open and save as text mode the file.
That's what i mean.

________
George, M
 
thanks guys....

a really appreciate ur help.... :)

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top