Image data processing methods, apparatus, computer equipment, and storage media
By monitoring and calculating the memory usage of image loading, and combining compression and resizing, the problem of application memory overflow was solved, improving image loading speed and display effect, and enhancing user experience.
Patent Information
- Application Number
- CN202210717365.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-06-23
AI Technical Summary
When existing applications load a large number of images within a certain time interval, they are prone to memory overflow, resulting in slow image loading speed and display lag, which affects the user experience.
During application runtime, monitor image loading actions, intercept resource file information of target images, calculate the total memory usage for loading, and compare it with a preset memory threshold. If it is less than the threshold, display the image; otherwise, compress or resize it until the threshold requirement is met.
It effectively avoids memory overflow, improves image loading speed and display effect, enhances user experience, and ensures the normal operation of the application.
Smart Images

Figure CN114995914B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to methods, apparatus, computer equipment and storage media for processing image data. Background Technology
[0002] The mobile internet industry is inseparable from applications. Each application has a different application scenario, and only applications that can provide a good user experience can effectively avoid user complaints.
[0003] Image loading is a common interaction in modern applications, and it consumes application memory resources. When operators upload images for an application, if the application needs to load a large number of images within a certain time interval, the memory consumed by the images may exceed the terminal's remaining available memory, leading to a memory overflow fault. This, in turn, results in slow image loading speeds and display stuttering, leading to a poor user experience. Summary of the Invention
[0004] The purpose of this application is to provide a method, apparatus, computer device, and storage medium for processing image data, so as to solve the technical problem that existing applications are prone to memory overflow when they need to load a large number of images within a certain time interval, which in turn causes slow image loading speed and display lag.
[0005] To address the aforementioned technical problems, this application provides a method for processing image data, employing the following technical solution:
[0006] During the application's operation, the loading of target images within a preset time period is monitored;
[0007] If loading of a target image is detected within the preset time period, the loading of the target image is intercepted, and the resource file information of the target image is obtained; wherein, the resource file information includes at least file size, pixel width, pixel height, file type, and frame number, and the number of target images includes multiple images;
[0008] Based on the resource file information, a preset memory usage algorithm is invoked to calculate and generate the total memory usage corresponding to the target image.
[0009] The total memory used by loading is compared with a preset memory threshold to determine whether the total memory used by loading is less than the preset memory threshold.
[0010] If the total memory usage of the loading is less than the preset memory threshold, the target image will be displayed within the application.
[0011] Furthermore, the file type includes static resource type and dynamic resource type. The step of calculating the total memory usage corresponding to the target image by calling a preset memory usage algorithm based on the resource file information specifically includes:
[0012] Obtain the file type of each target image from the resource file information;
[0013] Based on the file types of all the target images, all the target images are divided into a first set of images whose file types belong only to the static resource type, and a second set of images whose file types belong only to the dynamic resource type;
[0014] Based on the file size, pixel width, and pixel height of all first images contained in the first image set, the first memory usage algorithm corresponding to the static resource type is called to calculate the first loading memory usage of each first image.
[0015] Based on the file size, pixel width, pixel height, and frame count of all second images contained in the second image set, the second memory usage algorithm corresponding to the dynamic resource type is called to calculate the second loading memory usage of each second image;
[0016] Based on all the first loading memory usage and all the second loading memory usage, calculate and generate the total loading memory usage corresponding to all the target images.
[0017] Furthermore, after the step of comparing the total memory usage of loading with a preset memory threshold to determine whether the total memory usage of loading is less than the preset memory threshold, the method further includes:
[0018] If the total memory occupied by the loading is not less than the preset memory threshold, obtain the screen resolution of the terminal corresponding to the application;
[0019] Based on the screen resolution of the terminal, the resource file information, the total amount of memory occupied during loading, and the preset memory threshold, the target image is compressed so that the total amount of memory occupied during loading of the specified target image after compression is less than the preset memory threshold, and the resolution of the specified target image is less than the screen resolution of the terminal.
[0020] The specified target image is loaded into the memory of the terminal so that the specified target image can be invoked and displayed by the application within the terminal.
[0021] Furthermore, after the step of compressing the target image based on the terminal's screen resolution, the resource file information, the total memory occupied during loading, and the preset memory threshold, the method further includes:
[0022] Obtain the first size of the control used to display the image in the application, and obtain the second size of each specified target image;
[0023] The first dimension is matched with each of the second dimensions to determine whether there is a third dimension among all the second dimensions that is different from the first dimension;
[0024] If so, the image corresponding to the third size in the specified target image is resized so that the size of the resized specified target image is equal to the first size;
[0025] The step of loading the specified target image into the memory of the terminal, so as to call and display the specified target image through the application within the terminal, specifically includes:
[0026] The adjusted target image is loaded into the memory of the terminal so that it can be invoked and displayed by the application within the terminal.
[0027] Furthermore, after the step of loading the specified target image into the memory of the terminal so as to call and display the specified target image through the application within the terminal, the method further includes:
[0028] Obtain the amount of data stored in the terminal's memory, and obtain a preset capacity threshold;
[0029] Determine whether the amount of data has reached the capacity threshold;
[0030] If so, the images in the terminal's memory are cleaned up based on a preset image cleaning mechanism.
[0031] Furthermore, after the step of obtaining the image to be checked for plagiarism, the following steps are also included:
[0032] After the step of comparing the total memory usage of loading with a preset memory threshold to determine whether the total memory usage of loading is less than the preset memory threshold, the method further includes:
[0033] If the total memory occupied by the loading is not less than the preset memory threshold, then the image identification information of the target image is obtained;
[0034] Generate corresponding early warning information based on the image identification information;
[0035] Obtain the target user's communication address;
[0036] The warning information is sent to the communication address.
[0037] Furthermore, the image data processing method also includes:
[0038] Obtain the available memory of the terminal corresponding to the application;
[0039] Determine whether the available memory is less than a preset available memory threshold;
[0040] If so, generate a corresponding memory cleanup reminder message based on the available memory threshold;
[0041] The memory cleanup reminder message is displayed.
[0042] To address the aforementioned technical problems, this application also provides an image data processing apparatus, which employs the following technical solution:
[0043] The monitoring module is used to monitor the loading of target images within a preset time period during the operation of the application.
[0044] The interception module is used to intercept the loading action of the target image if the loading action of the target image is detected within the preset time period, and to obtain the resource file information of the target image; wherein, the resource file information includes at least the file size, pixel width, pixel height, file type and frame number, and the number of target images includes multiple images;
[0045] The first generation module is used to calculate the total amount of memory occupied for loading corresponding to the target image based on the resource file information by calling a preset memory usage algorithm.
[0046] The comparison module is used to compare the total memory occupied by loading with a preset memory threshold to determine whether the total memory occupied by loading is less than the preset memory threshold.
[0047] The first display module is used to display the target image within the application if the total memory occupied by the loading is less than the preset memory threshold.
[0048] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution:
[0049] During the application's operation, the loading of target images within a preset time period is monitored;
[0050] If loading of a target image is detected within the preset time period, the loading of the target image is intercepted, and the resource file information of the target image is obtained; wherein, the resource file information includes at least file size, pixel width, pixel height, file type, and frame number, and the number of target images includes multiple images;
[0051] Based on the resource file information, a preset memory usage algorithm is invoked to calculate and generate the total memory usage corresponding to the target image.
[0052] The total memory used by loading is compared with a preset memory threshold to determine whether the total memory used by loading is less than the preset memory threshold.
[0053] If the total memory usage of the loading is less than the preset memory threshold, the target image will be displayed within the application.
[0054] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below:
[0055] During the application's operation, the loading of target images within a preset time period is monitored;
[0056] If loading of a target image is detected within the preset time period, the loading of the target image is intercepted, and the resource file information of the target image is obtained; wherein, the resource file information includes at least file size, pixel width, pixel height, file type, and frame number, and the number of target images includes multiple images;
[0057] Based on the resource file information, a preset memory usage algorithm is invoked to calculate and generate the total memory usage corresponding to the target image.
[0058] The total memory used by loading is compared with a preset memory threshold to determine whether the total memory used by loading is less than the preset memory threshold.
[0059] If the total memory usage of the loading is less than the preset memory threshold, the target image will be displayed within the application.
[0060] Compared with the prior art, the embodiments of this application have the following main advantages:
[0061] In this embodiment of the application, if the loading action of a target image is detected within a preset time period during the application's operation, the loading action of the target image will be intercepted first, and the resource file information of the target image will be obtained. Then, based on the resource file information, a preset memory usage algorithm will be called to calculate the total memory usage corresponding to the target image. The total memory usage will then be compared with a preset memory threshold to determine if the total memory usage is less than the preset memory threshold. If the total memory usage is less than the preset memory threshold, the target image will be displayed within the application. This application calculates the total memory usage corresponding to the target image before displaying it in the application, compares the total memory usage with a preset memory threshold, and then processes the target image accordingly based on the comparison result. Only when the total memory usage is less than the preset memory threshold will the target image be displayed. This effectively avoids memory overflow faults, slow image loading speeds, and display lag, ensuring the normal operation of the application, improving the intelligence of image processing, and enhancing the user experience. Attached Figure Description
[0062] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0063] Figure 1 This is an exemplary system architecture diagram to which this application can be applied;
[0064] Figure 2 A flowchart of an embodiment of the image data processing method according to this application;
[0065] Figure 3 This is a schematic diagram of the structure of an embodiment of the image data processing apparatus according to this application;
[0066] Figure 4 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation
[0067] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0068] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0069] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0070] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0071] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0072] Terminal devices 101, 102, and 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, and desktop computers, etc.
[0073] Server 105 can be a server that provides various services, such as a backend server that supports the pages displayed on terminal devices 101, 102, and 103.
[0074] It should be noted that the image data processing method provided in the embodiments of this application is generally executed by a server / terminal device, and correspondingly, the image data processing device is generally located in the server / terminal device.
[0075] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0076] Continue to refer Figure 2 A flowchart illustrating an embodiment of the image data processing method according to this application is shown. The image data processing method includes the following steps:
[0077] Step S201: During the operation of the application, the loading action of the target image within a preset time period is monitored.
[0078] In this embodiment, the image data processing method runs on an electronic device (e.g., Figure 1 (The server / terminal device shown). It should be noted that the above wireless connection methods may include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra wideband) connections, and other currently known or future wireless connection methods.
[0079] In this embodiment, during actual application, multiple applications may be installed on the terminal. When any application on the terminal calls the image to be loaded, the image needs to be loaded into the terminal's memory first, and then displayed in the application's control. The target image is the image to be loaded, which can be an image stored on the terminal or an image from the network. Furthermore, the value of the preset time period is not specifically limited and can be set according to actual needs; for example, it can be set to 1 minute.
[0080] Step S202: If the loading action of the target image is detected within the preset time period, the loading action of the target image is intercepted, and the resource file information of the target image is obtained; wherein, the resource file information includes at least the file size, pixel width, pixel height, file type and frame number, and the number of target images includes multiple images.
[0081] In this embodiment, a hook mechanism can be used to intercept the loading action and execute the processing flow for obtaining resource file information of the target image. The hook mechanism, also known as a Hook, can intercept and monitor event transmission during the event delivery process, integrating its own code with system methods. Thus, when these system methods are called, its own code is executed to implement the corresponding image data processing method.
[0082] Step S203: Based on the resource file information, a preset memory usage algorithm is called to calculate and generate the total memory usage corresponding to the target image.
[0083] In this embodiment, the file types include static resource types and dynamic resource types. The aforementioned memory usage algorithm includes a first memory usage algorithm corresponding to static resource types and a second memory usage algorithm corresponding to dynamic resource types. Furthermore, the specific implementation process of calculating the total memory usage corresponding to the target image based on the resource file information using the preset memory usage algorithm will be described in further detail in subsequent embodiments of this application, and will not be elaborated upon here.
[0084] Step S204: Compare the total amount of memory occupied by loading with a preset memory threshold to determine whether the total amount of memory occupied by loading is less than the preset memory threshold.
[0085] In this embodiment, the value of the preset memory threshold is not specifically limited and can be set according to actual usage needs. Preferably, the current remaining memory of the terminal can be used as the preset memory threshold.
[0086] Step S205: If the total memory occupied by the loading is less than the preset memory threshold, then the target image is displayed in the application.
[0087] In this embodiment, the process of displaying the target image within the application may include: first loading the target image into the terminal's memory, and then calling and displaying the target image in the application's controls.
[0088] This application, during application execution, if the loading of a target image is detected within a preset time period, will first intercept the loading action and obtain the resource file information of the target image. Then, based on the resource file information, a preset memory usage algorithm is called to calculate the total memory usage corresponding to the target image. This total memory usage is then compared with a preset memory threshold to determine if it is less than the threshold. If the total memory usage is less than the threshold, the target image is displayed within the application. This application calculates the total memory usage corresponding to the target image before displaying it, compares it with a preset memory threshold, and then processes the target image accordingly based on the comparison result. Only when the total memory usage is less than the preset threshold will the target image be displayed, effectively avoiding memory overflow faults, slow image loading speeds, and display stuttering. This helps ensure the normal operation of the application, improves the intelligence of image processing, and enhances the user experience.
[0089] In some optional implementations, the file type includes static resource type and dynamic resource type, and step S203 includes the following steps:
[0090] The file type of each target image is obtained from the resource file information.
[0091] In this embodiment, the file type of each target image can be obtained from its resource file information. Target images can be static images, such as PNG, JPG, or WebP files, or they can be animated images, such as GIFs.
[0092] Based on the file types of all the target images, all the target images are divided into a first set of images whose file types belong only to the static resource type, and a second set of images whose file types belong only to the dynamic resource type.
[0093] In this embodiment, the first image set only stores the first image that belongs to the static resource type within the target image, and the second image set only stores the second image that belongs to the dynamic resource type within the target image.
[0094] Based on the file size, pixel width, and pixel height of all first images contained in the first image set, the first memory usage of each first image is calculated by calling the first memory usage algorithm corresponding to the static resource type.
[0095] In this embodiment, the first memory usage algorithm is specifically as follows: the first memory usage of the first image = the file size of the first image (K) * the pixel width of the first image * the pixel height of the first image * 4.
[0096] Based on the file size, pixel width, pixel height, and frame count of all second images contained in the second image set, the second memory usage algorithm corresponding to the dynamic resource type is called to calculate the second loading memory usage of each second image.
[0097] In this embodiment, the second memory usage algorithm is as follows: the second memory usage of the second image = the file size of the second image (K) * the pixel width of the second image * the pixel height of the second image * 4 * the number of frames of the second image.
[0098] Based on all the first loading memory usage and all the second loading memory usage, calculate and generate the total loading memory usage corresponding to all the target images.
[0099] In this embodiment, the sum of all first loading memory usages and all second loading memory usages can be calculated, and then the sum can be used as the total loading memory usage for all target images.
[0100] For target images belonging to different file types, this application employs a memory usage algorithm corresponding to the file type to quickly and accurately calculate the memory usage of each target image. Based on the obtained memory usage of each target image, the total memory usage can be quickly calculated. This allows for subsequent comparison of the total memory usage with a preset memory threshold, enabling corresponding processing of all target images based on the comparison results. This helps avoid memory overflow and effectively improves the intelligence of target image processing.
[0101] In some optional implementations of this embodiment, after step S204, the electronic device may further perform the following steps:
[0102] If the total memory occupied by the loading is not less than the preset memory threshold, obtain the screen resolution of the terminal corresponding to the application.
[0103] In this embodiment, a preset data acquisition instruction can be executed to obtain the screen resolution of the terminal corresponding to the application.
[0104] Based on the screen resolution of the terminal, the resource file information, the total amount of memory occupied during loading, and the preset memory threshold, the target image is compressed so that the total amount of memory occupied during loading of the specified target image after compression is less than the preset memory threshold, and the resolution of the specified target image is less than the screen resolution of the terminal.
[0105] In this embodiment, the value of the aforementioned preset memory threshold is not specifically limited and can be set according to actual usage needs. Preferably, the current remaining memory of the terminal can be used as the preset memory threshold. Furthermore, the specified target image obtained after compression simultaneously satisfies two conditions: its resolution is less than the terminal's screen resolution, and the total memory occupied by the specified target image during loading is less than the preset memory threshold. This not only avoids the memory overflow problem caused when the specified target image only satisfies a resolution less than the terminal's screen resolution but the total memory occupied during loading exceeds the preset memory threshold, but also avoids the problem of the terminal recompressing the image before loading it into memory based on the resolution of the image to be loaded and the terminal's resolution, thus wasting memory, when the specified target image only satisfies a total memory occupied during loading is less than the preset memory threshold but its resolution is greater than or equal to the terminal's screen resolution.
[0106] The specified target image is loaded into the memory of the terminal so that the specified target image can be invoked and displayed by the application within the terminal.
[0107] After detecting that the total memory occupied by the target image is not less than a preset memory threshold, this application intelligently compresses the target image to make its resolution smaller than the terminal's screen resolution, and the total memory occupied by the target image is less than the preset memory threshold. This avoids memory overflow failures while the application loads the target image, preventing further compression and memory waste, and ensuring that the application can run normally during the loading of the target image, thus improving the intelligence of the application's image loading.
[0108] In some optional implementations, after the steps described above for compressing the target image based on the terminal's screen resolution, the resource file information, the total memory usage, and the preset memory threshold, the electronic device may further perform the following steps:
[0109] Obtain the first size of the control used to display the image in the application, and obtain the second size of each specified target image.
[0110] In this embodiment, the first size of the control refers to the length and width of the control, and the size of the specified target image refers to the length and width of the specified target image.
[0111] The first dimension is matched with each of the second dimensions to determine whether there is a third dimension among all the second dimensions that is different from the first dimension.
[0112] In this embodiment, if the second size of the specified target image is different from the first size of the control, it will affect the display effect of the specified target image when it is displayed in the control, such as stretching or other abnormalities, which will affect the user's image viewing experience.
[0113] If so, the image corresponding to the third size in the specified target image is resized so that the size of the resized specified target image is equal to the first size.
[0114] The step of loading the specified target image into the memory of the terminal, so as to call and display the specified target image through the application within the terminal, specifically includes:
[0115] The adjusted target image is loaded into the memory of the terminal so that it can be invoked and displayed by the application within the terminal.
[0116] Before loading the specified target image into the terminal's memory, this application intelligently adjusts the size of any images in the specified target image that are inconsistent with the size of the control, so that the size of the specified target image after size adjustment is equal to the size of the control used to display the image. This improves the display effect of the image in the control, effectively enhances the intelligence of image display, and improves the user experience.
[0117] In some alternative implementations, after the step of loading the specified target image into the memory of the terminal so as to call and display the specified target image through the application within the terminal, the electronic device may further perform the following steps:
[0118] The amount of data stored in the terminal's memory is obtained, as well as a preset capacity threshold.
[0119] In this embodiment, the value of the aforementioned capacity threshold is not specifically limited and can be set according to actual usage needs. Preferably, there is a certain difference between the capacity threshold and the upper limit of memory storage capacity. This difference can prevent the situation where the storage capacity reaches the upper limit and the image cannot be loaded.
[0120] Determine whether the amount of data has reached the capacity threshold.
[0121] If so, the images in the terminal's memory are cleaned up based on a preset image cleaning mechanism.
[0122] In this embodiment, a pre-set image cleanup mechanism cleans up images in the terminal's memory as needed. Memory has a limited storage space; when the memory usage reaches a certain limit, slow loading, inability to load new images, and loss of image retention can occur. Therefore, a cleanup mechanism is implemented. Specifically, the cache cleanup mechanism works as follows: images in memory are cleaned when at least one or a combination of the following conditions are met: cleanup is performed when the user instructs it, and the processor performs cache cleanup and removes redundant images based on the user's request; cleanup is performed when the image cache or time reaches a predetermined period; cleanup is performed when the image access frequency is below a certain frequency threshold, and so on.
[0123] This application obtains the amount of data stored in the terminal's memory and a preset capacity threshold. If the obtained data amount reaches the capacity threshold, it will intelligently clean up the images in the terminal's memory based on a preset image cleaning mechanism, thereby effectively reducing the waste of space in the terminal's memory and improving the intelligence of memory data storage.
[0124] In some optional implementations of this embodiment, after step S204, the electronic device may further perform the following steps:
[0125] If the total memory occupied by the loading is not less than the preset memory threshold, then the image identification information of the target image is obtained.
[0126] In this embodiment, the identifier of the target image can be retrieved from the resource file of the target image, and this identifier can be used as the image identification information of the target image.
[0127] Based on the image identification information, a corresponding warning message is generated.
[0128] In this embodiment, image identification information can be input into a pre-created warning information template to generate warning information corresponding to the target image. Furthermore, the aforementioned warning information template can be written and generated according to actual usage requirements.
[0129] Obtain the target user's communication address.
[0130] In this embodiment, the target user can be an administrator responsible for the operation of the application's interface. Additionally, the aforementioned communication address can be an email address.
[0131] The warning information is sent to the communication address.
[0132] In this embodiment, if the communication address is an email address, the warning information can be sent to the target user's communication address by logging into the email server and then using the email server.
[0133] When this application detects that the total memory usage of the loaded image is not less than a preset memory threshold, it will not directly display the target image. Instead, it will generate a warning message corresponding to the target image and send it to the target user. This allows the target user to be aware that the target image to be displayed is using too much memory and to make timely adjustments to the target image, thus improving the user experience.
[0134] In some optional implementations of this embodiment, the electronic device may further include the following steps:
[0135] Obtain the available memory of the terminal corresponding to the application.
[0136] In this embodiment, the available memory of the terminal refers to the remaining memory currently available to the terminal.
[0137] Determine whether the available memory is less than a preset available memory threshold.
[0138] In this embodiment, the value of the available memory threshold is not specifically limited and can be set according to actual usage needs. Specifically, if the terminal's current available memory is greater than the available memory threshold, it indicates that the terminal can currently run normally; conversely, if the terminal's current available memory is less than the available memory threshold, it indicates that the terminal is prone to stuttering or other abnormal phenomena.
[0139] If so, generate a corresponding memory cleanup reminder message based on the available memory threshold.
[0140] In this embodiment, a memory cleanup reminder message is generated to remind the user to clean up the terminal's memory and ensure that the cleaned memory is less than the available memory threshold.
[0141] The memory cleanup reminder message is displayed.
[0142] In this embodiment, memory cleanup reminder information can be displayed on the current display interface of the terminal.
[0143] When this application detects that the available memory of the terminal corresponding to the application is less than a preset available memory threshold, it will intelligently generate and display a corresponding memory cleanup reminder based on the available memory threshold to remind the user to clean up the terminal's memory, thereby ensuring the normal operation of the terminal and protecting the user experience.
[0144] It should be emphasized that, to further ensure the privacy and security of the total memory usage of the aforementioned loading process, the total memory usage can also be stored in a blockchain node.
[0145] The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0146] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0147] Foundational technologies in artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0148] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware with computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When executed, the program can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0149] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0150] Further reference Figure 3 As a response to the above Figure 2 To implement the method shown, this application provides an embodiment of an image data processing apparatus, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0151] like Figure 3 As shown, the image data processing device 300 described in this embodiment includes: a monitoring module 301, an interception module 302, a first generation module 303, a comparison module 304, and a first display module 305. Wherein:
[0152] The monitoring module 301 is used to monitor the loading action of the target image within a preset time period during the operation of the application.
[0153] The interception module 302 is used to intercept the loading action of the target image if the loading action of the target image is detected within the preset time period, and to obtain the resource file information of the target image; wherein, the resource file information includes at least the file size, pixel width, pixel height, file type and frame number, and the number of target images includes multiple images;
[0154] The first generation module 303 is used to calculate the total amount of memory occupied for loading corresponding to the target image based on the resource file information by calling a preset memory usage algorithm.
[0155] Comparison module 304 is used to compare the total memory occupied by loading with a preset memory threshold, and determine whether the total memory occupied by loading is less than the preset memory threshold;
[0156] The first display module 305 is used to display the target image within the application if the total memory occupied by the loading is less than the preset memory threshold.
[0157] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0158] In some optional implementations of this embodiment, the file type includes static resource type and dynamic resource type, and the first generation module 303 includes:
[0159] The first acquisition submodule is used to obtain the file type of each target image from the resource file information;
[0160] The partitioning submodule is used to partition all the target images into a first set of images whose file types belong only to the static resource type, and a second set of images whose file types belong only to the dynamic resource type, based on the file types of all the target images.
[0161] The first calculation submodule is used to calculate the first loading memory usage of each first image based on the file size, pixel width and pixel height of all first images contained in the first image set, by calling the first memory usage algorithm corresponding to the static resource type.
[0162] The second calculation submodule is used to calculate the second loading memory usage of each second image based on the file size, pixel width, pixel height and frame number of all second images contained in the second image set, by calling the second memory usage algorithm corresponding to the dynamic resource type.
[0163] The generation submodule is used to calculate the total memory usage of all the target images based on the memory usage of all the first loading and all the memory usage of the second loading.
[0164] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0165] In some optional implementations of this embodiment, the image data processing device further includes:
[0166] The first acquisition module is used to acquire the screen resolution of the terminal corresponding to the application if the total memory occupied by the loading is not less than the preset memory threshold.
[0167] A compression module is used to compress the target image based on the screen resolution of the terminal, the resource file information, the total amount of memory occupied during loading, and the preset memory threshold, so that the total amount of memory occupied during loading of the specified target image after compression is less than the preset memory threshold, and the resolution of the specified target image is less than the screen resolution of the terminal.
[0168] A loading module is used to load the specified target image into the memory of the terminal, so that the specified target image can be called and displayed by the application within the terminal.
[0169] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0170] In some optional implementations of this embodiment, the image data processing apparatus further includes:
[0171] The second acquisition module is used to acquire the first size of the control used to display the image in the application, and to acquire the second size of each specified target image;
[0172] The first judgment module is used to match the first size with each of the second sizes and determine whether there is a third size among all the second sizes that is different from the first size;
[0173] An adjustment module is used to, if so, perform size adjustment processing on the image in the specified target image that corresponds to the third size, so that the size of the adjusted specified target image is equal to the first size;
[0174] The loading module specifically includes:
[0175] This is used to load the adjusted target image into the memory of the terminal, so that the adjusted target image can be called and displayed by the application within the terminal.
[0176] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0177] In some optional implementations of this embodiment, the image data processing apparatus further includes:
[0178] The third acquisition module is used to acquire the amount of data stored in the memory of the terminal and to acquire a preset capacity threshold.
[0179] The second judgment module is used to determine whether the amount of data has reached the capacity threshold.
[0180] The cleaning module is used to clean up the images in the terminal's memory based on a preset image cleaning mechanism, if applicable.
[0181] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0182] In some optional implementations of this embodiment, the image data processing apparatus further includes:
[0183] The fourth acquisition module is used to acquire the image identification information of the target image if the total memory occupied by the loading is not less than the preset memory threshold.
[0184] The second generation module is used to generate corresponding early warning information based on the image identification information;
[0185] The fifth acquisition module is used to acquire the target user's communication address;
[0186] The sending module is used to send the warning information to the communication address.
[0187] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0188] In some optional implementations of this embodiment, the image data processing apparatus further includes:
[0189] The sixth acquisition module is used to acquire the available memory of the terminal corresponding to the application.
[0190] The third judgment module is used to determine whether the available memory is less than a preset available memory threshold;
[0191] The third generation module is used to generate corresponding memory cleanup reminder information based on the available memory threshold if the condition is met.
[0192] The second display module is used to display the memory cleanup reminder information.
[0193] In this embodiment, the operations performed by the above-mentioned modules or units correspond one-to-one with the steps of the image data processing method in the aforementioned embodiments, and will not be repeated here.
[0194] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0195] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected via a system bus. It should be noted that only the computer device 4 with components 41-43 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0196] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0197] The memory 41 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 4. Of course, the memory 41 may include both the internal storage unit and its external storage device of the computer device 4. In this embodiment, the memory 41 is typically used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for image data processing methods. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or will be output.
[0198] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to execute computer-readable instructions stored in the memory 41 or to process data, such as computer-readable instructions for executing a method for processing the image data.
[0199] The network interface 43 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 4 and other electronic devices.
[0200] Compared with the prior art, the embodiments of this application have the following main advantages:
[0201] In this embodiment, during the application's operation, if the loading action of a target image is detected within a preset time period, the loading action is intercepted, and the resource file information of the target image is obtained. Then, based on the resource file information, a preset memory usage algorithm is called to calculate the total memory usage corresponding to the target image. The total memory usage is then compared with a preset memory threshold to determine if it is less than the threshold. If the total memory usage is less than the threshold, the target image is displayed within the application. This application calculates the total memory usage corresponding to the target image before displaying it, compares it with a preset memory threshold, and then processes the target image accordingly based on the comparison result. Only when the total memory usage is less than the preset threshold will the target image be displayed, effectively avoiding memory overflow faults, slow image loading speeds, and display lag. This helps ensure the normal operation of the application, improves the intelligence of image processing, and enhances the user experience.
[0202] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the image data processing method described above.
[0203] Compared with the prior art, the embodiments of this application have the following main advantages:
[0204] In this embodiment, during the application's operation, if the loading action of a target image is detected within a preset time period, the loading action is intercepted, and the resource file information of the target image is obtained. Then, based on the resource file information, a preset memory usage algorithm is called to calculate the total memory usage corresponding to the target image. The total memory usage is then compared with a preset memory threshold to determine if it is less than the threshold. If the total memory usage is less than the threshold, the target image is displayed within the application. This application calculates the total memory usage corresponding to the target image before displaying it, compares it with a preset memory threshold, and then processes the target image accordingly based on the comparison result. Only when the total memory usage is less than the preset threshold will the target image be displayed, effectively avoiding memory overflow faults, slow image loading speeds, and display lag. This helps ensure the normal operation of the application, improves the intelligence of image processing, and enhances the user experience.
[0205] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0206] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A method for processing image data, characterized in that, Includes the following steps: During the application's operation, the loading of target images within a preset time period is monitored; If loading of a target image is detected within the preset time period, the loading of the target image is intercepted, and the resource file information of the target image is obtained; wherein, the resource file information includes at least file size, pixel width, pixel height, file type, and frame number, and the number of target images includes multiple images; Based on the resource file information, a preset memory usage algorithm is invoked to calculate and generate the total memory usage corresponding to the target image. The total memory used by loading is compared with a preset memory threshold to determine whether the total memory used by loading is less than the preset memory threshold. If the total memory usage of the loading is less than the preset memory threshold, then the target image is displayed within the application. The file types include static resource types and dynamic resource types. The step of calculating the total memory usage corresponding to the target image by calling a preset memory usage algorithm based on the resource file information specifically includes: Obtain the file type of each target image from the resource file information; Based on the file types of all the target images, all the target images are divided into a first set of images whose file types belong only to the static resource type, and a second set of images whose file types belong only to the dynamic resource type; Based on the file size, pixel width, and pixel height of all first images contained in the first image set, the first memory usage algorithm corresponding to the static resource type is called to calculate the first loading memory usage of each first image. Based on the file size, pixel width, pixel height, and frame count of all second images contained in the second image set, the second memory usage algorithm corresponding to the dynamic resource type is called to calculate the second loading memory usage of each second image; Based on all the first loading memory usage and all the second loading memory usage, calculate and generate the total loading memory usage corresponding to all the target images; The first memory usage algorithm is as follows: the first memory usage of the first image = the file size of the first image (K) * the pixel width of the first image * the pixel height of the first image * 4; the second memory usage algorithm is as follows: the second memory usage of the second image = the file size of the second image (K) * the pixel width of the second image * the pixel height of the second image * 4 * the number of frames of the second image.
2. The image data processing method according to claim 1, characterized in that, After the step of comparing the total memory usage of loading with a preset memory threshold to determine whether the total memory usage of loading is less than the preset memory threshold, the method further includes: If the total memory occupied by the loading is not less than the preset memory threshold, obtain the screen resolution of the terminal corresponding to the application; Based on the screen resolution of the terminal, the resource file information, the total amount of memory occupied during loading, and the preset memory threshold, the target image is compressed so that the total amount of memory occupied during loading of the specified target image after compression is less than the preset memory threshold, and the resolution of the specified target image is less than the screen resolution of the terminal. The specified target image is loaded into the memory of the terminal so that the specified target image can be invoked and displayed by the application within the terminal.
3. The image data processing method according to claim 2, characterized in that, After the step of compressing the target image based on the terminal's screen resolution, the resource file information, the total memory usage, and the preset memory threshold, the method further includes: Obtain the first size of the control used to display the image in the application, and obtain the second size of each specified target image; The first dimension is matched with each of the second dimensions to determine whether there is a third dimension among all the second dimensions that is different from the first dimension; If so, the image corresponding to the third size in the specified target image is resized so that the size of the resized specified target image is equal to the first size; The step of loading the specified target image into the memory of the terminal, so as to call and display the specified target image through the application within the terminal, specifically includes: The adjusted target image is loaded into the memory of the terminal so that it can be invoked and displayed by the application within the terminal.
4. The image data processing method according to claim 2, characterized in that, After the step of loading the specified target image into the memory of the terminal so that the application within the terminal can call and display the specified target image, the method further includes: Obtain the amount of data stored in the terminal's memory, and obtain a preset capacity threshold; Determine whether the amount of data has reached the capacity threshold; If so, the images in the terminal's memory are cleaned up based on a preset image cleaning mechanism.
5. The image data processing method according to claim 1, characterized in that, After the step of comparing the total memory usage of loading with a preset memory threshold to determine whether the total memory usage of loading is less than the preset memory threshold, the method further includes: If the total memory occupied by the loading is not less than the preset memory threshold, then the image identification information of the target image is obtained; Generate corresponding early warning information based on the image identification information; Obtain the target user's communication address; The warning information is sent to the communication address.
6. The image data processing method according to claim 1, characterized in that, The image data processing method further includes: Obtain the available memory of the terminal corresponding to the application; Determine whether the available memory is less than a preset available memory threshold; If so, generate a corresponding memory cleanup reminder message based on the available memory threshold; The memory cleanup reminder message is displayed.
7. An image data processing apparatus, characterized in that, include: The monitoring module is used to monitor the loading of target images within a preset time period during the operation of the application. The interception module is used to intercept the loading action of the target image if the loading action of the target image is detected within the preset time period, and to obtain the resource file information of the target image; wherein, the resource file information includes at least the file size, pixel width, pixel height, file type and frame number, and the number of target images includes multiple images; The first generation module is used to calculate the total amount of memory occupied for loading corresponding to the target image based on the resource file information by calling a preset memory usage algorithm. The comparison module is used to compare the total memory occupied by loading with a preset memory threshold to determine whether the total memory occupied by loading is less than the preset memory threshold. The first display module is used to display the target image within the application if the total memory occupied by the loading is less than the preset memory threshold. The file types include static resource types and dynamic resource types, and the first generation module includes: The first acquisition submodule is used to obtain the file type of each target image from the resource file information; The partitioning submodule is used to partition all the target images into a first set of images whose file types belong only to the static resource type, and a second set of images whose file types belong only to the dynamic resource type, based on the file types of all the target images. The first calculation submodule is used to calculate the first loading memory usage of each first image based on the file size, pixel width and pixel height of all first images contained in the first image set, by calling the first memory usage algorithm corresponding to the static resource type. The second calculation submodule is used to calculate the second loading memory usage of each second image based on the file size, pixel width, pixel height and frame number of all second images contained in the second image set, by calling the second memory usage algorithm corresponding to the dynamic resource type. A generation submodule is used to calculate the total amount of memory occupied by loading for all the target images based on all the first loading memory occupancy amounts and all the second loading memory occupancy amounts. The first memory usage algorithm is as follows: the first memory usage of the first image = the file size of the first image (K) * the pixel width of the first image * the pixel height of the first image * 4; the second memory usage algorithm is as follows: the second memory usage of the second image = the file size of the second image (K) * the pixel width of the second image * the pixel height of the second image * 4 * the number of frames of the second image.
8. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor, when executing the computer-readable instructions, implements the steps of the method for processing image data as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the image data processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for operating application program
CN105824673A
Picture monitoring method and device, electronic equipment and storage medium
CN112199250A
Data loading method and device, computer equipment and storage medium
CN114116231A