CN111683189B - Picture compression method, system, terminal and storage medium - Google Patents

Picture compression method, system, terminal and storage medium Download PDF

Info

Publication number
CN111683189B
CN111683189B CN202010407913.0A CN202010407913A CN111683189B CN 111683189 B CN111683189 B CN 111683189B CN 202010407913 A CN202010407913 A CN 202010407913A CN 111683189 B CN111683189 B CN 111683189B
Authority
CN
China
Prior art keywords
compression
picture
sampling rate
compressed
type
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.)
Active
Application number
CN202010407913.0A
Other languages
Chinese (zh)
Other versions
CN111683189A (en
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.)
Suzhou Dajiaying Information Technology Co Ltd
Original Assignee
Suzhou Dajiaying Information 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 Suzhou Dajiaying Information Technology Co Ltd filed Critical Suzhou Dajiaying Information Technology Co Ltd
Priority to CN202010407913.0A priority Critical patent/CN111683189B/en
Publication of CN111683189A publication Critical patent/CN111683189A/en
Application granted granted Critical
Publication of CN111683189B publication Critical patent/CN111683189B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/41Bandwidth or redundancy reduction

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

A picture compression method, system, terminal and storage medium includes: receiving a trigger picture compression request, wherein the picture compression request comprises: a compression type, a size of a picture to be compressed, and/or an application type; selecting a corresponding compression mode to compress according to a compression type, wherein the compression type comprises one or more of sampling rate compression and quality compression, and if the sampling rate compression is set, the quality compression is also set, the sampling rate compression is firstly carried out, and then the quality compression is carried out; the image compression method, the image compression system, the image compression terminal and the readable storage medium can compress the image by performing sampling rate compression and quality compression or by combining sampling rate compression and quality compression according to instructions or requirements, so that the limitation of a single compression mode is avoided, the advantages of the sampling rate compression and the quality compression are fully played, different compression is performed according to different requirements, and the flexibility of compression is improved.

Description

Picture compression method, system, terminal and storage medium
Technical Field
The present invention relates to image processing technologies, and in particular, to an image compression method, system, terminal, and storage medium.
Background
In the prior art, the Luban number calls the open source library closest to WeChat compression, and writes down 60% of the mass compression. The Compressor customizes pixels and quality by a developer, and requires the developer to continuously try parameters and seek the most appropriate equalization effect, which brings a lot of time cost for testing the picture quality to the developer.
For another example, CN109672888 discloses a picture compression method, which needs to obtain historical compression data of each picture compression tool, obtain a ratio of picture compression adaptation and the picture compression tool according to the historical compression data, the size of the compressed picture, and the application type, compress the picture according to the compression ratio by calling an interface of the adapted picture compression tool, and calculate a ratio of picture adaptation to be compressed according to two end point values and the size of the compressed picture. The method needs to call historical data, a large amount of memory is needed, the adaptive proportion of the picture to be compressed is calculated according to the two endpoint values and the size of the compressed picture, and the picture to be compressed is compressed according to the proportion, so that the operation and the operation of a program are greatly influenced.
Disclosure of Invention
In view of the above, it is desirable to provide a picture compression method that can facilitate compression.
Meanwhile, the picture compression system capable of being conveniently compressed is provided.
And in addition, a terminal capable of conveniently compressing is provided.
A readable storage medium that can be conveniently compressed is also provided.
A picture compression method, comprising:
receiving a trigger picture compression request, wherein the picture compression request comprises: a compression type, a size of a picture to be compressed, and/or an application type;
and selecting a corresponding compression mode to compress according to the compression type, wherein the compression type comprises one or more of sampling rate compression and quality compression, and if the sampling rate compression is set, the quality compression is also set, and the sampling rate compression is firstly carried out, and then the quality compression is carried out.
In a preferred embodiment, a compression request is received, and if the compression type is sample rate compression or the compression type includes sample rate compression, size information of a graph to be compressed is obtained before the sample rate compression is performed, where the size information of the graph to be compressed includes: and the size information is used for comparing the height or width of the graph to be compressed with a set minimum pixel, a standard pixel or a maximum pixel, if any one of the obtained height or width parameters of the graph to be compressed is not greater than the set minimum pixel, the sampling rate takes a value according to a set minimum specific value, and the sampling rate is compressed according to the obtained sampling rate.
In a preferred embodiment, a compression request is received, if the compression type is sampling rate compression, size information of a picture to be compressed is acquired, the height or width of the picture to be compressed is compared with a set minimum pixel, a set standard pixel or a set maximum pixel, if any parameter of the height or width of the picture to be compressed is larger than the set minimum pixel but not larger than the set standard pixel, the sampling rate is taken according to a set standard specific value, and sampling rate compression is performed according to the acquired sampling rate.
In a preferred embodiment, a compression request is received, if the compression type is sampling rate compression, size information of a picture to be compressed is acquired, if the acquired picture to be compressed is higher than wide and higher than a set maximum pixel and the wide is higher than a set standard pixel, the sampling rate is acquired by dividing the high by the maximum pixel, and the sampling rate compression is performed according to the acquired sampling rate; if the height of the obtained graph to be compressed is smaller than the width, the width is larger than the set maximum pixel, and the height is larger than the set standard pixel, the sampling rate is obtained according to the width divided by the maximum pixel, and the sampling rate compression is carried out according to the obtained sampling rate.
In a preferred embodiment, a compression request is received, if the compression type is sampling rate compression, size information of a picture to be compressed is acquired, if the acquired picture to be compressed is larger than wide, the height is larger than a set maximum pixel, and the width is larger than a set standard pixel, the sampling rate is acquired by dividing the height by the value of the maximum pixel and then adding 1, and the sampling rate compression is performed according to the acquired sampling rate; if the height of the obtained graph to be compressed is smaller than the width, the size of the wide pixel is larger than the maximum pixel, and the height of the obtained graph is larger than the set standard pixel, the sampling rate is obtained by dividing the size of the wide pixel by the maximum pixel, rounding the maximum pixel and adding 1, and the sampling rate is compressed according to the obtained sampling rate.
In a preferred embodiment, a compression request is received, if the compression type is quality compression or comprises quality compression, a picture and an application type of the picture are obtained, size information of a picture file to be compressed is obtained, quality compression is performed according to a set parameter value or a set proportion, a compression range of a corresponding application type is obtained according to the application type of the picture to be compressed, the size of the compressed picture file and the compression range set by the corresponding application type are compared and judged, whether the compressed picture file is compressed to the set size is judged, if the compressed picture file does not reach the set size, quality compression is continued according to the set parameter value or the set proportion until the file size range set by the corresponding application type is reached.
In a preferred embodiment, a compression request is received, if the compression type is quality compression or comprises quality compression, a picture and an application type of the picture are obtained, size information of a picture file to be compressed is obtained, a compression range corresponding to the application type is obtained according to the application type of the picture to be compressed, the compression range is decreased by 5 each time, and the picture is subjected to quality compression from large to small until a set file size range corresponding to the application type is reached.
A picture compression system comprising:
a request receiving module: receiving a trigger picture compression request, wherein the picture compression request comprises: compression type, size of picture to be compressed, and/or application type information;
a compression module: and selecting a corresponding compression mode to compress according to the compression type, wherein the compression type comprises one or more of sampling rate compression and quality compression, and if the sampling rate compression is set, the quality compression is also set, and the sampling rate compression is firstly carried out, and then the quality compression is carried out.
In a preferred embodiment, the size information of the picture to be compressed includes: the size of the picture to be compressed and the file size of the picture to be compressed.
In a preferred embodiment, the compression module comprises: a sample rate compression module for compressing the data stream,
the sample rate compression module comprises:
a first compression unit: if the compression type is sampling rate compression or comprises sampling rate compression, acquiring the size information of the picture to be compressed, and if the size of the high or wide pixel of the acquired picture to be compressed is not larger than the set minimum pixel, carrying out value taking on the sampling rate according to the set minimum specific value, and carrying out sampling rate compression according to the acquired sampling rate;
a second compression unit: if the compression type is sampling rate compression or comprises sampling rate compression, the size of the picture to be compressed is obtained, if the height or width of the obtained picture to be compressed is larger than the set minimum pixel but not larger than the set standard pixel, the sampling rate takes a value according to the set standard specific value, and the sampling rate compression is carried out according to the obtained sampling rate.
In a preferred embodiment, the sample rate compression module further comprises: a third compression unit for compressing the compressed air in the second compression unit,
the third compression unit: if the compression type is sampling rate compression or comprises sampling rate compression, acquiring the size of a picture to be compressed, if the height of the acquired picture to be compressed is larger than the width, the height is larger than a set maximum pixel, and the width is larger than a set standard pixel, acquiring the sampling rate according to the maximum pixel divided by the height, and compressing the sampling rate according to the acquired sampling rate; if the height of the obtained graph to be compressed is smaller than the width, the width is larger than the maximum pixel, and the height is larger than the set standard pixel, the sampling rate is obtained according to the width divided by the maximum pixel, and the sampling rate compression is carried out according to the obtained sampling rate.
In a preferred embodiment, the third compression unit further comprises: if the compression type is sampling rate compression or comprises sampling rate compression, acquiring the size information of the picture to be compressed, if the height of the acquired picture to be compressed is larger than the width, the height is larger than the set maximum pixel, and the width is larger than the set standard pixel, acquiring the sampling rate by dividing the height by the value of the maximum pixel and then adding 1, and performing sampling rate compression according to the acquired sampling rate; if the height of the obtained graph to be compressed is smaller than the width, the size of the wide pixel is larger than the maximum pixel, and the height of the obtained graph is larger than the set standard pixel, the sampling rate is obtained by dividing the size of the wide pixel by the maximum pixel, rounding the maximum pixel and adding 1, and the sampling rate is compressed according to the obtained sampling rate.
In a preferred embodiment, the compression module further comprises:
a mass compression module: if the compression type is quality compression or the compression type comprises quality compression, obtaining a picture and an application type of the picture, obtaining size information of a picture file to be compressed, performing quality compression according to a set parameter value or a set proportion, obtaining a compression range corresponding to the application type according to the application type of the picture to be compressed, comparing and judging the size of the compressed picture file with the compression range set by the corresponding application type, judging whether the compressed picture file is compressed to the set size, and if the compressed picture file does not reach the set size, continuing performing quality compression according to the set parameter value or the set proportion until the file size range set by the corresponding application type is reached.
In a preferred embodiment, the mass compression module comprises: if the compression type is quality compression or the compression type comprises quality compression, obtaining the picture and the application type of the picture, obtaining the size information of the picture file to be compressed, obtaining the compression range of the corresponding application type according to the application type of the picture to be compressed, decreasing by 5 each time, and performing quality compression on the picture from large to small until the size range of the file set by the corresponding application type is reached.
A terminal, comprising: a memory, a processor and a program stored on the memory and executable on the processor, the processor implementing the picture compression method as described above when executing the program.
A readable storage medium having stored thereon a program which, when executed by a processor, implements a picture compression method as described above.
The image compression method, the image compression system, the image compression terminal and the readable storage medium can compress the image by performing sampling rate compression and quality compression or by combining sampling rate compression and quality compression according to instructions or requirements, so that the limitation of a single compression mode is avoided, the advantages of the sampling rate compression and the quality compression are fully played, different compression is performed according to different requirements, and the flexibility of compression is improved. And the program is simple, the operand is small, and the operation is simple and easy to operate.
In addition, in the quality compression, the picture is compressed by decreasing the parameter value, so that the closest compression effect is achieved.
The sampling rate compression can ensure that the memory occupation is greatly reduced under the condition of basically unchanging the picture display effect.
The method adopts a progressive parameter decreasing scheme to infinitely approach the compression purpose of the picture display effect and the occupied memory balance which are to be achieved.
Drawings
Fig. 1 is a flowchart of a picture compression method according to an embodiment of the invention.
Detailed Description
The following non-limiting detailed description of the present invention is provided in connection with the preferred embodiments and accompanying drawings.
As shown in fig. 1, the picture compression method according to an embodiment of the present invention, preferably, taking an Android system as an example, may perform compression based on the Android system, and includes:
step S101, receiving a trigger picture compression request, wherein the picture compression request comprises: the compression type, the size of the picture to be compressed and the application type;
and S103, selecting a corresponding compression mode according to the compression type to perform compression, wherein the compression type comprises one or more of sampling rate compression and quality compression, and if the sampling rate compression is set, the quality compression is also set, and the sampling rate compression is performed firstly, and then the quality compression is performed.
Subsamplesize, the value of sampling rate is the number of pixels in any dimension corresponding to one pixel of the decoded bitmap (bitmap), if the value of upsamplesize is greater than 1, and subsampling the original picture back to a smaller picture, thus saving memory. For example, inSampleSize = =4, the picture is 1/4 of the original, and the original pixel value is 1/16, that is, 4 pixels before decoding correspond to one pixel after decoding. When <1, the sampling rate is considered to be 1. The last value is always an exponent of 2 regardless of the sampling rate setting. Any other value that is not an exponent of 2 will take the sample rate of the nearest exponent of 2.
Bitmap: bitmap, an image represented using an array of pixels.
And (3) compression of a sampling rate: the method has the advantages that the use of the memory is greatly reduced, when the picture on the memory is read, if the high-definition effect is not needed, only the edge of the picture can be read, and the picture is loaded after the sampling rate is set through the width and the height, so that the memory cannot be excessively occupied.
If a request for triggering compression is received, the compression type is detected to be sampling rate compression, the obtained graph to be compressed is obtained, the height or width information of the graph to be compressed is obtained, the height or width of the graph to be compressed is compared with the set minimum pixel, or standard pixel, or maximum pixel, if any parameter of the obtained height or width of the graph to be compressed is not larger than the set minimum pixel, the sampling rate is a specific value, the specific value obtained at the moment is defined as the minimum specific value, and the sampling rate compression is carried out according to the minimum specific value. In this embodiment, if any one of the obtained height or width of the to-be-compressed image is not greater than the set minimum pixel, the sampling rate is 1, and the sampling rate compression is performed according to the obtained sampling rate 1.
Further, if a request for triggering compression is received, the compression type is detected to be sampling rate compression, the obtained graph to be compressed is compared with the set minimum pixel, the set standard pixel or the set maximum pixel, if the height or the width of the graph to be compressed is larger than the set minimum pixel but not larger than the set standard pixel, the sampling rate takes the set specific value, the specific value at the moment is defined as the standard specific value, and the sampling rate compression is carried out according to the obtained standard specific value. In the present embodiment, a sampling rate is preferably 2, and the sampling rate compression is performed based on the obtained sampling rate 2.
Further, if a request for triggering compression is received, the compression type is detected to be sampling rate compression, a picture to be compressed is obtained, the size relation between the height and the width is detected, the larger parameter of the height or the width is detected to be compared with the set maximum pixel, and if the larger parameter of the height or the width is larger than the set maximum pixel, the larger parameter of the height or the width is divided by the maximum pixel to calculate and obtain a preliminary sampling rate; and comparing the small parameter of the height or width of the graph to be compressed with the set standard pixel, if the small parameter of the height or width of the graph to be compressed is larger than the set standard pixel, obtaining a sampling rate according to the preliminary sampling rate obtained by dividing the large parameter of the height or width by the maximum pixel, and compressing the sampling rate according to the obtained sampling rate. If any parameter or smaller parameter of the height or width of the graph to be compressed is compared with the set standard pixel, if any parameter or smaller parameter of the height or width of the graph to be compressed is not larger than the set standard pixel, obtaining a first corrected sampling rate according to a set standard specific value, and if the standard specific value is 2, obtaining the first corrected sampling rate to be 2; and comparing any parameter of the height or width of the graph to be compressed with the set minimum pixel, preferably, comparing the smaller parameter of the height or width of the graph to be compressed with the set standard pixel, and if any parameter of the height or width of the graph to be compressed or the smaller parameter of the height or width of the graph to be compressed is greater than the set minimum pixel, taking the first corrected sampling rate as the sampling rate, and compressing the sampling rate according to the obtained sampling rate. If any parameter of the height or width of the graph to be compressed or a smaller parameter is smaller than the set minimum pixel, acquiring a second correction sampling rate according to the set minimum specific value, and if the minimum specific value is 1, acquiring the second correction sampling rate as 1, taking the second correction sampling rate as the sampling rate, and compressing the sampling rate according to the acquired sampling rate.
Further, in a preferred embodiment, if a request for triggering compression is received, it is detected that the compression type is sampling rate compression, a picture to be compressed is obtained, a size relationship between height and width is detected, a larger parameter of the height or the width is detected to be compared with a set maximum pixel, and if the larger parameter of the height or the width is larger than the set maximum pixel, a preliminary sampling rate is obtained by calculating according to the larger parameter of the height or the width divided by the maximum pixel; and then comparing the small parameter of the height or width of the graph to be compressed with the set standard pixel, if the small parameter of the height or width of the graph to be compressed is larger than the set standard pixel, obtaining a sampling rate according to a preliminary sampling rate obtained by adding 1 after the value obtained by dividing the large parameter of the height or width by the maximum pixel is rounded, and compressing the sampling rate according to the obtained sampling rate. If any parameter of the height or width of the graph to be compressed is compared with the set standard pixel, preferably, the smaller parameter of the height or width of the graph to be compressed is compared with the set standard pixel, and if any parameter of the height or width of the graph to be compressed or the smaller parameter of the height or width of the graph to be compressed is not greater than the standard pixel, the first time modified sampling rate is obtained according to the set standard specific value, such as the set 2; and comparing any parameter of the height or width of the graph to be compressed or a smaller parameter with the set minimum pixel, and if any parameter of the height or width of the graph to be compressed or the smaller parameter is greater than the set minimum pixel, taking the first modified sampling rate such as 2 as the sampling rate, and compressing the sampling rate according to the obtained sampling rate. If any parameter of the height or width of the graph to be compressed or a smaller parameter is smaller than the set minimum pixel, acquiring a second-time modified sampling rate according to a set minimum specific value such as 1, taking the second-time modified sampling rate such as 1 as the sampling rate, and compressing the sampling rate according to the acquired sampling rate.
If a request for triggering compression is received, and the compression type is sampling rate compression, acquiring a picture to be compressed, if the height of the acquired picture to be compressed is larger than the width, the height is larger than the set maximum pixel, and the width is larger than the set standard pixel, acquiring a sampling rate according to the height divided by the maximum pixel, and performing sampling rate compression according to the acquired sampling rate.
Preferably, a request for triggering compression is received, the compression type is sampling rate compression, a picture to be compressed is acquired before the sampling rate compression is performed, if the acquired picture to be compressed is larger than wide, the height is larger than a set maximum pixel, and the width is larger than a set standard pixel, the sampling rate is acquired by dividing the height by the value of the maximum pixel and then adding 1, and the sampling rate compression is performed according to the acquired sampling rate.
If a request for triggering compression is received, the compression type is sampling rate compression, a picture to be compressed is obtained, if the height of the obtained picture to be compressed is smaller than the width, the width is larger than the maximum pixel, and the height is larger than the set standard pixel, the sampling rate is obtained according to the width divided by the maximum pixel, and the sampling rate compression is carried out according to the obtained sampling rate.
Preferably, a request for triggering compression is received, the compression type is sampling rate compression, a picture to be compressed is obtained before the sampling rate compression is performed, if the height of the obtained picture to be compressed is smaller than that of a wide pixel and is larger than a maximum pixel, and the size of the high pixel is larger than a set standard pixel, the sampling rate is obtained by dividing the width by the maximum pixel and then adding 1, and the sampling rate compression is performed according to the obtained sampling rate.
The rounding of the embodiment can adopt tail-removing rounding and rounding. The present embodiment preferably employs tail-elimination rounding.
The following description will be given by way of further specific examples.
If the minimum pixel without compression is set to 1000px, the standard pixel without compression is set to 2000px, and the maximum pixel with no more than length or width is set to 1200px.
And receiving an instruction to perform sampling rate compression on an original picture to be compressed. If the original picture to be compressed is 1920 × 1080 in height × width. Since 1920 > 1080 and 1920 > the maximum pixel 1200 set, then according to: high 1920/max pixel 1200=1.6, rounded to 1. And after the integer is taken, 1 is added to be 1+1=2 to determine the preliminary sampling rate. Since 1080 is smaller than 2000, the sampling rate is first modified according to 2, which is a standard specific value; however, since 1080 is larger than the set minimum pixel, the sampling rate is determined according to the first correction sampling rate, the determined sampling rate is 2, and the sampling rate compression is performed according to the obtained sampling rate.
If the original picture to be compressed is 3000 × 2500 in height × width. Since 3000 > 2500, and 3000 > set max pixel 1200, then the following are taken: height 3000/max pixel 1200=2.5, rounded to 2. And after the integer is taken, 1 is added to be 2+1=3 to determine the preliminary sampling rate. Since 2500 is larger than the set standard pixel 2000, the sampling rate compression is performed according to the last sampling rate obtained from the preliminary sampling rate 3 and the obtained sampling rate.
If the original picture to be compressed is 800 × 600 in height × width. Because 800 is more than 600, 800 is less than 1200, 600 is less than 2000, 600 is less than 1000, any parameter of the height or width of the obtained graph to be compressed is not more than the set minimum pixel, the sampling rate is 1, and the sampling rate compression is carried out according to the obtained sampling rate 1.
Maximum pixel of the present embodiment: the developer sets the maximum pixel that is not exceeded by the length or width.
The sampling rate compression after the processing can be performed by adopting a sampling rate compression algorithm of an Android system or the prior art, namely, the compression is performed by changing the sampling rate or the pixel resolution. And will not be described in detail herein.
And (3) mass compression: the method can not reduce the pixels of the picture, and changes the bit depth, the transparency and the like of the picture on the premise of keeping the pixels so as to achieve the aim of compressing the picture. The size of the picture file compressed by the method can be changed, but the memory occupied by the picture file is unchanged after the picture file is imported into a bitmap. Since the pixels are kept unchanged, they cannot be compressed indefinitely and do not get further smaller after reaching a value. The method is not suitable for thumbnails, is also not suitable for reducing the memory by compressing pictures, and is suitable for reducing the file size while ensuring the picture quality.
The compression quality is from 0 to 100,0 indicating that the compression quality is small and 100 indicating the maximum compression quality.
Further, in this embodiment, if a file trigger compression request is received, if the file type is quality compression or the file type includes quality compression, a quality compression instruction is triggered, a picture and an application type of the picture are obtained, size information of the picture file to be compressed is obtained, quality compression is performed according to a set parameter value or a set proportion, a compression range of a corresponding application type is obtained according to the application type of the picture to be compressed, the size of the compressed picture file is compared with a compression range set by the corresponding application type to determine whether the picture file is compressed to the set size, and if the picture file does not reach the set size, quality compression is continued according to the set parameter value or the set proportion until the file size range set by the corresponding application type is reached.
Further, in this embodiment, if a file trigger compression request is received, if the file type is quality compression or the file type includes quality compression, a quality compression instruction is triggered, a picture and an application type of the picture are acquired, size information occupied by the picture file to be compressed is acquired, a corresponding file size range meeting requirements is set according to different application types of the picture, the picture to be compressed is decreased by 5 from 100 or from an initial value, the picture is subjected to quality compression from large to small, whether the size requirement is met is judged, and if the size requirement is not met, the size is continuously decreased by 5 until the set file size range is reached.
If the application type is that the display is a head portrait, the compression range can be set to be within 50kb of the file size; if the application type is to display a large map, the compression range may be set to a file size within 200 kb. When quality compression is needed, the application type of the obtained picture is a display large picture, the display large picture is reduced by 5 each time, whether the file size of the picture after quality compression is within 200kb or not is detected and judged, if the file size of the picture after quality compression is not within 200kb, the reduction is continued until the file size is reduced to meet the requirement, and if the file size is within 200 kb.
Or when the obtained picture application type is the display head portrait, decreasing by 5 each time, detecting and judging whether the file size of the picture after quality compression is within 50kb, if not, continuing decreasing until the file size is reduced to meet the requirement, such as within 50 kb.
If the sampling rate compression is set, the quality compression is also set, and the sampling rate compression is firstly carried out, and then the quality compression is carried out.
The quality compression after the processing can be performed by adopting a compression algorithm of an Android system or the quality compression in the prior art, namely, the compression is performed according to the bit depth, the transparency and the like of the picture. In this embodiment, the bit depth and the transparency of the picture are changed for compression by using the prior art, which is not described herein again.
The picture compression system according to an embodiment of the present invention, preferably, the picture compression system based on Android includes:
a request receiving module: receiving a trigger picture compression request, wherein the picture compression request comprises: compression type, size of picture to be compressed and application type information;
a compression module: and selecting a corresponding compression mode to compress according to the compression type, wherein the compression type comprises one or more of sampling rate compression and quality compression, and if the sampling rate compression is set, the quality compression is also set, and the sampling rate compression is firstly carried out, and then the quality compression is carried out.
Further, the size information of the picture to be compressed of the embodiment includes: the size of the picture to be compressed and the file size of the picture to be compressed.
In a preferred embodiment, the compression module comprises: and a sampling rate compression module.
The sample rate compression module includes: a first compression unit: if the compression type is sampling rate compression or comprises sampling rate compression, acquiring the size information of the picture to be compressed, if the height or width of the acquired picture to be compressed is not more than the set minimum pixel, taking the set minimum specific value as 1 for the sampling rate, and performing sampling rate compression according to the acquired sampling rate.
The sample rate compression module further comprises: a second compression unit: if the compression type is sampling rate compression or comprises sampling rate compression, acquiring the size information of the picture to be compressed, if the height or width of the acquired picture to be compressed is larger than the set minimum pixel but not larger than the set standard pixel, taking the set standard specific value such as 2 as the sampling rate, and performing sampling rate compression according to the obtained sampling rate.
The sample rate compression module further comprises: a third compression unit: if the compression type is sampling rate compression or comprises sampling rate compression, acquiring the size information of the picture to be compressed, if the height of the acquired picture to be compressed is larger than the width, the height is larger than the set maximum pixel, and the width is larger than the set standard pixel, acquiring the sampling rate according to the maximum pixel divided by the height, and compressing the sampling rate according to the acquired sampling rate; if the height of the obtained graph to be compressed is smaller than the width, the width is larger than the maximum pixel, and the height is larger than the set standard pixel, the sampling rate is obtained according to the width divided by the maximum pixel, and the sampling rate compression is carried out according to the obtained sampling rate.
Further, in a preferred embodiment, the third compression unit: if the height of the obtained graph to be compressed is larger than the width, the height is larger than the set maximum pixel, and the width is larger than the set standard pixel, the value of the height divided by the maximum pixel is rounded, then 1 is added to obtain the sampling rate, and the sampling rate compression is carried out according to the obtained sampling rate; and if the height of the obtained graph to be compressed is smaller than the width, the width is larger than the maximum pixel, and the height is larger than the set standard pixel, the sampling rate is obtained by adding 1 after the width is divided by the maximum pixel for rounding, and the sampling rate is compressed according to the obtained sampling rate.
Further, the compression module of the Android-based picture compression system of this embodiment further includes: and a mass compression module. A mass compression module: if the compression type is quality compression or comprises quality compression, acquiring the picture and the application type of the picture, setting a corresponding compression range which is required or meets the requirements according to different application types, performing quality compression according to a set parameter value or a set proportion, comparing and judging the size of the compressed picture with the size of a file set by the picture application type corresponding to the compressed picture, judging whether the compressed picture is compressed to the set size of the file, and if the compressed picture does not reach the set size of the file, continuing the quality compression until the compressed picture reaches the size range of the file set corresponding to the application type.
Further, preferably, the mass compression module: if the compression type is quality compression or comprises quality compression, the picture and the picture application type are obtained, the picture is reduced by 5 from large to small from 100 or from an initial value, the picture is subjected to quality compression, whether the set file size of the application type of the corresponding picture is reached is judged, and if the set file size of the application type of the corresponding picture is not reached, the picture is continuously reduced until the set file size range of the corresponding application type is reached.
If the compression type in the received compression request is set with both sampling rate compression and quality compression, the sampling rate compression is performed first, and then the quality compression is performed.
The terminal of an embodiment of the present invention includes: the image compression method comprises a memory, a processor and a program which is stored on the memory and can run on the processor, wherein the processor realizes the image compression method when executing the program.
The terminal of the embodiment can be a mobile phone, a tablet computer and the like. The terminal may include, but is not limited to, one or more processors or processing units.
The memory may include readable media in the form of volatile memory, such as Random Access Memory (RAM) and/or cache memory. The terminal can include other removable/non-removable, volatile/nonvolatile system storage media. These media may be any available media that can be accessed by a terminal device.
The memory may be used to store software programs as well as various data. The memory mainly comprises: a storage program area and a storage data area, wherein the storage program area can store an operating system, an application program (such as an interface for calling a picture compression tool) required by at least one function, and the like. The storage data area may include: and a database storing a data area that can store data or information created according to the use of the picture compression apparatus.
The processor is the control center of the picture compression device, connects various parts of the entire picture compression system using various interfaces and lines, by running or executing software programs and/or modules stored in the memory, and calls data in the memory. A processor includes one or more processing units. Preferably, the processor may integrate the application processor and the modem processor. The application processor mainly handles operating systems, user interfaces, application programs, and the like. The modem processor handles primarily wireless communications. The modem processor may not be integrated into the processor.
A readable storage medium, on which a program is stored, which, when executed by a processor, implements the picture compression method described above. A readable storage medium may be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, semiconductor system, apparatus, or device, or any combination thereof. A readable storage medium can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
According to the Android-based picture compression method and system, the pictures are compressed according to the setting, so that the storage pressure of the server is reduced, the consumption of user flow is reduced, and the expenses of mobile phone performance such as electric quantity and CPU consumption are reduced. The user experience is improved, and particularly under the condition of slightly poor network condition, the waiting time in the picture loading process is reduced.
In light of the foregoing description of the preferred embodiments according to the present application, it is to be understood that various changes and modifications may be made without departing from the spirit and scope of the invention. The technical scope of the present application is not limited to the contents of the specification, and must be determined according to the scope of the claims.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (9)

1. A picture compression method, comprising:
receiving a trigger picture compression request, wherein the picture compression request comprises: compression type, size of picture to be compressed and application type information;
selecting a corresponding compression mode to compress according to the compression type in the picture compression request, wherein the compression type in the picture compression request comprises one or more of sampling rate compression and quality compression, and if the compression type in the received picture compression request simultaneously sets the sampling rate compression and the quality compression, firstly carrying out the sampling rate compression and then carrying out the quality compression;
the selecting a corresponding compression mode for compression according to the compression type in the picture compression request further comprises:
if the compression type in the picture compression request is quality compression or comprises quality compression, obtaining a picture to be compressed and an application type of the picture to be compressed;
obtaining the size information of the picture to be compressed, performing quality compression according to a set proportion,
acquiring a compression range of a corresponding application type according to the application type of the picture to be compressed; wherein, different application types correspond to different compression ranges;
comparing and judging the size of the compressed picture file with the compression range of the corresponding application type, judging whether the picture file is compressed to a set size, if not, continuing to perform quality compression according to a set proportion until the picture file reaches the file size range set by the corresponding application type;
if the compression type is sampling rate compression or comprises sampling rate compression, size information of the picture to be compressed is obtained, and the size information of the picture to be compressed comprises: size information.
2. The method according to claim 1, wherein the selecting a corresponding compression method according to the compression type in the picture compression request for compression further comprises:
and comparing the height or width of the picture to be compressed with a set minimum pixel, or a standard pixel, or a maximum pixel, and if any one of the obtained height or width parameters of the picture to be compressed is not greater than the set minimum pixel, carrying out value taking on the sampling rate according to a set minimum specific value, and carrying out sampling rate compression according to the obtained sampling rate.
3. The method according to claim 1, wherein the selecting a corresponding compression method according to the compression type in the picture compression request for compression further comprises:
and comparing the height or width of the picture to be compressed with a set minimum pixel, a standard pixel or a maximum pixel, and if any one of the obtained height or width parameters of the picture to be compressed is greater than the set minimum pixel but not greater than the set standard pixel, carrying out value taking on the sampling rate according to a set standard specific value, and carrying out sampling rate compression according to the obtained sampling rate.
4. The method according to claim 1, wherein the selecting a corresponding compression method according to the compression type in the picture compression request for compression further comprises:
if the height of the obtained picture to be compressed is larger than the width, the height is larger than the set maximum pixel, and the width is larger than the set standard pixel, obtaining a sampling rate according to the height divided by the maximum pixel, and compressing the sampling rate according to the obtained sampling rate; if the height of the obtained picture to be compressed is smaller than the width, the width is larger than the set maximum pixel, and the height is larger than the set standard pixel, the sampling rate is obtained according to the width divided by the maximum pixel, and the sampling rate compression is carried out according to the obtained sampling rate.
5. The method according to claim 4, wherein the selecting a corresponding compression method according to the compression type in the picture compression request for compression further comprises:
if the height of the obtained picture to be compressed is larger than the width, the height is larger than the set maximum pixel, and the width is larger than the set standard pixel, the value of the height divided by the maximum pixel is rounded, then 1 is added to obtain the sampling rate, and the sampling rate compression is carried out according to the obtained sampling rate; if the height of the obtained picture to be compressed is smaller than the width, the size of the wide pixel is larger than the maximum pixel, and the height of the obtained picture is larger than the set standard pixel, the sampling rate is obtained by dividing the size of the wide pixel by the maximum pixel, rounding the maximum pixel and adding 1, and the sampling rate is compressed according to the obtained sampling rate.
6. The method according to claim 5, wherein the selecting a corresponding compression method according to the compression type in the picture compression request for compression further comprises:
if the compression type is quality compression or the compression type comprises quality compression, obtaining the picture and the application type of the picture, obtaining the size information of the picture file to be compressed, obtaining the compression range of the corresponding application type according to the application type of the picture to be compressed, decreasing the compression range by 5 from the initial value each time, and performing quality compression on the picture from large to small until the size range of the file set by the corresponding application type is reached.
7. A picture compression system, comprising:
a request receiving module, configured to receive a trigger picture compression request, where the picture compression request includes: compression type, size of picture to be compressed, and/or application type information;
the compression module is used for selecting a corresponding compression mode to compress according to the compression type in the picture compression request, wherein the compression type in the picture compression request comprises one or more of sampling rate compression and quality compression, and if the compression type in the received picture compression request simultaneously sets sampling rate compression and quality compression, the sampling rate compression is firstly carried out, and then the quality compression is carried out;
wherein, the compression module further comprises:
a first unit, configured to, if a compression type in the picture compression request is quality compression or includes quality compression, obtain a picture to be compressed and an application type of the picture to be compressed;
if the compression type is sampling rate compression or comprises sampling rate compression, size information of the picture to be compressed is obtained, and the size information of the picture to be compressed comprises: size information of the size;
the second unit is used for acquiring the size information of the picture to be compressed and compressing the quality according to a set proportion;
the third unit is used for acquiring the compression range of the corresponding application type according to the application type of the picture to be compressed; wherein, different application types correspond to different compression ranges;
and the fourth unit is used for comparing and judging the size of the compressed picture file with the compression range of the corresponding application type, judging whether the compressed picture file is compressed to a set size, and if the compressed picture file does not reach the set size, continuing to perform quality compression according to a set proportion until the compressed picture file reaches the file size range set by the corresponding application type.
8. A terminal, comprising: memory, processor and program stored on the memory and executable on the processor, characterized in that the processor implements the picture compression method as claimed in any one of claims 1 to 6 when executing the program.
9. A readable storage medium on which a program is stored, the program, when executed by a processor, implementing a picture compression method as claimed in any one of claims 1 to 6.
CN202010407913.0A 2020-05-14 2020-05-14 Picture compression method, system, terminal and storage medium Active CN111683189B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010407913.0A CN111683189B (en) 2020-05-14 2020-05-14 Picture compression method, system, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010407913.0A CN111683189B (en) 2020-05-14 2020-05-14 Picture compression method, system, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN111683189A CN111683189A (en) 2020-09-18
CN111683189B true CN111683189B (en) 2023-04-07

Family

ID=72452481

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010407913.0A Active CN111683189B (en) 2020-05-14 2020-05-14 Picture compression method, system, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN111683189B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112770114B (en) * 2020-12-29 2023-03-28 平安普惠企业管理有限公司 Image data compression method and device, computer equipment and storage medium
CN114095730B (en) * 2022-01-11 2022-04-19 山东捷瑞数字科技股份有限公司 Picture compression method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103532984A (en) * 2013-11-01 2014-01-22 中国联合网络通信集团有限公司 Data transmission method, device and system of websocket protocol
US10003803B1 (en) * 2012-04-18 2018-06-19 Matrox Graphics Inc. Motion-based adaptive quantization
CN108427704A (en) * 2018-01-05 2018-08-21 平安科技(深圳)有限公司 Tool of compression call method, device and storage medium
CN109672888A (en) * 2018-09-25 2019-04-23 平安科技(深圳)有限公司 Picture compression method, equipment and computer readable storage medium
CN109816739A (en) * 2018-12-14 2019-05-28 平安普惠企业管理有限公司 Picture compression method, apparatus, computer equipment and computer readable storage medium

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030103166A1 (en) * 2001-11-21 2003-06-05 Macinnis Alexander G. Method and apparatus for vertical compression and de-compression of progressive video data
KR100708180B1 (en) * 2005-09-22 2007-04-17 삼성전자주식회사 Apparatus and method for compressing color or gray scale documents
EP1845700A1 (en) * 2006-04-10 2007-10-17 Pixyfoto AG Method and device for preparing the generation of photo reproductions
US8463944B2 (en) * 2010-01-05 2013-06-11 International Business Machines Corporation Optimal compression process selection methods
CN105302415A (en) * 2015-10-19 2016-02-03 四川长虹电器股份有限公司 Image thumbnail generation method
GB2554686A (en) * 2016-10-04 2018-04-11 Nokia Technologies Oy An apparatus, a method and a computer program for video coding and decoding
EP3334164B1 (en) * 2016-12-09 2019-08-21 Nokia Technologies Oy A method and an apparatus and a computer program product for video encoding and decoding
CN108921784B (en) * 2018-06-13 2023-08-29 杭州吉吉知识产权运营有限公司 Picture compression method and system based on mobile terminal
CN110618973A (en) * 2019-09-09 2019-12-27 大唐网络有限公司 Image storage method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10003803B1 (en) * 2012-04-18 2018-06-19 Matrox Graphics Inc. Motion-based adaptive quantization
CN103532984A (en) * 2013-11-01 2014-01-22 中国联合网络通信集团有限公司 Data transmission method, device and system of websocket protocol
CN108427704A (en) * 2018-01-05 2018-08-21 平安科技(深圳)有限公司 Tool of compression call method, device and storage medium
CN109672888A (en) * 2018-09-25 2019-04-23 平安科技(深圳)有限公司 Picture compression method, equipment and computer readable storage medium
CN109816739A (en) * 2018-12-14 2019-05-28 平安普惠企业管理有限公司 Picture compression method, apparatus, computer equipment and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于移动智能终端的DMB+信息发布技术研究与实现;彭珂;《中国优秀博硕士学位论文全文数据库(硕士)》;中国学术期刊(光盘版)电子杂志社;20200119(第01期);正文部分第28-30页 *

Also Published As

Publication number Publication date
CN111683189A (en) 2020-09-18

Similar Documents

Publication Publication Date Title
CN111683189B (en) Picture compression method, system, terminal and storage medium
CN108171662B (en) Method for reading image compression data and anti-distortion method comprising same
US20090300015A1 (en) Aging and compressing multimedia content
CN111158619B (en) Picture processing method and device
WO2021057665A1 (en) Data storage method and apparatus, mobile terminal, and storage medium
CN112135140B (en) Video definition identification method, electronic device and storage medium
CN110457235B (en) Memory compression method, device, terminal and storage medium
CN108509272B (en) Method and device for copying GPU (graphics processing Unit) video memory texture to system memory and electronic equipment
CN111681291A (en) Image processing method, device, equipment and computer readable storage medium
EP4243415A1 (en) Image compression method and apparatus, and intelligent terminal and computer-readable storage medium
CN111508051B (en) Texture loading method and related device
CN105677259A (en) Method for storing file in mobile terminal and mobile terminal
CN107808394B (en) Image processing method based on convolutional neural network and mobile terminal
CN113873255A (en) Video data transmission method, video data decoding method and related devices
CN108921784B (en) Picture compression method and system based on mobile terminal
CN111491169A (en) Digital image compression method, device, equipment and medium
WO2018161791A1 (en) Method and device for compressing executable file
CN110858388B (en) Method and device for enhancing video image quality
CN107783990B (en) Data compression method and terminal
CN109819187B (en) Video recording control method and device, mobile terminal and storage medium
CN110417811B (en) Method and device for bit stream coding compression
CN107871162B (en) Image processing method based on convolutional neural network and mobile terminal
CN111142751A (en) Image processing method and device, intelligent terminal and storage medium
CN115037937B (en) Image compression method, apparatus, device and medium
CN110677728A (en) Method, device and equipment for playing video 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
GR01 Patent grant
GR01 Patent grant