Picture compression method and device
Technical Field
The invention relates to the technical field of picture compression, in particular to a picture compression method and device.
Background
With the progress of science and technology, different mobile terminals with a photographing function are continuously brought into the market, so that more and more photos are taken by the mobile terminals. In order to enhance the resolution of pictures taken by mobile terminals, picture compression becomes a crucial issue, and is also crucial to data transmission of networks.
At present, the traditional picture compression method mainly obtains a proper compression ratio by adjusting the ratio of the length to the width of a picture to realize the compression of the picture, however, the proper compression ratio requires a processor to perform multiple calculation comparisons on the length and the width of the picture until the compression ratio is proper, so that the processing speed of the processor is slow, and only the ratio of the length to the width of the picture is adjusted, so that the compression quality of the picture is poor, when the ratio of the length to the width of the picture is adjusted too much, the compressed picture still has redundant data, which affects the network transmission speed of the picture.
Disclosure of Invention
Therefore, the technical problem to be solved by the embodiments of the present invention is that in the picture compression method in the prior art, obtaining an appropriate compression ratio by adjusting the length-to-width ratio of a picture results in a slower processing speed of a processor, and also affects the picture compression quality and the network transmission speed of the picture.
Therefore, the embodiment of the invention provides the following technical scheme:
the embodiment of the invention provides a picture compression method, which comprises the following steps:
acquiring a plurality of pictures to be compressed, and acquiring a first edge length value and a second edge length value of each picture to be compressed;
calculating compression reference proportion values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed;
acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value;
calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier;
calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed;
and compressing each picture to be compressed according to the compression value.
Optionally, after the step of compressing each to-be-compressed picture according to the compression value, the method further includes:
judging whether the compression value is less than or equal to a preset compression value or not;
and if the compression value is less than or equal to a preset compression value, compressing the picture to be compressed by using the preset compression value.
Optionally, the step of calculating the compression reference ratio values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed includes:
selecting a maximum first edge length value and a minimum second edge length value according to the first edge length value and the second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value;
and calculating a quotient of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain the compression reference proportion value.
Optionally, the step of obtaining the preset compression reference identifier of each picture to be compressed according to the compression reference ratio value includes:
presetting a first preset range threshold, a second preset range threshold and a third preset range threshold;
acquiring a preset range threshold value to which the compression reference proportion belongs according to the first preset range threshold value, the second preset range threshold value and the third preset range threshold value;
acquiring the first edge length value of each picture to be compressed corresponding to the compression reference proportion according to the preset range threshold value to which the compression reference proportion belongs;
and obtaining the corresponding preset compression reference identifier according to the first edge length value.
Optionally, the step of obtaining the preset compression ratio of each to-be-compressed picture according to the compression reference ratio value includes:
presetting a first preset range threshold, a second preset range threshold and a third preset range threshold;
acquiring a preset range threshold value to which the compression reference proportion belongs according to the first preset range threshold value, the second preset range threshold value and the third preset range threshold value;
acquiring a first edge length value and/or a second edge length value of each picture to be compressed corresponding to the compression reference ratio according to a preset range threshold value to which the compression reference ratio belongs;
and obtaining a preset compression reference ratio corresponding to the first side length value and/or the second side length value according to the first side length value and/or the second side length value.
Optionally, the calculating, according to the preset compression reference identifier, the first target compression edge length value and the second target compression edge length value of each picture are calculated according to the following formulas:
wherein the content of the first and second substances,
compressing the edge length value for the first target,
is the second target compression edge length value, n is the preset compression reference mark,
is the value of the first side length,
is the second edge length value.
Optionally, the calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each picture to be compressed is performed by using the following formula:
wherein the size is the compression value,
compressing the edge length value for the first target,
compressing the edge length value for the second target,
is the value of the first side length,
and m is the second edge length value and the preset compression ratio.
An embodiment of the present invention provides an image compression apparatus, including:
the first acquisition module is used for acquiring a plurality of pictures to be compressed and acquiring a first edge length value and a second edge length value of each picture to be compressed;
the first calculation module is used for calculating compression reference proportion values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed;
the second acquisition module is used for acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value;
the second calculation module is used for calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier;
a third calculating module, configured to calculate a compression value of each to-be-compressed picture according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each to-be-compressed picture;
and the first compression module is used for compressing each picture to be compressed according to the compression value.
The embodiment of the invention provides a computer readable storage medium, which stores computer instructions, and the instructions are executed by a processor to realize the steps of the picture compression method.
The embodiment of the invention provides a picture compression device, which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the steps of the picture compression method when executing the program.
The technical scheme of the embodiment of the invention has the following advantages:
the invention discloses a picture compression method and a picture compression device, wherein the method comprises the following steps: acquiring a plurality of pictures to be compressed, acquiring a first edge length value and a second edge length value of each picture to be compressed, and calculating compression reference ratio values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed; acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value; calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to a preset compression reference identifier; calculating the compression value of each picture to be compressed; and compressing each picture to be compressed according to the compression value. The invention not only ensures the compression quality of the picture to be compressed, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the redundant data transmission of a network, and further improves the transmission speed of the picture to be compressed.
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, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a first flowchart of a method for compressing pictures according to an embodiment of the present invention;
FIG. 2 is a second flowchart of a method for compressing pictures according to an embodiment of the present invention;
FIG. 3 is a first block diagram of a picture compression apparatus according to an embodiment of the present invention;
FIG. 4 is a block diagram of a second structure of the image compression apparatus according to the embodiment of the present invention;
fig. 5 is a hardware diagram of a picture compression device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings, and it is to be understood that the described embodiments are some, but not all embodiments of the present invention. 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 the description of the embodiments of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience in describing the embodiments of the present invention and simplifying the description, but do not indicate or imply that the referred devices or elements must have specific orientations, be configured in specific orientations, and operate, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the embodiments of the present invention, it should be noted that, unless explicitly stated or limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; the two elements may be directly connected or indirectly connected through an intermediate medium, or may be communicated with each other inside the two elements, or may be wirelessly connected or wired connected. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Example 1
An embodiment of the present invention provides a picture compression method, as shown in fig. 1, including the following steps:
and S1, acquiring a plurality of pictures to be compressed, and acquiring a first edge length value and a second edge length value of each picture to be compressed. The first edge length value and the second edge length value are even numbers. The pictures to be compressed here are multiple original pictures shot by the mobile terminal or the camera device, and the pictures need to be compressed for data transmission. The first edge length value may be considered as the length of each picture to be compressed, the second edge length value may be considered as the width of each picture to be compressed, and the first edge length value and the second edge length value appear at the same time and represent the resolution of the picture to be compressed. For convenience of calculation, the first edge length value and the second edge length value are usually selected as even numbers, and if the first edge length value or the second edge length value of the shot picture to be compressed is an odd number, the odd number is increased by 1 to become an even number. For example: the resolution of the picture to be compressed is 1018 × 720, the first edge length value is 1018, and the second edge length value is 720, so that both the first edge length value and the second edge length value are even numbers. For example: the multiple pictures to be compressed are respectively: 1018*724,1018*728, 1016*718,1014*728,1012*726.
And S2, calculating compression reference proportion values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed. The compression reference ratio value is a compression reference value of the group of the plurality of pictures to be compressed. The compression reference scale value is used to assist in calculating the compression value of the picture to be compressed.
The step S2 of calculating the compression reference ratio values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed includes:
firstly, selecting a maximum first edge length value and a minimum second edge length value according to a first edge length value and a second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value. For example: the first picture to be compressed is: 1018 x 720, first edge length value of 1018, second edge length value of 720; the second picture to be compressed is: 1018 x 724, first edge length value 1018; the second edge length value is 724, the third picture to be compressed is 1014 x 728, the first edge length value is 1014, and the second edge length value is 728. Therefore, the maximum first edge length value is 1018 and the minimum second edge length value is 720.
And then, calculating a quotient value of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain a compression reference proportion value. The maximum first edge length value obtained in the above steps is 1018, and the minimum second edge length value is 720. Compression reference ratio value = minimum second side length value maximum first side length value, i.e. 7201018= 0.707. Therefore, the compression reference ratio of the plurality of pictures to be compressed in the present embodiment is 0.707. The minimum second edge length value of the plurality of pictures to be compressed is selected, the maximum first edge length value of the plurality of pictures to be compressed is selected, and then the quotient of the minimum second edge length value and the maximum first edge length value is calculated, so that the minimum compression reference ratio can be obtained, the minimum compression reference ratio is utilized to assist in calculating the compression value, and the compression value of the pictures to be compressed can be enabled to be as small as possible.
And S3, acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference ratio value. The preset compression reference mark is set by artificial experiments when the compression reference proportion belongs to different preset range thresholds, so that the reference mark can be directly used for calculation by a processor, the calculation process and the calculation amount of the processor can be reduced, and the image compression speed is improved.
The step S3 of obtaining the preset compression reference identifier of each to-be-compressed picture according to the compression reference ratio value includes:
the method comprises the following steps of firstly, presetting a first preset range threshold, a second preset range threshold and a third preset range threshold. For example: the first preset range threshold is [0.5625,1 ], the second preset range threshold is [0.5,0.5625 ], and the third preset range threshold is [0, 0.5). Here, the first preset range threshold, the second preset range threshold, and the third preset range threshold are set according to the zoom size of the picture, for example: when the picture to be compressed belongs to a first preset range threshold, the length-width ratio of the picture is in the range of [1:1-9:16), when the picture to be compressed belongs to a second preset range threshold, the length-width ratio of the picture is in the range of [9:16-1:2), and when the picture to be compressed belongs to a third preset range, the length-width ratio of the picture is in the range of [1: 2-1: infinity).
And step two, acquiring a preset range threshold to which the compression reference proportion belongs according to the first preset range threshold, the second preset range threshold and the third preset range threshold. For example: when x is less than or equal to 0.5625 and less than or equal to 1, x represents a compression reference ratio of the picture to be compressed, and at this time, the picture to be compressed belongs to an interval of a first preset range threshold, when x is less than or equal to 0.5 and less than or equal to 0.5625, the picture to be compressed belongs to an interval of a second preset range threshold, and when x is less than or equal to 0.5, the picture to be compressed belongs to an interval of a third preset range threshold.
And thirdly, acquiring a first edge length value of each picture to be compressed corresponding to the compression reference proportion according to the preset range threshold value of the compression reference proportion. Here, the first edge length value of each picture to be compressed is greater than the second edge length value, i.e., the length is greater than the width.
And fourthly, obtaining a preset compression reference identifier corresponding to the first edge length value according to the first edge length value. The default compression reference mark herein will be different in different default ranges to which the compression reference ratio belongs.
For example: when 0.5625 ≦ x <1, the first edge length value may typically be 1920,4128,6433, these three first edge length values being the prevalent edge length values of the picture. When the first edge length value is smaller than or equal to 1920, the default compression reference flag corresponding to the first edge length value 1920 can be obtained as 1, when the first edge length value is equal to 4128, the default compression reference flag corresponding to the first edge length value 4128 can be obtained as 2, and when the first edge length value is equal to 6433, the default compression reference flag corresponding to the first edge length value 6433 can be obtained as 4.
For example: when 0.5 ≦ x <0.5625, the first edge length value is usually 1080, and the first edge length value may be a value near 1080, and when the first edge length value is 1080, the first edge length value/1280 ≈ 0, a preset compression reference mark corresponding to the first edge length value is 1, and when the first edge length value is not equal to 1080 when 0.5 ≦ x <0.5625, the preset compression reference mark corresponding to the first edge length is a first edge length value/1280. The preset compression reference mark can directly assist in calculating the compression value by summarizing the characteristics of the preset compression reference mark in advance according to the second preset range to which the compression reference proportion belongs and the characteristics of the first edge length value in the preset range.
For example: when 0 ≦ x <0.5, the first edge length value is usually 1280/compression reference ratio, and when the first edge length value is 1280/compression reference ratio, the default compression reference identifier corresponding to the first edge length value is obtained as the first edge length value/(1280/compression reference ratio). Similarly, the preset compression reference identifier here may directly assist in calculating the compression value by summarizing the characteristics of the preset compression reference identifier in advance according to the third preset range to which the compression reference ratio belongs and the characteristics of the first edge length value within the preset range.
The step S3 of obtaining the preset compression ratio of each to-be-compressed picture according to the compression reference ratio value includes:
the method comprises the following steps of firstly, presetting a first preset range threshold, a second preset range threshold and a third preset range threshold. For example: the first preset range threshold is [0.5625,1 ], the second preset range threshold is [0.5,0.5625 ], and the third preset range threshold is [0, 0.5). Here, the first preset range threshold, the second preset range threshold, and the third preset range threshold are set according to the zoom size of the picture, for example: when the picture to be compressed belongs to a first preset range threshold, the length-width ratio of the picture is in the range of [1:1-9:16), when the picture to be compressed belongs to a second preset range threshold, the length-width ratio of the picture is in the range of [9:16-1:2), and when the picture to be compressed belongs to a third preset range, the length-width ratio of the picture is in the range of [1: 2-1: infinity).
And step two, acquiring a preset range threshold to which the compression reference proportion belongs according to the first preset range threshold, the second preset range threshold and the third preset range threshold. For example: when x is less than or equal to 0.5625 and less than or equal to 1, x represents a compression reference ratio of the picture to be compressed, and at this time, the picture to be compressed belongs to an interval of a first preset range threshold, when x is less than or equal to 0.5 and less than or equal to 0.5625, the picture to be compressed belongs to an interval of a second preset range threshold, and when x is less than or equal to 0.5, the picture to be compressed belongs to an interval of a third preset range threshold.
And thirdly, acquiring a first edge length value and/or a second edge length value of each picture to be compressed corresponding to the compression reference ratio according to the preset range threshold value to which the compression reference ratio belongs. Here, the first edge length value of each picture to be compressed is greater than the second edge length value. I.e. longer than wider.
And fourthly, obtaining a preset compression reference ratio corresponding to the first side length value and/or the second side length value according to the first side length value and/or the second side length value. The preset compression ratio here is also a preset compression ratio characteristic value summarized from the preset range to which the compression reference ratio belongs and the characteristics of the first margin value and/or the second margin value.
For example: when 0.5625 ≦ x <1, the first edge length of the picture to be compressed is usually 1920,4128,6433, when the first edge length is 1920, the corresponding preset compression ratio is 150, when the first edge length is 4128, the corresponding preset compression ratio is 300, and when the first edge length is 6433, the corresponding preset compression ratio is 300.
For example: when 0.5 ≦ x <0.5625, the first side length is usually 3096, and the second side length is usually 4128, a preset compression ratio of 200 corresponding to the first side length and the second side length, respectively, can be obtained.
For example: when 0 ≦ x <0.5, the first side length is usually 1280, and the second side length is usually 1280/compression reference ratio, and then the corresponding preset compression ratio is 500.
And S4, calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier. The first target compression edge length value is an actual value of compression required by the first edge length value of each picture to be compressed, and the second target compression edge length value is an actual value of compression required by the second edge length value of each picture to be compressed.
The above-mentioned first target compressed edge length value and the second target compressed edge length value of each picture are calculated by the following formula:
wherein the content of the first and second substances,
the edge length value is compressed for the first target,
is a second target compression edge length value, n is a preset compression reference mark,
is the first side length value and is the second side length value,
is the second edge length value.
For example: when 0 ≦ x<At 0.5, the first edge length value is normally 1920, and at this time, the preset compression reference flag corresponding to the first edge length 1920 is 1, so that the first target compression edge length value of the first edge length value is calculated by the above formula
。
And S5, calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed.
The compression value of each picture to be compressed is calculated according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed by the following formula:
wherein, the size is the compression value,
the edge length value is compressed for the first target,
the edge length value is compressed for the second target,
is the first side length value and is the second side length value,
and m is a preset compression ratio, and is a second edge length value.
And S6, compressing each picture to be compressed according to the compression value. And after the file size of each picture to be compressed is obtained, directly compressing the pictures. The embodiment of the invention obtains the reference values related to the compression value for assisting in calculating the picture to be compressed, such as the compression reference ratio value, the preset compression reference mark and the preset compression ratio, through artificial pre-experiments, and further can directly assist in calculating the compression value of each picture to be compressed, and simultaneously integrates the length-width ratio of each picture to be compressed, so that the compression accuracy of the picture to be compressed is obviously improved, namely the compression quality of the picture is improved, the proper compression ratio of each picture to be compressed is not required to be calculated by multiple attempts, and the calculation amount of a processor is reduced, therefore, the picture compression method in the embodiment also improves the compression speed. Therefore, the picture compression method in this embodiment not only ensures the compression quality of the picture, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the transmission of redundant data of a network, and further improves the transmission speed of the picture to be compressed.
As shown in fig. 2, the method for compressing pictures in the embodiment of the present invention further includes, after the step of compressing each picture to be compressed according to the compression value:
and S7, judging whether the compression value is less than or equal to the preset compression value. The preset compression value is a reference compression value, so that the phenomenon that the quality of the picture to be compressed is poor and a fuzzy or mosaic phenomenon occurs due to the fact that the compression value of the picture to be compressed is too small is prevented, and therefore the preset reference value is set to be compared with the calculated compression value.
And S8, if the compression value is less than or equal to the preset compression value, compressing the picture to be compressed by using the preset compression value. When the compression value is too small, the preset compression value is directly utilized to carry out picture compression.
Specifically, when 0.5625 ≦ x <1, the preset compression value is 60 when the first edge length value is 1920, 60 when the first edge length value is 4128, and 100 when the first edge length value is 6433. The predetermined compression values are all 100 when 0.5 ≦ x <0.5625, and 100 when 0 ≦ x < 0.5.
According to the picture compression method in the embodiment of the invention, different preset compression values are set through different preset ranges to which the compression reference ratios belong, so that the phenomenon that the picture to be compressed is fuzzy or mosaic due to the fact that the compression value of the picture to be compressed is too small can be prevented. Therefore, the quality of the picture to be compressed is improved.
Example 2
An embodiment of the present invention provides a picture compression apparatus, as shown in fig. 3, including:
the first obtaining module 31 is configured to obtain a plurality of pictures to be compressed, and obtain a first edge length value and a second edge length value of each picture to be compressed;
the first calculating module 32 is configured to calculate compression reference ratio values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed;
the second obtaining module 33 is configured to obtain a preset compression reference identifier and a preset compression ratio of each to-be-compressed picture according to the compression reference ratio value;
the second calculating module 34 is configured to calculate a first target compression edge length value and a second target compression edge length value of each to-be-compressed picture according to the compression reference identifier;
the third calculating module 35 is configured to calculate a compression value of each to-be-compressed picture according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each to-be-compressed picture;
and the first compression module 36 is configured to compress each picture to be compressed according to the compression value.
The image compression device provided by the embodiment of the invention further comprises the following steps after the step of compressing each image to be compressed according to the compression value:
a judging module 37, configured to judge whether the compression value is smaller than or equal to a preset compression value;
and a second compression module 38, configured to compress the picture to be compressed by using the preset compression value if the compression value is smaller than or equal to the preset compression value.
In the image compression apparatus provided in the embodiment of the present invention, the first calculating module 32 includes:
the selecting submodule is used for selecting a maximum first edge length value and a minimum second edge length value according to the first edge length value and the second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value;
and the calculation submodule is used for calculating a quotient of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain a compression reference proportion value.
In the image compression apparatus according to the embodiment of the present invention, as shown in fig. 4, the second obtaining module 33 includes:
the first setting submodule 331 is configured to preset a first preset range threshold, a second preset range threshold, and a third preset range threshold;
the first obtaining submodule 332 is configured to obtain a preset range threshold to which the compression reference ratio belongs according to a first preset range threshold, a second preset range threshold, and a third preset range threshold;
the second obtaining sub-module 333 is configured to obtain, according to a preset range threshold to which the compression reference ratio belongs, a first edge length value of each to-be-compressed picture corresponding to the compression reference ratio;
the first corresponding sub-module 334 is configured to obtain a preset compression reference identifier corresponding to the first edge length value according to the first edge length value.
In the image compression apparatus in the embodiment of the present invention, the second obtaining module 33 further includes:
a second setting submodule 335 that presets a first preset range threshold, a second preset range threshold, and a third preset range threshold;
the third obtaining sub-module 336 is configured to obtain a preset range threshold to which the compression reference ratio belongs according to the first preset range threshold, the second preset range threshold, and the third preset range threshold;
the fourth obtaining submodule 337 is configured to obtain a first edge length value and/or a second edge length value of each to-be-compressed picture corresponding to the compression reference ratio according to the preset range threshold to which the compression reference ratio belongs;
and a second corresponding sub-module 338, configured to obtain a preset compression reference ratio corresponding to the first side length value and/or the second side length value.
In the image compression apparatus according to the embodiment of the present invention, the second calculating module 34 calculates the first target compression edge length value and the second target compression edge length value of each image according to the following formulas:
wherein the content of the first and second substances,
the edge length value is compressed for the first target,
is a second target compression edge length value, n is a preset compression reference mark,
is the first side length value and is the second side length value,
is the second edge length value.
In the image compression apparatus in the embodiment of the present invention, the third calculation module 35 calculates the compression value of each image to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each image to be compressed, and by using the following formula:
wherein, the size is the compression value,
the edge length value is compressed for the first target,
the edge length value is compressed for the second target,
is the first side length value and is the second side length value,
and m is a preset compression ratio, and is a second edge length value.
The picture compression device in the embodiment of the invention not only ensures the quality of the picture, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the transmission of redundant data of a network and further improves the transmission speed of the picture to be compressed.
Example 3
Embodiments of the present invention provide a computer-readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of embodiment 1. The storage medium further stores a first edge length value, a second edge length value, a compression reference proportion value, a preset compression reference identifier, a preset compression ratio, a first target compression edge length value, a second target compression edge length value, a compression value and the like of each picture to be compressed.
The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard disk (Hard disk Drive, abbreviated as HDD) or a Solid State Drive (SSD), etc.; the storage medium may also comprise a combination of memories of the kind described above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like.
Example 4
An embodiment of the present invention provides a picture compression apparatus, as shown in fig. 5, which includes a memory 520, a processor 510, and a computer program stored in the memory 520 and executable on the processor 510, and when the processor 510 executes the computer program, the steps of the method in embodiment 1 are implemented.
Fig. 5 is a schematic diagram of a hardware structure of a picture compression device for executing a processing method for list item operations according to an embodiment of the present invention, as shown in fig. 5, the picture compression device includes one or more processors 510 and a memory 520, where one processor 510 is taken as an example in fig. 5.
The apparatus for performing the processing method of the list item operation may further include: the obtaining means 530.
The processor 510, the memory 520, and the obtaining device 530 may be connected by a bus or other means, and fig. 5 illustrates the connection by the bus as an example.
Processor 510 may be a Central Processing Unit (CPU). The Processor 510 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.