CN108933945B - GIF picture compression method, device and storage medium - Google Patents
GIF picture compression method, device and storage medium Download PDFInfo
- Publication number
- CN108933945B CN108933945B CN201810942788.6A CN201810942788A CN108933945B CN 108933945 B CN108933945 B CN 108933945B CN 201810942788 A CN201810942788 A CN 201810942788A CN 108933945 B CN108933945 B CN 108933945B
- Authority
- CN
- China
- Prior art keywords
- palette
- picture
- gif
- gif picture
- colors
- 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
Links
- 230000006835 compression Effects 0.000 title claims abstract description 254
- 238000007906 compression Methods 0.000 title claims abstract description 254
- 238000000034 method Methods 0.000 title claims abstract description 61
- 239000003086 colorant Substances 0.000 claims description 167
- 238000004590 computer program Methods 0.000 claims description 10
- 230000008569 process Effects 0.000 description 15
- 238000010586 diagram Methods 0.000 description 10
- 230000000694 effects Effects 0.000 description 9
- 238000012545 processing Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 5
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000015556 catabolic process Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000006731 degradation reaction Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/42—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/85—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
- H04N21/2343—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
- H04N21/234309—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention relates to the technical field of computers, and discloses a compression method, a device and a storage medium of GIF pictures, which are used for realizing the further compression of the GIF pictures and reducing the file size of the GIF pictures to save bandwidth under the condition of ensuring the subjective quality, thereby reducing the storage cost of a server and improving the storage capacity of the server, wherein the method comprises the following steps: receiving a GIF picture; acquiring palette information of the GIF picture; determining whether the GIF picture meets the condition of compressing a video compression format or not according to the palette information; and if the GIF picture meets the condition, decompressing the GIF picture and recompressing the GIF picture by adopting a video compression format to obtain a video compression picture.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for compressing a GIF (Graphics Interchange Format) picture, and a storage medium.
Background
With the rapid development of computer technology, picture sharing through a network has become a very important information sharing mode in daily life, for example, an image to be shared can be uploaded to a server through a picture sharing client, the server stores the uploaded picture, and the client that needs to acquire the picture can download the uploaded picture from the server, so that picture sharing is realized.
In the prior art, in the process of uploading an image to be shared to a server, a picture is compressed into a GIF image in a GIF format, however, since the GIF is a lossless compression method, the server still needs a large amount of storage space to store the GIF image compressed by the GIF. Therefore, how to compress the GIF image in one step to improve the storage capacity of the server is also a technical problem to be solved.
Disclosure of Invention
Embodiments of the present invention provide a compression method, an apparatus, and a storage medium for a GIF image, which are used for further compressing the GIF image and reducing the file size of the GIF image to save bandwidth while ensuring subjective quality, thereby reducing the storage cost of a server and improving the storage capacity of the server.
In a first aspect, a method for compressing a GIF picture provided in an embodiment of the present invention includes:
receiving a GIF picture;
acquiring palette information of the GIF picture;
determining whether the GIF picture meets the condition of compressing a video compression format or not according to the palette information;
and if the GIF picture meets the condition, decompressing the GIF picture and recompressing the GIF picture by adopting a video compression format to obtain a video compression picture.
According to the compression method of the GIF picture, after the GIF picture compressed by the GIF picture is received, the palette information of the GIF picture needs to be obtained first, whether the GIF picture meets the condition of video compression format compression or not is determined according to the palette information, the GIF picture which is small in palette color number and is not suitable for further compression is screened out, and therefore the GIF picture which is large in palette color number, namely the GIF picture which meets the condition of video compression format compression, is only compressed by adopting the video compression format, and the compressed video compression picture is obtained.
Optionally, the method further includes:
and if the file size of the video compressed picture is smaller than that of the GIF picture, saving the video compressed picture.
In the embodiment of the invention, after the GIF picture meeting the condition of video compression format compression is compressed, in order to further ensure that the file size of the video compression picture after transcoding compression is smaller than that of the GIF picture before compression, the server can further judge whether the file size of the video compression picture is smaller than that of the GIF picture before compression, and if the file size of the video compression picture is smaller than that of the GIF picture before compression, the compressed video compression picture is stored, so that the purposes of saving bandwidth, reducing the storage cost of the server and improving the storage capacity of the server are achieved.
Optionally, the method further includes:
and the quality of the video restored by the video compressed picture is not lower than a set standard.
Optionally, the determining, according to the palette information, whether the GIF picture meets a condition for performing video compression format compression specifically includes:
acquiring the total number of palette colors used by the GIF picture from the palette information;
determining whether the GIF picture meets the condition of compressing the video compression format according to the total color of the palette, wherein the condition is set according to the following conditions: the file size of the video compressed picture is smaller than that of the GIF picture and/or the quality of the restored video is not lower than a set standard.
In the embodiment of the invention, whether the GIF picture meets the condition of compressing the video compression format is determined according to the requirement that the file size of the video compression picture is smaller than that of the GIF picture and/or the video quality after the video compression picture is decompressed and restored is not lower than the set standard, so that the purposes of saving bandwidth, reducing the storage cost of a server and improving the storage capacity of the server can be achieved.
Optionally, when the palette information includes a global palette, the total number of palette colors is the total number of global palette colors;
determining whether the GIF picture meets the condition of compressing the video compression format according to the total number of the palette colors, specifically:
judging whether the total number of the colors of the global palette is larger than or equal to a first threshold value;
wherein the GIF picture is determined to satisfy the condition when the global palette color total is greater than or equal to the first threshold, and the GIF picture is determined not to satisfy the condition when the global palette color total is less than the first threshold.
In the embodiment of the invention, when the GIF picture only comprises the global palette, as long as the total number of colors of the global palette is not less than the minimum number of colors of the global palette for further compressing the GIF picture to save bandwidth and ensure the subjective quality of the video compressed picture after transcoding compression, the GIF picture is required to have the minimum number of colors of the global palette, and then the video format compression is carried out on the GIF picture to achieve the effects of further compressing to save bandwidth and ensuring the subjective quality. Therefore, when the GIF picture includes the global palette, it may be determined whether the GIF picture satisfies the conditions for performing the video compression format compression by determining whether the total number of colors of the global palette is greater than or equal to a first threshold.
Optionally, when the palette information includes a global palette and a local palette, the total number of palette colors is the sum of the total number of global palette colors and the total number of local palette colors;
determining whether the GIF picture meets the condition of compressing the video compression format according to the total number of the palette colors, specifically:
judging whether the sum of the total number of the global palette colors and the total number of the local palette colors is larger than or equal to a second threshold value or not;
wherein the GIF picture is determined to satisfy the condition when the sum is greater than or equal to the second threshold, and the GIF picture is determined not to satisfy the condition when the sum is less than the second threshold, the second threshold being greater than or equal to the first threshold.
In the embodiment of the invention, when the GIF picture comprises the global palette and the local palette, as long as the total number of colors of the global palette and the total number of colors of the local palette are not less than the minimum number of colors of the palette required by the GIF picture for further compressing the GIF picture to save bandwidth and ensure the subjective quality of the transcoded and compressed video compressed picture, the effect of further compressing the GIF picture to save bandwidth and ensure the subjective quality can be achieved.
Therefore, when the GIF picture includes the global palette and the local palette, whether the GIF picture satisfies the condition for compressing the video compression format may be determined by determining whether the total number of the global palette colors and the total number of the local palette colors are greater than or equal to a first threshold.
Optionally, when the palette information includes a global palette and a local palette, obtaining, from the palette information, a total number of palette colors used by the GIF picture, specifically including:
determining whether the picture frame number of a local palette used in the GIF picture is less than a picture frame threshold;
if so, acquiring the total number of colors of a global palette from the palette information, wherein the total number of colors of the palette is the total number of colors of the global palette;
if not, acquiring the sum of the total number of the global palette colors and the total number of the local palette colors of the GIF picture from the palette information, wherein the total number of the palette colors is the sum of the total number of the global palette colors and the total number of the local palette colors.
In the embodiment of the invention, when the GIF picture comprises the global palette and the local palette, the situation that most pictures in the GIF picture use the global palette and only a small part of pictures use the local palette also exists, at this time, the server can firstly judge whether the number of picture frames using the local palette in the GIF picture is less than a picture frame threshold, and judge whether the GIF picture meets the condition of compressing the video compression format by using the total number of the global color palettes in the GIF picture when determining that the number of picture frames using the local palette in the GIF picture is less than the picture frame threshold; and judging whether the GIF picture meets the condition of compressing the video compression format or not after the total number of colors of the global palette and the total number of the local palettes in the GIF picture are used, wherein the number of picture frames using the local palette in the GIF picture is larger than a picture frame threshold. Therefore, the effects of further compressing, saving bandwidth and ensuring subjective quality can be achieved, and meanwhile, the diversity of the GIF image compression method is enriched.
Optionally, the determining, according to the palette information, whether the GIF picture meets a condition for performing video compression format compression specifically includes:
determining whether global palette information and local palette information are included in the palette information;
if the palette information is determined to comprise the global palette information and the local palette information, the GIF picture is represented to meet the condition, otherwise, the GIF picture is represented to not meet the condition.
In the embodiment of the present invention, when the GIF picture includes the global palette and the local palette, and the GIF picture of the plurality of palettes has a certain data size, the server stores the GIF picture including the plurality of palettes, which occupies a larger space, and therefore, the GIF picture including the global palette and the local palette can be directly compressed in the video compression format. Therefore, the effects of further compressing, saving bandwidth and ensuring subjective quality can be achieved, and meanwhile, the diversity of the GIF image compression method is further enriched.
Optionally, the obtaining of the palette information of the GIF picture specifically includes:
acquiring the size of the long edge and/or the size of the short edge of the GIF picture;
determining whether the long side size and/or the short side size are larger than a third threshold value;
and if the long edge size and/or the short edge size are determined to be larger than a third threshold, obtaining the palette information of the GIF picture.
In the embodiment of the invention, the long side size and/or the short side size of the GIF picture also influence the further compression effect of the GIF picture, so that the long side size and/or the short side size of the GIF picture can be obtained firstly, and then the palette information of the GIF picture is obtained when the long side size and/or the short side size of the GIF picture is determined to be larger than the threshold, so that the compression effect of the compressed video compression picture can be further ensured.
In a second aspect, an embodiment of the present invention further provides a compression apparatus for a GIF picture, including:
a receiving unit for receiving the GIF picture;
an obtaining unit, configured to obtain palette information of the GIF picture;
a determining unit, configured to determine whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information; and when the GIF picture is determined to meet the conditions, decompressing the GIF picture and recompressing the GIF picture by adopting a video compression format to obtain a video compression picture.
Optionally, the apparatus further comprises:
and the storage unit is used for storing the video compressed picture if the file size of the video compressed picture is smaller than that of the GIF picture.
Optionally, the quality of the video restored from the video compressed picture is not lower than a set standard.
Optionally, the obtaining unit is specifically configured to:
acquiring the total number of palette colors used by the GIF picture from the palette information;
and determining whether the GIF picture meets the condition of compressing the video compression format or not according to the total number of the colors of the palette.
Optionally, when the palette information includes a global palette, the total number of palette colors is the total number of global palette colors;
the obtaining unit is further configured to:
judging whether the total number of the colors of the global palette is larger than or equal to a first threshold value;
wherein the GIF picture is determined to satisfy the condition when the global palette color total is greater than or equal to the first threshold, and the GIF picture is determined not to satisfy the condition when the global palette color total is less than the first threshold.
Optionally, when the palette information includes a global palette and a local palette, the total number of palette colors is the sum of the total number of global palette colors and the total number of local palette colors;
the obtaining unit is further configured to:
judging whether the sum of the total number of the global palette colors and the total number of the local palette colors is larger than or equal to a second threshold value or not;
wherein the GIF picture is determined to satisfy the condition when the sum is greater than or equal to the second threshold, and the GIF picture is determined not to satisfy the condition when the sum is less than the second threshold, the second threshold being greater than or equal to the first threshold.
Optionally, when the palette information includes a global palette and a local palette, the obtaining unit is further configured to:
determining whether the picture frame number of a local palette used in the GIF picture is less than a picture frame threshold;
if so, acquiring the total number of colors of a global palette from the palette information, wherein the total number of colors of the palette is the total number of colors of the global palette;
otherwise, obtaining the sum of the total number of the global palette colors and the total number of the local palette colors of the GIF picture from the palette information, wherein the total number of the palette colors is the sum of the total number of the global palette colors and the total number of the local palette colors.
Optionally, the determining unit is further configured to:
determining whether global palette information and local palette information are included in the palette information;
if the palette information is determined to comprise the global palette information and the local palette information, determining that the GIF picture meets the condition, otherwise determining that the GIF picture does not meet the condition.
Optionally, the obtaining unit is further configured to:
acquiring the size of the long edge and/or the size of the short edge of the GIF picture;
determining whether the long side size and/or the short side size are larger than a third threshold value;
and if the long edge size and/or the short edge size are determined to be larger than a third threshold, obtaining the palette information of the GIF picture.
In a third aspect, an embodiment of the present invention further provides a compression apparatus for GIF pictures, including at least one processor and at least one memory, where the memory stores a computer program, and when the program is executed by the processor, the processor is caused to execute the steps of the method according to the first aspect.
In a fourth aspect, the present invention further provides a storage medium storing computer instructions, which when executed on a computer, cause the computer to perform the steps of the method according to the first aspect.
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 will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present invention;
fig. 2 is a flowchart of a GIF picture compression method according to an embodiment of the present invention;
FIG. 3 is a flow chart of determining the GIF picture size according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a process for a GIF picture including only global palettes according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a process of a GIF picture including a global palette and a local palette according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating another process for a GIF picture including a global palette and a local palette according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating a further process for a GIF picture including a global palette and a local palette according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a GIF picture compression device according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a server according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the technical solutions of the present invention. All other embodiments obtained by a person skilled in the art without any inventive work based on the embodiments described in the present application are within the scope of the protection of the technical solution of the present invention.
Some concepts related to the embodiments of the present invention are described below.
And (4) GIF: the method is an image file Format, namely an abbreviation of Graphics exchange Format, also called an image exchange Format, and the method saves a plurality of images into one file, and plays the images frame by frame during playing to form animation.
H.264: is a new generation of digital video compression format following MPEG4 commonly proposed by the international organization for standardization (ISO) and the International Telecommunications Union (ITU).
HEVC: i.e., the abbreviation of High Efficiency Video Coding, is a new generation of Video Coding standards that follows h.264.
The terminal equipment: the electronic device may be a mobile device or a fixed device, such as a mobile phone, a tablet computer, a Personal Digital Assistant (PDA), or other electronic devices that can implement the above functions.
In a specific practical process, in the prior art, in the process of uploading the GIF picture to the background server for storage, the GIF picture is directly transcoded and stored, that is, the GIF picture is decoded and then compressed into other formats for storage, for example, the GIF picture is compressed into a video compression format.
Therefore, the GIF pictures received by the server may be pictures with more color numbers of color palettes, such as pictures in film and television works, and such GIF pictures have more color numbers of each frame of pictures; the image with a small palette color number may be used, such GIF images as cartoon images, black and white images, etc., in which the number of colors used by each frame of image is small, if the server transcodes and compresses the GIF image with a small palette color number, the edge of an object in the image is easily distorted, which causes serious reduction in subjective quality of the transcoded and compressed video compressed image, and because the number of colors used by such GIF images is small, the size of such GIF images is not too large, and if the GIF image is transcoded and compressed into other formats, the situation that the bandwidth saving effect is not obvious also exists, even the situation that the compressed video compressed image is larger than the GIF image occurs.
For example, when the volume of such a GIF picture does not meet the minimum volume requirement of video compression format compression, if such a GIF picture is transcoded and compressed into a video compression format, the size of such a GIF picture needs to be expanded first to meet the minimum volume requirement of video compression format compression, and then the expanded GIF picture is compressed using the video compression format.
Based on this, the embodiment of the present invention provides a method for compressing a GIF picture, where after receiving a GIF picture compressed by a GIF, the method needs to first obtain palette information of the GIF picture, and then determines whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information, so as to screen out a GIF picture which has a smaller palette color number and is not suitable for further compression, so that the method can further compress the GIF picture by using a video compression format only for the GIF picture with a larger palette color number, that is, the GIF picture satisfying the condition for performing video compression format compression, and obtain a compressed video compression picture.
The GIF picture compression method in the embodiment of the present invention may be applied to an application scenario as shown in fig. 1, where the application scenario includes a first terminal device 10, a second terminal device 11, and a server 12, and the first terminal device 10 and the second terminal device 11 may be any intelligent electronic device that can operate according to a program and automatically process a large amount of data at a high speed, such as a computer, an ipad, a mobile phone, and the like. The server 12 may be one server, or may be a server cluster or a cloud computing center formed by several servers.
The first terminal device 10 and the second terminal device 11 are connected to the server 12 through a network, which may be any one of communication networks such as a local area network, a wide area network, and a mobile internet. In this scenario, after receiving the GIF picture which is uploaded by the first terminal device 10 and is compressed by the server 12, the palette information in the GIF picture may be acquired according to the GIF picture compression method provided in the embodiment of the present invention, and then the server may determine whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information, and when it is determined that the GIF picture satisfies the condition, the server 12 compresses the GIF picture by using the video compression format to obtain the compressed video compressed picture, so that the second terminal device 11 may download the compressed video compressed picture from the server 12.
Another possible application scenario is that, for example, the first terminal device 10 and the second terminal device 11 are the same terminal device, and then the same terminal device may upload a GIF picture to the server, and after the server recompresses the uploaded GIF picture into a video compressed picture by using the GIF picture compression method provided by the embodiment of the present invention, the same terminal device may also download the recompressed video compressed picture from the server.
It should be noted that the above-mentioned application scenarios are only presented to facilitate understanding of the spirit and principles of the present invention, and the present invention is not limited in this respect. Rather, embodiments of the present invention may be applied in any scenario where applicable.
The following describes a GIF picture compression method according to an embodiment of the present invention with reference to the application scenario shown in fig. 1.
Referring to fig. 2, a method for compressing a GIF picture according to an embodiment of the present invention includes:
step 201: receiving a GIF picture compressed by a GIF compression mode;
in the embodiment of the invention, a user can upload a picture to be shared to a server through a network application in a first terminal device, for example, through WeChat, QQ and the like in a mobile phone, and in the picture uploading process, the picture can be compressed into a GIF picture in a GIF compression mode, so that the size of the original picture is reduced, wherein the size (size) of the picture is the size of a storage space occupied by a picture file, and therefore, the server receives the GIF picture which is reduced in size after being compressed in the GIF compression mode.
Step 202: obtaining palette information of the GIF picture;
in the embodiment of the present invention, the palette is one of the most important characteristic features of the GIF picture in the GIF compression format, and the palette feature can affect the compression effect of the GIF picture after further compression.
The compression effect at least comprises the file size of the compressed picture and the subjective quality of the compressed picture, wherein the file size of the picture refers to the size of the compressed picture. The subjective quality of a picture is a quality index visually generated when the picture is viewed.
In the embodiment of the present invention, the server may determine whether the GIF picture is suitable for one-step compression by using a characteristic feature, i.e., a palette feature, of the GIF picture, and therefore, after receiving the GIF picture in the GIF compression format, the server may first obtain palette information of the GIF picture.
Step 203: and determining whether the GIF picture meets the condition of compressing the video compression format or not according to the palette information.
In the embodiment of the present invention, the server may preset a condition for triggering video compression processing on the GIF picture, that is, a condition for performing video compression format compression in step 103. And then after the server acquires the palette information in the GIF picture, the server can determine whether the GIF picture meets the condition of performing video compression format compression according to the acquired palette information.
In practical applications, since the palettes in the GIF compression scheme are divided into a global palette and a local palette, the GIF picture palette information acquired by the server may include only the global palette, only the local palette, or both the global palette and the local palette.
The global palette, which may also be referred to as a universal palette, refers to a palette in which all frames of the entire GIF image share one 256 colors, and thus, the total number of colors included in all frames of the entire GIF image is less than or equal to 256. The local color palette means that each frame in the GIF image may include 256 colors independent of itself, and each frame may use several colors out of the 256 colors independent of itself.
Therefore, in the embodiment of the present invention, the server may determine whether the GIF picture satisfies the condition for performing video compression format compression according to the obtained palette information, that is, the global palette and the local palette included in the palette information, and hereinafter, detailed descriptions will be separately provided on how to determine whether the GIF picture satisfies the condition for performing video compression format compression when the palette information includes only the global palette and when the palette information includes both the global palette and the local palette.
Step 204: and if the GIF picture does not meet the condition of compressing the video compression format, storing the GIF picture.
In practical application, the server determines that the GIF picture does not satisfy the condition for compressing the video compression format according to the obtained palette information, for example, the total number of palette colors in the GIF picture is too small, further video format compression easily causes distortion of the edge of an object in an image, and further causes the video quality of the transcoded and compressed video compression picture after decoding and restoring to be lower than a set standard, that is, the subjective quality of the video compression picture is seriously reduced, at this time, the server can determine that the GIF picture does not satisfy the condition for compressing the video compression format according to the obtained palette information, and then the server can directly store the GIF picture.
Step 205: if the GIF picture meets the conditions, the GIF picture is compressed by adopting a video compression format, the GIF picture is decompressed and is recompressed by adopting the video compression format, and the video compression picture compressed by the video compression format is obtained so as to be stored.
In the embodiment of the present invention, if the server determines that the GIF picture satisfies the condition for compressing the video compression format according to the obtained palette information, for example, the total number of palette colors of the GIF picture is large, and further video compression does not distort the edge of an object in the image, so that the GIF picture can be further compressed to reduce the file size of the picture and further save the bandwidth while preserving the compressed subjective quality.
When the server determines that the GIF picture meets the condition of performing video compression format compression, the server may perform video compression format compression on the GIF picture, for example, compress the GIF picture by using a video compression format H.264 to obtain a compressed video compression picture, or compress the GIF picture by using a video compression format HEVC to obtain a compressed video compression picture, and further store the compressed video compression picture.
Of course, other video compression formats may be used for compression, and this is not necessarily the case.
Therefore, according to the GIF picture compression method in the embodiment of the present invention, after receiving a GIF picture compressed by GIF, a server needs to first obtain palette information of the GIF picture, and then determines whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information, so as to screen out a GIF picture which has a smaller palette color number and is not suitable for further compression, so that the GIF picture which has a larger palette color number, that is, a GIF picture which satisfies the condition for performing video compression format compression, is further compressed in a video compression format, and a compressed video compression picture is obtained.
In an optional manner, in the embodiment of the present invention, after the server receives the GIF picture compressed in the GIF compression manner, the server may execute the process shown in fig. 3 to obtain the long edge and/or the short edge of the GIF picture, further determine whether the obtained long edge and/or short edge is greater than a preset threshold, and obtain the palette information of the GIF picture when it is determined that the size of the long edge and/or the size of the short edge is greater than the threshold.
The process shown in fig. 3 includes:
step 301: acquiring the size of the long edge and/or the size of the short edge of the GIF picture;
step 302: determining whether the size of the long side and/or the size of the short side is larger than a third threshold, if so, executing a step 303, otherwise, executing a step 304;
step 303: obtaining palette information of the GIF picture;
step 304: the GIF picture is stored.
In a specific practice process, the long side of the GIF picture may be referred to as the length of the GIF picture, and the short side of the GIF picture may be referred to as the width of the GIF picture. The length and width of the GIF picture can be expressed by a length unit, or can be expressed by a pixel unit, and it can be understood that when the length and width of the GIF picture are expressed by a length unit, the size of the long side or the short side of the picture can be referred to as the length of the long side or the length of the short side; when the length and width of a GIF picture are expressed in units of pixels, the size of the long or short side of the picture may be referred to as a picture resolution.
The server may preset a length threshold or set a resolution threshold for comparing with the long edge and/or the short edge of the obtained GIF picture, for example, when the server obtains the long edge of the GIF picture and uses a length unit, the server may compare the length of the obtained long edge with the length threshold, and then determine whether the length of the long edge is greater than the length threshold;
if the server acquires the short edge of the GIF picture and uses the pixel unit, the server can compare the resolution of the acquired short edge with a resolution threshold value so as to determine whether the resolution of the short edge is greater than the resolution threshold value; the server acquires the short side and the long side of the GIF picture at the same time, and if the pixel unit is used, the server can compare the resolution of the acquired short side and the resolution of the acquired long side with the resolution threshold respectively, and further determine whether the resolution of the long side and the resolution of the short side are both greater than the resolution threshold.
In the embodiment of the present invention, specifically, taking the short side and the long side of the GIF picture acquired at the same time and the length threshold preset by the server as an example, if the server determines that the long side of the GIF picture is smaller than the length threshold and the short side of the GIF picture is also smaller than the length threshold according to the acquired long side and short side of the GIF picture, the server may directly store the GIF picture in the picture storage module.
If the server determines that the long edge of the GIF picture is larger than the length threshold and the short edge of the GIF picture is also larger than the length threshold according to the long edge and the short edge of the obtained GIF picture, the server can further obtain the palette information of the GIF picture and determine whether the GIF picture meets the condition of compressing the video compression format according to the palette information of the GIF picture.
The following description will be made in detail respectively on how to determine whether the GIF picture satisfies the condition for performing video compression format compression when the palette information includes only the global palette and includes both the global palette and the local palette.
In the embodiment of the present invention, as described above, the palettes in the GIF compression method are divided into the global palettes and the local palettes, and therefore, in the embodiment of the present invention, the GIF picture compressed by the GIF compression method received by the server may include the global palettes, may also include the local palettes, and may also include both the global palettes and the local palettes. Therefore, the server can obtain the palette information in the GIF picture, determine the palette included in the received GIF picture through the analysis of the palette information of the GIF picture, and determine the total number of palette colors used by the GIF picture according to the palette included in the GIF picture, and the server can further determine whether the GIF picture meets the condition for compressing the video compression format according to the determined total number of the palette colors, wherein whether the GIF picture meets the condition for compressing the video compression format is set according to the condition that the file size of the video compression picture is smaller than the file size of the GIF picture and/or the video quality after the video compression picture is restored is not lower than the set standard.
In an alternative implementation manner, in the embodiment of the present invention, when only the global palette is included in the palette information of the GIF picture acquired by the server, the processing may be performed according to the flow shown in fig. 4.
The process shown in fig. 4 includes:
step 401: acquiring the total number of colors of a global palette of the GIF picture from the palette information;
step 402: judging whether the total number of the colors of the global palette is greater than or equal to a threshold value of the colors of the global palette, if so, executing a step 403, otherwise, executing a step 407;
step 403: determining that the GIF picture meets the condition of compressing the video compression format;
step 404: compressing the GIF picture by adopting a video compression format to obtain a compressed video compression picture;
step 405: judging whether the file size of the video compressed picture is smaller than that of the GIF picture before compression or not, if so, executing a step 406, otherwise, executing a step 407;
step 406: saving the video compression picture;
step 407: the GIF picture is saved.
In the embodiment of the present invention, the server may preset a global palette color threshold, where the global palette color threshold is a threshold of a preset number of global palette colors, and the global palette color threshold is a threshold that represents that when the GIF picture includes a global palette, the GIF picture is further compressed, so as to save bandwidth, and also ensure subjective quality of the transcoded and compressed video compressed picture, that is, the GIF picture is required to have the minimum number of global palette colors under the condition that the video quality after the video compressed picture is decompressed and restored is not lower than a set standard.
The set standard is a video quality standard which is set so that quality degradation does not occur visually when a video compressed picture is viewed after being decompressed and restored into a video.
Therefore, in the embodiment of the present invention, when the server determines that the GIF picture only includes the total global palette according to the palette information of the GIF picture, it may be determined whether the GIF picture satisfies the condition for performing the video compression format compression by determining whether the total global palette color of the GIF picture is greater than the threshold global palette color.
When the total number of the colors of the global palette is greater than or equal to the threshold value of the colors of the global palette, the server determines that the GIF picture meets the condition for compressing the video compression format, namely the total number of the colors of the global palette of the GIF picture meets the condition for the minimum number of the colors of the global palette capable of compressing the video compression format, and the server can compress the GIF picture in the video compression format to further obtain the compressed video compression picture.
For example, when the global palette color threshold is 20, the server determines that the GIF picture only includes the global palette according to the palette information of the GIF picture, and determines that the total global palette color of the GIF picture is 100, then, the server compares the global palette color threshold with the total global palette color of the GIF picture, and determines that the total global palette color of the GIF picture is greater than the global palette color threshold, at this time, the server may compress the GIF picture in a video compression format, and obtain a compressed video picture.
In order to further ensure that the file size of the video compression picture after transcoding compression is smaller than the file size of the GIF picture before compression, the server can further judge whether the file size of the video compression picture is smaller than the file size of the GIF picture before compression, if the file size of the video compression picture is smaller than the file size of the GIF picture before compression, the compressed video compression picture is stored, the GIF picture before compression can be deleted, and the storage space of the server is further saved. If the file size of the video compressed picture is larger than that of the GIF picture before compression, the server can also store the GIF picture before compression.
In practical applications, there may be a case that the total number of the global palette colors is smaller than the global palette color threshold, for example, when the number of the global palette colors in the GIF picture is small, for example, the GIF picture is a black-and-white picture and includes only black and white colors, the total number of the global palette colors of the GIF picture is 2, the server compares the total number of the global palette colors of the GIF picture with the global palette color threshold, and determines that the total number of the global palette colors of the GIF picture is smaller than the global palette color threshold, thereby determining that the GIF picture does not satisfy the condition for performing the video compression format compression, and at this time, the server may directly store the received GIF picture subjected to the GIF compression.
In an optional implementation manner, in the embodiment of the present invention, when the server determines that the GIF picture includes the global palette and the local palette according to the obtained palette information of the GIF picture, the server may perform processing in any one of the following three manners.
The first way, as shown in fig. 5, includes:
step 501: acquiring the sum of the total number of colors of the global palette and the total number of colors of the local palette in the GIF picture;
step 502: judging whether the sum of the total number of the colors of the global color palette and the total number of the colors of the local color palette is larger than or equal to the sum threshold of the total number of the colors, if so, executing a step 503, otherwise, executing a step 507;
step 503: determining that the GIF picture meets the condition of compressing the video compression format;
step 504: compressing the GIF picture by adopting a video compression format to obtain a compressed video compression picture;
step 505: judging whether the file size of the video compressed picture is smaller than that of the GIF picture before compression or not, if so, executing a step 506, otherwise, executing a step 507;
step 506: saving the video compression picture;
step 507: the GIF picture is saved.
In the embodiment of the present invention, when the GIF picture includes both the global palette and the local palette, the total number of colors included in the GIF picture is usually greater than the total number of colors of only the global palette in the GIF picture, so that the server may obtain both the total number of colors of the global palette and the total number of colors of the local palette when determining that the GIF picture includes both the global palette and the local palette, and further determine whether the GIF picture satisfies the condition for performing the video compression format compression according to the sum of the total number of colors of the global palette and the total number of colors of the local palette in the GIF picture.
The server may preset a sum threshold of the total number of colors, where the sum threshold of the total number of colors refers to a threshold of a sum of the total number of colors of the global palette and the total number of colors of the local palette, and represents that the GIF image further compresses to save bandwidth when the GIF image includes the global palette and the local palette, and requires a minimum value of a sum of the total number of colors of the global palette and the total number of colors of the local palette that are included in the GIF image under the condition that the subjective quality of the transcoded and compressed video compressed image is also guaranteed.
The server may further determine whether a sum of a total number of colors of the global palette and a total number of colors of the local palette in the GIF picture is greater than or equal to a sum threshold of the total number of colors when determining that the GIF picture includes the global palette and the local palette.
If the server determines that the sum of the total number of the global palette colors and the total number of the local palette colors in the GIF picture is greater than the sum threshold of the total number of the colors, the server determines that the GIF picture meets the condition for compressing the video compression format, namely the total number of the global palette colors of the GIF picture reaches the condition for compressing the video compression format, and the server can compress the GIF picture in the video compression format to further obtain the compressed video compression picture.
In order to further ensure that the file size of the video compression picture after transcoding compression is smaller than the file size of the GIF picture before compression, the server can further judge whether the file size of the video compression picture is smaller than the file size of the GIF picture before compression, if the file size of the video compression picture is smaller than the file size of the GIF picture before compression, the compressed video compression picture is stored, the GIF picture before compression can be deleted, and the storage space of the server is further saved. If the file size of the video compressed picture is larger than that of the GIF picture before compression, the server can also store the GIF picture before compression.
If the server determines that the sum of the total number of colors of the global palette and the total number of colors of the local palette in the GIF picture is smaller than the sum threshold of the total numbers of colors, the server determines that the GIF picture does not meet the condition of compressing the video compression format, and at the moment, the server can directly store the received GIF picture which is compressed by the GIF.
The second mode, as shown in fig. 6, includes:
step 601: judging whether the number of picture frames using the local palette in the GIF picture is smaller than a picture frame threshold, if so, executing a step 602, otherwise, executing a step 603;
step 602: acquiring the total number of colors of a global palette in the GIF picture, and judging whether the total number of colors of the global palette is greater than or equal to a threshold value of the colors of the global palette, if so, executing a step 604, otherwise, executing a step 608;
step 603: acquiring the sum of the total number of colors of the global palette and the total number of colors of the local palette in the GIF picture, and judging whether the sum of the total number of colors of the global palette and the total number of colors of the local palette is greater than or equal to the sum threshold of the total number of colors, if so, executing a step 604, otherwise, executing a step 608;
step 604: determining that the GIF picture meets the condition of compressing the video compression format;
step 605: compressing the GIF picture by adopting a video compression format to obtain a compressed video compression picture;
step 606: judging whether the file size of the video compressed picture is smaller than that of the GIF picture before compression, if so, executing a step 607, otherwise, executing a step 608;
step 607: saving the video compression picture;
step 608: the GIF picture is saved.
In the embodiment of the present invention, in practical applications, when the GIF picture includes the global palette and the local palette, a situation may also exist where most pictures in the GIF picture use the global palette, and only a small part of pictures use the local palette, and at this time, the server may first determine whether the number of picture frames in the GIF picture that use the local palette is smaller than a picture frame threshold.
The server may preset a picture frame threshold, where the picture frame threshold refers to a threshold of the number of picture frames.
If the server determines that the number of picture frames using the local palette in the GIF picture is smaller than the picture frame threshold, the server may only obtain the total number of the global palette colors in the GIF picture, and then determine whether the GIF picture satisfies the condition for compressing the video compression format according to the total number of the global palette colors of the GIF picture.
Likewise, the server may preset a global palette color threshold, where the global palette color threshold is a preset threshold of the number of global palette colors, and the server may further determine whether the GIF picture satisfies the condition for performing video compression format compression by determining whether the total number of global palette colors of the GIF picture is greater than or equal to the global palette color threshold.
When the total number of the colors of the global palette is greater than or equal to the threshold value of the colors of the global palette, the server determines that the GIF picture meets the condition for compressing the video compression format, namely the total number of the colors of the global palette of the GIF picture meets the condition for compressing the video compression format, and the server can compress the GIF picture in the video compression format to further obtain the compressed video compression picture.
And when the total number of the colors of the global palette is smaller than the threshold value of the colors of the global palette, the server determines that the GIF picture does not meet the condition for compressing the video compression format, and at the moment, the server can directly store the received GIF picture which is compressed by the GIF.
If the server determines that the number of picture frames using the local palette in the GIF picture is greater than or equal to the picture frame threshold, the server may obtain the sum of the total number of the global palette colors and the total number of the local palette colors in the GIF picture, and determine whether the sum of the total number of the global palette colors and the total number of the local palette colors is greater than or equal to the sum threshold of the total number of colors in the first manner described above, and further determine whether the GIF picture has a condition for performing video compression format compression, which is not repeatedly described herein.
Similarly, in order to further ensure that the file size of the transcoded and compressed video compressed picture is smaller than the file size of the pre-compressed GIF picture, the server can further judge whether the file size of the video compressed picture is smaller than the file size of the pre-compressed GIF picture, if the file size of the video compressed picture is smaller than the file size of the pre-compressed GIF picture, the compressed video compressed picture is stored, the pre-compressed GIF picture can be deleted, and the storage space of the server is further saved. If the file size of the video compressed picture is larger than that of the GIF picture before compression, the server can also store the GIF picture before compression.
The third mode, as shown in fig. 7, includes:
step 701: determining that the palette information comprises global palette information and local palette information;
step 702: determining that the GIF picture meets the condition of compressing the video compression format;
step 703: compressing the GIF picture by adopting a video compression format to obtain a compressed video compression picture;
step 704: judging whether the file size of the video compressed picture is smaller than that of the GIF picture before compression, if so, executing a step 705, otherwise, executing a step 706;
step 705: saving the video compression picture;
step 706: the GIF picture is saved.
In the embodiment of the present invention, when the GIF picture includes both the global palette and the local palette, the GIF pictures of the plurality of palettes have a certain amount of data, and the server stores the GIF picture including the plurality of palettes, which occupies a larger space.
Therefore, when the server determines that the GIF picture simultaneously comprises the global palette and the local palette, the server can directly determine that the GIF picture meets the condition for compressing the video compression format, namely that the GIF picture meets the condition for compressing the video compression format that the GIF picture simultaneously comprises the global palette and the local palette, and the server compresses the GIF picture in the video compression format to further obtain the compressed video compression picture.
Similarly, in order to further ensure that the file size of the transcoded and compressed video compressed picture is smaller than the file size of the pre-compressed GIF picture, the server can further judge whether the file size of the video compressed picture is smaller than the file size of the pre-compressed GIF picture, if the file size of the video compressed picture is smaller than the file size of the pre-compressed GIF picture, the compressed video compressed picture is stored, the pre-compressed GIF picture can be deleted, and the storage space of the server is further saved. If the file size of the video compressed picture is larger than that of the GIF picture before compression, the server can also store the GIF picture before compression.
The fourth mode is that:
in the embodiment of the present invention, in practical applications, there may be a case where a global palette is used for most pictures in the GIF picture, and only a very small part of the pictures use a local palette, for example, only one frame of image or two frames of images use a local palette, at this time, the server may determine whether the GIF picture satisfies a condition for performing video compression format compression according to only the global palette in the GIF picture, and a specific implementation process may refer to a processing procedure when only the global palette is included in the GIF picture in the foregoing, which is not repeatedly described here.
In practical application, the GIF image compression method in the embodiment of the present invention may be applied to any application scenario involving GIF image compression, so as to implement further compression of GIF images and reduce the file size of GIF images to save bandwidth while ensuring subjective quality.
In practical application, programming languages such as C language, C + + language, Java language, and the like may also be used, based on the GIF picture compression provided by the embodiment of the present invention, a program or APP dedicated to GIF picture compression is developed, and when GIF picture compression is required, the program or APP is called to complete GIF picture compression.
Based on the same inventive concept, an embodiment of the present invention provides a GIF picture compression apparatus, and the specific implementation of the GIF picture compression method of the apparatus may refer to the description of the above method embodiment, and repeated parts are not repeated, as shown in fig. 8, the apparatus includes:
a receiving unit 80, configured to receive a GIF picture;
an obtaining unit 81 configured to obtain palette information of the GIF picture;
a determining unit 82, configured to determine whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information; and when the GIF picture is determined to meet the conditions, decompressing the GIF picture and recompressing the GIF picture by adopting a video compression format to obtain a video compression picture.
Optionally, the apparatus further comprises:
the saving unit 83 is configured to save the video compressed picture if the file size of the video compressed picture is smaller than the file size of the GIF picture.
Optionally, the obtaining unit is specifically configured to:
acquiring the total number of palette colors used by the GIF picture from the palette information;
and determining whether the GIF picture meets the condition of compressing the video compression format or not according to the total number of the colors of the palette.
Optionally, the quality of the video restored from the video compressed picture is not lower than a set standard.
Optionally, when the palette information includes a global palette, the total number of colors of the palette is the total number of colors of the global palette;
an acquisition unit further configured to:
judging whether the total number of colors of the global palette is greater than or equal to a first threshold value;
and when the total number of the colors of the global palette is greater than or equal to a first threshold, determining that the GIF picture meets the condition, and when the total number of the colors of the global palette is less than the first threshold, determining that the GIF picture does not meet the condition.
Optionally, when the palette information includes a global palette and a local palette, the total number of colors in the palette is the sum of the total number of colors in the global palette and the total number of colors in the local palette;
an acquisition unit further configured to:
judging whether the sum of the total number of the colors of the global palette and the total number of the colors of the local palette is larger than or equal to a second threshold value or not;
and when the sum is smaller than the second threshold value, determining that the GIF picture does not meet the condition, wherein the second threshold value is larger than or equal to the first threshold value.
Optionally, when the palette information includes a global palette and a local palette, the obtaining unit is further configured to:
determining whether the picture frame number of a local palette used in the GIF picture is less than a picture frame threshold;
if so, acquiring the total number of colors of the global palette from the palette information, wherein the total number of colors of the palette is the total number of colors of the global palette;
otherwise, obtaining the sum of the total number of the global palette colors and the total number of the local palette colors of the GIF picture from the palette information, wherein the total number of the palette colors is the sum of the total number of the global palette colors and the total number of the local palette colors.
Optionally, the determining unit is further configured to:
determining whether the palette information includes global palette information and local palette information;
and if the palette information is determined to comprise the global palette information and the local palette information, determining that the GIF picture meets the condition, otherwise, determining that the GIF picture does not meet the condition.
Optionally, the obtaining unit is further configured to:
acquiring the size of the long edge and/or the size of the short edge of the GIF picture;
determining whether the size of the long side and/or the size of the short side is larger than a third threshold value;
and if the long side size and/or the short side size are determined to be larger than a third threshold, obtaining the palette information of the GIF picture.
Based on the same inventive concept, the embodiment of the present invention further provides a compression apparatus for GIF pictures, as shown in fig. 9, including at least one processor 90 and at least one memory 91, wherein the memory 91 stores a computer program, and when the program is executed by the processor, the processor 90 executes the steps of the compression method for GIF pictures as described above.
Based on the same inventive concept, embodiments of the present invention further provide a storage medium storing computer instructions, which when run on a computer, cause the computer to perform the steps of the above-mentioned GIF picture compression method.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention 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, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. 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.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
Claims (13)
1. A compression method of GIF pictures is characterized by comprising the following steps:
receiving a GIF picture;
acquiring palette information of the GIF picture;
determining whether the GIF picture meets the condition of compressing a video compression format or not according to the palette information; wherein the condition is satisfied if the total number of palette colors used by the GIF picture is greater than or equal to a threshold;
if the GIF picture meets the condition, decompressing the GIF picture and recompressing the GIF picture by adopting a video compression format to obtain a video compression picture;
when the palette information includes a global palette and a local palette, obtaining the total number of palette colors used by the GIF picture from the palette information in the following manner:
determining whether a picture frame number of a local palette used in the GIF picture is less than a picture frame threshold;
if so, acquiring the total number of colors of a global palette from the palette information, wherein the total number of colors of the palette is the total number of colors of the global palette;
otherwise, obtaining the sum of the total number of the global palette colors and the total number of the local palette colors of the GIF picture from the palette information, wherein the total number of the palette colors is the sum of the total number of the global palette colors and the total number of the local palette colors.
2. The method of claim 1, wherein the method further comprises:
and if the file size of the video compressed picture is smaller than that of the GIF picture, saving the video compressed picture.
3. The method of claim 2, wherein the video quality of the restored video compressed pictures is not lower than a predetermined standard.
4. The method of claim 1, wherein when the palette information includes only a global palette, the total number of palette colors is a global palette color total number;
the determining, according to the palette information, whether the GIF picture satisfies a condition for performing video compression format compression specifically includes:
judging whether the total number of the colors of the global palette is larger than or equal to a first threshold value;
wherein the GIF picture is determined to satisfy the condition when the global palette color total is greater than or equal to the first threshold, and the GIF picture is determined not to satisfy the condition when the global palette color total is less than the first threshold.
5. The method of claim 4, wherein when the palette information comprises a global palette and a local palette, the determining whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information comprises:
judging whether the total color number of the color palette is larger than or equal to a second threshold value;
wherein the GIF picture is determined to satisfy the condition when the palette color total is greater than or equal to the second threshold, and the GIF picture is determined not to satisfy the condition when the palette color total is less than the second threshold, the second threshold being greater than or equal to the first threshold.
6. The method of claim 1, wherein obtaining palette information for the GIF picture comprises:
acquiring the size of the long edge and/or the size of the short edge of the GIF picture;
determining whether the long side size and/or the short side size are larger than a third threshold value;
and if the long edge size and/or the short edge size are determined to be larger than a third threshold, obtaining the palette information of the GIF picture.
7. A GIF picture compression apparatus, comprising:
a receiving unit for receiving the GIF picture;
an obtaining unit, configured to obtain palette information of the GIF picture;
a determining unit, configured to determine whether the GIF picture satisfies a condition for performing video compression format compression according to the palette information; when the GIF picture is determined to meet the conditions, decompressing the GIF picture and recompressing the GIF picture by adopting a video compression format to obtain a video compression picture; wherein the condition is satisfied if the total number of palette colors used by the GIF picture is greater than or equal to a threshold;
the obtaining unit is specifically configured to:
when the palette information comprises a global palette and a local palette, determining whether the number of picture frames of the local palette used in the GIF picture is less than a picture frame threshold;
if so, acquiring the total number of colors of a global palette from the palette information, wherein the total number of colors of the palette is the total number of colors of the global palette;
otherwise, obtaining the sum of the total number of the global palette colors and the total number of the local palette colors of the GIF picture from the palette information, wherein the total number of the palette colors is the sum of the total number of the global palette colors and the total number of the local palette colors.
8. The apparatus of claim 7, wherein the apparatus further comprises:
and the storage unit is used for storing the video compressed picture if the file size of the video compressed picture is smaller than that of the GIF picture.
9. The apparatus of claim 7, wherein the total number of palette colors is a total number of global palette colors when the palette information includes only a global palette;
the obtaining unit is further configured to:
judging whether the total number of the colors of the global palette is larger than or equal to a first threshold value;
wherein the GIF picture is determined to satisfy the condition when the global palette color total is greater than or equal to the first threshold, and the GIF picture is determined not to satisfy the condition when the global palette color total is less than the first threshold.
10. The apparatus of claim 9, wherein when the palette information comprises a global palette and a local palette, the obtaining unit is further configured to:
judging whether the total color number of the color palette is larger than or equal to a second threshold value;
wherein the GIF picture is determined to satisfy the condition when the palette color total is greater than or equal to the second threshold, and the GIF picture is determined not to satisfy the condition when the palette color total is less than the second threshold, the second threshold being greater than or equal to the first threshold.
11. The apparatus of claim 9, wherein the obtaining unit is further configured to:
acquiring the size of the long edge and/or the size of the short edge of the GIF picture;
determining whether the long side size and/or the short side size are larger than a third threshold value;
and if the long edge size and/or the short edge size are determined to be larger than a third threshold, obtaining the palette information of the GIF picture.
12. A device for compressing GIF pictures, comprising at least one processor and at least one memory, wherein said memory stores a computer program which, when executed by said processor, causes said processor to carry out the steps of the method according to any one of claims 1 to 6.
13. A storage medium storing computer instructions which, when executed on a computer, cause the computer to perform the steps of the method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810942788.6A CN108933945B (en) | 2018-08-17 | 2018-08-17 | GIF picture compression method, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810942788.6A CN108933945B (en) | 2018-08-17 | 2018-08-17 | GIF picture compression method, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108933945A CN108933945A (en) | 2018-12-04 |
CN108933945B true CN108933945B (en) | 2020-06-19 |
Family
ID=64445934
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810942788.6A Active CN108933945B (en) | 2018-08-17 | 2018-08-17 | GIF picture compression method, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108933945B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110351312B (en) | 2018-04-02 | 2021-10-26 | 腾讯科技(深圳)有限公司 | Picture sharing method and device, computer equipment and storage medium |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1573808A (en) * | 2003-05-19 | 2005-02-02 | 富士胶片株式会社 | Apparatus and method for moving image conversion, apparatus and method for moving image transmission, and programs therefor |
CN101075344A (en) * | 2006-06-21 | 2007-11-21 | 腾讯科技(深圳)有限公司 | Method for merging image format based on index color |
CN101087355A (en) * | 2007-06-27 | 2007-12-12 | 北京海尔集成电路设计有限公司 | Method for dynamic phone storage using small-capacity memory in digital photo frame |
CN101778270A (en) * | 2009-01-13 | 2010-07-14 | 深圳市同洲电子股份有限公司 | Method for accelerating the image displaying speed, system and digital television receiving terminal |
CN101916276A (en) * | 2010-08-13 | 2010-12-15 | 北京新岸线网络技术有限公司 | Method, device and server for improving release of rich media file in network |
CN102164167A (en) * | 2011-02-21 | 2011-08-24 | 北京奇虎科技有限公司 | Method and system for remote-control classified transmission |
CN103873860A (en) * | 2014-03-18 | 2014-06-18 | 深信服网络科技(深圳)有限公司 | Document transmission method and device |
CN104376584A (en) * | 2013-08-15 | 2015-02-25 | 华为技术有限公司 | Data compression method, computer system and device |
CN105808567A (en) * | 2014-12-30 | 2016-07-27 | 航天信息股份有限公司 | Method and device for reducing sizes of PNG pictures |
CN106921869A (en) * | 2017-04-08 | 2017-07-04 | 腾讯科技(深圳)有限公司 | A kind of photograph document handling method and its equipment |
CN106937111A (en) * | 2015-12-31 | 2017-07-07 | 纳宝株式会社 | Optimize the method and system of image compression quality |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7106908B2 (en) * | 2002-03-12 | 2006-09-12 | Nokia Corporation | Method and apparatus for selecting a format in which to re-encode a quantized image |
US7539341B2 (en) * | 2004-07-29 | 2009-05-26 | Xerox Corporation | Systems and methods for processing image data prior to compression |
CN1696977A (en) * | 2005-05-26 | 2005-11-16 | 无敌科技(西安)有限公司 | Method for compressing image |
CN100514366C (en) * | 2006-11-30 | 2009-07-15 | 腾讯科技(深圳)有限公司 | Method and device for compressing image |
US20100049832A1 (en) * | 2008-08-21 | 2010-02-25 | Comverse Ltd | Computer program product, a system and a method for providing video content to a target system |
JP4697557B2 (en) * | 2009-01-07 | 2011-06-08 | ソニー株式会社 | Encoding apparatus, encoding method, recording medium, and image processing apparatus |
CN103886623B (en) * | 2012-12-19 | 2017-03-15 | 华为技术有限公司 | A kind of method for compressing image, equipment and system |
-
2018
- 2018-08-17 CN CN201810942788.6A patent/CN108933945B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1573808A (en) * | 2003-05-19 | 2005-02-02 | 富士胶片株式会社 | Apparatus and method for moving image conversion, apparatus and method for moving image transmission, and programs therefor |
CN101075344A (en) * | 2006-06-21 | 2007-11-21 | 腾讯科技(深圳)有限公司 | Method for merging image format based on index color |
CN101087355A (en) * | 2007-06-27 | 2007-12-12 | 北京海尔集成电路设计有限公司 | Method for dynamic phone storage using small-capacity memory in digital photo frame |
CN101778270A (en) * | 2009-01-13 | 2010-07-14 | 深圳市同洲电子股份有限公司 | Method for accelerating the image displaying speed, system and digital television receiving terminal |
CN101916276A (en) * | 2010-08-13 | 2010-12-15 | 北京新岸线网络技术有限公司 | Method, device and server for improving release of rich media file in network |
CN102164167A (en) * | 2011-02-21 | 2011-08-24 | 北京奇虎科技有限公司 | Method and system for remote-control classified transmission |
CN104376584A (en) * | 2013-08-15 | 2015-02-25 | 华为技术有限公司 | Data compression method, computer system and device |
CN103873860A (en) * | 2014-03-18 | 2014-06-18 | 深信服网络科技(深圳)有限公司 | Document transmission method and device |
CN105808567A (en) * | 2014-12-30 | 2016-07-27 | 航天信息股份有限公司 | Method and device for reducing sizes of PNG pictures |
CN106937111A (en) * | 2015-12-31 | 2017-07-07 | 纳宝株式会社 | Optimize the method and system of image compression quality |
CN106921869A (en) * | 2017-04-08 | 2017-07-04 | 腾讯科技(深圳)有限公司 | A kind of photograph document handling method and its equipment |
Also Published As
Publication number | Publication date |
---|---|
CN108933945A (en) | 2018-12-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11445201B2 (en) | Video encoding and decoding method, device, and system, and storage medium | |
CN108833938B (en) | Method and apparatus for selecting video covers | |
EP3089453A1 (en) | Image coding and decoding methods and devices | |
US11985358B2 (en) | Artifact removal method and apparatus based on machine learning, and method and apparatus for training artifact removal model based on machine learning | |
KR101805550B1 (en) | Image data encoding method for presentation virtualization and server therefor | |
JP2015507902A (en) | Separate encoding and decoding of stable information and transient / stochastic information | |
CN111918065A (en) | Information compression/decompression method and device | |
CN113784175A (en) | HDR video conversion method, device, equipment and computer storage medium | |
CN110740316A (en) | Data coding method and device | |
US10674163B2 (en) | Color space compression | |
CN110740352B (en) | SPICE protocol-based difference image display method in video card transparent transmission environment | |
EP3855754A1 (en) | Video processing method and apparatus, electronic device, and storage medium | |
CN110545446B (en) | Desktop image encoding and decoding methods, related devices and storage medium | |
CN108933945B (en) | GIF picture compression method, device and storage medium | |
CN115118964A (en) | Video encoding method, video encoding device, electronic equipment and computer-readable storage medium | |
CN114125448B (en) | Video coding method, decoding method and related devices | |
US11146826B2 (en) | Image filtering method and apparatus | |
WO2024078066A1 (en) | Video decoding method and apparatus, video encoding method and apparatus, storage medium, and device | |
CN110662071A (en) | Video decoding method and apparatus, storage medium, and electronic apparatus | |
KR20160082521A (en) | Chroma down-conversion and up-conversion processing | |
CN118138770A (en) | Video processing method, device, electronic equipment and storage medium | |
CN114079823A (en) | Video rendering method, device, equipment and medium based on Flutter | |
US12095981B2 (en) | Visual lossless image/video fixed-rate compression | |
CN113450293A (en) | Video information processing method, device and system, electronic equipment and storage medium | |
CN106954073B (en) | Video data input and output method, device and system |
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 |