Write an arbitrary file to the iTXt chunk of PNG?
-
- Posts: 2
- Joined: 2011-06-07T03:29:28-07:00
- Authentication code: 8675308
Write an arbitrary file to the iTXt chunk of PNG?
Tell me please, how to write an arbitrary file to the iTXt chunk of PNG file, like it does Adobe Fireworks, writing all project data in the PNG in addition to the image.
Re: Write an arbitrary file to the iTXt chunk of PNG?
The feature for writing arbitrary PNG chunks is documented as a comment
in coders/png.c but doesn't seem to be in the manual:
The five binary zeroes convey the iTXt keyword terminator, compression flag,
compression method, language tag terminator, and translated keyword terminator.
If you do further operations on the file with ImageMagick, this new
chunk will probably get lost or maybe converted to a zTXt chunk
because IM doesn't recognize iTXt.
Glenn
in coders/png.c but doesn't seem to be in the manual:
- %
% It is possible to request that the PNG encoder write previously-formatted
% ancillary chunks in the output PNG file, using the "-profile" commandline
% option as shown below or by setting the profile via a programming
% interface:
%
% -profile PNG-chunk-x:<file>
%
% where x is a location flag and <file> is a file containing the chunk
% name in the first 4 bytes, then a colon (":"), followed by the chunk data.
% This encoder will compute the chunk length and CRC, so those must not
% be included in the file.
%
% "x" can be "b" (before PLTE), "m" (middle, i.e., between PLTE and IDAT),
% or "e" (end, i.e., after IDAT). If you want to write multiple chunks
% of the same type, then add a short unique string after the "x" to prevent
% subsequent profiles from overwriting the preceding ones, e.g.,
%
% -profile PNG-chunk-b01:file01 -profile PNG-chunk-b02:file02
%
Code: Select all
-profile PNG-chunk-e:filename
compression method, language tag terminator, and translated keyword terminator.
If you do further operations on the file with ImageMagick, this new
chunk will probably get lost or maybe converted to a zTXt chunk
because IM doesn't recognize iTXt.
Glenn
-
- Posts: 2
- Joined: 2011-06-07T03:29:28-07:00
- Authentication code: 8675308
Re: Write an arbitrary file to the iTXt chunk of PNG?
Will be the file corrupted, if written to another type of chunk?
(Excuse me for my bad English, it's not my native language
(Excuse me for my bad English, it's not my native language
Re: Write an arbitrary file to the iTXt chunk of PNG?
If it contains only symbols from the Latin-1 character set you
can write it as tEXt or zTXt and it won't be corrupted.
can write it as tEXt or zTXt and it won't be corrupted.
Re: Write an arbitrary file to the iTXt chunk of PNG?
The method for injecting arbitrary PNG chunks via the "-profile" option
is not working in recent versions of IM. We are working on a fix.
Meanwhile, using "-set profile PNG-chunk-x:<file>" works.
is not working in recent versions of IM. We are working on a fix.
Meanwhile, using "-set profile PNG-chunk-x:<file>" works.