#!/usr/bin/perl use strict; use warnings; my $ifh = open("<:raw", "./file-bar.png"); my $data = unpack('a*', $ifh); my $outputfile = "newfile.png"; open (my $ofh, '>:raw', $outputfile) or die "Could not open '$outputfile' $!"; print $ofh pack('a*', $data); close $ofh; print("Image created.\n"); #### $ file file-bar.png file-bar.png: PNG image data, 400 x 300, 4-bit colormap, interlaced $ file newfile.png newfile.png: very short file (no magic)