Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Štvrtok, 22. máj 2025

Súbor: [Platon] / scripts / shell / img2text / img2text (stiahnutie)

Revízia 1.3, Tue Sep 10 23:25:34 2002 UTC (22 years, 8 months ago) by nepto


Zmeny od 1.2: +26 -7 [lines]

Headers update in img2text file.
File magic.mgk added to repository to avoid warnings from `convert'.

#!/usr/bin/awk -f

#
# scripts/shell/ - Platon SDG shell scripts
#
# img2text - script for converting images to text files
# ____________________________________________________________
#
# Developed by Lubomir Host 'rajo' <rajo AT host.sk>
# Copyright (c) 2001-2002 Platon SDG, http://www.platon.sk/
# All rights reserved.
#
# Licensed under terms of GNU General Public License.
# See README file for more information about this software.
# See COPYING file for license information.
#
# Download the latest version from
# http://www.platon.sk/projects/scripts/
#

# $Id: img2text,v 1.3 2002/09/10 23:25:34 nepto Exp $

#
# This script is meaned to be part of another script, which will send SMS
# message over public SMS gateway.
#
# Usage:
#   cat img.png | convert - text:- | ./img2text
#
# Enjoy flooding sms gateway! ;))
#

BEGIN {
    FS="[,:# \t]+"
    prev_line = 0;
    line   = 1;
    column = 0;
    color  = "";
    start_char = 41;
}

{
    n = split($0, a, FS);

    column = a[1];
    line   = a[2];
    color  = a[6];
    if (colormap[color] == 0) {
        #printf "adding color %s to colormap\n", color;
        colormap[color] = ++start_char;
    }
    if (column == 0 && line == 0) {
        # first pixel 0,0 is probably background color,
        # we will background filled with spaces
        colormap[color] = 32;
    }
    output[line] = sprintf("%s%c", output[line], colormap[color]);
}

END {
    for (i = 0; i <= line; i++) {
        if (output[i] !~ /^ +$/)
            printf "%s\n", output[i];
    }
}

# vim: ft=awk cindent
# vim600: fdl=0 fdc=3 fdm=marker


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok