Arc
Arc

Reputation: 11296

Are there ASCII-only image files?

I need some sample image data that consists of ASCII (or maybe UTF-8) characters only, with a license suitable for commercial use (in documentation).

Data should ideally be printable and unambiguous (i.e. no control chars, no tab, but space 0x20 would be ok).

Do you have any or know of any links?

Can be JPEG, PNG, GIF, BMP, TIF.

Something similar to the EICAR antivirus test file that is a valid executable made up of printable ASCII characters only.

Upvotes: 3

Views: 2863

Answers (2)

fferri
fferri

Reputation: 18950

XPM is also a ASCII-only image file format.

It has several variants: XPM1 and XPM3 can be emdedded directly in C programs.

Sample (XPM3):

/* XPM */
static char * plaid[] = {
/* plaid pixmap 
 * width height ncolors chars_per_pixel */
"22 22 5 2",
/* colors */
".  c red       m white  s light_color ",
"Y  c green     m black  s lines_in_mix ",
"+  c yellow    m white  s lines_in_dark ",
"x              m black  s dark_color ",
"   c none               s mask ",
/* pixels */
"                      x x x x x + x x x x x ", 
"                    . x x x x x x x x x x x ", 
"                  . x x x x x x + x x x x x ", 
"                . x . x x x x x x x x x x x ", 
"              . x . x x x x x x + x x x x x ", 
"            Y Y Y Y Y + x + x + x + x + x + ", 
"          x x . x . x x x x x x + x x x x x ", 
"        . x . x . x . x x x x x x x x x x x ", 
"      . x x x . x . x x x x x x + x x x x x ", 
"    . x . x . x . x . x x x x x x x x x x x ", 
"  . x . x x x . x . x x x x x x + x x x x x ", 
". . . . . x . . . . . x . x . x Y x . x . x ", 
". . . . . x . . . . . . x . x . Y . x . x . ",
". . . . . x . . . . . x . x . x Y x . x . x ", 
". . . . . x . . . . . . x . x . Y . x . x . ", 
". . . . . x . . . . . x . x . x Y x . x . x ", 
"x x x x x x x x x x x x x x x x x x x x x x ", 
". . . . . x . . . . . x . x . x Y x . x . x ", 
". . . . . x . . . . . . x . x . Y . x . x . ", 
". . . . . x . . . . . x . x . x Y x . x . x ", 
". . . . . x . . . . . . x . x . Y . x . x . ", 
". . . . . x . . . . . x . x . x Y x . x . x "
} ;

XPM2 has a more concise syntax:

! XPM2
48 4 2 1
a c #FFFFFF
b c #000000
abaabaababaaabaabababaabaabaababaabaaababaabaaab
abaabaababaaabaabababaabaabaababaabaaababaabaaab
abaabaababaaabaabababaabaabaababaabaaababaabaaab
abaabaababaaabaabababaabaabaababaabaaababaabaaab

Upvotes: 0

Joe
Joe

Reputation: 31087

The Netpbm format is exactly that, an image format made entirely of printable characters.

The example in that Wikipedia article shows a single-bit image:

P1
# This is an example bitmap of the letter "J"
6 10
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
1 0 0 0 1 0
0 1 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0

This includes the magic number, dimensions and the pixel data, all expressed in ASCII.

The other file formats you suggest all require non-printable characters, either as specific magic numbers or to express any reasonable image.

Upvotes: 3

Related Questions