A method, system, computer device, and media for optimizing application installation package size.
By analyzing the loading frequency of images in the app package and saving low-frequency images to the cloud, the problem of users downloading excessively large application installation packages was solved, thus improving the user experience.
Patent Information
- Application Number
- CN202210893714.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-27
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-07-27
AI Technical Summary
In existing technologies, the large size of application installation packages leads to concerns about data usage and download time for users, and traditional optimization methods negatively impact user experience.
By searching for resource information of all images in the APP package, collecting image loading frequency within a preset period, determining the image sequence to be optimized, and saving low-frequency images to the cloud, an optimized APP package is generated.
While reducing the app's package size, we ensure that frequently used images load quickly, thus improving the user experience.
Smart Images

Figure CN115098160B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to an application program installation package size optimization method and system, computer equipment and medium. BACKGROUND
[0002] The application program (APP) package is the code file data of the software system. With the continuous expansion of the business system, the APP needs continuous iteration and update. In the update process, engineers add user-friendly picture resources to the APP for better visual effect, which will cause the APP package size to increase continuously. The large package size will make users worry about traffic or time and choose to give up APP download. Therefore, how to reduce the APP package size and protect normal download of users is a problem that needs to be solved urgently.
[0003] In the prior art, in order to reduce the APP package size, engineers manually search and merge redundant pictures before APP packaging. Since the APP package often contains thousands of pictures of different sizes and styles, the manual merging method is time-consuming and laborious, or the traditional package size optimization based on pictures is to put as many pictures as possible into the cloud. At this time, in the case of slow network speed, the frequently displayed pictures cannot be displayed to the user in time, which will reduce the display speed of the APP page and affect the user experience. SUMMARY
[0004] Therefore, it is necessary to provide an application program installation package size optimization method and system, computer equipment and medium to solve the problem of reducing the display speed of the APP page.
[0005] An application program installation package size optimization method, the method comprising: searching resource information of all pictures in a to-be-optimized APP package; collecting target picture names reported by the to-be-optimized APP package in a running environment within a preset period, and determining a loading frequency of each target picture name according to the reported target picture names; determining a to-be-optimized picture sequence according to the loading frequency of each target picture name and the resource information of all pictures; and performing optimization processing on the to-be-optimized picture sequence to generate an optimized APP package.
[0006] In one embodiment, before obtaining the to-be-optimized APP package, the method further comprises: loading the to-be-optimized APP package; determining a picture resource loading script in the to-be-optimized APP package; setting a picture name reporting instruction for the picture resource loading script to report the loaded picture name when the picture resource loading script loads the picture; and running the picture resource loading script with the set picture name reporting instruction in the running environment.
[0007] In one embodiment, the sequence of images to be optimized is determined based on the loading frequency of each target image name and the resource information of all images. This includes: identifying image names that do not match the reported target image names from the resource information of all images to obtain image names to be deleted; sorting the loading frequency of each target image name in ascending order to obtain sorted target image names; extracting a preset percentage of target image names from the sorted target image names according to the order of sorting to obtain low-frequency target image names; and determining the images corresponding to the image names to be deleted and the low-frequency target image names as the sequence of images to be optimized.
[0008] In one embodiment, the optimization process for the image sequence to be optimized includes: deleting the image corresponding to the name of the image to be deleted from the APP package to be optimized; and sending the image corresponding to the name of the low-frequency target image in the APP package to be optimized to a cloud server for storage.
[0009] In one embodiment, after optimizing the image sequence to be optimized and generating an optimized APP package, the process further includes: packaging and publishing the optimized APP package to obtain a published APP package; when the published APP package is downloaded and launched, connecting to a cloud server and caching the images corresponding to the published APP package on the cloud server.
[0010] In one embodiment, determining the loading frequency of each target image name based on the reported target image names includes: grouping the same target image names among the reported target image names into a group to obtain multiple groups of target image names; counting the number of target image names in each group of target image names to obtain the loading frequency of each target image name.
[0011] In one embodiment, searching for resource information of all images in the APP package to be optimized includes: obtaining the name and type of each image in the APP package to be optimized one by one; calculating the size of each image; determining the name, type, and size of each image as the resource information of each image; and summarizing the resource information of each image to obtain the resource information of all images in the APP package to be optimized.
[0012] An application installation package size optimization system includes: a resource information search module for searching resource information of all images in the APP package to be optimized; a loading frequency statistics module for collecting target image names reported by the APP package to be optimized in the runtime environment within a preset period, and determining the loading frequency of each target image name based on the reported target image names; a target image sequence determination module for determining the target image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images; and an image sequence optimization module for optimizing the target image sequence to generate an optimized APP package.
[0013] A computer device includes a memory and a processor, the memory storing computer-readable instructions that, when executed by the processor, cause the processor to perform the steps of the above-described method for optimizing the size of the application installation package.
[0014] A medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the above-described method for optimizing the size of the application installation package.
[0015] The aforementioned method, system, device, and medium for optimizing the application installation package size involve a system that first searches for resource information of all images in the APP package to be optimized. Then, it collects the target image names reported by the APP package in the runtime environment within a preset period and determines the loading frequency of each target image name based on the reported names. Next, based on the loading frequency of each target image name and the resource information of all images, it determines the sequence of images to be optimized. Finally, it optimizes the sequence of images to be optimized to generate the optimized APP package. Because this application determines the sequence of images to be optimized by determining the loading frequency of each target image name, the loading frequency can determine the specific number of times each image is used, thus ensuring that while reducing the size of the APP package, it does not affect the fast loading of frequently used images, thereby improving the user experience. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] Figure 1 This is a diagram illustrating the implementation environment of the method for optimizing the size of the application installation package provided in one embodiment of this application.
[0018] Figure 2 This is a schematic diagram of the internal structure of a computer device in one embodiment of this application;
[0019] Figure 3 This is a schematic diagram of a method for optimizing the size of an application installation package provided in one embodiment of this application;
[0020] Figure 4 This is a schematic block diagram illustrating the process of optimizing the application installation package size provided in another embodiment of this application;
[0021] Figure 5 This is a schematic diagram of a method for optimizing the size of an application installation package provided in another embodiment of this application;
[0022] Figure 6This is a schematic diagram of the system architecture of an application installation package size optimization system provided in an embodiment of this application. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0024] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another.
[0025] Figure 1 This is a diagram illustrating the implementation environment of an application installation package size optimization method provided in one embodiment, such as... Figure 1 As shown, this implementation environment includes a server 110 and a client 120.
[0026] Server 110 can be a server, specifically a standalone server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. For example, it could be a server device running the APP package to be optimized. Client 120 connects to server 110 and searches for resource information of all images in the APP package to be optimized within server 110. Client 120 collects the target image names reported by the APP package in its runtime environment within a preset period and determines the loading frequency of each target image name based on the reported target image names. Client 120 determines the sequence of images to be optimized based on the loading frequency of each target image name and the resource information of all images. Client 120 optimizes the sequence of images to be optimized, generates the optimized APP package, and deploys the optimized APP package to server 110.
[0027] It should be noted that the client 120 can be a smartphone, tablet, laptop, desktop computer, etc., but is not limited to these. The server 110 and the client 120 can connect via Bluetooth, USB (Universal Serial Bus), or other communication connection methods, which are not limited in this invention.
[0028] Figure 2 This is a schematic diagram of the internal structure of a computer device in one embodiment. For example... Figure 2As shown, the computer device includes a processor, media, memory, and network interface connected via a system bus. The media of the computer device stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When executed by the processor, the computer-readable instructions enable the processor to implement a method for optimizing the size of an application installation package. The processor of the computer device provides computing and control capabilities to support the operation of the entire device. The memory of the computer device may store computer-readable instructions, which, when executed by the processor, enable the processor to implement a method for optimizing the size of an application installation package. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that... Figure 2 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. A specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. The medium is a readable storage medium.
[0029] The following will be combined with the appendix Figures 3-5 This application provides a detailed description of the method for optimizing the size of application installation packages according to embodiments. This method can be implemented using a computer program and can run on an application installation package size optimization system based on the von Neumann architecture. This computer program can be integrated into an application or run as a standalone utility application.
[0030] 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.
[0031] Foundational artificial intelligence technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, optimization techniques for large application installation packages, operating / interactive systems, and mechatronics. Artificial intelligence software technologies mainly include computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0032] Please see Figure 3 This is a flowchart illustrating a method for optimizing the size of an application installation package, as provided in this application embodiment. Figure 3 As shown, the method in this application embodiment may include the following steps:
[0033] S101, Search for resource information of all images in the APP package to be optimized;
[0034] The "App package to be optimized" refers to the program code file package of the specified system that needs optimization. Resource information includes the name, type, and size of each image.
[0035] In this embodiment of the application, when searching for resource information of all images in the APP package to be optimized, the name and type of each image in the APP package to be optimized are first obtained one by one, then the size of each image is calculated, then the name, type and size of each image are determined as the resource information of each image, and finally the resource information of each image is summarized to obtain the resource information of all images in the APP package to be optimized.
[0036] Furthermore, a script document is written to explore all image resource information in the APP package to be optimized, including file size, name, and type.
[0037] Specifically, when calculating the size of each image, the pixel parameters of each image are first extracted, and an image matrix for each image is constructed based on the pixel parameters. The mean and standard deviation of the image matrix for each image are then calculated, and the size of each image is calculated based on the image matrix, the mean, and the standard deviation.
[0038] S102, collect the target image names reported by the APP package to be optimized in the running environment within a preset period, and determine the loading frequency of each target image name based on the reported target image names;
[0039] The preset period is a time frame set by the engineer, which can be a week or a month, depending on the specific scenario. The runtime environment is the server on which the APP code package is deployed and executed, such as a Tomcat server or other web server.
[0040] In this embodiment of the application, before searching for resource information of all images in the APP package to be optimized, it is also necessary to set an image resource loading script with an image name reporting instruction. First, the APP package to be optimized is loaded, then the image resource loading script in the APP package to be optimized is determined, then an image name reporting instruction is set for the image resource loading script so that the image name is reported when the image resource loading script loads the image, and finally the image resource loading script with the image name reporting instruction is run in the runtime environment.
[0041] In one possible implementation, the target image names reported by the APP package to be optimized in the runtime environment within a preset period are first collected. Then, the same target image names among the reported target image names are grouped together to obtain multiple groups of target image names. Finally, the number of target image names in each group is counted to obtain the loading frequency of each target image name.
[0042] For example, if the reported target image names are A, B, C, C, A, D, C, B, A, then (A, A, A) can be grouped together, (B, B) can be grouped together, (C, C, C) can be grouped together, and (D) can be grouped together. Finally, by counting the number of each group, we can find that the loading frequency of target image name A is 3, the loading frequency of target image name B is 2, the loading frequency of target image name C is 3, and the loading frequency of target image name D is 1, as shown in Table 1.
[0043] Table 1
[0044] Picture name A B C D Load frequency 3 2 3 1
[0045] Specifically, the image name reporting instruction here involves rewriting the method for loading image resources, so that this method function performs data tracking and reporting while loading image resources, and reports the name of the loaded image resources.
[0046] In another possible implementation, a sliding window algorithm can be used to create a sliding window, and the reported target image names can be entered into the sliding window one by one. The number of times each different target image name appears can be recorded, and finally the loading frequency of each target image name can be obtained.
[0047] S103, determine the sequence of images to be optimized based on the loading frequency of each target image name and the resource information of all images;
[0048] In this embodiment, when determining the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images, firstly, image names that are inconsistent with the reported target image names are identified from the resource information of all images to obtain the image names to be deleted. Then, the loading frequency of each target image name is sorted in ascending order to obtain the sorted target image names. Next, a preset percentage of target image names are extracted from the sorted target image names in the order of sorting to obtain the low-frequency target image names. Finally, the images corresponding to the image names to be deleted and the low-frequency target image names are determined as the image sequence to be optimized.
[0049] For example, if all the image names in the resource information of all images are A, B, C, D, E, and F, it can be seen that image names E and F are inconsistent with those in Table 1. In this case, E and F are determined as image names to be deleted. After sorting the image names in Table 1, we can get A, C, B, and D. If the preset percentage is 50%, then image names B and D are regarded as low-frequency image names, and A and C are regarded as high-frequency image names.
[0050] Specifically, after a period of data collection, the loading frequency of images can be determined, and information on images loaded frequently and infrequently can be obtained.
[0051] S104: Optimize the image sequence to be optimized and generate the optimized APP package.
[0052] In this embodiment, when optimizing the image sequence to generate an optimized APP package, the images corresponding to the names of the images to be deleted are first removed from the APP package. Then, the images corresponding to the names of low-frequency target images in the APP package are sent to a cloud server for storage. This method allows low-frequency images to be cloud-based, rather than simply cloud-based all images or large images, thereby reducing the size of the APP package while ensuring the loading efficiency of high-frequency images.
[0053] For example, in the app package to be optimized, the images corresponding to image names E and F are deleted, and the images corresponding to image names B and D are cached to the cloud server. Since A and C are accessed more frequently, they are placed locally, which ensures that the loading speed of high-frequency images is improved while reducing the size of the app installation package.
[0054] Furthermore, after generating the optimized APP package, the optimized APP package is first packaged and published to obtain the published APP package. Finally, when the published APP package is downloaded and launched, it connects to the cloud server and caches the images corresponding to the published APP package on the cloud server.
[0055] In one possible implementation, after the optimized app is deployed to the server, when a user downloads the app and opens it to perform operations, the system can monitor the user's operation trends in real time and determine whether low-frequency images need to be cached from the cloud based on these trends.
[0056] For example Figure 4 As shown, Figure 4This application provides a schematic flowchart of an optimization process for application installation package size. First, a script is written to explore image resources in the project. Then, the image loading method is rewritten, and the image name is reported by embedding a tracking point during loading. Next, the version is released. After a period of data collection, the frequency of image loading is obtained by combining the explored image information and the tracking point information. Finally, the redundant image resources are deleted, and the low-frequency image resources are cloudified. The cloudified images are downloaded after the APP is launched.
[0057] In this embodiment, the application installation package size optimization system first searches for resource information of all images in the APP package to be optimized. Then, it collects the target image names reported by the APP package in the runtime environment within a preset period and determines the loading frequency of each target image name based on the reported target image names. Next, it determines the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images. Finally, it optimizes the image sequence to generate the optimized APP package. Because this application determines the image sequence to be optimized by determining the loading frequency of each target image name, the loading frequency can determine the specific number of times each image is used, thereby ensuring that while reducing the size of the APP package, it does not affect the fast loading of frequently used images, thus improving the user experience.
[0058] Please see Figure 5 This is a flowchart illustrating a method for optimizing the size of an application installation package, as provided in this application embodiment. Figure 5 As shown, the method in this application embodiment may include the following steps:
[0059] S201, Search for resource information of all images in the APP package to be optimized;
[0060] S202, collect the target image names reported by the APP package to be optimized in the running environment within a preset period, and determine the loading frequency of each target image name based on the reported target image names;
[0061] S203, Identify the image names that do not match the reported target image names from the resource information of all images, and obtain the image names to be deleted;
[0062] S204, Sort the loading frequency of each target image name in ascending order to obtain the sorted target image names;
[0063] S205, extract a preset percentage of target image names from the sorted target image names in the order of sorting to obtain low-frequency target image names;
[0064] S206, determine the images corresponding to the image names to be deleted and the low-frequency target image names as the image sequence to be optimized;
[0065] S207, Delete the image corresponding to the image name to be deleted in the APP package to be optimized;
[0066] S208: Send the images corresponding to the low-frequency target image names in the APP package to be optimized to the cloud server for storage, and generate the optimized APP package;
[0067] In this embodiment, the application installation package size optimization system first searches for resource information of all images in the APP package to be optimized. Then, it collects the target image names reported by the APP package in the runtime environment within a preset period and determines the loading frequency of each target image name based on the reported target image names. Next, it determines the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images. Finally, it optimizes the image sequence to generate the optimized APP package. Because this application determines the image sequence to be optimized by determining the loading frequency of each target image name, the loading frequency can determine the specific number of times each image is used, thereby ensuring that while reducing the size of the APP package, it does not affect the fast loading of frequently used images, thus improving the user experience.
[0068] The following are system embodiments of the present invention, which can be used to execute the method embodiments of the present invention. For details not disclosed in the system embodiments of the present invention, please refer to the method embodiments of the present invention.
[0069] Please see Figure 6 This illustration shows a schematic diagram of an application installation package size optimization system provided by an exemplary embodiment of the present invention. The application installation package size optimization system can be implemented as all or part of a device through software, hardware, or a combination of both. System 1 includes a resource information search module 10, a loading frequency statistics module 20, a picture sequence determination module 30, and an picture sequence optimization module 40.
[0070] Resource information search module 10 is used to search for resource information of all images in the APP package to be optimized;
[0071] The loading frequency statistics module 20 is used to collect the target image names reported by the APP package to be optimized in the running environment within a preset period, and to determine the loading frequency of each target image name based on the reported target image names.
[0072] The image sequence determination module 30 is used to determine the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images.
[0073] Image sequence optimization module 40 is used to optimize the image sequence to be optimized and generate the optimized APP package.
[0074] It should be noted that the application installation package size optimization system provided in the above embodiments is only illustrated by the division of the above functional modules when executing the application installation package size optimization method. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the application installation package size optimization system and the application installation package size optimization method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.
[0075] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0076] In this embodiment, the application installation package size optimization system first searches for resource information of all images in the APP package to be optimized. Then, it collects the target image names reported by the APP package in the runtime environment within a preset period and determines the loading frequency of each target image name based on the reported target image names. Next, it determines the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images. Finally, it optimizes the image sequence to generate the optimized APP package. Because this application determines the image sequence to be optimized by determining the loading frequency of each target image name, the loading frequency can determine the specific number of times each image is used, thereby ensuring that while reducing the size of the APP package, it does not affect the fast loading of frequently used images, thus improving the user experience.
[0077] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps: searching for resource information of all images in an APP package to be optimized; collecting the names of target images reported by the APP package to be optimized in the runtime environment within a preset period, and determining the loading frequency of each target image name based on the reported target image names; determining the sequence of images to be optimized based on the loading frequency of each target image name and the resource information of all images; and optimizing the sequence of images to be optimized to generate an optimized APP package.
[0078] In one embodiment, before the processor retrieves the app package to be optimized, it also performs the following operations:
[0079] Load the APP package to be optimized; identify the image resource loading script in the APP package to be optimized; set an image name reporting instruction for the image resource loading script so that the image name is reported when the image resource loading script loads an image; run the image resource loading script with the image name reporting instruction set in the runtime environment.
[0080] In one embodiment, when the processor determines the sequence of images to be optimized based on the loading frequency of each target image name and the resource information of all images, it specifically performs the following operations:
[0081] In the resource information of all images, identify the image names that do not match the reported target image names to obtain the image names to be deleted; sort the loading frequency of each target image name in ascending order to obtain the sorted target image names; extract a preset percentage of target image names from the sorted target image names in the order of sorting to obtain the low-frequency target image names; determine the images corresponding to the image names to be deleted and the low-frequency target image names as the image sequences to be optimized.
[0082] In one embodiment, when the processor performs optimization processing on the image sequence to be optimized, it specifically performs the following operations:
[0083] Delete the images corresponding to the names of the images to be deleted from the APP package to be optimized; send the images corresponding to the names of low-frequency target images in the APP package to the cloud server for storage.
[0084] In one embodiment, after the processor performs optimization processing on the image sequence to be optimized and generates the optimized APP package, it also performs the following operations:
[0085] The optimized APP package is packaged and published to obtain the published APP package; when the published APP package is downloaded and launched, it connects to the cloud server and caches the images corresponding to the published APP package on the cloud server.
[0086] In one embodiment, when the processor determines the loading frequency of each target image name based on the reported target image names, it specifically performs the following operations:
[0087] Group the target image names that are the same among the reported target image names to obtain multiple groups of target image names; count the number of target image names in each group to obtain the loading frequency of each target image name.
[0088] In one embodiment, when the processor performs a search for resource information of all images in the app package to be optimized, it specifically performs the following operations:
[0089] In the APP package to be optimized, obtain the name and type of each image one by one; calculate the size of each image; determine the resource information of each image based on its name, type, and size; and summarize the resource information of each image to obtain the resource information of all images in the APP package to be optimized.
[0090] In this embodiment, the application installation package size optimization system first searches for resource information of all images in the APP package to be optimized. Then, it collects the target image names reported by the APP package in the runtime environment within a preset period and determines the loading frequency of each target image name based on the reported target image names. Next, it determines the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images. Finally, it optimizes the image sequence to generate the optimized APP package. Because this application determines the image sequence to be optimized by determining the loading frequency of each target image name, the loading frequency can determine the specific number of times each image is used, thereby ensuring that while reducing the size of the APP package, it does not affect the fast loading of frequently used images, thus improving the user experience.
[0091] In one embodiment, a medium storing computer-readable instructions is provided, which, when executed by one or more processors, cause the one or more processors to perform the following steps: searching for resource information of all images in an app package to be optimized; collecting the names of target images reported by the app package to be optimized in the runtime environment within a preset period, and determining the loading frequency of each target image name based on the reported target image names; determining the sequence of images to be optimized based on the loading frequency of each target image name and the resource information of all images; and optimizing the sequence of images to be optimized to generate an optimized app package.
[0092] In one embodiment, before the processor retrieves the app package to be optimized, it also performs the following operations:
[0093] Load the APP package to be optimized; identify the image resource loading script in the APP package to be optimized; set an image name reporting instruction for the image resource loading script so that the image name is reported when the image resource loading script loads an image; run the image resource loading script with the image name reporting instruction set in the runtime environment.
[0094] In one embodiment, when the processor determines the sequence of images to be optimized based on the loading frequency of each target image name and the resource information of all images, it specifically performs the following operations:
[0095] In the resource information of all images, identify the image names that do not match the reported target image names to obtain the image names to be deleted; sort the loading frequency of each target image name in ascending order to obtain the sorted target image names; extract a preset percentage of target image names from the sorted target image names in the order of sorting to obtain the low-frequency target image names; determine the images corresponding to the image names to be deleted and the low-frequency target image names as the image sequences to be optimized.
[0096] In one embodiment, when the processor performs optimization processing on the image sequence to be optimized, it specifically performs the following operations:
[0097] Delete the images corresponding to the names of the images to be deleted from the APP package to be optimized; send the images corresponding to the names of low-frequency target images in the APP package to the cloud server for storage.
[0098] In one embodiment, after the processor performs optimization processing on the image sequence to be optimized and generates the optimized APP package, it also performs the following operations:
[0099] The optimized APP package is packaged and published to obtain the published APP package; when the published APP package is downloaded and launched, it connects to the cloud server and caches the images corresponding to the published APP package on the cloud server.
[0100] In one embodiment, when the processor determines the loading frequency of each target image name based on the reported target image names, it specifically performs the following operations:
[0101] Group the target image names that are the same among the reported target image names to obtain multiple groups of target image names; count the number of target image names in each group to obtain the loading frequency of each target image name.
[0102] In one embodiment, when the processor performs a search for resource information of all images in the app package to be optimized, it specifically performs the following operations:
[0103] In the APP package to be optimized, obtain the name and type of each image one by one; calculate the size of each image; determine the resource information of each image based on its name, type, and size; and summarize the resource information of each image to obtain the resource information of all images in the APP package to be optimized.
[0104] In this embodiment, the application installation package size optimization system first searches for resource information of all images in the APP package to be optimized. Then, it collects the target image names reported by the APP package in the runtime environment within a preset period and determines the loading frequency of each target image name based on the reported target image names. Next, it determines the image sequence to be optimized based on the loading frequency of each target image name and the resource information of all images. Finally, it optimizes the image sequence to generate the optimized APP package. Because this application determines the image sequence to be optimized by determining the loading frequency of each target image name, the loading frequency can determine the specific number of times each image is used, thereby ensuring that while reducing the size of the APP package, it does not affect the fast loading of frequently used images, thus improving the user experience.
[0105] 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 a computer program instructing related hardware. This computer program can be stored in a computer-readable medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned medium can be a non-volatile medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0106] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0107] The above embodiments merely illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this patent should be determined by the appended claims.
Claims
1. A method for optimizing the size of an application installation package, characterized in that, The method comprises: searching resource information of all pictures in an APP package to be optimized; collecting target picture names reported by the APP package to be optimized in a running environment in a preset period, and determining a loading frequency of each target picture name according to the reported target picture names; determining a picture sequence to be optimized according to the loading frequency of each target picture name and the resource information of all pictures; optimizing the picture sequence to be optimized to generate an optimized APP package; the determining of the picture sequence to be optimized according to the loading frequency of each target picture name and the resource information of all pictures comprises: determining picture names inconsistent with the reported target picture names in the resource information of all pictures to obtain picture names to be deleted; arranging the loading frequency of each target picture name in ascending order to obtain sorted target picture names; sequentially cutting a preset percentage of target picture names in the sorted target picture names according to the order to obtain low-frequency target picture names; determining pictures corresponding to the picture names to be deleted and the low-frequency target picture names as the picture sequence to be optimized; when calculating the size of each picture, extracting pixel parameters in each picture, constructing an image matrix of each image according to the pixel parameters, calculating a matrix mean value and a standard deviation of the image matrix of each image, and calculating the size of each picture according to the image matrix, the matrix mean value and the standard deviation of each image; the searching of the resource information of all pictures in the APP package to be optimized comprises: determining the name, type and size of each picture as the resource information of each picture; the determining of the loading frequency of each target picture name according to the reported target picture names comprises: dividing the same target picture names in the reported target picture names into a group to obtain multiple groups of target picture names; and counting the number of target picture names in each group of target picture names to obtain the loading frequency of each target picture name.
2. The method of claim 1, wherein, Before obtaining the APP package to be optimized, the method further comprises: loading the APP package to be optimized; determining a picture resource loading script in the APP package to be optimized; setting a picture name reporting instruction for the picture resource loading script to report the loaded picture names when the picture resource loading script loads pictures; running the picture resource loading script with the picture name reporting instruction in a running environment.
3. The method of claim 1, wherein, the optimization of the picture sequence to be optimized comprises: deleting pictures corresponding to the picture names to be deleted in the APP package to be optimized; sending pictures corresponding to the low-frequency target picture names in the APP package to be optimized to a cloud server for storage.
4. The method of claim 1, wherein, after the optimization of the picture sequence to be optimized to generate the optimized APP package, the method further comprises: packing and publishing the optimized APP package to obtain a published APP package; when the published APP package is downloaded and started, connecting the cloud server and caching pictures corresponding to the published APP package in the cloud server.
5. The method of claim 1, wherein, the searching of the resource information of all pictures in the APP package to be optimized further comprises: Obtain the name and type of each picture one by one in the APP package to be optimized; Calculate the size of each picture; Summarize the resource information of each picture to obtain the resource information of all pictures in the APP package to be optimized.
6. A system for optimization of application package size, characterized by, The system comprises: A resource information searching module for searching the resource information of all pictures in the APP package to be optimized; A loading frequency statistical module for collecting the target picture names reported by the APP package to be optimized in a running environment within a preset period, and determining the loading frequency of each target picture name according to the reported target picture names; A to-be-optimized picture sequence determining module for determining the to-be-optimized picture sequence according to the loading frequency of each target picture name and the resource information of all pictures; A picture sequence optimizing module for optimizing the to-be-optimized picture sequence to generate an optimized APP package. The to-be-optimized picture sequence is determined according to the loading frequency of each target picture name and the resource information of all pictures, which comprises: Determine the picture names inconsistent with the reported target picture names from the resource information of all pictures to obtain to-be-deleted picture names; Arrange the loading frequency of each target picture name in ascending order to obtain sorted target picture names; Extract a preset percentage of target picture names in the order of sorting to obtain low-frequency target picture names; Determine the pictures corresponding to the to-be-deleted picture names and the low-frequency target picture names as the to-be-optimized picture sequence; When calculating the size of each picture, extract the pixel parameters in each picture, construct the image matrix of each image according to the pixel parameters, calculate the matrix mean and standard deviation of the image matrix of each image, and calculate the size of each picture according to the image matrix, matrix mean and standard deviation of each image; The resource information searching module is further configured to search the resource information of all pictures in the APP package to be optimized in the following manner: determine the name, type and size of each picture as the resource information of each picture; The loading frequency statistical module is further configured to determine the loading frequency of each target picture name according to the reported target picture names in the following manner: divide the same target picture names in the reported target picture names into a group to obtain multiple groups of target picture names; and count the number of target picture names in each group of target picture names to obtain the loading frequency of each target picture name.
7. A computer device, comprising: The computer readable instructions are executed by one or more processors to cause the one or more processors to perform the steps of the application program installation package size optimization method.
8. A medium having computer readable instructions stored therein, characterized in that, The computer readable instructions are executed by one or more processors to cause the one or more processors to perform the steps of the application program installation package size optimization method.
Citation Information
Patent Citations
Picture resource processing method and system, client, server, processor and medium
CN110489576A
Application package processing method and device, electronic equipment and storage medium
CN112306542A