Skip to Content.
Sympa Menu

baslinux - Re: [BL] simple doc to png convertor

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: "David Moberg" <davidjmoberg AT lycos.com>
  • To: baslinux AT lists.ibiblio.org
  • Subject: Re: [BL] simple doc to png convertor
  • Date: Sun, 24 Apr 2005 16:14:15 -0500

----- Original Message -----
From: "sindi keesan" <keesan AT sdf.lonestar.org>

> I used a DOS port of wvware to extract the png from a doc file that
> consists only of one embedded png, produced by a scanner.
>
> Viewed with less, the png file starts with <89>PNG.

According to /etc/magic, this is "\x89PNG". \x89 means a byte/char of
value 89. So, 4 bytes:

1 89
2 'P'
3 'N'
4 'G'

(C char notation)

> The doc file has a lot of <FF) and @^ and then <89>PNG. At the end
> it has more <FF> and @^ and then something about WORD.
>
> I could probably just use a text editor to manually chop off the
> beginning and end of this sort of doc file instead of wvware, but
> can someone suggest a script which would delete all characters
> before <89>PNG

#!/bin/sh
export POSIXLY_CORRECT=""
expr index "`cat $1`" "`echo 3PNG | tr 3 '\211'`" >/tmp/1
expr `cat /tmp/1` - 1 >/tmp/1
expr `cat $1 | wc -c` - `cat /tmp/1` >/tmp/1
tail -c `cat /tmp/1` $1
rm -f /tmp/1

I'm not sure if BusyBox wc will work with this. You need write
access to /tmp/1. To run, save to (for example) pngtrim.sh and
do pngtrim.sh example.doc >output.png.

> The png file ends with IEND<AE>B`<82>. The WORD file continues
> with many pages of @^ (to encourage you to get a larger hard
> drive?) and <FF> and then the names of the two people working at
> that office repeatedly, some comments on what is in the document
> that they probably added, and various mentions of Microsoft Word
> 9.0. So I could also just chop that off.

Do you want a script that does that, too?

> <82> is presumably a hex character and perhaps a shell script would
> need to refer to it differently.

Very differently for <89>. The method I used above is very ugly.

> Pico shows a file starting in a
> small dark box and ending in this same box plus Spanish upside-down
> question mark.
> I included the IEND in case the <AE>etc. part occurred elsewhere.

I wonder if all PNG files end this way?

> Antiword does fine with text WORD files so the above could for my
> purposes substitute for wvware and be a lot smaller. (Like pbmtolj
> instead of gs to print my own scanner output). It would also be
> library independent.
>
> It would not be difficult to edit one file manually with e3 or pico
> but people send me collections of them.
>
> This would be a handy script to use with netpbm instead of wvware.
>
> keesan AT sdf.lonestar.org
> SDF Public Access UNIX System - http://sdf.lonestar.org
> _______________________________________________
> BasLinux mailing list
> BasLinux AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/baslinux

--
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at
once.
http://datingsearch.lycos.com





Archive powered by MHonArc 2.6.24.

Top of Page