1. Technical Field
Embodiments of the present disclosure relate to file processing technology, and particularly to a system and method for compressing files.
2. Description of Related Art
Currently, a file may be compressed using a single compression algorithm, such as an image compression algorithm or a text compression algorithm. However, if the file is compressed using the image compression algorithm, compression efficiency of text in the file is low, and a size of the file being compressed would be too big. If the file is compressed using the text compression algorithm, compression efficiency of the texts in the file may be increased, but images in the file are converted to binary images, causing definitions of the images in the file to be degraded. Therefore, prompt and efficient method for compressing files is desired.
All of the processes described below may be embodied in, and fully automated via, functional code modules executed by one or more general purpose computers or processors. The code modules may be stored in any type of readable medium or other storage device. Some or all of the methods may alternatively be embodied in specialized hardware. Depending on the embodiment, the readable medium may be a hard disk drive, a compact disc, a digital video disc, or a tape drive.
In one embodiment, the computer 2 is electronically connected to a display device 1, a file creating system 3, and an input device 4. Depending on the embodiment, the display device 1 may be a liquid crystal display (LCD) or a cathode ray tube (CRT) display, for example.
The computer 2 further includes a storage device 20 for storing information, such as file data 22 created by the file creating system 3. In one embodiment, the file data 22 may include images and text.
The input device 4 may be used for manual editing of a file displayed on the display device 1. In one embodiment, the input device 4 may be a keyboard.
In one embodiment, the file compressing system 21 includes an obtaining module 210, a dividing module 211, a determining module 212, a compressing module 213, and a merging module 214. In one embodiment, the modules 210-214 comprise one or more computerized instructions that are stored in the storage device 20. A processor 23 of the computer 2 executes the computerized instructions to implement one or more operations of the computer 2.
The obtaining module 210 obtains a file to be compressed from the storage device 20.
The dividing module 211 divides the file into different sections. In one embodiment, types of the different sections include at least an image section and a text section. Referring to
The determining module 212 determines a type of each section. In one embodiment, the determining module 212 determines a section is the image section if a number of color pixels in the section is greater than or equal to a preset threshold value (e.g., a half total number of pixels in the section). Otherwise, the determining module 212 determines a section is the text section if a number of color pixels in the section is less than the preset threshold value.
The compressing module 213 compresses a section with an image compression algorithm if the section is the image section (refer to 5b of
The compressing module 213 compresses the section with a text compression algorithm if the section is the text section (refer to 5a of
The merging module 214 connects all compressed sections to obtain a compressed file.
In block S1, the obtaining module 210 obtains a file to be compressed from the storage device 20.
In block S2, the dividing module 211 divides the file into different sections. In one embodiment, types of the different sections include at least an image section and a text section. Referring to
In block S3, the determining module 212 determines a type of each section. The procedure goes to block S4 if the section is the image section. Otherwise, the procedure goes to block S5 if the section is the text section. In one embodiment, the determining module 212 determines a section is the image section if a number of color pixels in the section is greater than or equal to a preset threshold value. Otherwise, the determining module 212 determines a section is the text section if a number of color pixels in the section is less than the preset threshold value.
In block S4, the compressing module 213 compresses a section with an image compression algorithm (refer to 5b of
In block S5, the compressing module 213 compresses the section with a text compression algorithm (refer to 5a of
In block S6, the merging module 214 connects all compressed sections to obtain a compressed file. In one embodiment, the merging module 214 obtains a header of each page, connects each compressed section belong to a same page according to the header of the page, and connects all pages to obtain the compressed file.
It should be emphasized that the above-described embodiments of the present disclosure, particularly, any embodiments, are merely possible examples of implementations, merely set forth for a clear understanding of the principles of the disclosure. Many variations and modifications may be made to the above-described embodiment(s) of the disclosure without departing substantially from the spirit and principles of the disclosure. All such modifications and variations are intended to be included herein within the scope of this disclosure and the present disclosure and protected by the following claims.
| Number | Date | Country | Kind |
|---|---|---|---|
| 200910305574.9 | Aug 2009 | CN | national |