简体   繁体   English

将背景添加到双音djvu文件

[英]Add background to bitonal djvu file

I have a few black and white djvu files that I would like to add a few different background images to at random. 我有一些黑白djvu文件,我想随机添加一些不同的背景图像。 This is to make it seem more book like and I think looks better. 这是为了使它看起来更像书,而且我认为看起来更好。

Using the command line I can extract each image and then write some code to add the background however this bloats the file a lot because of duplication. 使用命令行,我可以提取每个图像,然后编写一些代码以添加背景,但是由于重复,这会使文件非常膨胀。 I would like to add the background to the file once and then include it using the INCL chunk for the other pages. 我想一次将背景添加到文件中,然后使用INCL块将其包括在其他页面中。 However it is very confusing how to do this through the DjvuLibre command set. 但是,如何通过DjvuLibre命令集执行此操作非常令人困惑。

The current djvu file also has a text layer that I would like to extract and then reapply. 当前的djvu文件也有一个文本层,我想提取然后重新应用。

I wrote some code to automate the steps here . 我编写了一些代码来自动化此处的步骤。

Which are listed below: 列出如下:

In order to successfully add a background image to a foreground image, I have to follow these steps (using a DOS Cmd window): 为了成功地将背景图像添加到前景图像,我必须遵循以下步骤(使用DOS Cmd窗口):

1- extract the bitomal RLE image from the Djvu File 1-从Djvu文件中提取二进制RLE图像

ddjvu -format=rle -v myfile.djvu temp.rle ddjvu -format = rle -v myfile.djvu temp.rle

2- extract (or create) the background image. 2-提取(或创建)背景图像。 Be sure that the size of this image is equal or greater than the foreground image in order to have, after a reduction a integer: 确保此图像的大小等于或大于前景图像,以便在缩小后具有整数:

eg I have a 2592 x 3508 300dpi foreground image, and I want a background image of 100dpi. 例如,我有一个2592 x 3508 300dpi的前景图像,而我想要一个100dpi的背景图像。 So I create a 2592] x 3510 100dpi image (I added 2 pixels to the height in order to have 2594 modulo 3=0). 因此,我创建了2592] x 3510 100dpi图像(我在高度上添加了2个像素,以使2594模数为3 = 0)。 After a 1/3 resampling, I have a 864 x 1170 image. 经过1/3的重采样后,我得到了864 x 1170的图像。

3- (do something with this background image) and save it as myfile.ppm (24 bits per pixel) 3-(对此背景图片进行处理)并将其另存为myfile.ppm(每像素24位)

4- join into an unique file the 2 images: 4-将2张图片加入一个唯一的文件:

copy /b myfile.rle + myfile.ppm myfile.mix (using a brave old DOS command) 复制/ b myfile.rle + myfile.ppm myfile.mix(使用旧的DOS命令)

5- encode the new page into a DjVu file: 5-将新页面编码为DjVu文件:

csepdjvu -vv -d 300 myfile.mix myNewFile.DjVu csepdjvu -vv -d 300 myfile.mix myNewFile.DjVu

Bingo: It works!!! 宾果游戏:有效!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM