Image processing method and electronic device
Embodiments of this application provide an image processing method and an electronic device, and the method includes: in response to a first operation performed by a user, obtaining a first image, where the first image is an image on which image post-processing has not been performed; obtaining a power level of an electronic device; and when a preset condition is met, saving the first image, generating a first thumbnail, and establishing a correspondence between the first thumbnail and the first image, where the preset condition at least includes that the power level of the electronic device is less than a first preset power level threshold. The method can prolong battery life of an electronic device, and improve user experience.
1 . An image processing method, wherein the method is performed by an electronic device, and the method comprises:
determining user habit information, wherein the user habit information represents whether a user is accustomed to viewing an obtained image within preset duration after shooting is completed;
in response to a first operation from the user, obtaining a first image, wherein the first image is an image on which image post-processing has not been performed;
obtaining a power level of the electronic device; and
when a preset condition is met, saving the first image, generating a first thumbnail, and establishing a correspondence between the first thumbnail and the first image, wherein the preset condition at least comprises that the power level of the electronic device is less than a first preset power level threshold, and wherein the preset condition further comprises that the user habit information is first information, wherein the first information represents that the user is not accustomed to viewing an obtained image within the preset duration after shooting is completed.
2 . The method according to claim 1 , wherein the determining user habit information comprises:
dividing a preset historical time period into n time sub-periods, wherein n is an integer greater than 1;
determining a quantity of target time periods in the n time sub-periods, wherein a ratio of a first quantity corresponding to the target time period to a second quantity corresponding to the target time period is greater than a first preset ratio, the first quantity corresponding to the target time period is a quantity of images whose shooting times are within the target time period and whose time intervals between times at which the images are initially viewed and shooting times are less than the preset duration, and the second quantity corresponding to the target time period is a total quantity of images whose shooting times are within the target time period; and
when a ratio of the quantity of target time periods to n is less than or equal to a second preset ratio, determining that the user habit information is the first information; or
when a ratio of the quantity of target time periods to n is greater than the second preset ratio, determining that the user habit information is second information, wherein the second information is used to represent that the user is accustomed to viewing an obtained image within the preset duration after shooting is completed.
3 . The method according to claim 2 , wherein the determining a quantity of target time periods in the n time sub-periods comprises:
performing first processing on each time sub-period to obtain a processing result corresponding to each time sub-period, wherein the processing result comprises that a time sub-period is the target time period, or that a time sub-period is not the target time period; and
counting, based on the processing result corresponding to each time sub-period, the quantity of target time periods in the n time sub-periods, wherein the first processing comprises:
counting a total quantity of images whose shooting times are within a first time sub-period, to obtain a second quantity corresponding to the first time sub-period, wherein the first time sub-period is any one of the n time sub-periods;
obtaining times at which the images whose shooting times are within the first time sub-period are initially viewed;
determining a quantity of images whose shooting times are within the first time sub-period and whose time intervals between times at which the images are initially viewed and shooting times are less than the preset duration, to obtain a first quantity corresponding to the first time sub-period; and
when a ratio of the first quantity corresponding to the first time sub-period to the second quantity corresponding to the first time sub-period is greater than the first preset ratio, determining that the first time sub-period is the target time period.
4 . The method according to claim 1 , wherein after the saving the first image, generating a first thumbnail, and establishing a correspondence between the first thumbnail and the first image, the method further comprises:
receiving a second operation performed by the user on the first image; and
when a type of the second operation is one of preset types, performing image post-processing on the first image to obtain a second image, and processing the second image based on the type of the second operation; or
when a type of the second operation is not any one of the preset types, processing the first image based on the type of the second operation.
5 . The method according to claim 4 , wherein the method further comprises:
displaying third information in a process of performing image post-processing on the first image, wherein the third information is used to represent that image post-processing is being performed on the first image.
6 . The method according to claim 4 , wherein the preset type comprises at least one of a viewing operation, a sharing operation, a moving operation, a copying operation, and an editing operation.
7 . The method according to claim 4 , wherein the receiving a second operation performed by the user on first image comprises:
displaying the first thumbnail; and
receiving the second operation performed by the user on the first thumbnail.
8 . The method according to claim 4 , wherein after the performing image post-processing on the first image to obtain a second image, the method further comprises:
saving the second image, generating a second thumbnail, and establishing a correspondence between the second thumbnail and the second image.
9 . The method according to claim 1 , wherein after the saving the first image, generating a first thumbnail, and establishing a correspondence between the first thumbnail and the first image, the method further comprises:
performing image post-processing on the first image to obtain a second image, when it is detected that the electronic device starts charging, or that the power level of the electronic device is greater than a second preset power level threshold, or that the electronic device is in a charging state and the power level of the electronic device is greater than a third preset power level threshold.
10 . An electronic device, comprising:
at least one processor; and
one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to cause the electronic device to:
determine user habit information, wherein the user habit information represents whether a user is accustomed to viewing an obtained image within preset duration after shooting is completed;
in response to a first operation from the user, obtain a first image, wherein the first image is an image on which image post-processing has not been performed;
obtain a power level of the electronic device; and
when a preset condition is met, save the first image, generate a first thumbnail, and establish a correspondence between the first thumbnail and the first image, wherein the preset condition at least comprises that the power level of the electronic device is less than a first preset power level threshold, and wherein the preset condition further comprises that the user habit information is first information, wherein the first information represents that the user is not accustomed to viewing an obtained image within the preset duration after shooting is completed.
11 . The electronic device according to claim 10 , wherein the determining user habit information comprises:
dividing a preset historical time period into n time sub-periods, wherein n is an integer greater than 1;
determining a quantity of target time periods in the n time sub-periods, wherein a ratio of a first quantity corresponding to the target time period to a second quantity corresponding to the target time period is greater than a first preset ratio, the first quantity corresponding to the target time period is a quantity of images whose shooting times are within the target time period and whose time intervals between times at which the images are initially viewed and shooting times are less than the preset duration, and the second quantity corresponding to the target time period is a total quantity of images whose shooting times are within the target time period; and
when a ratio of the quantity of target time periods to n is less than or equal to a second preset ratio, determining that the user habit information is the first information; or
when a ratio of the quantity of target time periods to n is greater than the second preset ratio, determining that the user habit information is second information, wherein the second information is used to represent that the user is accustomed to viewing an obtained image within the preset duration after shooting is completed.
12 . The electronic device according to claim 11 , wherein the determining a quantity of target time periods in the n time sub-periods comprises:
performing first processing on each time sub-period to obtain a processing result corresponding to each time sub-period, wherein the processing result comprises that a time sub-period is the target time period, or that a time sub-period is not the target time period; and
counting, based on the processing result corresponding to each time sub-period, the quantity of target time periods in the n time sub-periods, wherein
the first processing comprises:
counting a total quantity of images whose shooting times are within a first time sub-period, to obtain a second quantity corresponding to the first time sub-period, wherein the first time sub-period is any one of the n time sub-periods;
obtaining times at which the images whose shooting times are within the first time sub-period are initially viewed;
determining a quantity of images whose shooting times are within the first time sub-period and whose time intervals between times at which the images are initially viewed and shooting times are less than the preset duration, to obtain a first quantity corresponding to the first time sub-period; and
when a ratio of the first quantity corresponding to the first time sub-period to the second quantity corresponding to the first time sub-period is greater than the first preset ratio, determining that the first time sub-period is the target time period.
13 . The electronic device according to claim 10 , wherein the programming instructions, when executed by the at least one processor, cause the electronic device to:
after the saving the first image, generating a first thumbnail, and establishing a correspondence between the first thumbnail and the first image,
receive a second operation performed by the user on the first image; and
when a type of the second operation is one of preset types, perform image post-processing on the first image to obtain a second image, and processing the second image based on the type of the second operation; or
when a type of the second operation is not any one of the preset types, process the first image based on the type of the second operation.
14 . The electronic device according to claim 13 , the programming instructions, when executed by the at least one processor, cause the electronic device to:
display third information in a process of performing image post-processing on the first image, wherein the third information is used to represent that image post-processing is being performed on the first image.
15 . The electronic device according to claim 13 , wherein the preset type comprises at least one of a viewing operation, a sharing operation, a moving operation, a copying operation, and an editing operation.
16 . The electronic device according to claim 13 , wherein the receiving a second operation performed by the user on first image comprises:
displaying the first thumbnail; and
receiving the second operation performed by the user on the first thumbnail.
17 . The electronic device according to claim 13 , wherein the programming instructions, when executed by the at least one processor, cause the electronic device to: after the performing image post-processing on the first image to obtain a second image,
save the second image, generate a second thumbnail, and establish a correspondence between the second thumbnail and the second image.
18 . A non-transitory computer-readable storage medium storing computer instructions, that when executed by one or more processors, cause an electronic device to:
determine user habit information, wherein the user habit information represents whether a user is accustomed to viewing an obtained image within preset duration after shooting is completed;
in response to a first operation from the user, obtain a first image, wherein the first image is an image on which image post-processing has not been performed;
obtain a power level of the electronic device; and
when a preset condition is met, save the first image, generate a first thumbnail, and establish a correspondence between the first thumbnail and the first image, wherein the preset condition at least comprises that the power level of the electronic device is less than a first preset power level threshold, and wherein the preset condition further comprises that the user habit information is first information, wherein the first information represents that the user is not accustomed to viewing an obtained image within the preset duration after shooting is completed.
19 . The non-transitory computer-readable storage medium according to claim 18 ,
wherein the determining user habit information comprises:
dividing a preset historical time period into n time sub-periods, wherein n is an integer greater than 1;
determining a quantity of target time periods in the n time sub-periods, wherein a ratio of a first quantity corresponding to the target time period to a second quantity corresponding to the target time period is greater than a first preset ratio, the first quantity corresponding to the target time period is a quantity of images whose shooting times are within the target time period and whose time intervals between times at which the images are initially viewed and shooting times are less than the preset duration, and the second quantity corresponding to the target time period is a total quantity of images whose shooting times are within the target time period; and
when a ratio of the quantity of target time periods to n is less than or equal to a second preset ratio, determining that the user habit information is the first information; or
when a ratio of the quantity of target time periods to n is greater than the second preset ratio, determining that the user habit information is second information, wherein the second information is used to represent that the user is accustomed to viewing an obtained image within the preset duration after shooting is completed.