CN111813574A - Picture compression method and device, storage medium and electronic equipment - Google Patents

Picture compression method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN111813574A
CN111813574A CN202010626661.0A CN202010626661A CN111813574A CN 111813574 A CN111813574 A CN 111813574A CN 202010626661 A CN202010626661 A CN 202010626661A CN 111813574 A CN111813574 A CN 111813574A
Authority
CN
China
Prior art keywords
picture compression
picture
task
link
compression
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010626661.0A
Other languages
Chinese (zh)
Inventor
李翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent 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 Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN202010626661.0A priority Critical patent/CN111813574A/en
Publication of CN111813574A publication Critical patent/CN111813574A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a picture compression method, a picture compression device, a storage medium and electronic equipment, wherein the method comprises the following steps: acquiring a picture compression request aiming at a target picture, and generating a picture compression task corresponding to the picture compression request; adding the picture compression task to a message queue; and reading the picture compression task from the message queue and executing the picture compression task. By adopting the embodiment of the application, the request access service and the picture compression service do not need to be communicated through a network, and the communication mode between the access service and the picture compression service is more flexible.

Description

Picture compression method and device, storage medium and electronic equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for compressing a picture, a storage medium, and an electronic device.
Background
Many internet services use pictures, some of which may occupy a relatively large storage space, and directly processing the pictures consumes a large amount of resources. Therefore, the picture needs to be compressed first to solve the problem of the picture being too large. The commonly adopted picture compression mode is that the access service is separated from the compression service, and the access service and the compression service are called through network communication to realize the picture compression function.
Disclosure of Invention
In order to solve the above problem, embodiments of the present application provide a picture compression method, apparatus, storage medium, and electronic device, which can improve flexibility of communication between a request access service and a picture compression service. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a picture compression method, including the following steps:
acquiring a picture compression request aiming at a target picture, and generating a picture compression task corresponding to the picture compression request;
adding the picture compression task to a message queue;
and reading the picture compression task from the message queue and executing the picture compression task.
In a second aspect, an embodiment of the present application provides a picture compression apparatus, including:
the task generating unit is used for acquiring a picture compression request aiming at a target picture and generating a picture compression task corresponding to the picture compression request;
the task adding unit is used for adding the picture compression task to a message queue;
and the picture compression unit is used for reading the picture compression task from the message queue and executing the picture compression task.
In a third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of any one of the above methods.
In a fourth aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of any one of the above methods when executing the program.
In the embodiment of the application, the picture compression task corresponding to the picture compression request is generated, and the picture compression task is added to the message queue. The access service and the picture compression service are coupled, a picture compression task can be transmitted between the access service and the picture compression service through the message queue, communication between the request access service and the picture compression service does not need to be carried out through a network, the communication mode between the request access service and the picture compression service is more flexible, and the picture compression efficiency is high.
Drawings
Fig. 1 is a schematic diagram of a system architecture of a picture compression method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a picture compression method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another picture compression method according to an embodiment of the present application;
fig. 4 is a schematic system architecture diagram of another picture compression method according to an embodiment of the present application;
fig. 5 is a schematic system architecture diagram of another picture compression method according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a picture compression apparatus according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The present application is further described with reference to the following figures and examples.
In the following description, the terms "first" and "second" are used for descriptive purposes only and are not intended to indicate or imply relative importance. The following description provides embodiments of the present application, where different embodiments may be substituted or combined, and thus the present application is intended to include all possible combinations of the same and/or different embodiments described. Thus, if one embodiment includes feature A, B, C and another embodiment includes feature B, D, then this application should also be considered to include an embodiment that includes one or more of all other possible combinations of A, B, C, D, even though this embodiment may not be explicitly recited in text below.
The following description provides examples, and does not limit the scope, applicability, or examples set forth in the claims. Changes may be made in the function and arrangement of elements described without departing from the scope of the disclosure. Various examples may omit, substitute, or add various procedures or components as appropriate. For example, the described methods may be performed in an order different than the order described, and various steps may be added, omitted, or combined. Furthermore, features described with respect to some examples may be combined into other examples.
Internet services often require the processing of large amounts of content data. In the process of processing content data, a lot of external picture data are often accessed, and the external pictures may be pictures with relatively large occupied space, such as high-definition large pictures. The processing process of the picture with a large occupied space consumes more resources in the terminal. Therefore, the system needs to compress such pictures before performing picture processing.
Fig. 1 is a schematic system architecture diagram of a picture compression method according to an embodiment of the present disclosure. As shown in fig. 1, the system separates an access service from a picture compression service, the access service communicates with the compression service in a calling manner, the access service sends a picture link to be compressed to the compression service, the compression service returns the compressed picture link to the access service, and the access service sends the compressed picture link to a designated terminal. In the system architecture shown in fig. 1, the access service and the compression service communicate with each other through a network, and the communication method is not flexible.
Based on this, the present application proposes a picture compression method. Referring to fig. 2, fig. 2 is a schematic flowchart of a picture compression method provided in an embodiment of the present application, where the method includes:
s201, obtaining a picture compression request aiming at a target picture, and generating a picture compression task corresponding to the picture compression request.
The picture compression request can come from a terminal or other servers. Specifically, the terminal and other servers may send the image compression request through internet, wireless lan, bluetooth connection, infrared connection, or the like.
Optionally, the picture compression request includes a size and/or an application type of the target picture. The system can select a reasonable compression mode based on the size and/or application type of the target picture, and compress the target picture to a proper size so as to meet the requirements of subsequent application.
S202, adding the picture compression task into a message queue.
A message queue is a container that holds messages during their transmission. The message queue may include: ActiveMQ, RabbitMQ, ZeroMQ, Kafka, etc.
S203, reading the picture compression task from the message queue, and executing the picture compression task.
Alternatively, when the picture compression task includes a plurality of tasks, step S203 may include:
and reading a plurality of picture compression tasks from the message queue, respectively distributing each picture compression task to an idle thread in a thread pool, and controlling each idle thread to execute the picture compression tasks in parallel.
A thread pool is a pattern of thread usage, and a thread pool maintains multiple threads and can concurrently execute multiple tasks. By using the thread pool, on one hand, scheduling overhead caused by excessive cost threads for creating and destroying threads when a plurality of tasks are processed in a short time is avoided, and further the overall performance is slowed down. On the other hand, the thread pool can also ensure the full utilization of the kernel and accelerate the system operation efficiency.
Optionally, the method further comprises:
acquiring the write failure times of the compressed link;
and if the writing failure times exceed a time threshold, adding the original link into a blacklist.
The number threshold may be configured according to the application scenario. If the number of times of writing failure of the compression connection is too large, the target picture may be in an abnormal format, and the target picture file may be in an error. Such target pictures have a high probability of failing to successfully perform the compression step. Therefore, when the number of times of writing failure of the compression connection exceeds the number threshold, the original link is added into the blacklist so as to prevent the picture compression task from being executed again, and further reduce the consumption of system resources.
According to the picture compression method, the picture compression task corresponding to the picture compression request is generated, and the picture compression task is added to the message queue. The request access service and the picture compression service can transmit the picture compression task through the message queue. In the architecture shown in fig. 1, the access service and the picture compression service are invoked via network communication. By adopting the method of the embodiment of the application, the communication mode between the access service and the picture compression service can be more flexible.
In addition, in the embodiment of the application, the access service and the picture compression service may be deployed according to specific needs, for example, both the access service and the picture compression service are deployed on the same server, or multiple service networks may be clustered, and the access service and the picture compression service are deployed on a cluster server. In the architecture shown in fig. 1, the access server and the picture compression service are deployed on a fixed access server and a picture compression server, respectively. Compared with the architecture shown in fig. 1, the method provided by the embodiment of the application can more flexibly deploy the service terminal.
In addition, as in the architecture shown in fig. 1, the access service and the picture compression service communicate with each other in a direct call manner, the coupling between the access service and the picture compression service is strong, and the pressure of the picture compression service is large. By adopting the method of the embodiment of the application, the coupling between the access service and the picture compression service can be reduced. In addition, in the method of the embodiment of the application, the same message in the message queue is processed by the access service and the picture compression service, and the messages are processed concurrently between the applications, so that compared with serial processing, the processing time is reduced.
In addition, in the method of the embodiment of the application, the access service and the picture compression service process the same message through the message queue, so that the failure of the whole processing process caused by the failure of calling the interface is avoided.
Referring to fig. 3, fig. 3 is a schematic flowchart of a picture compression method according to an embodiment of the present application, where the method includes:
s301, acquiring a picture compression request aiming at a target picture, and acquiring an original link of the target picture.
S302, whether a compressed link corresponding to the original link exists or not is searched in a cache.
And searching a compressed link corresponding to the original link in the cache by taking the original link of the target picture as a key value. If the compressed link corresponding to the original link is stored in the cache, the target picture is compressed, and the compressed link corresponding to the original link is directly returned.
Optionally, S302 includes:
searching whether the original link exists in a blacklist;
if the original link does not exist in the blacklist, whether a compressed link corresponding to the original link exists or not is searched in a cache.
If the original link of the target picture exists in the blacklist, the target picture is indicated to have been compressed and cannot be compressed successfully. And directly returning the original link of the target picture to the access service corresponding to the original link of the target picture existing in the blacklist so as to avoid the step of compressing the pictures in the blacklist again.
And S303, if the compression link corresponding to the original link does not exist in the cache, returning the original link and generating the image compression task containing the original link.
If the compressed link corresponding to the original link is not stored in the cache, it indicates that the target picture is not compressed, and the following compression steps need to be performed.
And S304, adding the picture compression task into a message queue.
S305, reading the picture compression task from the message queue, and executing the picture compression task.
Optionally, the method further comprises:
and if the compressed link corresponding to the target original link exists in the cache, returning the compressed link.
If the compressed link corresponding to the original link is stored in the cache, the target picture is compressed, and the compressed link corresponding to the original link is directly returned.
Optionally, after S305, the method further includes:
generating a compression link corresponding to the target picture;
writing the compressed link to the cache.
And writing the compression link corresponding to the generated target picture into a cache. If a compressed picture corresponding to the target picture is needed subsequently, the compressed link corresponding to the target picture is directly searched in the cache, and the picture compression process does not need to be executed repeatedly. Therefore, the method of the embodiment of the application can save system resources, and further improve the running speed of the system.
According to the image compression method provided by the embodiment of the application, the compression link corresponding to the target image is searched based on the cache, and the compression link is directly returned under the condition of being found. And if the picture is not found, performing the subsequent picture compression process. Compared with the method of directly compressing the picture without searching the cache, the method can improve the system efficiency and reduce the unnecessary resource consumption of the system.
To facilitate an understanding of the methods of the embodiments of the present application, a specific implementation is described below. The technical scheme provided by the embodiment is combined with a distributed technology, a caching technology, a message queue technology and the like, and service dependencies are decoupled, so that the image compression capabilities of high concurrency, low delay, general service and the like are achieved. Fig. 4 is a schematic system architecture diagram of another picture compression method according to an embodiment of the present application. As shown in fig. 4, the whole system is divided into 2 main services:
request processing service: the service is used for receiving and processing a picture compression request, and when the request processing service receives the request, firstly, the picture link is used as a key value (key) to search the compressed compression link of the picture from the cache. And searching whether the picture is pulled into the blacklist or not by taking the picture link as a key value. If the compressed link of the picture is searched in the cache, the picture is compressed, and the compressed picture connection is returned; if the compressed link of the picture is not searched in the cache, the picture is not compressed, the picture is returned to the original picture chain, and then the picture task corresponding to the picture link needing to be compressed is placed into the message queue.
Picture compression service: the service is used for compressing the pictures, reading the compression task from the message queue, synchronously compressing a plurality of pictures by adopting the thread pool technology, and writing the compressed picture links into the cache, thereby facilitating the follow-up inquiry of the request service.
Request processing service communication between picture compression services uses the kafka message queue approach. Dependencies between the two applications are decoupled by using the kafka message queue. The request service greatly improves the response speed of the service by inquiring the compression link of the picture in the cache. By means of the kafka message queue, the compression function is completed asynchronously, and the process of compressing the picture can be completed in a short time.
Fig. 5 is a schematic system architecture diagram of another picture compression method according to an embodiment of the present application. As shown in fig. 5, the request processing service obtains a picture compression request through an https request. Whether the target picture is compressed or not is firstly searched by the cache service. If the target picture is compressed, returning a compressed picture link; and if the compression image link of the target image is not found, returning the original image link, and putting the image compression task corresponding to the target image into kafka.
And the picture compression service acquires the picture compression task from the kafka through an idle thread in the thread pool and executes the picture compression task. And if the number of times of executing the picture compression task fails is large, putting the picture compression task into a blacklist. And if the picture compression task is successfully executed, uploading the picture to a cache.
According to the scheme of the embodiment of the application, the problem that the compression service performance is limited is solved by adopting the modes of decoupling request and compression service, asynchronous functions, communication through a message queue and the like. The high-concurrency request problem is solved by adopting technologies of respectively deploying and caching compression services and request services. And sending a picture compression request by adopting https, and returning a compression result in real time, so that the service of a picture compression request party, a request processing service party and a picture compression service method can be decoupled. Therefore, the scheme of the embodiment of the application has strong universality.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a picture compression apparatus according to an embodiment of the present disclosure. As shown in fig. 6, the picture compression apparatus includes:
the task generating unit 601 is configured to acquire a picture compression request for a target picture, and generate a picture compression task corresponding to the picture compression request;
a task adding unit 602, configured to add the picture compression task to a message queue;
a picture compression unit 603, configured to read the picture compression task from the message queue, and execute the picture compression task.
Optionally, the task generating unit 601 is specifically configured to:
acquiring a picture compression request aiming at a target picture, and acquiring an original link of the target picture;
searching whether a compressed link corresponding to the original link exists in a cache;
if the compression link corresponding to the original link does not exist in the cache, returning the original link, and generating the picture compression task containing the original link.
Optionally, the task generating unit 601 is further configured to:
and if the compressed link corresponding to the target original link exists in the cache, returning the compressed link.
Optionally, the task generating unit 601 is specifically configured to:
searching whether the original link exists in a blacklist;
if the original link does not exist in the blacklist, whether a compressed link corresponding to the original link exists or not is searched in a cache.
Optionally, the task generating unit 601 is specifically configured to:
and if the original link exists in the blacklist, returning the original link.
Optionally, the apparatus further comprises:
a cache writing unit 604, configured to generate a compression link corresponding to the target picture;
writing the compressed link to the cache.
Optionally, when the picture compression task includes a plurality of tasks, the picture compression unit 603 is specifically configured to:
and reading a plurality of picture compression tasks from the message queue, respectively distributing each picture compression task to an idle thread in a thread pool, and controlling each idle thread to execute the picture compression tasks in parallel.
Optionally, the apparatus further comprises:
a blacklist adding unit 605, configured to obtain the number of write failures of the compressed link;
and if the writing failure times exceed a time threshold, adding the original link into a blacklist.
It is clear to a person skilled in the art that the solution according to the embodiments of the present application can be implemented by means of software and/or hardware. The "unit" and "module" in this specification refer to software and/or hardware that can perform a specific function independently or in cooperation with other components, where the hardware may be, for example, an FPGA (Field-Programmable Gate Array), an IC (Integrated Circuit), or the like.
Each processing unit and/or module in the embodiments of the present application may be implemented by an analog circuit that implements the functions described in the embodiments of the present application, or may be implemented by software that executes the functions described in the embodiments of the present application.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the above-mentioned picture compression method. The computer-readable storage medium may include, but is not limited to, any type of disk including floppy disks, optical disks, DVD, CD-ROMs, microdrive, and magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic or optical cards, nanosystems (including molecular memory ICs), or any type of media or device suitable for storing instructions and/or data.
Referring to fig. 6, a schematic structural diagram of an electronic device according to an embodiment of the present application is shown, where the electronic device may be used to implement the picture compression method provided in the foregoing embodiment. Specifically, the method comprises the following steps:
the memory 1020 may be used to store software programs and modules, and the processor 1080 executes various functional applications and data processing by operating the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal device, and the like. Further, the memory 1020 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 1020 may also include a memory controller to provide access to memory 1020 by processor 1080 and input unit 1030.
The input unit 1030 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 1030 may include a touch-sensitive surface 1031 (e.g., a touch screen, a touchpad, or a touch frame). The touch-sensitive surface 1031, also referred to as a touch display screen or a touch pad, may collect touch operations by a user (such as operations by a user on or near the touch-sensitive surface 1031 using any suitable object or attachment, such as a finger, a stylus, etc.) on or near the touch-sensitive surface 1031 and drive the corresponding connection device according to a preset program. Optionally, the touch sensitive surface 1031 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 1080, and can receive and execute commands sent by the processor 1080. In addition, the touch-sensitive surface 1031 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves.
The display unit 1040 may be used to display information input by or provided to a user and various graphical user interfaces of the terminal device, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 1040 may include a Display panel 1041, and optionally, the Display panel 1041 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 1031 may overlay the display panel 1041, and when a touch operation is detected on or near the touch-sensitive surface 1031, the touch operation is transmitted to the processor 1080 for determining the type of the touch event, and the processor 1080 then provides a corresponding visual output on the display panel 1041 according to the type of the touch event. Although the touch-sensitive surface 1031 and the display panel 1041 may be two separate components that implement input and output functions, in some embodiments, the touch-sensitive surface 1031 may be integrated with the display panel 1041 that implements input and output functions.
The processor 1080 is a control center of the terminal device, connects various parts of the whole terminal device by using various interfaces and lines, and executes various functions of the terminal device and processes data by operating or executing software programs and/or modules stored in the memory 1020 and calling data stored in the memory 1020, thereby monitoring the whole terminal device. Optionally, processor 1080 may include one or more processing cores; processor 1080 may integrate an application processor that handles operating system, user interfaces, applications, etc. and a modem processor that handles wireless communications. It is to be appreciated that the modem processor described above may not be integrated into processor 1080.
Specifically, in this embodiment, the display unit of the terminal device is a touch screen display, the terminal device further includes a memory and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include steps for implementing the image compression method.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
All functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (11)

1. A method of picture compression, the method comprising:
acquiring a picture compression request aiming at a target picture, and generating a picture compression task corresponding to the picture compression request;
adding the picture compression task to a message queue;
and reading the picture compression task from the message queue and executing the picture compression task.
2. The method according to claim 1, wherein the obtaining of the picture compression request for the target picture and the generating of the picture compression task corresponding to the picture compression request comprise:
acquiring a picture compression request aiming at a target picture, and acquiring an original link of the target picture;
searching whether a compressed link corresponding to the original link exists in a cache;
if the compression link corresponding to the original link does not exist in the cache, returning the original link, and generating the picture compression task containing the original link.
3. The method of claim 2, further comprising:
and if the compressed link corresponding to the target original link exists in the cache, returning the compressed link.
4. The method of claim 2, wherein the searching for whether the compressed link corresponding to the original link exists in the cache comprises:
searching whether the original link exists in a blacklist;
if the original link does not exist in the blacklist, whether a compressed link corresponding to the original link exists or not is searched in a cache.
5. The method of claim 4, further comprising:
and if the original link exists in the blacklist, returning the original link.
6. The method of claim 4, wherein after the performing the picture compression task, further comprising:
generating a compression link corresponding to the target picture;
writing the compressed link to the cache.
7. The method according to claim 1, wherein when the picture compression task includes a plurality of tasks, the reading the picture compression task from the message queue and executing the picture compression task includes:
and reading a plurality of picture compression tasks from the message queue, respectively distributing each picture compression task to an idle thread in a thread pool, and controlling each idle thread to execute the picture compression tasks in parallel.
8. The method of claim 7, further comprising:
acquiring the write failure times of the compressed link;
and if the writing failure times exceed a time threshold, adding the original link into a blacklist.
9. An apparatus for compressing pictures, the apparatus comprising:
the task generating unit is used for acquiring a picture compression request aiming at a target picture and generating a picture compression task corresponding to the picture compression request;
the task adding unit is used for adding the picture compression task to a message queue;
and the picture compression unit is used for reading the picture compression task from the message queue and executing the picture compression task.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 8.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1-8 are implemented when the program is executed by the processor.
CN202010626661.0A 2020-07-02 2020-07-02 Picture compression method and device, storage medium and electronic equipment Pending CN111813574A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010626661.0A CN111813574A (en) 2020-07-02 2020-07-02 Picture compression method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010626661.0A CN111813574A (en) 2020-07-02 2020-07-02 Picture compression method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN111813574A true CN111813574A (en) 2020-10-23

Family

ID=72855837

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010626661.0A Pending CN111813574A (en) 2020-07-02 2020-07-02 Picture compression method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111813574A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114245173A (en) * 2021-12-17 2022-03-25 中国平安财产保险股份有限公司 Image compression method, device, terminal equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080095450A1 (en) * 2004-07-13 2008-04-24 Koninklijke Philips Electronics, N.V. Method of spatial and snr picture compression
CN104768079A (en) * 2014-01-03 2015-07-08 腾讯科技(深圳)有限公司 Method, device and system for distributing multimedia resources
CN105162863A (en) * 2015-09-01 2015-12-16 北京皮尔布莱尼软件有限公司 Picture uploading device and method and computing equipment
CN106534505A (en) * 2016-10-25 2017-03-22 Tcl集团股份有限公司 Picture sending method and device
CN106649377A (en) * 2015-11-02 2017-05-10 中兴通讯股份有限公司 Image processing system and method
CN109947722A (en) * 2019-02-13 2019-06-28 北京达佳互联信息技术有限公司 Data compression method, device and computer readable storage medium for application program

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080095450A1 (en) * 2004-07-13 2008-04-24 Koninklijke Philips Electronics, N.V. Method of spatial and snr picture compression
CN104768079A (en) * 2014-01-03 2015-07-08 腾讯科技(深圳)有限公司 Method, device and system for distributing multimedia resources
CN105162863A (en) * 2015-09-01 2015-12-16 北京皮尔布莱尼软件有限公司 Picture uploading device and method and computing equipment
CN106649377A (en) * 2015-11-02 2017-05-10 中兴通讯股份有限公司 Image processing system and method
CN106534505A (en) * 2016-10-25 2017-03-22 Tcl集团股份有限公司 Picture sending method and device
CN109947722A (en) * 2019-02-13 2019-06-28 北京达佳互联信息技术有限公司 Data compression method, device and computer readable storage medium for application program

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘军等: "《例说STM32(第3版)》", 28 February 2018 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114245173A (en) * 2021-12-17 2022-03-25 中国平安财产保险股份有限公司 Image compression method, device, terminal equipment and storage medium
CN114245173B (en) * 2021-12-17 2023-04-25 中国平安财产保险股份有限公司 Image compression method, device, terminal equipment and storage medium

Similar Documents

Publication Publication Date Title
US10437631B2 (en) Operating system hot-switching method and apparatus and mobile terminal
CN108512695B (en) Method and device for monitoring application blockage
US11868785B2 (en) Application program page processing method and device
CN109582472B (en) Micro-service processing method and device
US11803451B2 (en) Application exception recovery
CN112257135B (en) Model loading method and device based on multithreading, storage medium and terminal
EP3531290B1 (en) Data backup method, apparatus, electronic device, storage medium, and system
CN107832100B (en) APK plug-in loading method and terminal thereof
US20170201449A1 (en) Detecting patterns of events in information systems
US20220012085A1 (en) Memory management method and apparatus
CN106502703B (en) Function calling method and device
US7716522B2 (en) Information processing system and method for executing process during communication error
CN111767124B (en) Request response method, device, storage medium and electronic equipment
CN113592209A (en) Model training task management method, device, terminal and storage medium
CN107408073B (en) Reducing memory commit overhead using memory compression
CN113032099A (en) Cloud computing node, file management method and device
KR20210040864A (en) File directory traversal method, apparatus, device, and medium
CN116107922A (en) Application management method and electronic device
CN114327087A (en) Input event processing method and device, electronic equipment and storage medium
CN110765085A (en) Log information writing method, system, storage medium and mobile terminal
CN111813574A (en) Picture compression method and device, storage medium and electronic equipment
CN107818036B (en) Black screen detection method, mobile terminal and computer readable storage medium
CN111400072B (en) Interface calling method, storage medium and related equipment
CN113535368B (en) Task processing method and device and electronic equipment
CN114489826B (en) Chip operation method and device, storage medium and electronic equipment

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201023