Image::PNG::FileConvert - convert a file to or from a PNG image
use Image::PNG::FileConvert qw/file2png png2file/; # Convert a data file into a PNG image file2png ('myfile.txt', 'myfile.png'); # Extract a data file from a PNG image png2file ('myfile.png');
file2png ('myfile.txt', 'myfile.png');
Convert myfile.txt into a PNG graphic. The function uses the data from myfile.txt to write a greyscale (black and white) image. The bytes of the file correspond to the pixels of the image.
myfile.txt
When this PNG is unwrapped using "png2file", it will be called myfile.txt again. If you want to specify a different name,
file2png ('myfile.txt', 'myfile.png', { name => 'not-the-same-name.txt' });
and the file will be unwrapped into not-the-same-name.txt.
not-the-same-name.txt
If you want your PNG to have a different width than the default, there is another option, row_length, specified in the same way:
row_length
file2png ('myfile.txt', 'myfile.png', { row_length => 0x100 });
The number you specify for row_length will be the width of the image in pixels.
png2file ('myfile.png');
Convert myfile.png into a data file. myfile.png must be a PNG created using "file2png". The file is stored in whatever the name of the file given to "file2png" was.
myfile.png
Please note that this only converts PNG files output by "file2png", not general PNG files.
Both the routines here hold the entire file in memory, limiting the data size which can be converted to or from a PNG.
There should be some option to specify the name of the output file in "png2file".
Ben Bullock, <bkb@cpan.org>
You can use, modify and distribute this software under the Perl Artistic Licence or the GNU General Public Licence.
Acme::Steganography::Image::Png I'm not sure what this does, but maybe it does something similar to Image::PNG::FileConvert.
The distribution also includes two utility scripts, file2png and png2file, which convert a file to a PNG image and back again.
To install Image::PNG::FileConvert, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::PNG::FileConvert
CPAN shell
perl -MCPAN -e shell install Image::PNG::FileConvert
For more information on module installation, please visit the detailed CPAN module installation guide.