Skip to content

FilkerZero/png-text-embed-tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The utility 'png-text-append' inserts "text chunks" into PNG files.
*Note: this does _not_ mean 'drawing text on the image' in any way;
the appearance of the image will be unchanged.  This means inserting
an ancillary text chunk into the PNG stream, which can be used for 
example, to hold copyright information.

The utility 'png-text-dump' displays all text chunks present in a PNG 
file.

References:
http://stackoverflow.com/questions/9036152/insert-a-text-chunk-into-a-png-image

The "png-text-embed-tools" fork makes the following changes:
1) Removes several memory leaks and buffer overflow issues
2) Makes tools that build and work on both Linux and Windows (under Mingw64)
3) Replaced "png-text-append" with "png-text-add" that works with files as well as stdin/stdout.

The text extraction tool source built under Mingw, but didn't work because the PNG file
was opened with `fopen(name, "r")`, not `fopen(name, "rb")` - that "b" after the "r"
is required on Windows to get a stream or FILE to not do newline conversion, and it's
harmless on Linux.

The "png-text-append" program was another matter. I substantially rewrote it, using
"ntohl()" and "htonl()" instead of the byte swapping function that acted on a buffer
that the original version implemented directly. Outside of error exits, the new
version now releases the memory it allocates, and it does not overwrite the bounds
of the explcitly allocated buffers. It uses binary I/O with "open()", "read()",
and "write()", it can accept either stdin or a file for its input and can write
either to a file or stdout for its output, has better error messages, and
in general is less sloppy.

All that said, the code in this repository is not up to my standards.
I'm a professional software engineer, and even on throw-away projects like
this one, I have standards to uphold.

The original is 14 years old. I forked it because I am being lazy and
didn't want to write my own tool to pull prompts out of Stable Diffusion Webui
generated PNG files when my DB of prompts I liked got corrupted. I'm a bit
of a perfectionist, so this fork will probably go from the soon to be
current state to something I can look at and not want to rewrite.

About

Insert "text chunks" into PNG files (and read text chunks)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.0%
  • Makefile 3.0%