CN111414214A - Document compression method and device, electronic equipment and computer storage medium - Google Patents

Document compression method and device, electronic equipment and computer storage medium Download PDF

Info

Publication number
CN111414214A
CN111414214A CN201910012642.6A CN201910012642A CN111414214A CN 111414214 A CN111414214 A CN 111414214A CN 201910012642 A CN201910012642 A CN 201910012642A CN 111414214 A CN111414214 A CN 111414214A
Authority
CN
China
Prior art keywords
document
compressed
action
compression
volume
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910012642.6A
Other languages
Chinese (zh)
Inventor
邓斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Kingsoft Mobile Technology Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Kingsoft Mobile Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Guangzhou Kingsoft Mobile Technology Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to CN201910012642.6A priority Critical patent/CN111414214A/en
Publication of CN111414214A publication Critical patent/CN111414214A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324Display of status information

Abstract

The invention discloses a document compression method, a document compression device, electronic equipment and a computer storage medium. The document compression method comprises the steps of obtaining a target compression volume appointed by a document to be compressed, sequentially executing each preset compression action according to the execution sequence of each preset compression action, and compressing the document to be compressed. And when a preset compression action is executed, correspondingly judging whether the volume of the document to be compressed is less than or equal to the target compression volume after the compression action is executed, and if so, completing the compression of the document to be compressed. The document volume of the document after being compressed can be equal to or similar to the specified target compressed volume, so that the document can be effectively compressed under the condition that the volume of the compressed document is specified.

Description

Document compression method and device, electronic equipment and computer storage medium
Technical Field
The present invention relates to the field of document compression technologies, and in particular, to a document compression method and apparatus, an electronic device, and a computer storage medium.
Background
At present, a server or a client supporting document uploading often has a limited requirement on the volume of an uploaded document, and at this time, if a user wants to upload a document to these servers or clients, the document to be uploaded needs to be compressed.
In the related art, a document compression method is as follows: and (4) selecting the document to be compressed by the user, starting one-key compression, and completing the compression to obtain the compressed document. At this time, the user cannot know what the volume of the compressed document is. Since the size of the compressed document represents the degree to which the document is compressed to some extent, the user may expect to specify the compressed document volume and thus control the degree to which the document is compressed.
Therefore, under the condition of specifying the volume of the compressed document, how to effectively compress the document is an urgent problem to be solved.
Disclosure of Invention
An object of an embodiment of the present invention is to provide a document compression method, apparatus, electronic device, and computer storage medium, so as to compress a document when a volume of the compressed document is specified. The specific technical scheme is as follows:
a method of document compression, comprising:
acquiring a target compression volume appointed by a document to be compressed;
sequentially executing each preset compression action on the document to be compressed according to the execution sequence corresponding to each preset compression action;
in the process of sequentially executing each preset compression action on the document to be compressed, judging whether the current volume of the document to be compressed is smaller than or equal to the target compression volume or not when each preset compression action is executed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
Optionally, the obtaining a target compression volume specified by the document to be compressed includes:
acquiring a target compression volume appointed by a user for a document to be compressed; or
The method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded.
Optionally, the respective predetermined compression actions include at least one of the following actions:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
Optionally, the types of the removing action on the removable data are:
a removal action with respect to stale class data or a removal action with respect to embedded class data.
Optionally, the determining rule of the execution order of the compression actions includes:
the removing action on the failure class data precedes the removing action on the embedded class data;
the removing action on the embedded class data precedes the zooming-out action on the picture;
in the at least one image-related reduction operation, a corresponding reduction operation with a high reduction ratio precedes a reduction operation with a low reduction ratio.
Optionally, the respective predetermined compression actions include:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
Optionally, before the at least one removing action on the embedded class data is performed and the at least one zooming-out action on the picture is performed, the method further comprises:
judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of pictures in the document to be compressed or not;
if not, continuing to execute the at least one zooming-out action related to the picture.
Optionally, the failure class data includes: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data;
the historical conversion data is data introduced by software for converting the document to be compressed to the current document type.
Optionally, the embedding class data includes:
font-generated data embedded in the document, and/or page thumbnails embedded in the document.
Optionally, the document type of the document to be compressed includes: a PDF document.
A document compression apparatus comprising:
the acquisition module is used for acquiring a target compression volume appointed by a document to be compressed;
the compression module is used for sequentially executing each preset compression action on the document to be compressed according to the execution sequence corresponding to each preset compression action;
the first judgment module is used for judging whether the current volume of the document to be compressed is less than or equal to the target compression volume or not when each preset compression action is executed in the process of sequentially executing each preset compression action on the document to be compressed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
Optionally, the obtaining module is specifically configured to:
acquiring a target compression volume appointed by a user for a document to be compressed; or
The method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded.
Optionally, the respective predetermined compression actions include at least one of the following actions:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
Optionally, the types of the removing action on the removable data are:
a removal action with respect to stale class data or a removal action with respect to embedded class data.
Optionally, the determining rule of the execution order of the compression actions includes:
the removing action on the failure class data precedes the removing action on the embedded class data;
the removing action on the embedded class data is prior to the zooming-out action on the at least one picture;
in the at least one image-related reduction operation, a corresponding reduction operation with a high reduction ratio precedes a reduction operation with a low reduction ratio.
Optionally, the respective predetermined compression actions include:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
Optionally, the apparatus further comprises: a second judgment module;
the second judging module is used for judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of the pictures in the document to be compressed or not before the at least one removing action related to the embedded class data is executed and the at least one reducing action related to the pictures is executed;
if not, continuing to execute the at least one zooming-out action related to the picture.
Optionally, the failure class data includes: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data;
the historical conversion data is data introduced by software for converting the document to be compressed to the current document type.
Optionally, the embedding class data includes:
font-generated data embedded in the document, and/or page thumbnails embedded in the document.
Optionally, the document type of the document to be compressed includes: a PDF document.
An electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the steps of any document compression method when executing the program stored in the memory.
A computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of any of the document compression methods described above.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the steps of any of the document compression methods described above.
In the document compression method provided by the embodiment of the invention, the target compression volume specified by the document to be compressed is obtained, and each preset compression action is executed in sequence according to the execution sequence of each preset compression action to compress the document to be compressed. And when a preset compression action is executed, correspondingly judging whether the volume of the document to be compressed is less than or equal to the target compression volume after the compression action is executed, and if so, completing the compression of the document to be compressed. The document volume of the document after being compressed can be equal to or similar to the specified target compressed volume, so that the document can be effectively compressed under the condition that the volume of the compressed document is specified. Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of a document compression method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a document compression method according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a document compression apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to effectively compress a document under the condition of specifying the volume of the compressed document, the embodiment of the invention provides a document compression method, a document compression device, electronic equipment and a computer storage medium.
It should be noted that, an execution subject of the document compression method provided in the embodiment of the present invention may be a document compression apparatus, and the document compression apparatus may be applied to an electronic device, where the electronic device may be a server or a terminal device, it may be understood that, when the electronic device is a terminal device, the document compression apparatus may be a client terminal specially used for document compression, or a plug-in an existing client terminal, for example, the document compression apparatus may be a plug-in a PDF reader, and at this time, the PDF reader may implement both PDF reading and PDF document compression.
In a first aspect, a document compression method provided by an embodiment of the present invention is described in detail. As shown in fig. 1, a document compression method provided by an embodiment of the present invention may include the following steps:
s101: and acquiring a target compression volume appointed by the document to be compressed.
Here, the object for specifying the target compression volume of the document to be compressed may be a user, or may be a server or a client to which the document to be compressed needs to be uploaded. Therefore, there are various embodiments for obtaining the target compressed volume specified by the document to be compressed.
For example, in one implementation, obtaining the target compression volume specified by the document to be compressed may include:
and acquiring a target compression volume specified by a user for the document to be compressed.
In this implementation, the document compression apparatus may provide an input interface for a user, so that the user may input the target compression volume specified for the document to be compressed in the input interface, and thus the document compression apparatus may obtain the target compression volume specified for the document to be compressed by the user.
For example, in another implementation, obtaining the target compression volume specified by the document to be compressed may include:
the method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded. It can be understood that, for the case of obtaining the upper limit of the document volume of the target server, the document compression apparatus may be a plug-in the client corresponding to the target server; in the case of obtaining the document volume upper limit specified by the target client, the document compression device may be a plug-in the target client, or another client in communication with the target client.
It is understood that, when the target compression volume specified by the document to be compressed is obtained, S102 may be executed to compress the document to be compressed by taking the target compression volume as a target.
S102: and sequentially executing each preset compression action on the document to be compressed according to the execution sequence corresponding to each preset compression action.
In this step, there are a plurality of kinds of the predetermined compression actions.
Illustratively, each predetermined compression action may include at least one of the following actions:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
In addition, for example, the types of the removal action with respect to the removable data may be:
a removal action with respect to stale class data or a removal action with respect to embedded class data. Of course, the kind of the removing action on the removable data is not limited to the removing action on the failure class data or the removing action on the embedded class data.
The failure class data specifically includes a plurality of types of failure data.
Exemplary failure class data may include: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data, although not limited thereto. The historical conversion data is data introduced by software for converting the document to be compressed to the current document type. For example, if the current document type of the document to be compressed is a PDF document, the PDF document is converted by a certain software, and the software introduces data into the converted PDF document, and the data can only be used by the software, so that the document to be compressed belongs to invalid data.
Additionally, exemplary, embedding class data may include:
font-generated data embedded in the document, and/or page thumbnails embedded in the document, although not limited thereto.
It is understood that the removal of a dead class data in the document to be compressed is a removal action on the dead class data, for example, the removal of a dead bookmark in the document to be compressed is a removal action on the dead class data. Similarly, the removal of a kind of embedded data in the document to be compressed is a removal action on embedded class data, for example, the removal of a page thumbnail in the document to be compressed is a removal action on embedded class data.
In addition, when the pictures in the document to be compressed are reduced, there may be a plurality of reduction ratios used, and therefore, the reduction of the pictures in the document to be compressed is performed by using one reduction ratio, that is, one reduction operation on the pictures.
In this step, each predetermined compression action to be performed on the document to be compressed is preset. There are many possible settings for the selection when presetting each of the predetermined compression actions.
For example, in the first implementation, only one zoom-out action with respect to the picture may be selected as the only one predetermined compression action, or only one removal action with respect to the failure class data or one removal action with respect to the embedded class data may be selected as the only one predetermined compression action. For example, the action of removing the dead link in the document to be compressed is set to only one predetermined compression action.
In a second implementation, a plurality of zoom-out actions with respect to the picture may be selected as the respective predetermined compression actions. For example, each predetermined compression action may specifically include: the image in the document to be compressed is reduced at a reduction ratio of 80%, the image in the document to be compressed is reduced at a reduction ratio of 50%, the image in the document to be compressed is reduced at a reduction ratio of 20%, and the like. Alternatively, a plurality of removal actions on removable data may be selected as the respective predetermined compression actions. For example, each predetermined compression action may specifically include: removing expired bookmarks, removing expired links, removing unreferenced document objects, and removing page thumbnails embedded in the document, etc.
It is understood that, as for the manner of selecting a plurality of zoom-out actions with respect to pictures as the respective predetermined compression actions, it is applicable to a document to be compressed having no removable data. And for the way of selecting a plurality of removal actions on removable data as respective predetermined compression actions, it can be applied to a document to be compressed without a picture.
In a third implementation, each of the predetermined compression actions may include:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
For example, each predetermined compression action may specifically include: removing expired bookmarks, removing expired links, removing historical conversion data, removing data resulting from fonts embedded in the document, and reducing pictures in the document to be compressed at a 50% reduction scale, etc.
It will be appreciated that if there are both removable data and few pictures in the document to be compressed, then more removal actions on the removable data and one or fewer zoom-out actions on the pictures may be selected as the respective predetermined compression actions. If the removable data in the document to be compressed is small but the number of pictures is large, one or a few of the removal actions related to the removable data and a large number of the reduction actions related to the pictures can be selected as the predetermined compression actions. In addition, if there are many removable data and many pictures in the document to be compressed, more removal actions on the removable data and more reduction actions on the pictures can be selected as the respective predetermined compression actions.
In other embodiments, in order to compress the document to be compressed more quickly, the action of removing various invalid data at one time may be set as a predetermined compression action, or the action of removing various embedded data at one time may be set as a predetermined compression action. Further, when the picture in the document to be compressed is reduced, the picture in the document to be compressed may be reduced only once using an empirical value regarding the reduction ratio, for example, using a reduction ratio of 30%. Thus, the compression of the document to be compressed can be completed quickly.
In addition, each pair of documents to be compressed executes a predetermined compression action, and a part of original data or a part of picture definition and resolution of the documents to be compressed are correspondingly lost, and the lost data or picture definition and resolution are different from each other in importance of the documents to be compressed. Therefore, when compressing a document, it is necessary to reasonably arrange the execution sequence of each predetermined compression action, to reserve relatively important data for the document to be compressed as much as possible, and to make the definition and resolution of the image of the document to be compressed relatively high as much as possible. For clarity and layout clarity, the following description will be made for the determination principle of the execution sequence of each predetermined compression action.
S103: in the process of sequentially executing each preset compression action on the document to be compressed, judging whether the current volume of the document to be compressed is smaller than or equal to the target compression volume or not when each preset compression action is executed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
In this step, after the document to be compressed is compressed, the volume of the compressed document may be equal to or smaller than the target compressed volume. In the case where the volume of the document whose compression is completed is smaller than the target compressed volume, if the predetermined compression action performed before the compression is completed is a removal action with respect to removable data, the difference between the volume of the document whose compression is completed and the target compressed volume depends on the size of the removable data that is removed. If the predetermined compression action is a reduction action on the picture before the compression is finished, the difference between the volume of the compressed document and the target compressed volume depends on the total volume difference before and after the picture in the document is reduced.
It can be understood that, after the last predetermined compressing action is performed, if the current volume of the document to be compressed is still larger than the target compressing volume, it indicates that the compression of the document to be compressed cannot be achieved according to the target compressing volume. At this time, a prompt may pop up to indicate that the compression cannot be completed.
In summary, the embodiments of the present invention can be seen in that, in the document compression method provided in the embodiments of the present invention, a target compression volume specified by a document to be compressed is obtained, and each predetermined compression action is sequentially executed according to an execution sequence of each predetermined compression action, so as to compress the document to be compressed. And when a preset compression action is executed, correspondingly judging whether the volume of the document to be compressed is less than or equal to the target compression volume after the compression action is executed, and if so, completing the compression of the document to be compressed. The document volume of the document after being compressed can be equal to or similar to the specified target compressed volume, so that the document can be effectively compressed under the condition that the volume of the compressed document is specified.
In addition, in the document compression method provided by the embodiment of the present invention, each predetermined compression action may be any number of removal actions on removable data and/or any number of reduction actions on pictures, so that each predetermined compression action may be set in advance for a document to be compressed according to the number of removable data, the number and size of pictures, and the like in the document to be compressed. Therefore, the document to be compressed is effectively compressed in a targeted manner, and the compression action which does not play a compression role on the document to be compressed is avoided.
For clarity of the scheme and clarity of layout, the following is an exemplary description of the determination principle of the execution sequence of each predetermined compression action.
Alternatively, the determination principle of the execution order of each compression action may include:
the removing action on the failure class data is prior to the removing action on the embedded class data;
the removal action on the embedded class data precedes the zoom-out action on the picture;
in at least one of the zoom-out operations related to the picture, the corresponding zoom-out operation with a high zoom-out ratio precedes the zoom-out operation with a low zoom-out ratio.
It is understood that the importance of the dead class data to the document to be compressed is lower than that of the embedded class data, and thus, the removing action on the dead class data may be performed prior to the removing action on the embedded class data.
In addition, the pictures in the document to be compressed are data containing useful information for a user of the document to be compressed, so that the pictures in the document to be compressed are not changed as much as possible before removable data which does not contain useful information, such as failure class data and embedded class data, is removed. Thus, the removal action with respect to the embedded class data may be performed prior to the zoom-out action with respect to the picture.
It should be noted that, in the embodiment of the present invention, the reduction ratio corresponding to the reduction operation of the picture refers to a ratio of a size of the compressed picture to an original picture size, for example, the original size of the picture is a, the picture is reduced by half, the picture size is a/2, at this time, the reduction ratio corresponding to the compression operation is 50%, and if the picture is reduced to one tenth of the original size, at this time, the reduction ratio corresponding to the compression operation is 10%. Therefore, a reduction action with a high reduction ratio is performed prior to a reduction action with a low reduction ratio, so that the picture in the document to be compressed can be gradually reduced.
In addition, the present invention is not limited to the execution order of the removing operation of each failure data in the failure-type data. Similarly, the present invention is not limited to the execution sequence of the removing actions of various embedded data in the embedded data.
Taking an exemplary document compression method as an example, the execution sequence of each predetermined compression action is illustrated when each predetermined compression action comprises at least one removal action on failure class data, at least one removal action on embedded class data and at least one reduction action on pictures. As shown in fig. 2, the document compression method may include the following steps:
s201: acquiring a target compression volume appointed by a document to be compressed;
s202: executing each removing action related to the failure class data, judging whether the current volume of the document to be compressed is less than or equal to the target compression volume or not after executing each removing action related to the failure class data, and if so, completing the compression of the document to be compressed; if not, continuing to execute the next removing action about the failure class data;
s203: after the removing action of each invalid class data is finished, executing each removing action of each embedded class data, judging whether the current volume of the document to be compressed is less than or equal to the target compression volume or not after executing each removing action of each embedded class data, and if so, completing the compression of the document to be compressed; if not, continuing to execute the next removal action related to the embedded class data;
s204: after the removing action of each embedded type data is finished, the reducing actions of each picture are sequentially executed according to the using sequence of the reducing proportion from large to small, and whether the current volume of the document to be compressed is smaller than or equal to the target compression volume is judged every time one reducing action of the picture is finished, and if so, the compression of the document to be compressed is finished.
In step S204, the reduction ratio corresponding to each of the reduction actions regarding the picture and the number of the reduction actions regarding the picture are related to both the resolution and the resolution of the picture in the compressed document and the execution efficiency of the document compression method. Thus, in one implementation, 5 zoom-out actions for a picture may be set in advance. The first performed zoom-out action with respect to the picture may correspond to a zoom-out ratio of 50%, the second performed zoom-out action with respect to the picture may correspond to a zoom-out ratio of 40%, the third performed zoom-out action with respect to the picture may correspond to a zoom-out ratio of 32%, the fourth performed zoom-out action with respect to the picture may correspond to a zoom-out ratio of 25%, and the fifth performed zoom-out action with respect to the picture may correspond to a zoom-out ratio of 20%. In this way, after the first image reduction action is completed, the images in the document to be compressed are reduced by 50%, so that the compression of the document to be compressed can be completed with a high probability. In addition, the more the reduction action on the picture is executed later, the smaller the difference between the reduction ratio and the reduction ratio of the last reduction action is, so that the target compression volume can be gradually approximated nonlinearly, and the picture in the document to be compressed can be prevented from being excessively compressed.
It can be understood that, if the preset zooming-out actions on the pictures are all executed and the judgment result is still negative, at this time, the document to be compressed cannot be compressed according to the target compression volume, a prompt needs to pop up: the document compression fails. In addition, when each removing action on the failure class data or each removing action on the embedded class data is performed, if some failure data or some embedded data to be removed does not exist in the document to be compressed, the compressing action of removing the failure data or the embedded data may be skipped, and the next compressing action may be continued. Thus, the exemplary document compression method is applicable to any document to be compressed.
In one case, after the invalid data and the embedded data in the document to be compressed are removed, the volume of the document to be compressed is still much larger than the target compressed volume, and even if the picture in the document to be compressed is compressed to be very small, even the content displayed in the picture cannot be seen, the volume of the document to be compressed cannot reach the degree of being smaller than or equal to the target compressed volume, and at this time, it has no meaning to continue to perform the reducing action on the picture. For such a situation, the document compression method provided by the embodiment of the invention provides a solution that can discriminate such a situation and perform corresponding processing.
Optionally, before the at least one removing action on the embedded class data is performed and the at least one zooming-out action on the picture is performed, the method for compressing the document according to the embodiment of the present invention may further include:
judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of pictures in the document to be compressed or not;
if not, continuing to execute the at least one zooming-out action related to the picture.
It can be understood that if the determination result is greater than the predetermined threshold, it may be determined that the zooming-out operation on the picture is not required to be continuously performed, and accordingly, the prompt may not complete the compression of the document.
In a second aspect, corresponding to the above document compression method, an embodiment of the present invention further provides a document compression apparatus, as shown in fig. 3, the document compression apparatus provided in the embodiment of the present invention may include:
an obtaining module 301, configured to obtain a target compression volume specified by a document to be compressed;
the compression module 302 is configured to sequentially execute each predetermined compression action on the document to be compressed according to the execution sequence corresponding to each predetermined compression action;
the first judging module 303 is configured to, in the process of sequentially executing each predetermined compression action on the document to be compressed, judge whether the current volume of the document to be compressed is less than or equal to the target compression volume when each predetermined compression action is completed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
Optionally, the obtaining module may be specifically configured to:
acquiring a target compression volume appointed by a user for a document to be compressed; or
The method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded.
Optionally, each predetermined compression action may comprise at least one of the following actions:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
Optionally, the types of the removing action on the removable data are:
a removal action with respect to stale class data or a removal action with respect to embedded class data.
Alternatively, the determination principle of the execution order of each compression action may include:
the removing action on the failure class data is prior to the removing action on the embedded class data;
the removing action of the embedded class data is prior to the zooming-out action of the picture;
in at least one of the zoom-out operations related to the picture, the corresponding zoom-out operation with a high zoom-out ratio precedes the zoom-out operation with a low zoom-out ratio.
Optionally, each predetermined compression action may include:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
Optionally, the document compression apparatus provided in the embodiment of the present invention may further include: a second judgment module;
the second judging module is used for judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of the pictures in the document to be compressed or not before the at least one removing action related to the embedded class data is executed and the at least one reducing action related to the pictures is executed;
if not, continuing to execute the at least one zooming-out action related to the picture.
Optionally, the failure class data may include: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data;
the historical conversion data is data introduced by software for converting the document to be compressed to the current document type.
Optionally, embedding class data may include:
font-generated data embedded in the document, and/or page thumbnails embedded in the document.
Optionally, the document type of the document to be compressed may include: a PDF document.
In summary, the document compression apparatus provided in the embodiment of the present invention obtains the target compression volume specified by the document to be compressed, and sequentially executes each predetermined compression action according to the execution sequence of each predetermined compression action to compress the document to be compressed. And when a preset compression action is executed, correspondingly judging whether the volume of the document to be compressed is less than or equal to the target compression volume after the compression action is executed, and if so, completing the compression of the document to be compressed. The document volume of the document after being compressed can be equal to or similar to the specified target compressed volume, so that the document can be effectively compressed under the condition that the volume of the compressed document is specified.
In addition, in the document compression apparatus provided by the embodiment of the present invention, each predetermined compression action may be any number of removal actions with respect to removable data, and/or any number of reduction actions with respect to pictures, so that each predetermined compression action may be set in advance as appropriate for the document to be compressed according to the number of removable data, the number and size of pictures, and the like in the document to be compressed. Therefore, the document to be compressed is effectively compressed in a targeted manner, and the compression action which does not play a compression role on the document to be compressed is avoided.
In a third aspect, an embodiment of the present invention further provides an electronic device, as shown in fig. 4, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete mutual communication through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401, when executing the program stored in the memory 403, implements the following steps:
acquiring a target compression volume appointed by a document to be compressed;
sequentially executing each preset compression action on the document to be compressed according to the execution sequence corresponding to each preset compression action;
in the process of sequentially executing each preset compression action on the document to be compressed, judging whether the current volume of the document to be compressed is smaller than or equal to the target compression volume or not when each preset compression action is executed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
Optionally, the obtaining a target compression volume specified by the document to be compressed may include:
acquiring a target compression volume appointed by a user for a document to be compressed; or
The method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded.
Optionally, the predetermined compressing actions may include at least one of the following actions:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
Optionally, the types of the removing action on the removable data are:
a removal action with respect to stale class data or a removal action with respect to embedded class data.
Optionally, the determining rule of the execution order of the compression actions may include:
the removing action on the failure class data precedes the removing action on the embedded class data;
the removing action on the embedded class data precedes the zooming-out action on the picture;
in the at least one image-related reduction operation, a corresponding reduction operation with a high reduction ratio precedes a reduction operation with a low reduction ratio.
Optionally, the respective predetermined compression actions may include:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
Optionally, before the at least one removing action on the embedded class data is performed and the at least one zooming-out action on the picture is performed, the method may further include:
judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of pictures in the document to be compressed or not;
if not, continuing to execute the at least one zooming-out action related to the picture.
Optionally, the failure class data may include: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data;
the historical conversion data is data introduced by software for converting the document to be compressed to the current document type.
Optionally, the embedding class data may include:
font-generated data embedded in the document, and/or page thumbnails embedded in the document.
Optionally, the document type of the document to be compressed may include: a PDF document.
The electronic device provided by the embodiment of the invention acquires the target compression volume designated by the document to be compressed, sequentially executes each preset compression action according to the execution sequence of each preset compression action, and compresses the document to be compressed. And when a preset compression action is executed, correspondingly judging whether the volume of the document to be compressed is less than or equal to the target compression volume after the compression action is executed, and if so, completing the compression of the document to be compressed. The document volume of the document after being compressed can be equal to or similar to the specified target compressed volume, so that the document can be effectively compressed under the condition that the volume of the compressed document is specified.
In addition, in the electronic device provided by the embodiment of the present invention, each predetermined compression action may be any number of removal actions on removable data and/or any number of reduction actions on pictures, so that each predetermined compression action may be set in advance for a document to be compressed according to the number of removable data, the number and size of pictures, and the like in the document to be compressed. Therefore, the document to be compressed is effectively compressed in a targeted manner, and the compression action which does not play a compression role on the document to be compressed is avoided.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
In yet another embodiment of the present invention, a computer-readable storage medium is further provided, which has instructions stored therein, and when the instructions are executed on a computer, the instructions cause the computer to perform the steps of any of the document compression methods in the above embodiments.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the steps of any of the document compression methods described in the above embodiments.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the device and electronic apparatus embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (22)

1. A method of document compression, comprising:
acquiring a target compression volume appointed by a document to be compressed;
sequentially executing each preset compression action on the document to be compressed according to the execution sequence corresponding to each preset compression action;
in the process of sequentially executing each preset compression action on the document to be compressed, judging whether the current volume of the document to be compressed is smaller than or equal to the target compression volume or not when each preset compression action is executed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
2. The method according to claim 1, wherein the obtaining of the target compression volume specified for the document to be compressed comprises:
acquiring a target compression volume appointed by a user for a document to be compressed; or
The method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded.
3. The method of claim 1, wherein the respective predetermined compression action comprises at least one of:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
4. A method according to claim 3, wherein the types of removal actions on removable data are:
a removal action with respect to stale class data or a removal action with respect to embedded class data.
5. The method according to claim 4, wherein the determining rule of the execution order of the compression actions comprises:
the removing action on the failure class data precedes the removing action on the embedded class data;
the removing action on the embedded class data precedes the zooming-out action on the picture;
in the at least one image-related reduction operation, a corresponding reduction operation with a high reduction ratio precedes a reduction operation with a low reduction ratio.
6. The method of claim 5, wherein the respective predetermined compression action comprises:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
7. The method of claim 6, wherein before the at least one removing action for embedded class data is performed and the at least one zooming out action for the picture is performed, the method further comprises:
judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of pictures in the document to be compressed or not;
if not, continuing to execute the at least one zooming-out action related to the picture.
8. The method of claim 4, wherein the failure class data comprises: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data;
the historical conversion data is data introduced by software for converting the document to be compressed to the current document type.
9. The method of claim 4, wherein embedding the class data comprises:
font-generated data embedded in the document, and/or page thumbnails embedded in the document.
10. The method according to any one of claims 1-9, wherein the document type of the document to be compressed comprises: a PDF document.
11. A document compression apparatus, comprising:
the acquisition module is used for acquiring a target compression volume appointed by a document to be compressed;
the compression module is used for sequentially executing each preset compression action on the document to be compressed according to the execution sequence corresponding to each preset compression action;
the first judgment module is used for judging whether the current volume of the document to be compressed is less than or equal to the target compression volume or not when each preset compression action is executed in the process of sequentially executing each preset compression action on the document to be compressed; if yes, completing the compression of the document to be compressed, and if not, continuing to execute the next compression action.
12. The apparatus of claim 11, wherein the obtaining module is specifically configured to:
acquiring a target compression volume appointed by a user for a document to be compressed; or
The method comprises the steps of obtaining a document volume upper limit specified by a target server or a target client, and determining a target compression volume specified by a document to be compressed based on the document volume upper limit, wherein the target server is a server to which the document to be compressed needs to be uploaded, and the target client is a client to which the document to be compressed needs to be uploaded.
13. The apparatus of claim 11, wherein each of the predetermined compression actions comprises at least one of:
at least one zoom-out action with respect to the picture and at least one removal action with respect to the removable data; wherein different zoom-out actions related to the picture correspond to different zoom-out ratios.
14. The apparatus according to claim 13, wherein the type of the removal action for removable data is:
a removal action with respect to stale class data or a removal action with respect to embedded class data.
15. The apparatus of claim 14, wherein the determination rule of the execution order of the compression actions comprises:
the removing action on the failure class data precedes the removing action on the embedded class data;
the removing action on the embedded class data is prior to the zooming-out action on the at least one picture;
in the at least one image-related reduction operation, a corresponding reduction operation with a high reduction ratio precedes a reduction operation with a low reduction ratio.
16. The apparatus of claim 15, wherein each of the predetermined compression actions comprises:
at least one removal action on stale class data, at least one removal action on embedded class data, and the at least one zoom-out action on pictures.
17. The apparatus of claim 16, further comprising: a second judgment module;
the second judging module is used for judging whether the difference between the volume of the document to be compressed and the target compressed volume is larger than the total volume of the pictures in the document to be compressed or not before the at least one removing action related to the embedded class data is executed and the at least one reducing action related to the pictures is executed;
if not, continuing to execute the at least one zooming-out action related to the picture.
18. The apparatus of claim 14, wherein the failure class data comprises: one or more of expired bookmarks, expired links, unreferenced document objects, and historical translation data;
the historical conversion data is data introduced by software for converting the document to be compressed to the current document type.
19. The apparatus of claim 14, wherein the embedded class data comprises:
font-generated data embedded in the document, and/or page thumbnails embedded in the document.
20. The apparatus according to any one of claims 11-19, wherein the document type of the document to be compressed comprises: a PDF document.
21. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-10 when executing a program stored in the memory.
22. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-10.
CN201910012642.6A 2019-01-07 2019-01-07 Document compression method and device, electronic equipment and computer storage medium Pending CN111414214A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910012642.6A CN111414214A (en) 2019-01-07 2019-01-07 Document compression method and device, electronic equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910012642.6A CN111414214A (en) 2019-01-07 2019-01-07 Document compression method and device, electronic equipment and computer storage medium

Publications (1)

Publication Number Publication Date
CN111414214A true CN111414214A (en) 2020-07-14

Family

ID=71494012

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910012642.6A Pending CN111414214A (en) 2019-01-07 2019-01-07 Document compression method and device, electronic equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN111414214A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008229923A (en) * 2007-03-18 2008-10-02 Ricoh Co Ltd Print data processing device, print data processing method and program
US20150249827A1 (en) * 2014-02-28 2015-09-03 Brother Kogyo Kabushiki Kaisha Image processing device for reducing data size of object in image data based on target value
CN107622026A (en) * 2012-11-22 2018-01-23 华为终端有限公司 The method and apparatus of data transfer
CN108650435A (en) * 2018-05-29 2018-10-12 广东微校信息科技有限公司 A kind of picture multistage limiting file size threshold values in browser end is guaranteed the quality compression method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008229923A (en) * 2007-03-18 2008-10-02 Ricoh Co Ltd Print data processing device, print data processing method and program
CN107622026A (en) * 2012-11-22 2018-01-23 华为终端有限公司 The method and apparatus of data transfer
US20150249827A1 (en) * 2014-02-28 2015-09-03 Brother Kogyo Kabushiki Kaisha Image processing device for reducing data size of object in image data based on target value
CN108650435A (en) * 2018-05-29 2018-10-12 广东微校信息科技有限公司 A kind of picture multistage limiting file size threshold values in browser end is guaranteed the quality compression method

Similar Documents

Publication Publication Date Title
US7933473B2 (en) Multiple resolution image storage
EP3633991A1 (en) Method and system for optimized encoding
CN108063818B (en) Data downloading method, device, terminal and computer readable storage medium
CN104580907A (en) Anti-shake photographing method and device
CN110930467A (en) Image processing method, electronic device and readable storage medium
US9247099B2 (en) Image file editing apparatus and method, and program
CN110888843A (en) Cross-host sparse file copying method, device, equipment and storage medium
CN111970518B (en) Image frame loss processing method, system, equipment and computer storage medium
CN108958755B (en) Method and device for generating application program installation package and electronic equipment
CN113573072B (en) Image processing method and device and related components
CN111124470A (en) Automatic optimization method and device for program package based on cloud platform
CN111414214A (en) Document compression method and device, electronic equipment and computer storage medium
WO2020093879A1 (en) Video synthesis method and apparatus, computer device and readable storage medium
CN112650881A (en) Monitoring data processing method and device and storage medium
CN110378479B (en) Image input method and device based on deep learning and terminal equipment
CN111009017B (en) Picture compression method and device, storage medium and computer equipment
CN110545427A (en) PDF document compression method and device and electronic equipment
CN110457264B (en) Conference file processing method, device, equipment and computer readable storage medium
US20150177924A1 (en) Image processing apparatus and image processing method
US8967479B2 (en) Image processing apparatus and method for converting a color barcode into a monochrome barcode
CN111713099A (en) Image correction method, image correction device and electronic equipment
CN110662088B (en) Duplicate removal method and processing terminal for preventing video from being transcoded repeatedly
JP5612851B2 (en) Information processing apparatus, information processing method, and program
CN113992618B (en) Super-resolution image processing method, system, electronic device and storage medium
CN113450361B (en) Crawler image processing method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination