Image Processing Method and Apparatus
By adjusting the size of the large image in the electronic device to meet the first threshold, the problem of slow and crash when loading the large image is solved, and faster loading speed and more stable image display are achieved.
Patent Information
- Application Number
- CN202210201513.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-03-02
AI Technical Summary
When loading images that take up a large memory, the loading speed of electronic devices is very slow and prone to failure in loading, resulting in the image not being displayed normally.
Before displaying the target interface, a first image with a size greater than the first threshold among the multiple images to be displayed on the target interface is obtained, and by determining the second image associated with the first image, the first image is adjusted to the target size, so that its memory occupancy is reduced, thereby increasing the loading speed.
By adjusting the size of the first image, it reduces its memory occupancy, effectively improves the loading speed of the image, and improves the crash phenomenon of electronic devices when loading images with large memory, reducing the probability that the image cannot be displayed normally.
Smart Images

Figure CN114626972B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of image processing, and particularly relates to an image processing method and apparatus. Background Art
[0002] With the booming development of the mobile Internet and the continuous popularization of electronic devices, browsing interfaces through electronic devices has become a regular operation of users in daily life.
[0003] In related technologies, various images can usually be displayed on the interface for users to browse and view. When an image occupies a large amount of memory, the electronic device is very slow in loading such an image and is prone to loading failure, resulting in the image not being displayed properly. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide an image processing method and apparatus, which can solve the problem of slow loading speed when loading an image that occupies a large amount of memory in related technologies.
[0005] In a first aspect, the embodiments of this application provide an image processing method, which includes: before displaying a target interface, obtaining first images with sizes larger than a first threshold among multiple images to be displayed on the target interface; determining second images that are associated with the first images and have sizes less than or equal to the first threshold among the multiple images, where the display area sizes of the first images and the second images in the target interface are the same, or the display positions of the first images and the second images in the target interface are adjacent; adjusting the first images to a target size according to the size information corresponding to the second images, where the target size is less than or equal to the first threshold; and displaying the target interface, where the target interface includes the second images and the first images with the target size.
[0006] In a second aspect, the embodiments of this application provide an image processing apparatus, which includes: an obtaining module, configured to obtain first images with sizes larger than a first threshold among multiple images to be displayed on the target interface before displaying the target interface; a determining module, configured to determine second images that are associated with the first images and have sizes less than or equal to the first threshold among the multiple images, where the display area sizes of the first images and the second images in the target interface are the same, or the display positions of the first images and the second images in the target interface are adjacent; an adjusting module, configured to adjust the first images to a target size according to the size information corresponding to the second images, where the target size is less than or equal to the first threshold; and a displaying module, configured to display the target interface, where the target interface includes the second images and the first images with the target size.
[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, the steps of the image processing method as described in the first aspect are implemented.
[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the image processing method as described in the first aspect are implemented.
[0009] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is configured to run a program or instruction to implement the steps of the image processing method as described in the first aspect.
[0010] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the steps of the image processing method as described in the first aspect.
[0011] In the embodiment of the present application, before the electronic device displays a target interface, it acquires a first image among multiple images to be displayed on the target interface, where the size of the first image is greater than a first threshold. Since the size of the first image is relatively large, the corresponding memory occupancy is also large. Therefore, by determining a second image among the multiple images that is associated with the first image and has a size less than or equal to the first threshold, the first image can be adjusted to a target size not greater than the first threshold according to the size information corresponding to the second image. Based on this, by adjusting the size of the first image before displaying it, the memory occupancy of the first image can be reduced. When the first image with the target size is displayed on the target interface, the loading speed of the first image can be effectively improved, and at the same time, the crash phenomenon caused by the electronic device loading an image with a large memory can be improved, and the probability that the image cannot be normally displayed can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 is one of the flow diagrams of the image processing method provided by an embodiment of the present application;
[0013] Figure 2 is a schematic diagram of an example of a target interface provided by an embodiment of the present application;
[0014] Figure 3 is a second flow diagram of the image processing method provided by an embodiment of the present application;
[0015] Figure 4 is a third flow diagram of the image processing method provided by an embodiment of the present application;
[0016] Figure 5It is the fourth schematic flow chart of the image processing method provided by the embodiments of the present application;
[0017] Figure 6 It is a schematic structural diagram of an image processing device provided by the embodiments of the present application;
[0018] Figure 7 It is a schematic structural diagram of an electronic device provided by the embodiments of the present application;
[0019] Figure 8 It is a schematic hardware structure diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners
[0020] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.
[0021] Terms such as "first" and "second" in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such used data may be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. generally belong to the same category, and the number of objects is not limited. For example, the first object may be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means an "or" relationship between the associated objects before and after.
[0022] As in the background art, various images can usually be displayed on the interface for users to browse and view. When an image occupies a large amount of memory, the electronic device is very slow to load such an image and is prone to loading failure, resulting in the image not being displayed properly. For example, the memory occupied by a certain image uploaded in the background is 10M. Due to the large memory occupancy, the electronic device is very slow to load this image in a web page or application. If the electronic device has insufficient memory, it will also crash during loading, resulting in the inability to display this image.
[0023] In view of the problems in the related art, an embodiment of the present application provides an image processing method. Before displaying a target interface, an electronic device obtains a first image with a size greater than a first threshold among multiple images to be displayed on the target interface. Since the size of the first image is relatively large, the corresponding memory occupancy is also large. Therefore, by determining a second image that is associated with the first image and has a size less than or equal to the first threshold among multiple images, the first image can be adjusted to a target size not greater than the first threshold according to the size information corresponding to the second image. Based on this, by adjusting the size of the first image before displaying the first image, the memory occupancy of the first image can be reduced. When the first image with the target size is displayed on the target interface, the loading speed of the first image can be effectively improved, and at the same time, the crash phenomenon caused by the electronic device loading an image with a large memory can be improved, and the probability that the image cannot be normally displayed can be reduced, solving the problem of slow loading speed when loading an image with a large memory occupancy in the related art.
[0024] The following will specifically describe the image processing method provided by the embodiment of the present application in conjunction with the accompanying drawings and through specific embodiments and their application scenarios.
[0025] Figure 1 FIG. is a schematic flowchart of an image processing method provided by an embodiment of the present application. The execution subject of this image processing method can be an electronic device. It should be noted that the above execution subject does not limit the present application.
[0026] As Figure 1 shown, the image processing method provided by the embodiment of the present application may include step 110-step 140.
[0027] Step 110, before displaying the target interface, obtain a first image with a size greater than a first threshold among multiple images to be displayed on the target interface.
[0028] Exemplarily, the target interface may be the interface 201 as Figure 2 shown. This interface 201 is used to display images A-E in regions 1-5 respectively. Therefore, images A-E are multiple images corresponding to the target interface, and the first image is the image among images A-E with a size greater than the first threshold. Before the electronic device displays images A-E on the interface 201, it obtains the image among images A-E with a size greater than the first threshold.
[0029] Step 120, determine a second image that is associated with the first image and has a size less than or equal to the first threshold among multiple images.
[0030] Among them, the display area sizes of the first image and the second image in the target interface are the same, or the display positions of the first image and the second image in the target interface are adjacent.
[0031] Specifically, the electronic device may obtain a second image from multiple images that has the same display area size as the first image and a size less than or equal to a first threshold, or obtain a second image from multiple images that is adjacent to the position of the first image and has a size less than or equal to the first threshold.
[0032] In one example, the first image is image B displayed in area 2. Since the display area sizes of images A and C in the target interface 201 are the same as the size of area 2, for example, both are 2 cm * 2 cm, when the sizes of both image A and image B are less than or equal to the first threshold, the second image may include image A and image B.
[0033] In another example, the first image may be image B displayed in area 2, and the images adjacent to the display position of image B include images A, C, and D. Then, when the sizes of images A, C, and D are all less than or equal to the first threshold, the second image may include images A, C, and D.
[0034] Step 130: Adjust the first image to a target size according to the size information corresponding to the second image, where the target size is less than or equal to the first threshold.
[0035] Specifically, since the second image is less than or equal to the first threshold and has an appropriate size, it can be normally displayed on the target interface. Therefore, by using the size information of the second image to adjust the size of the first image, the size of the first image can be corrected. By reducing the size of the first image, the memory occupied by the first image can be reduced, ensuring that the first image can be normally displayed on the target interface like the second image.
[0036] Step 140: Display the target interface, which includes the second image and the first image of the target size.
[0037] Exemplarily, as Figure 2 shown, if the first image is image B displayed in area 2, after adjusting the size of image B to a target size less than the first threshold, the memory occupied by image B can be reduced from 8M to 50KB. Therefore, the electronic device can normally display image B in area 2 of the target interface.
[0038] The image processing method provided by the embodiments of the present application. Before the electronic device displays the target interface, it obtains the first image with a size greater than the first threshold among multiple images to be displayed on the target interface. Since the first image has a large size, the corresponding memory occupancy is also large. Therefore, by determining the second image associated with the first image and having a size less than or equal to the first threshold among multiple images, the first image can be adjusted to a target size not greater than the first threshold according to the size information corresponding to the second image. Based on this, by adjusting the size of the first image before displaying the first image, the memory occupancy of the first image can be reduced. When the first image with the target size is displayed on the target interface, the loading speed of the first image can be effectively improved, and at the same time, the crash phenomenon caused by the electronic device loading an image with a large memory can be improved, and the probability that the image cannot be normally displayed can be reduced.
[0039] The following specifically introduces the above steps 110 - 140 in combination with specific embodiments.
[0040] Regarding step 110, before displaying the target interface, obtain the first image with a size greater than the first threshold among multiple images to be displayed on the target interface.
[0041] In some embodiments of the present application, multiple images correspond to at least one type, and the display area sizes of all images of the same type in the target interface are the same. The first threshold is determined according to the type of the image. To obtain the first image among multiple images to be displayed on the target interface, step 110 may specifically include Figure 3 The steps 340 shown.
[0042] Step 340, obtain the first image with a size greater than the first threshold corresponding to the type among the images corresponding to each type.
[0043] Among them, the type corresponds to the first threshold, and different types have different corresponding first thresholds.
[0044] Exemplarily, Figure 2 The images A, B, and C shown all belong to type 1, and the display area sizes of the three images in the interface 201 are the same. Therefore, the first threshold corresponding to type 1 can be determined based on type 1, and the first image among images A, B, and C can be determined based on this first threshold; images D and E both belong to type 2, and their display area sizes in the interface 201 are also the same. Therefore, the first threshold corresponding to type 2 can be determined based on type 2, and the first image among images D and E can be determined based on this first threshold.
[0045] Referring to the above example, the display area sizes of images A - C in the target interface 201 are the same, and the display area sizes of images D and E in the target interface 201 are the same. Therefore, images A - C are of the same type, and images D and E are of the same type. If the first threshold corresponding to images A - C (type 1) is 100px * 100px, the size of image A is 90px * 90px, the size of image B is 800px * 800px, and the size of image C is 100px * 100px, then image B with a size larger than 100px * 100px among images A - C is the first image. If the first threshold corresponding to images D and E (type 2) is 200px * 100px, the size of image D is 200px * 100px, and the size of image E is 210px * 100px, then image E is the first image.
[0046] In one example, image B with a size larger than the first threshold of 100px * 100px is the first image. When the display area sizes of the first image and the second image in the target interface are the same, since the display area sizes of images A, C and image B are the same, and their sizes are less than or equal to the first threshold of 100px * 100px corresponding to type 1, images A and C are both second images associated with image B.
[0047] In another example, image B with a size larger than the first threshold of 100px * 100px is the first image. When the display positions of the first image and the second image in the target interface are adjacent, since the display positions of images A, C, D and image B are adjacent, the sizes of images A and C are less than or equal to the first threshold of 100px * 100px corresponding to type 1, and the size of image D is equal to the first threshold of 200px * 100px corresponding to type 2, images A, C and D are all second images associated with image B.
[0048] In the embodiments of the present application, since the display areas corresponding to multiple images to be displayed on the target interface are different, correspondingly, the criteria for judging whether multiple images are too large are also different. Therefore, when determining whether multiple images are the first images, it is inaccurate to make a judgment based on the same first threshold. Based on this, the first threshold in the present application can correspond to the type of the image, and the type of the image is related to the display area size. In this way, when judging whether images of the same type are the first images, the same first threshold can be used to ensure the accuracy of the judgment process and accurately screen out the first images that need to adjust the size from multiple images.
[0049] It should be noted that the display area sizes of all images of the same type in the target interface are the same, and the display area sizes of images of different types in the target interface can be the same or different.
[0050] In some embodiments of the present application, in order to determine the first threshold corresponding to each type, Figure 3 It is a schematic flowchart of another image processing method provided by an embodiment of the present application.
[0051] Such as Figure 3 shown, before step 340, the method may further include steps 310 - 330.
[0052] Step 310, obtain multiple images, and type information corresponding to each image.
[0053] In one embodiment, the type information may include the element name or link domain name corresponding to the image, and the element names or link domain names corresponding to all images of the same type are the same.
[0054] Specifically, a same interface is composed of multiple elements, and the type of each element can be obtained. An image is one of the elements. Therefore, by parsing the elements of the image, the element name ID or link domain name corresponding to the image is obtained, so as to obtain the type information corresponding to the image.
[0055] Exemplarily, the element names corresponding to images A - C are all "hot_topic_img", so it can be determined that images A - C are of the same type ImageView; the link domain names corresponding to images D and E are the same, then it can be determined that images D and E are of the same type.
[0056] In one embodiment, multiple elements in the same interface have a subordinate relationship. For example, the uppermost element is the DecorView corresponding to the complete page. Recursively in turn, when reaching the parent layout of the image layer, the element is RootView. The next layer of RootView can be leaf nodes, and the leaf nodes are composed of different elements, and the element types include pictures, buttons, texts, etc.
[0057] In one example, the Imageview has attributes such as id (hot_topic_img) and index position, which are used to uniquely identify an image, and the subordinate relationship of the image can be obtained through XPathLite: id = "com.vivo.space:id / common_listview"] / androidx.recyclerview.widget.RecyclerView[2] / android.widget.RelativeLayout[2] / android.widget.RelativeLayout[1] / android.widget.ImageView[1].
[0058] Step 320: Classify the multiple images according to the type information corresponding to each image to obtain at least one type.
[0059] In one embodiment, step 320 may specifically include: determining that images with the same element name or link domain name among the multiple images belong to the same type.
[0060] In the embodiment of the present application, while the electronic device obtains multiple images to be displayed on the target interface, it can also obtain the element name or link domain name corresponding to each image. By determining whether the element name or link domain name is the same, it can be determined whether the types of different images are the same. Based on this, according to the element name or link domain name, the multiple images can be divided into at least one type. Based on the first threshold corresponding to each type, the first image to be adjusted in size is obtained from all the images corresponding to each type, so as to ensure that the first images that need to be adjusted in size are accurately selected from the multiple images.
[0061] Step 330: Determine that the size of the target image corresponding to the images of each type is the first threshold, or determine the first threshold corresponding to each type according to the display area size and the target screen resolution of the images of each type.
[0062] Wherein, the target image is the image with the smallest size among all the images of the same type, and the target screen resolution is the screen resolution of the electronic device.
[0063] Specifically, when the size of the target image is the first threshold, the images other than the target image are all first images, and the first threshold is the target size.
[0064] In an example, images A - C correspond to the ImageView type. The size of image A is 90px * 90px, the size of image B is 800px * 800px, and the size of image C is 100px * 100px. Then it can be determined that image A is the target image, and 90px * 90px is the first threshold corresponding to the ImageView type; similarly, images D and E correspond to the Linearlayout type, and the smallest-sized image D among images D and E is the target image, then the size of image D is the first threshold corresponding to the Linearlayout type.
[0065] In the embodiment of the present application, the electronic device can determine that the image with the smallest size among the images of each type is the target image, and the size of the target image is the first threshold. Based on this, it can be determined that among the images of each type, the images other than the target image are the first images. Therefore, the first images can be adjusted to the size of the target image based on the size of the target image, ensuring that all the first images can be normally displayed on the target interface together with the target image.
[0066] In the embodiment of the present application, there is a phenomenon that the original resolution of the first image is too large, resulting in a large memory occupation. However, when the first image is displayed on the electronic device, its display resolution will not exceed the screen resolution of the electronic device. Therefore, when the display area sizes of all images of the same type in the target interface are the same, the electronic device can determine the first threshold corresponding to each type according to the display area size corresponding to each type of image and the screen resolution of the electronic device. Based on this, by adjusting the first image to a target size smaller than the first threshold, the size and memory occupation of the first image can be reduced, and the loading crash phenomenon caused by the excessive memory occupation of the first image can be improved. At the same time, it is ensured that there is no pixel loss when the first image is displayed on the target interface.
[0067] Involving step 120, determine the second image that is associated with the first image and has a size less than or equal to the first threshold among multiple images.
[0068] After obtaining the first image in step 110, if the display area size is the same as that of the first image, or the sizes of all images adjacent to the display position of the first image are greater than the first threshold, that is, when there is no second image that is associated with the first image and has a size not greater than the second threshold, in order to be able to correct the sizes of all first images and ensure that all first images can be normally displayed on the target interface, Figure 4 It is a schematic flowchart of another image processing method provided by the embodiment of the present application. Step 120 may include Figure 4 the shown step 410 and step 420.
[0069] Step 410, determine all third images associated with the first image.
[0070] Among them, the third image is the image with the same display area size as the first image or adjacent to the display position of the first image.
[0071] In one embodiment, step 120 may include: after step 410, determine the second image with a size less than or equal to the first threshold among all third images.
[0072] Step 420, when the sizes of all third images are greater than the first threshold, adjust the size of any third image to the first threshold to obtain the second image.
[0073] As a specific example, the multiple images to be displayed on the target interface include Image X, Image Y, and Image Z. Among them, the display area sizes of the three images are the same and are all greater than the first threshold. The first image obtained by the electronic device is Image X, and it is determined that the third images associated with Image X include Image Y and Image Z. Since the sizes of Image Y and Image Z are both greater than the first threshold, the electronic device can directly adjust the size of any of Image Y and Image Z, for example, adjust the size of Image Y to the first threshold, so as to obtain a second image that is associated with Image X and has a size equal to the first threshold. In this way, the electronic device can adjust Image X and Image Z to the target size based on the size information of Image Y.
[0074] In the embodiment of the present application, after the electronic device obtains the first image and the third images associated with the first image, in the scenario where the sizes of all the third images are greater than the first threshold, by adjusting the size of any third image to the first threshold, a second image can be obtained, so that the size of the first image can be corrected based on the size information of the second image, ensuring that all the first images can be normally displayed on the target interface.
[0075] It involves step 130 of adjusting the first image to the target size according to the size information corresponding to the second image.
[0076] In some embodiments of the present application, when the display area sizes of the first image and the second image on the target interface are the same, step 130 may include any one of the following: determining that the size of the fourth image in the second image is the target size, where the fourth image is the image with the smallest or largest size in the second image; determining the median value of the sizes corresponding to all the second images as the target size; determining the average value of the sizes corresponding to all the second images as the target size.
[0077] In an example, Images A - C correspond to the ImageView type. The size of Image A is 90px * 90px, the size of Image B is 800px * 800px, the size of Image C is 100px * 100px. Image B is the first image, and Images A and C are the second images. Optionally, the electronic device can determine that the smallest size 90px * 90px in the second images is the target size, or determine that the largest size 100px * 100px is the target size, or determine that the average value 95px * 95px of Images A and C is the target size.
[0078] In the embodiments of the present application, since the size of the second image is smaller than the first threshold and the display area sizes of the first image and the second image in the target interface are the same, the size of the first image can be adjusted by using the second image that can be normally displayed in the target interface. Specifically, the electronic device can determine the smallest or largest image size in the second image, or the median value of the sizes corresponding to all the second images, or the average value of the sizes corresponding to all the second images as the target size. However, no matter which method is used, it can be ensured that the target size will not be greater than the first threshold. Based on this, by adjusting the first image to the target size, the memory occupied by the first image can be effectively reduced, achieving the purpose of correcting the image memory size.
[0079] In some other embodiments of the present application, in order to effectively adjust the size of the first image, Figure 5 is a schematic flowchart of another image processing method provided by the embodiments of the present application.
[0080] As Figure 5 shown, step 130 may include Figure 5 steps 510 - step 530 shown in
[0081] Step 510, when the display positions of the first image and the second image in the target interface are adjacent, determine that the ratio of the display area size of the fifth image to the display area size of the first image is the first ratio.
[0082] Wherein, the fifth image is any image in the second image.
[0083] Exemplarily, the first image may be the image B displayed in the Figure 2 area 2 shown. Then, the images A, C, and D adjacent to the display position of the image B can all be the second images. If the fifth image is the image D, then it can be determined that the ratio of the display area size of the image D (4 cm * 2 cm) to the display area size of the image B (2 cm * 2 cm) is the first ratio, and this first ratio is 2:1.
[0084] Step 520, calculate the target size according to the first ratio and the size corresponding to the fifth image.
[0085] Referring to the above example, when the fifth image is the image D, if the size corresponding to the image D is 200 px * 100 px, then it can be determined that the quotient of this size and the first ratio, 100 px * 100 px, is the target size. Therefore, the size of the image B can be adjusted to 100 px * 100 px.
[0086] Step 530, adjust the first image to the target size.
[0087] In the embodiments of the present application, the electronic device may determine a first ratio based on the ratio of the display area sizes of any fifth image in the second image to the first image, and calculate a target size based on the first ratio and the size of the fifth image. In this way, by adjusting the first image to the target size, it can be ensured that the ratio of the display area sizes of the first image to the fifth image is the same as the ratio of the image sizes, ensuring that the size of the first image is adapted to the display area size, so that it can be smoothly displayed in the target interface.
[0088] It should be noted that for the image processing method provided in the embodiments of the present application, the execution subject may be an image processing device. In the embodiments of the present application, taking the image processing device executing the image processing method as an example, the image processing device provided in the embodiments of the present application is described. The following provides a detailed introduction to the image processing device.
[0089] Figure 6 It is a schematic structural diagram of an image processing device provided by the present application.
[0090] As Figure 6 shown, the embodiments of the present application provide an image processing device 600, and the image processing device 600 includes: an acquisition module 610, a determination module 620, an adjustment module 630, and a display module 640.
[0091] Among them, the acquisition module 610 is configured to acquire a first image with a size greater than a first threshold among multiple images to be displayed on a target interface before the target interface is displayed; the determination module 620 is configured to determine a second image associated with the first image and having a size less than or equal to the first threshold among the multiple images, where the display area sizes of the first image and the second image in the target interface are the same, or the display positions of the first image and the second image in the target interface are adjacent; the adjustment module 630 is configured to adjust the first image to a target size according to the size information corresponding to the second image, and the target size is less than or equal to the first threshold; the display module 640 is configured to display the target interface, and the target interface includes the second image and the first image with the target size.
[0092] The image processing method provided by the embodiments of the present application. Before the electronic device displays the target interface, it acquires the first image with a size greater than the first threshold among the multiple images to be displayed on the target interface. Since the size of the first image is relatively large, the corresponding memory occupancy is also large. Therefore, by determining the second image that is associated with the first image and has a size less than or equal to the first threshold among the multiple images, the first image can be adjusted to a target size not greater than the first threshold according to the size information corresponding to the second image. Based on this, by adjusting the size of the first image before displaying the first image, the memory occupancy of the first image can be reduced. When the first image with the target size is displayed on the target interface, the loading speed of the first image can be effectively improved, and at the same time, the crash phenomenon caused by the electronic device loading an image with a large memory can be improved, and the probability of the image not being displayed normally can be reduced.
[0093] In some embodiments of the present application, the multiple images correspond to at least one type, and the display area sizes of all images of the same type in the target interface are the same. The first threshold is determined according to the type of the image. The acquisition module 610 is specifically configured to: acquire the first image with a size greater than the first threshold corresponding to the type among the images corresponding to each type.
[0094] In some embodiments of the present application, the device further includes: an acquisition module 610, further configured to acquire multiple images and the type information corresponding to each image before acquiring the first image with a size greater than the first threshold corresponding to the type among the images corresponding to each type; a classification module, configured to classify the multiple images according to the type information corresponding to each image to obtain at least one type; a determination module 620, configured to determine that the size of the target image corresponding to each type of image is the first threshold, where the target image is the image with the smallest size among all images of the same type; or, the determination module 620 is configured to determine the first threshold corresponding to each type according to the display area size corresponding to each type of image and the target screen resolution, and the target screen resolution is the screen resolution of the electronic device.
[0095] In some embodiments of the present application, the type information includes the element name or link domain name corresponding to the image. The classification module is specifically configured to: determine that the images with the same element name or link domain name among the multiple images are of the same type.
[0096] In some embodiments of the present application, the determination module 620 includes: a determination unit, configured to determine all the third images associated with the first image; an adjustment unit, configured to, when the sizes of all the third images are greater than the first threshold, adjust the size of any third image to the first threshold to obtain the second image.
[0097] In some embodiments of the present application, when the display area sizes of the first image and the second image in the target interface are the same, the adjustment module 630 is specifically configured to perform any one of the following: determining that the size of the fourth image in the second image is the target size, where the fourth image is the smallest or largest image in the second image; determining that the median value of the sizes corresponding to all the second images is the target size; determining that the average value of the sizes corresponding to all the second images is the target size.
[0098] In some embodiments of the present application, when the display positions of the first image and the second image in the target interface are adjacent, the adjustment module 630 is specifically configured to: determine that the ratio of the display area size of the fifth image to that of the first image is the first ratio, where the fifth image is any image in the second image; and calculate the target size according to the first ratio and the size corresponding to the fifth image.
[0099] The image processing apparatus provided by the embodiments of the present application can implement Figures 1 - 5 each process implemented by the electronic device in the method embodiments, and can achieve the same technical effects. To avoid repetition, details are not described herein again.
[0100] The image processing apparatus in the embodiments of the present application may be an electronic device, or a component, an integrated circuit, or a chip in the electronic device. The electronic device may be a terminal or other devices other than the terminal. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. It may also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.
[0101] The image processing apparatus in the embodiments of the present application may be a device with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.
[0102] Optionally, as Figure 7As shown in the figure, an embodiment of the present application further provides an electronic device 700, including a processor 701, a memory 702, a program or instruction stored on the memory 702 and executable on the processor 701. When the program or instruction is executed by the processor 701, it implements each process of the above-mentioned embodiment of the image processing method and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0103] It should be noted that the electronic device in the embodiment of the present application includes the above-mentioned mobile electronic device and non-mobile electronic device.
[0104] Figure 8 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application.
[0105] The electronic device 800 includes, but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, and a processor 810 and other components.
[0106] Those skilled in the art can understand that the electronic device 800 may further include a power source (such as a battery) for supplying power to each component. The power source can be logically connected to the processor 810 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. Figure 8 The structure of the electronic device shown in the figure does not limit the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements, which will not be elaborated here.
[0107] Among them, the processor 810 is used to obtain, before displaying the target interface, a first image with a size greater than a first threshold among multiple images to be displayed on the target interface; the processor 810 is used to determine, among the multiple images, a second image associated with the first image and having a size less than or equal to the first threshold, where the display area sizes of the first image and the second image in the target interface are the same, or the display positions of the first image and the second image in the target interface are adjacent; the processor 810 is used to adjust the first image to a target size according to the size information corresponding to the second image, where the target size is less than or equal to the first threshold; the display unit 806 is used to display the target interface, and the target interface includes the second image and the first image with the target size.
[0108] In an embodiment of the present application, before the electronic device displays the target interface, it obtains a first image among multiple images to be displayed on the target interface, where the size of the first image is greater than a first threshold. Since the size of the first image is relatively large, the corresponding memory occupancy is also large. Therefore, by determining a second image among the multiple images that is associated with the first image and has a size less than or equal to the first threshold, the first image can be adjusted to a target size not greater than the first threshold according to the size information corresponding to the second image. Based on this, by adjusting the size of the first image before displaying the first image, the memory occupancy of the first image can be reduced. When the first image with the target size is displayed on the target interface, the loading speed of the first image can be effectively improved, and at the same time, the crash phenomenon caused by the electronic device loading an image with a large memory can be improved, and the probability that the image cannot be normally displayed can be reduced.
[0109] In some embodiments of the present application, the multiple images correspond to at least one type, and the display area sizes of all images of the same type in the target interface are the same. The first threshold is determined according to the type of the image. The processor 810 is specifically configured to: obtain a first image among the images corresponding to each type, where the size of the first image is greater than the first threshold corresponding to the type.
[0110] In some embodiments of the present application, the processor 810 is further configured to, before obtaining a first image among the images corresponding to each type, where the size of the first image is greater than the first threshold corresponding to the type, obtain multiple images and the type information corresponding to each image; the processor 810 is configured to classify the multiple images according to the type information corresponding to each image to obtain at least one type; the processor 810 is configured to determine that the size of the target image corresponding to each type of image is the first threshold, where the target image is the image with the smallest size among all images of the same type; or, the processor 810 is configured to determine the first threshold corresponding to each type according to the display area size corresponding to each type of image and the target screen resolution, and the target screen resolution is the screen resolution of the electronic device.
[0111] In some embodiments of the present application, the type information includes the element name or link domain name corresponding to the image. The processor 810 is specifically configured to: determine that images with the same element name or link domain name among the multiple images are of the same type.
[0112] In some embodiments of the present application, the processor 810 is specifically configured to: determine all third images associated with the first image; in the case where the sizes of all third images are greater than the first threshold, adjust the size of any third image to the first threshold to obtain a second image.
[0113] In some embodiments of the present application, when the display area sizes of the first image and the second image in the target interface are the same, the processor 810 is specifically configured to perform any one of the following: determining that the size of the fourth image in the second image is the target size, where the fourth image is the image with the smallest or largest size in the second image; determining the median value of the sizes corresponding to all the second images as the target size; determining the average value of the sizes corresponding to all the second images as the target size.
[0114] In some embodiments of the present application, when the display positions of the first image and the second image in the target interface are adjacent, the processor 810 is specifically configured to: determine that the ratio of the display area size of the fifth image to that of the first image is the first ratio, where the fifth image is any image in the second image; calculate the target size according to the first ratio and the size corresponding to the fifth image.
[0115] It should be understood that in the embodiments of the present application, the input unit 804 may include a Graphics Processing Unit (GPU) 8041 and a microphone 8042. The GPU 8041 processes the image data of static pictures or videos obtained by an image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 806 may include a display panel 8061, and the display panel 8061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 807 includes at least one of a touch panel 8071 and other input devices 8072. The touch panel 8071 is also referred to as a touch screen. The touch panel 8071 may include two parts: a touch detection device and a touch controller. The other input devices 8072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be elaborated here.
[0116] The memory 809 can be used to store software programs and various data. The memory 809 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data. Among them, the first storage area may store an operating system, application programs or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 809 may include a volatile memory or a non-volatile memory, or the memory 809 may include both a volatile memory and a non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synch link dynamic random access memory (SLDRAM), and a direct rambus random access memory (DRRAM). The memory 809 in the embodiments of the present application includes but is not limited to these and any other suitable types of memories.
[0117] The processor 810 may include one or more processing units; optionally, the processor 810 integrates an application processor and a modem processor. Among them, the application processor mainly processes operations related to the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above modem processor may not be integrated into the processor 810.
[0118] The embodiments of the present application also provide a readable storage medium. A program or instruction is stored on the readable storage medium. When the program or instruction is executed by a processor, each process of the above-mentioned embodiment of the image processing method is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described in detail here.
[0119] Among them, the processor is the processor in the electronic device in the above-mentioned embodiment. The readable storage medium includes a computer-readable storage medium. Examples of the computer-readable storage medium include non-transitory computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs, etc.
[0120] Another embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above-mentioned embodiment of the image processing method, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0121] It should be understood that the chip mentioned in the embodiment of the present application can also be referred to as a system-on-chip, system chip, chip system, or system-on-chip, etc.
[0122] The embodiment of the present application provides a computer program product. The program product is stored in a storage medium. The program product is executed by at least one processor to implement each process of the above-mentioned embodiment of the image processing method, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0123] It should be noted that in this article, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0124] Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.
[0125] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative rather than restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.
Claims
1. An image processing method, characterized in that, it includes: Before displaying the target interface, obtain a first image among multiple images to be displayed on the target interface, where the pixel size of the first image is greater than a first threshold; Determine a second image among the multiple images that is associated with the first image and has a pixel size less than or equal to the first threshold, where the display area size of the first image and the second image in the target interface is the same, or the display positions of the first image and the second image in the target interface are adjacent; Adjust the first image to a target pixel size according to the size information corresponding to the second image, where the target pixel size is less than or equal to the first threshold; Display the target interface, where the target interface includes the second image and the first image with the target pixel size.
2. The method according to claim 1, characterized in that, The multiple images correspond to at least one type, and the display area sizes of all images of the same type in the target interface are the same, and the first threshold is determined according to the type of the images; The step of obtaining a first image among multiple images to be displayed on the target interface, where the pixel size of the first image is greater than a first threshold, includes: Obtain a first image among the images corresponding to each type, where the pixel size of the first image is greater than the first threshold corresponding to the type.
3. The method according to claim 2, characterized in that, Before the step of obtaining a first image among the images corresponding to each type, where the pixel size of the first image is greater than the first threshold corresponding to the type, the method further includes: Obtain the multiple images and the type information corresponding to each image; Classify the multiple images according to the type information corresponding to each image to obtain the at least one type; Determine that the pixel size of the target image corresponding to each type of image is the first threshold, where the target image is the image with the smallest pixel size among all images of the same type; Or, Determine the first threshold corresponding to each type according to the display area size corresponding to each type of image and the target screen resolution, where the target screen resolution is the screen resolution of the electronic device.
4. The method according to claim 3, characterized in that, The type information includes the element name or link domain name corresponding to the image, and the step of classifying the multiple images according to the type information corresponding to each image includes: Determine that images with the same element name or link domain name among the multiple images belong to the same type.
5. The method according to claim 1, characterized in that, The step of determining a second image among the multiple images that is associated with the first image and has a pixel size less than or equal to the first threshold includes: Determine all third images associated with the first image; In the case where the pixel sizes of all the third images are greater than the first threshold, adjust the pixel size of any third image to the first threshold to obtain the second image.
6. The method according to claim 1, characterized in that, When the display area sizes of the first image and the second image in the target interface are the same, adjusting the first image to a target pixel size according to the size information corresponding to the second image includes any one of the following: Determine that the pixel size of the fourth image in the second image is the target pixel size, where the fourth image is the image with the smallest or largest pixel size in the second image; Determine that the median value of the pixel sizes corresponding to all the second images is the target pixel size; Determine that the average value of the pixel sizes corresponding to all the second images is the target pixel size.
7. The method according to claim 1, wherein, When the display positions of the first image and the second image in the target interface are adjacent, adjusting the first image to a target pixel size according to the size information corresponding to the second image includes: Determine that the ratio of the display area size of the fifth image to that of the first image is a first ratio, where the fifth image is any image in the second image; Calculate the target pixel size according to the first ratio and the pixel size corresponding to the fifth image.
8. An image processing apparatus, wherein, comprises: An acquisition module, configured to acquire, before displaying the target interface, a first image with a pixel size greater than a first threshold among multiple images to be displayed on the target interface; A determination module, configured to determine, among the multiple images, a second image associated with the first image and having a pixel size less than or equal to the first threshold, where the display area sizes of the first image and the second image in the target interface are the same, or the display positions of the first image and the second image in the target interface are adjacent; An adjustment module, configured to adjust the first image to a target pixel size according to the size information corresponding to the second image, where the target pixel size is less than or equal to the first threshold; A display module, configured to display the target interface, where the target interface includes the second image and the first image with the target pixel size.
9. The apparatus according to claim 8, wherein, The multiple images correspond to at least one type, and the display area sizes of all images of the same type in the target interface are the same, and the first threshold is determined according to the type of the image; The acquisition module is specifically configured to: acquire a first image with a pixel size greater than the first threshold corresponding to the type from the images corresponding to each type.
10. The apparatus according to claim 9, wherein, The apparatus further comprises: The acquisition module is further configured to acquire the multiple images and the type information corresponding to each image before acquiring a first image with a pixel size greater than the first threshold corresponding to the type from the images corresponding to each type; A classification module, configured to classify the multiple images according to the type information corresponding to each image to obtain the at least one type; The determining module is configured to determine that the pixel size of the target image corresponding to the image of each type is the first threshold, where the target image is the image with the smallest pixel size among all images of the same type; Or, The determining module is configured to determine the first threshold corresponding to each type according to the display area size corresponding to the image of each type and the target screen resolution, where the target screen resolution is the screen resolution of the electronic device.
11. The apparatus according to claim 10, wherein, The type information includes the element name or link domain name corresponding to the image, and the classifying module is specifically configured to: Determine that images with the same element name or link domain name among the multiple images are of the same type.
12. The apparatus according to claim 8, wherein, The determining module includes: A determining unit, configured to determine all third images associated with the first image; An adjusting unit, configured to, when the pixel sizes of all the third images are greater than the first threshold, adjust the pixel size of any third image to the first threshold to obtain the second image.
13. The apparatus according to claim 8, wherein, When the display area sizes of the first image and the second image in the target interface are the same, the adjusting module is specifically configured to perform any one of the following: Determine that the pixel size of the fourth image in the second image is the target pixel size, where the fourth image is the image with the smallest or largest pixel size in the second image; Determine the median of the pixel sizes corresponding to all the second images as the target pixel size; Determine the average value of the pixel sizes corresponding to all the second images as the target pixel size.
14. The apparatus according to claim 8, wherein, When the display positions of the first image and the second image in the target interface are adjacent, the adjusting module is specifically configured to: Determine that the ratio of the display area size of the fifth image to that of the first image is a first ratio, where the fifth image is any image in the second image; Calculate the target pixel size according to the first ratio and the pixel size corresponding to the fifth image.
Citation Information
Patent Citations
Method, device and system for transmitting web page pictures
CN109003313A
Image processing method and device, equipment and storage medium
CN114118029A