.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Data::Printer::Filter::ContentType 3pm" .TH Data::Printer::Filter::ContentType 3pm "2023-01-02" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::Printer::Filter::ContentType \- detect popular (binary) content in strings .SH "SYNOPSIS" .IX Header "SYNOPSIS" In your \f(CW\*(C`.dataprinter\*(C'\fR file: .PP .Vb 1 \& filters = ContentType .Ve .PP You may also customize the look and feel with the following options (defaults shown): .PP .Vb 2 \& filter_contenttype.show_size = 1 \& filter_contenttype.size_unit = auto \& \& # play around with these if you want to print the binary content: \& filter_contenttype.hexdump = 0 \& filter_contenttype.hexdump_size = 0 \& filter_contenttype.hexdump_offset = 0 \& filter_contenttype.hexdump_indent = 0 \& \& # you can even customize your themes: \& colors.filter_contenttype = #ca88dd \& colors.filter_contenttype_hexdump = #ffcb68 .Ve .PP That's it! .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a filter plugin for Data::Printer that looks for binary strings with signatures from popular file types. If one is detected, instead of the bogus binary dump it will print the content type and the string size. .PP For example, let's say you've read an image file into \f(CW$data\fR, maybe from a user upload or from Imager or ImageMagick. If you use Data::Printer with this filter, it will show you something like this: .PP .Vb 1 \& my $data = get_image_content_from_somewhere(); \& \& use DDP; p $data; # (PNG Image, 32K) .Ve .SS "hexdump" .IX Subsection "hexdump" If, for whatever reason, you want to inspect the actual content of the binary data, you may set \f(CW\*(C`filter_contenttype.hexdump\*(C'\fR to true. This will pretty-print your data in hexadecimal, similar to tools like \f(CW\*(C`hexdump\*(C'\fR. Once active, it will print the entire content, but you may limit the size by changing \&\f(CW\*(C`filter_contenttype.hexdump_size\*(C'\fR to any value (unit == bytes), and you can even start from a different position using \&\f(CW\*(C`filter_contenttype.hexdump_offset\*(C'\fR. Set it to a negative value to make your offset relative to the end to the data. .PP Finally, the default hexdump mode will not indent your content. Since it's a binary dump, we want to get as much terminal space as we can. If you rather have the dump properly indented (relative to your current dump indentation level), just set \f(CW\*(C`filter_contenttype.hexdump_indent\*(C'\fR to 1. .SS "Detected Content" .IX Subsection "Detected Content" Below are the signatures detected by this filter. .PP \fIImages\fR .IX Subsection "Images" .IP "\(bu" 4 \&\s-1PNG\s0 .IP "\(bu" 4 \&\s-1JPEG\s0 .IP "\(bu" 4 \&\s-1GIF\s0 .IP "\(bu" 4 \&\s-1ICO\s0 .IP "\(bu" 4 \&\s-1TIFF\s0 .IP "\(bu" 4 \&\s-1BMP\s0 .PP \fIVideo\fR .IX Subsection "Video" .IP "\(bu" 4 \&\s-1AVI\s0 .IP "\(bu" 4 \&\s-1MPEG\s0 .PP \fIAudio\fR .IX Subsection "Audio" .IP "\(bu" 4 \&\s-1WAV\s0 .IP "\(bu" 4 \&\s-1MP3\s0 .IP "\(bu" 4 \&\s-1FLAC\s0 .IP "\(bu" 4 \&\s-1OGG\s0 .PP \fIDocuments and Archives\fR .IX Subsection "Documents and Archives" .IP "\(bu" 4 \&\s-1ZIP\s0 .IP "\(bu" 4 \&\s-1GZIP\s0 .IP "\(bu" 4 \&\s-1BZIP2\s0 .IP "\(bu" 4 \&\s-1PDF\s0 .IP "\(bu" 4 Binary Executables (\s-1ELF\s0 and Win32) .PP We don't want this list to grow into a full-blown detection system, and instead just focus on common types. So if you want to contribute with patches or open an issue for a missing type, please make sure you \&\fIactually have data structures with that content\fR (e.g. you were bit by this in your code and \s-1DDP\s0 didn't help). .PP We want to help people debug code, not add content types just for the sake of it :) .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Printer