Will random data appended to a JPG make it unusable?

余生长醉 提交于 2019-12-03 10:46:38

No, you can add bits to the end of a jpg file, without making it unusable. The heading of the jpg file tells how to read it, so the program reading it will stop at the end of the jpg data.

In fact, people have hidden zip files inside jpg files by appending the zip data to the end of the jpg data. Because of the way these formats are structured, the resulting file is valid in either format.

You can .. but the results may be unpredictable.

Even though there is enough information in the format to tell the client to ignore the extra data it is likely not a case the programmer tested for.

A paranoid program might look at the size, notice the discrepancy and decide it won't process your file because clearly it doesn't fully understand it. This is particularly likely when reading data from the web when random bytes in a file could be considered a security risk.

You can embed your data in the XMP tag within a JPEG (or EXIF or IPTC fields for that matter). XMP is XML so you have a fair bit of flexibility there to do you own custom stuff.

It's probably not the simplest thing possible but putting your data here will maintain the integrity of the JPEG and require no "post processing".

You data will then show up in other imaging software such as PhotoShop, which may not be ideal.

As others have stated, you have no control how programs process image files and therefore some programs may find the images valid others may not.

However, there is a bigger issue here. Judging by your question, I'm deducing you're practicing "security through obscurity." It's widely considered a very bad practice. Use Google to find a plethora of articles about the topic.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!