Text Pictures [was : Re: Decomposing a B&W...]
Text Pictures [was : Re: Decomposing a B&W...]
- Subject: Text Pictures [was : Re: Decomposing a B&W...]
- From: Mr Tea <email@hidden>
- Date: Tue, 26 Mar 2002 22:37:17 +0000
This from Roger Howard - dated 26/3/02 08:18 pm:
>
Sounds like a job for Akua Sweet's "extract color", should be faster than
>
opening the image in an app and querying the contents of selections you have
>
to create and destroy.
It would probably be faster still to batch convert bitmap images to text
with GraphicConverter, then process the text with (eg) Tex-Edit Plus to get
the desired result.
This thread got me musing about ASCII art and using AS to make pictures from
text, so I wrote a decomposing solution (ewww!) that works with 2-bit images
(offering a slightly broader palette) saved as ASCII text. Run the script
that follows on the block of numbers below it (pasted into a Tex-Edit Plus
window) to see an example. Note that the tab-removal line has been disabled,
as the tabs in the original text file have been taken out prior to posting.
tell application "Tex-Edit Plus"
activate
--replace window 1 looking for tab replacing with ""
replace window 1 looking for "0" replacing with " "
replace window 1 looking for "1" replacing with "~~"
replace window 1 looking for "2" replacing with "oo"
replace window 1 looking for "3" replacing with ".."
set theText to a reference to contents of window 1
set font of theText to "Monaco"
set style of theText to {class:text style info, on styles:{bold,
condensed}, off styles:{}}
end tell
0000000011332321110000000000000000
0000000123333323322222111000000000
0000122223333333332233322210000000
0012322323333333333322332221000000
0022333333333333333332333322100000
0133333333333332333332333332110000
0233333332223333222322333332210000
2333333221001123322222232333221000
1332222210000011233322122233322100
1321111000000000012333222222332200
2310000000000000001222222322232210
3200000000000000001222222333222210
3100000000000000001223222323322210
3100000000000000001223333333332220
2110000000000000000133333333333221
2110000000000000000023333333333321
3110000000012100000002333332222332
2110000122222221000001333321112132
1110112233321122100000223322121222
1222211333322221110000133322012322
0233300122322101000000133332112332
0233300112221000000000022222201333
0233200001110000000000000011202333
0122100000000000000000000011113332
0022000000000000000000000000013332
0022000001100000000000000000133331
0012000000220000000000000101333331
0012222222012100000000000212333320
0012333210001221100000000002333320
0013233211000011000000000002333310
0003222211111220000000000001333300
0002321222223331000000001000333100
0001333322222021111101111000232000
0000233221110011111111111000131000
0000122112211011111111211000020000
0000013333321000001112111000011000
0000012333210000011111111000012000
0000002221100000112111110000002100
0000000222211111122111110000001220
0000000222222222222111110000002332
0000000233333333221100110000003333
0000023333333333321100011000013333
For those who wish to try this with their own images, the original colour
image file was converted to greyscale, and the contrast and brightness
tweaked before scaling down to a manageable size (34x42 pixels) and final
conversion to 2-bit mode. When saving as ASCII from GraphicConverter, the
header information checkbox in the save options dialog was unchecked. Note
also that when saving files in this format, GraphicConverter saves an
additional file (default extn: ".pal") containing rgb values used in the
image. This can be discarded.
I just wish I hadn't wasted half a day figuring out how to applescript the
image-to-text conversion pixel by pixel in GraphicConverter, before the
realisation dawned that GC could do most of the donkey work by simply saving
the image as text. Pah!
Mr Tea.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.