DjVu/Weiterführende Informationen: Unterschied zwischen den Versionen

aus wiki, dem genealogischen Lexikon zum Mitmachen.
Zur Navigation springen Zur Suche springen
(Was ist '''DjVu'''? siehe {{Wikipedia-Link|DjVu|DjVu}})
K (+kat)
 
(8 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
Was ist '''DjVu'''? siehe {{Wikipedia-Link|DjVu|DjVu}}
== Script zum Konvertieren vom Bildern ==
<source lang="bash">#!/bin/sh
#
# Copyright (C) 2008 Jesper Zedlitz <jesper@zedlitz.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/> for a copy of the GNU General
# Public License.


Hier ein paar Tricks zum Erstellen von DjVu-Dateien:
# This script helps to convert images into DjVu files.


Schwarz-weiß Datei in DjVu umwandeln:
# OPTIONS
# djpeg image.jpg > image.ppm
-s <N>    scale factor for mkbitmap (default=2)
# mkbitmap image.ppm
# -d        create a darker results by combining high-pass filtered image
# cjb2 -lossy image.pbm bild.djvu
#               with a simple by thresholding created bi-tonal image
# -c        try to preserve the color of the background (currently results have low quality)


Trennung von Vorder- und Hintergrund:
# djpeg image.jpg > image.ppm
# mkbitmap -s1 image.ppm
# cjb2 -lossy image.pbm mymask.djvu
# djvumake image.djvu Sjbz=mymask.djvu PPM=image.ppm


Trennung von Vorder- und Hintergrund bei doppelter Größe:
# You need these Debian/Ubuntu packages to use the script:
# djpeg image.jpg image.ppm
# sudo apt-get install djvulibre-bin imagemagick mktemp netpbm potrace
# pnmscale 2 image.ppm > 2.ppm
# mkbitmap image.ppm
# cjb2 -lossy image.pbm mymask.djvu
# djvumake image.djvu Sjbz=mymask.djvu PPM=2.ppm


Man braucht dazu folgende Debian-Pakete (für Debian etch):
scale="-s2"
* libjpeg-progs
 
* potrace
while getopts "dcs:" opt
* djvulibre-bin
do
* netpbm
  case "$opt" in
    s) scale="-s"${OPTARG};;
    d) doubledjvu=1;;
    c) color=1
  esac
done
shift $(($OPTIND - 1))
 
# make sure that the file exists
if [ -f "$1" ]
then
    image=`basename "$1"`
    image=`echo -n "$image" | sed 's/\.[a-zA-Z]*$//'`
else
    echo 1>&2 "Image $1 does not exist."
    exit 1
fi
 
TEMPDIR=`/bin/mktemp -d`
 
if [ $color ]
then
  # a color background implies "-s 1"
  scale="-s1"
fi
 
image=`basename "$1"`
image=`echo -n "$image" | sed 's/\.[a-zA-Z]*$//'`
 
PPM=$TEMPDIR/image.ppm
PBM=$TEMPDIR/bw.pbm
 
# convert image (any format) into PPM
/usr/bin/convert "$1" "$PPM"
 
if [ $doubledjvu ]
then
  # A "double DjVu" is an overlay two parts:
  #  the (usual) highpass filtered image
  #  an only by thresholding created bitonal image
  /usr/bin/mkbitmap $scale -n $PPM -o "$TEMPDIR/a.pbm"
  /usr/bin/mkbitmap $scale $PPM -o "$TEMPDIR/b.pbm"
  /usr/bin/pnmarith -multiply "$TEMPDIR/a.pbm" "$TEMPDIR/b.pbm" > $PBM
else
  # make bitonal PBM image
  /usr/bin/mkbitmap $scale $PPM -o $PBM
fi
 
# encode the PBM image into DjVu
/usr/bin/cjb2 -lossy $PBM "$image.djvu"
 
# some special treatment in case of a color background
if [ $color ]
then
  MASK=$TEMPDIR/mask.djvu
  mv "$image.djvu" $MASK
  /usr/bin/djvumake "$image.djvu" Sjbz=$MASK PPM="$PPM"
fi
 
rm -rf "$TEMPDIR"</source>
 
== Beschriftung zu einem Foto hinzufügen==
Ausgangspunkt ist ein GIMP-Bild. Es geht aber auch mit einem JPEG und dem Text auf einem gleich großen Bild auf weißem Hintergrund.
 
<source lang="bash">
xcf2pnm bild.xcf Hintergrund > hintergrund.ppm
xcf2pnm -b white bild.xcf Text > text.ppm
 
# Foto komprimieren und IW44-Datei extrahieren
c44 hintergrund.ppm
djvuextract hintergrund.djvu BG44=hintergrund.iw44
 
# Beschriftung komprimieren
cpaldjvu text.ppm text.djvu
djvuextract text.djvu Sjbz=text.jb2 FGbz=text.bzz
 
djvumake bild.djvu  Sjbz=text.jb2 FGbz=text.bzz BG44=hintergrund.iw44
</source>


== Test ==
== Test ==
Zeile 35: Zeile 120:
  DjVu Farbe doppelte Auflösung            29
  DjVu Farbe doppelte Auflösung            29
  DjVu Farbe                                9,8
  DjVu Farbe                                9,8
[[Kategorie:DjVu]]

Aktuelle Version vom 2. Juli 2011, 18:05 Uhr

Script zum Konvertieren vom Bildern[Bearbeiten]

#!/bin/sh
#
# Copyright (C) 2008 Jesper Zedlitz <jesper@zedlitz.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/> for a copy of the GNU General 
# Public License.

# This script helps to convert images into DjVu files.

# OPTIONS
#  -s <N>     scale factor for mkbitmap (default=2)
#  -d         create a darker results by combining high-pass filtered image
#                with a simple by thresholding created bi-tonal image
#  -c         try to preserve the color of the background (currently results have low quality)


# You need these Debian/Ubuntu packages to use the script:
#  sudo apt-get install djvulibre-bin imagemagick mktemp netpbm potrace 

scale="-s2"

while getopts "dcs:" opt
do
  case "$opt" in
    s) scale="-s"${OPTARG};;
    d) doubledjvu=1;;
    c) color=1
  esac
done
shift $(($OPTIND - 1))

# make sure that the file exists
if [ -f "$1" ]
then
    image=`basename "$1"`
    image=`echo -n "$image" | sed 's/\.[a-zA-Z]*$//'`
else
    echo 1>&2 "Image $1 does not exist."
    exit 1
fi

TEMPDIR=`/bin/mktemp -d`

if [ $color ]
then
   # a color background implies "-s 1"
   scale="-s1"
fi

image=`basename "$1"`
image=`echo -n "$image" | sed 's/\.[a-zA-Z]*$//'`

PPM=$TEMPDIR/image.ppm
PBM=$TEMPDIR/bw.pbm

# convert image (any format) into PPM
/usr/bin/convert "$1" "$PPM"

if [ $doubledjvu ] 
then
   # A "double DjVu" is an overlay two parts:
   #   the (usual) highpass filtered image
   #   an only by thresholding created bitonal image
   /usr/bin/mkbitmap $scale -n $PPM -o "$TEMPDIR/a.pbm"
   /usr/bin/mkbitmap $scale $PPM -o "$TEMPDIR/b.pbm"
   /usr/bin/pnmarith -multiply "$TEMPDIR/a.pbm" "$TEMPDIR/b.pbm" > $PBM
else
   # make bitonal PBM image
   /usr/bin/mkbitmap $scale $PPM -o $PBM
fi

# encode the PBM image into DjVu
/usr/bin/cjb2 -lossy $PBM "$image.djvu"

# some special treatment in case of a color background
if [ $color ]
then
   MASK=$TEMPDIR/mask.djvu
   mv "$image.djvu" $MASK
   /usr/bin/djvumake "$image.djvu" Sjbz=$MASK PPM="$PPM"
fi

rm -rf "$TEMPDIR"

Beschriftung zu einem Foto hinzufügen[Bearbeiten]

Ausgangspunkt ist ein GIMP-Bild. Es geht aber auch mit einem JPEG und dem Text auf einem gleich großen Bild auf weißem Hintergrund.

xcf2pnm bild.xcf Hintergrund > hintergrund.ppm
xcf2pnm -b white bild.xcf Text > text.ppm

# Foto komprimieren und IW44-Datei extrahieren
c44 hintergrund.ppm
djvuextract hintergrund.djvu BG44=hintergrund.iw44

# Beschriftung komprimieren
cpaldjvu text.ppm text.djvu
djvuextract text.djvu Sjbz=text.jb2 FGbz=text.bzz

djvumake bild.djvu  Sjbz=text.jb2 FGbz=text.bzz BG44=hintergrund.iw44

Test[Bearbeiten]

Ein Test mit 227 Seiten aus dem Amtsblatt Schleswig 1870. Es handelt sich um farbige Fotografien, die als jpg-Dateien der Größe 1600x1200 Pixel vorliegen.

Art der Datei                     Gesamtgröße (MB)
jpg                                     111
DjVu sw                                  15
DjVu Farbe doppelte Auflösung            29
DjVu Farbe                                9,8