CN111836052A - Image compression method, image compression device, electronic equipment and storage medium - Google Patents
Image compression method, image compression device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN111836052A CN111836052A CN202010642564.0A CN202010642564A CN111836052A CN 111836052 A CN111836052 A CN 111836052A CN 202010642564 A CN202010642564 A CN 202010642564A CN 111836052 A CN111836052 A CN 111836052A
- Authority
- CN
- China
- Prior art keywords
- image
- compression
- processed
- storage
- compression parameters
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/42—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/156—Availability of hardware or computational resources, e.g. encoding based on power-saving criteria
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
- H04N19/17—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
- H04N19/172—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a picture, frame or field
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Computing Systems (AREA)
- Theoretical Computer Science (AREA)
- Compression Of Band Width Or Redundancy In Fax (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The application discloses an image compression method, an image compression device, electronic equipment and a storage medium, wherein the image to be processed acquired by an image acquisition device is acquired, then if the image compression function is detected to be started, image compression parameters configured by a user are acquired, the image to be processed is compressed based on the image compression parameters to obtain a target image, and then the target image is stored. Therefore, by the aid of the mode, the image to be processed is compressed based on the image compression parameters configured by the user under the condition that the image compression function is detected to be started, so that the user can define the storage size of the shot image according to needs, the occupancy rate of the storage space is reduced by compressing the image to be processed, and user experience is improved.
Description
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image compression method and apparatus, an electronic device, and a storage medium.
Background
With the increase of the popularity of smart terminals such as mobile phones, more and more users record various moments of life, work and study by taking pictures or videos through mobile phones, and the taken images can be stored or uploaded and shared in real time through a network. However, in order to ensure the picture quality of the shot pictures or videos, the pictures or videos need to be shot and stored according to a predetermined parameter mode, and as the number of the pictures or videos increases, a large storage space is occupied, thereby reducing the user experience.
Disclosure of Invention
In view of the above problems, the present application provides an image compression method, apparatus, electronic device and storage medium to improve the above problems.
In a first aspect, an embodiment of the present application provides an image compression method, where the method includes: acquiring an image to be processed acquired by an image acquisition device; if the image compression function is detected to be started, acquiring image compression parameters configured by a user; compressing the image to be processed based on the image compression parameters to obtain a target image; and storing the target image.
In a second aspect, an embodiment of the present application provides an image compression apparatus, including: the image acquisition module is used for acquiring the image to be processed acquired by the image acquisition device; the compression parameter acquisition module is used for acquiring image compression parameters configured by a user if the image compression function is detected to be started; the compression processing module is used for compressing the image to be processed based on the image compression parameters to obtain a target image; and the storage module is used for storing the target image.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory and one or more processors; one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the method of the first aspect described above.
In a fourth aspect, the present application provides a computer-readable storage medium, in which a program code is stored, wherein when the program code is executed by a processor, the method according to the first aspect is performed.
According to the image compression method and device, the electronic equipment and the storage medium, the image to be processed collected by the image collection device is obtained, then if the image compression function is detected to be started, the image compression parameters configured by a user are obtained, then the image to be processed is compressed based on the image compression parameters, the target image is obtained, and then the target image is stored. Therefore, by the aid of the mode, the image to be processed is compressed based on the image compression parameters configured by the user under the condition that the image compression function is detected to be started, so that the user can define the storage size of the shot image according to needs, the occupancy rate of the storage space is reduced by compressing the image to be processed, and user experience is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 shows a flowchart of a method of image compression according to an embodiment of the present application.
Fig. 2 is a diagram showing a display example of a setting button of an image compression function provided in an embodiment of the present application.
Fig. 3 is a diagram showing another display example of a setting button of the image compression function provided in the embodiment of the present application.
Fig. 4 shows a flowchart of a method for compressing an image according to another embodiment of the present application.
Fig. 5 shows a flowchart for determining whether compression processing is required for a picture taken by a camera according to an embodiment of the present application.
Fig. 6 shows a flowchart of a method for compressing an image according to another embodiment of the present application.
Fig. 7 is a diagram illustrating an example of a setting interface for setting compression parameters included in image compression parameters according to an embodiment of the present application.
Fig. 8 is a flowchart illustrating an image compression method according to still another embodiment of the present application.
Fig. 9 is a flowchart illustrating a method of compressing an image according to still another embodiment of the present application.
Fig. 10 is a diagram illustrating a display example of a picture setting resume function button provided in an embodiment of the present application.
Fig. 11 shows a block diagram of an image compression apparatus according to an embodiment of the present application.
Fig. 12 shows a block diagram of an electronic device according to an embodiment of the present application.
Fig. 13 illustrates a storage unit for storing or carrying program codes for implementing an image compression method according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
Along with the improvement of the living standard of people, the popularization rate of the intelligent terminal in daily life use is nearly the coverage of people, wherein, a camera module becomes the main function point of the intelligent terminal, a common user can shoot photos and videos, record the moments of life, study and work, the intelligent terminal automatically stores picture files after shooting, and meanwhile, the user can upload and share the picture files in real time through a network, so that the camera function of the intelligent terminal is always concerned by the user.
As a mode for improving the imaging quality of a photo, the shooting effect can be improved by continuously improving the parameters of a camera module, debugging the beautifying effect of software and the like, however, in order to ensure the picture quality of the shot picture or video, the picture or video needs to be shot and stored according to a set parameter mode, and along with the increase of the number of the pictures or videos, more storage space can be occupied, and further the user experience is reduced.
In view of the above problems, the inventors have found through long-term research that an image to be processed acquired by an image acquisition device can be acquired, then if it is detected that an image compression function is started, an image compression parameter configured by a user is acquired, then the image to be processed is compressed based on the image compression parameter to obtain a target image, and then the target image is stored. Therefore, by the aid of the mode, the image to be processed is compressed based on the image compression parameters configured by the user under the condition that the image compression function is detected to be started, so that the user can define the storage size of the shot image according to needs, the occupancy rate of the storage space is reduced by compressing the image to be processed, and user experience is improved. Therefore, an image compression method, an image compression device, an electronic device and a storage medium provided by the embodiments of the present application are provided.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of an image compression method according to an embodiment of the present application is shown, where the embodiment provides an image compression method applicable to an electronic device, and the method includes:
step S110: and acquiring the image to be processed acquired by the image acquisition device.
Optionally, the image capturing device may be a camera or a camera, and the image capturing device may be a camera module configured inside the electronic device, or may be a camera in communication connection with the electronic device, for example, an external camera. Optionally, the number of the image capturing devices may not be limited, for example, if the image capturing device is a camera configured inside the electronic device, the image capturing device may be at least one camera, for example, two cameras, three cameras, four cameras, or a greater number of cameras, and the specific number may not be limited. The installation position of the image capturing device may not be limited, and for example, the image capturing device may be a front camera of a mobile phone, a rear camera of a mobile phone, or a camera of another part of a mobile phone.
The image to be processed may be understood as an image captured by an image capturing device, for example, the image to be processed may be a picture, a video, or the like taken by a camera module of a mobile phone. As one way, when it is detected that the user turns on the camera function to shoot, a shot picture or video or the like may be taken as an image to be processed.
Step S120: and if the image compression function is detected to be started, acquiring image compression parameters configured by a user.
For example, as shown in fig. 2, a picture 102 taken by a user through a camera is displayed on a display interface 101 of the electronic device 100, a setting button 103 of the configured image compression function is displayed on the upper right corner of the display interface 101 of the electronic device, and the user can set a compression mode of a taken picture (i.e., how to compress the taken picture specifically) by touching the setting button 103 of the image compression function, that is, jump to the interface shown in fig. 3, and after the setting is completed, the taken picture can be automatically compressed by turning on the compression function button, so that the storage space occupied by the taken picture is reduced.
As one way, an identification value corresponding to an on or off state of the image compression function may be configured, and then whether the image compression function is in the on state may be determined by detecting a specific value of the identification value, that is, whether the image compression function is turned on is detected by detecting the specific value of the identification value. For example, assuming that it is preconfigured that the identification value "1" represents that the image compression function is in the on state, and the identification value "0" represents that the image compression function is in the off state, in this manner, it may be determined that the image compression function is detected to be on when the identification value "1" is detected, and that the image compression function is not detected to be on when the identification value "0" is detected.
As a mode, if it is detected that the image compression function is turned on, the image compression parameter configured by the user may be obtained, so that the image acquired by the image acquisition device may be encoded and compressed subsequently according to the image compression parameter. The image compression parameters configured by the user can be stored in a certain configuration file, and when the image compression function is detected to be started, the image compression parameters configured by the user can be obtained by reading the configuration file.
Step S130: and compressing the image to be processed based on the image compression parameters to obtain a target image.
As a mode, the image to be processed may be compressed based on the obtained image compression parameter, so that the target image with a reduced size of the storage space may be obtained, that is, the size of the storage space occupied by the target image is reduced relative to the size of the storage space occupied by the image to be processed.
Step S140: and storing the target image.
Optionally, the content of the target image is the same as that of the image to be processed, and the size of the storage space occupied by the target image is relatively small, so that the size of the storage space occupied by the shot picture can be reduced by storing the target image.
As a mode, by storing the target image, when the target image is sent through the network, the data traffic consumption can be reduced, and meanwhile, because the storage space occupied by the target image is small, the sending time of the picture can be reduced.
In the image compression method provided by this embodiment, an image to be processed acquired by an image acquisition device is acquired, then, if it is detected that an image compression function is started, an image compression parameter configured by a user is acquired, then, the image to be processed is compressed based on the image compression parameter to obtain a target image, and then, the target image is stored. Therefore, by the aid of the mode, the image to be processed is compressed based on the image compression parameters configured by the user under the condition that the image compression function is detected to be started, so that the user can define the storage size of the shot image according to needs, the occupancy rate of the storage space is reduced by compressing the image to be processed, and user experience is improved.
Referring to fig. 4, a flowchart of an image compression method according to another embodiment of the present application is shown, where the embodiment provides an image compression method applicable to an electronic device, the method includes:
step S210: and acquiring the image to be processed acquired by the image acquisition device.
Step S220: it is detected whether the image compression function is turned on.
As a mode, when the image compression function is started, when a user finishes taking a picture, a floating frame pop-up event may be automatically triggered, that is, a floating prompt box is popped up to prompt the user whether to compress the picture. Optionally, if a floating frame ejection event is detected to exist, it may be determined that the image compression function is started; if the floating frame ejection event is not detected, it can be determined that the image compression function is not started.
Step S231: and acquiring image compression parameters configured by a user.
As one way, if it is detected that the image compression function is turned on, the image compression parameters configured by the user may be obtained.
Step S232: and acquiring the size of the image to be processed.
In this embodiment, the size of the image of the to-be-processed image may represent the size of the storage space occupied by the to-be-processed image. Optionally, after the to-be-processed image acquired by the image acquisition device is acquired, the image size of the to-be-processed image may be acquired (for example, the image size of the to-be-processed image may be acquired by reading the "occupied space" of the photographed to-be-processed image), so that it may be determined whether compression processing needs to be performed on the to-be-processed image based on the image size of the to-be-processed image in the following process.
Step S233: and comparing the image size with the image size corresponding to the image compression parameter.
Optionally, the image compression parameter in this embodiment may include a specified image storage size, where the specified image storage size may be a fixed value, may also be a custom value, or may include both a fixed value and a custom value. The specified storage size can be understood as a specified storage space size, for example, the specified storage size can be "3M", "1.5M", and the like, and the specific value can be set according to actual requirements. Alternatively, the specified storage size may be used as the image size corresponding to the image compression parameter.
As a mode, the image size of the image to be processed may be compared with the image size corresponding to the image compression parameter, so as to determine whether the image to be processed needs to be compressed according to the comparison result.
Step S234: and if the image size of the image to be processed is larger than the image size corresponding to the image compression parameter, compressing the image to be processed based on the image compression parameter to obtain a target image.
In an implementation manner, if the image size of the image to be processed is larger than the image size corresponding to the image compression parameter, the image to be processed may be compressed based on the image compression parameter, so as to obtain the target image. For example, in a specific example, assuming that the image size of the image to be processed is 3.5M, and the image size corresponding to the image compression parameter is 3M, where 3.5M >3M, in this way, it may be determined that the image to be processed needs to be compressed, and specifically, the image size of the image to be processed may be compressed from 3.5M to 3M; optionally, if the size of the image corresponding to the image compression parameter is 5M, and 3.5M <5M, in this way, it may be determined that the image to be processed does not need to be compressed, and the image to be processed may be directly stored according to 3.5M.
Step S235: and storing the target image.
Step S241: and storing the image to be processed.
As a mode, if the image size of the image to be processed is smaller than or equal to the image size corresponding to the image compression parameter, the image to be processed may be directly stored without performing compression processing on the image to be processed.
As another way, if it is not detected that the image compression function is turned on, the image to be processed may be directly stored.
For example, in a specific application scenario, please refer to fig. 5, which shows a flowchart for determining whether a compression process is required for a picture taken by a camera. As shown in fig. 5, after taking a picture with a camera, the camera may return the taken picture data, and at this time, the user may check the image quality, the storage size, and the like of the taken picture, optionally, the electronic device may detect whether the user sets a picture compression function, optionally, if the user detects that the picture compression function is set, it may determine whether the picture needs to be compressed, where the determination principle and the determination process may refer to the foregoing description, and are not described herein again. Optionally, if it is determined that the photo needs to be compressed, the photo may be compressed by a photo polling compression algorithm, and the photo may be stored in a JPEG format after compression is completed. Optionally, if it is not detected that the user sets the picture compression, the shot picture may be directly stored according to the JPEG format. The specific principle and implementation process of compressing the picture by the picture polling compression algorithm may refer to related technologies, which are not described herein again.
According to the image compression method provided by the embodiment, the image size of the image to be processed is obtained under the condition that the image compression function is detected to be started, then the image size of the image to be processed is compared with the image size corresponding to the image compression parameter, and the image to be processed is compressed based on the image compression parameter under the condition that it is judged that the image size of the image to be processed is larger than the image size corresponding to the image compression parameter, so that misoperation caused by direct compression processing of the image to be processed can be avoided, and the accuracy of the compression processing is improved. The image to be processed is compressed based on the image compression parameters configured by the user, so that the user can define the storage size of the shot image according to the requirement, the occupancy rate of the storage space is reduced by compressing the image to be processed, and the user experience is improved.
Referring to fig. 6, a flowchart of an image compression method according to another embodiment of the present application is shown, where the embodiment provides an image compression method applicable to an electronic device, the method includes:
step S310: and acquiring the image to be processed acquired by the image acquisition device.
Step S320: it is detected whether the image compression function is turned on.
Step S331: and acquiring image compression parameters configured by a user.
Step S332: and detecting the compression parameters included in the image compression parameters.
Alternatively, the image compression parameters in the present embodiment may include a plurality of types of compression parameters, for example, the image compression parameters may include a first compression parameter and a second compression parameter, and the first compression parameter and the second compression parameter are different in type. The first compression parameter may characterize a compression ratio and the second compression parameter may characterize a specified stored value, e.g., the first compression parameter may be 70%, 50%, 30%, the second compression parameter may be 5M, 3M, 2M, etc. The types and specific values of the first compression parameters may not be limited, and the number and specific values of the second compression parameters may not be limited. Alternatively, only the first compression parameter and the second compression parameter are described here, and more types of compression parameters may be included in actual implementation.
Optionally, the image compression parameters may include one type of compression parameter, or may also include multiple types of compression parameters, and optionally, compression modes corresponding to different types of compression parameters are different. In this way, the compression parameter currently included in the image compression parameter can be detected. Optionally, the different types of compression parameters may configure corresponding type identifiers, so that the compression parameters included in the image compression parameters may be obtained according to the type identifiers included in the image compression parameters.
Step S333: and compressing the image to be processed based on the included compression parameters to obtain a target image.
As one mode, the target image may be obtained by compressing the image to be processed based on the compression parameters included in the detected image compression parameters.
In an implementation manner, if it is detected that the image compression parameter includes the first compression parameter, the target image may be obtained by compressing the image to be processed based on the first compression parameter.
In another implementation, if it is detected that the image compression parameters include the second compression parameter, the image to be processed may be compressed to the specified stored value based on the second compression parameter, so as to obtain the target image. The designated storage value may be a predetermined fixed storage value or a storage value customized by the user. The second compression parameter may include only a predetermined fixed stored value, only a user-defined stored value, or both a predetermined fixed stored value and a user-defined stored value. Optionally, if the second compression parameter includes a preset fixed storage value and a user-defined storage value at the same time, the image to be processed may be compressed based on the preset fixed storage value and the user-defined storage value, and the image that occupies a smaller storage space after compression is acquired as the target image.
In another implementation, if it is detected that the image compression parameters include a first compression parameter and a second compression parameter, the storage size of the image after the image to be processed is compressed based on the first compression parameter may be estimated as a first storage size, then the storage size of the image after the image to be processed is pre-compressed based on the second compression parameter may be estimated as a second storage size, and then the image to be processed is compressed based on the compression parameter corresponding to the smaller storage size of the first storage size and the second storage size, so as to obtain the target image. It should be noted that, if the second compression parameter includes a preset fixed storage value and a user-defined storage value at the same time, the image storage size after pre-compression processing is performed on the image to be processed based on the preset fixed storage value and the user-defined storage value may be respectively estimated as the second storage size and the third storage size.
For example, in a specific application scenario, please refer to fig. 7, which shows an exemplary diagram of a setting interface for setting compression parameters included in image compression parameters. As shown in fig. 7, in the process of setting the compression parameters corresponding to the automatic compression of the picture, the compression parameters may be set in a mode of picture size compression percentage, as shown in fig. 7, the picture size compression percentage includes 50%, 70%, and 90%, and different compression percentages are selected, so that the picture to be processed is compressed according to the corresponding percentages, and a target image with a reduced occupied storage space is obtained. Optionally, the image storage size may also be set according to a mode of the image storage size, as shown in fig. 7, the image storage size includes 5M, 3M, and 1M, different image storage sizes are selected, the image to be processed is compressed to the selected image storage size, and optionally, the storage space of the compressed image to be processed is reduced. Optionally, or the image compression size can be set according to a user-defined image compression size mode, as shown in fig. 7, a user can input a stored value of any numerical value in a blank frame, and after clicking a storage button, the image to be processed can be compressed to the user-defined image storage size, so that the user-defined size of a photographing file can be realized, the autonomy of the user in using a camera is improved, and further the user experience is improved.
As an embodiment, if it is detected that the image compression parameters include a first compression parameter and a second compression parameter, the image to be processed may be compressed based on the first parameter and the second parameter, and the image with a smaller storage space after the compression processing is acquired as the target image.
Step S334: and storing the target image.
Step S341: and storing the image to be processed.
According to the image compression method provided by the embodiment, the image to be processed is compressed based on the image compression parameters configured by the user, so that the autonomy of the user in using the camera is improved, the image to be processed is compressed based on the compression parameters defined by the user, the size of the photographing file defined by the user can be realized, and the flexibility of compressing the image is improved. The image to be processed is compressed based on the image compression parameters configured by the user, so that the user can define the storage size of the shot image according to the requirement, the occupancy rate of the storage space is reduced by compressing the image to be processed, and the user experience is improved.
Referring to fig. 8, a flowchart of an image compression method according to still another embodiment of the present application is shown, where the embodiment provides an image compression method applicable to an electronic device, and the method includes:
step S410: and acquiring the image to be processed acquired by the image acquisition device.
Step S420: it is detected whether the image compression function is turned on.
Step S431: and acquiring image compression parameters configured by a user.
Step S432: and acquiring a storage area corresponding to the image to be processed.
Optionally, the electronic device may include a plurality of storage regions, each storage region corresponds to an image compression parameter, for example, different folders may be set according to storage requirements, the different folders are used to store pictures with different sizes, for example, a folder 1, a folder 2, and a folder 3 may be set, where the folder 1 is used to store 1 inch identification photos, the folder 2 is used to store photos taken during traveling (the size may be limited to within 3M), and the folder 3 is used to store life photos (the size may be limited to within 2M). In this way, the user can store the shot photos in the corresponding folders, for example, when the user travels outside, the shot photos can be stored in the folder 2, if the user takes the photos with various ground colors, the photos can be stored in the folder 1, if the user takes some photos recording moments in life, the photos can be stored in the folder 3, and the storage areas corresponding to the images to be processed can be obtained according to the shooting scenes of the photos.
Optionally, the types of the compression parameters corresponding to different storage areas may be different, for example, in the foregoing example, it is assumed that there are two types of storage areas, which are storage area 1 and storage area 2, respectively, the compression parameter corresponding to storage area 1 is a first compression parameter, the compression parameter corresponding to storage area 2 is a second compression parameter, and the first compression parameter and the second compression parameter are different types of compression parameters, so the types of the compression parameters corresponding to different types of storage areas may be different.
Optionally, the types of compression parameters corresponding to different storage areas may be the same. For example, in the above example, it is assumed that the second compression parameter includes both a preset fixed storage value and a user-defined storage value, and if the compression parameter corresponding to the storage area 1 is the preset fixed storage value, and the compression parameter corresponding to the storage area 2 is the user-defined storage value, the types of the compression parameters corresponding to different storage areas are the same.
Step S433: and compressing the image to be processed based on the image compression parameters corresponding to the storage area to obtain a target image.
As one mode, after the storage area corresponding to the image to be processed is obtained, the image to be processed may be compressed based on the image compression parameter corresponding to the storage area where the image to be processed is currently located, so as to obtain the target image.
Step S434: and storing the target image.
Step S441: and storing the image to be processed.
According to the image compression method provided by the embodiment, the storage area corresponding to the image to be processed is obtained, and then the image to be processed is compressed based on the image compression parameters corresponding to the obtained storage area, so that the target image is obtained, and the compression of the compressed image to be processed with pertinence can be realized, so that different images to be processed can be compressed to different storage space sizes based on different requirements of users, the autonomy of the users in using the camera is improved, and further the user experience is improved. The image to be processed is compressed based on the image compression parameters configured by the user, so that the user can define the storage size of the shot image according to the requirement, the occupancy rate of the storage space is reduced by compressing the image to be processed, and the user experience is improved.
Referring to fig. 9, a flowchart of an image compression method according to still another embodiment of the present application is shown, where the embodiment provides an image compression method applicable to an electronic device, and the method includes:
step S510: and acquiring the image to be processed acquired by the image acquisition device.
Step S520: and if the image compression function is detected to be started, acquiring image compression parameters configured by a user.
Step S530: and compressing the image to be processed based on the image compression parameters to obtain a target image.
Step S540: and storing the target image.
Step S550: and responding to an image restoration instruction, and restoring the target image to the image to be processed.
The image restoration instruction is used for restoring the storage space occupied by the target image, namely restoring the storage space occupied by the target image to the storage space occupied by the image to be processed. Optionally, an image restoration function may be configured in advance, and a user may trigger the restoration instruction by touching a function button corresponding to the image restoration function.
It can be understood that, for a picture of particular interest to the user, the user may prefer to keep the size of the picture when the picture is taken, so as to better keep the original image quality, for example, if the user takes a photo of a good friend with a mobile phone and suddenly thinks that the photo is good, and wants to print out the picture and keep the picture, the user may touch the function button corresponding to the image restoring function to restore the target image to the image to be processed.
For example, as shown in fig. 10, the display interface 101 of the electronic device 100 displays a picture setting and restoring function button, that is, "picture quality setting one-key restoration" shown in fig. 10, and by touching "picture quality setting one-key restoration", an image restoration instruction may be triggered. As a mode, if the image restoring instruction is triggered, the electronic device may restore the target image to the image to be processed by one key in response to the image restoring instruction, that is, the size of the storage space occupied by the target image is restored to the size of the storage space occupied by the image to be processed.
According to the image compression method provided by the embodiment, the image to be processed is compressed based on the image compression parameters configured by the user, so that the user can define the storage size of the shot image according to the requirement, the occupancy rate of the storage space is reduced by compressing the image to be processed, and the user experience is improved. By responding to the image restoration instruction, the size of the storage space of the target image can be restored to the size of the storage space of the image to be processed before compression processing by one key, and the flexibility of the compression processing of the image is improved.
Referring to fig. 11, which is a block diagram of an image compression apparatus according to an embodiment of the present disclosure, in this embodiment, an image compression apparatus 600 is provided, which can be operated in an electronic device, where the apparatus 600 includes: the image acquisition module 610, the compression parameter acquisition module 620, the compression processing module 630, and the storage module 640:
the image acquiring module 610 is configured to acquire an image to be processed acquired by the image acquiring apparatus.
A compression parameter obtaining module 620, configured to obtain an image compression parameter configured by a user if it is detected that the image compression function is started.
And a compression processing module 630, configured to perform compression processing on the image to be processed based on the image compression parameter, so as to obtain a target image.
As one mode, the apparatus 600 may further include an image size comparison module, configured to obtain an image size of the image to be processed, compare the image size with an image size corresponding to the image compression parameter, and if the image size of the image to be processed is larger than the image size corresponding to the image compression parameter, perform the step of compressing the image to be processed based on the image compression parameter.
Optionally, the compression processing module 630 may be specifically configured to detect a compression parameter included in the image compression parameter; and compressing the image to be processed based on the included compression parameters to obtain a target image. In an implementation manner, if the image compression parameter includes a first compression parameter, the image to be processed may be compressed based on the first compression parameter to obtain a target image, and optionally, the first compression parameter may represent a compression ratio. In another implementation manner, if the image compression parameter includes a second compression parameter, the image to be processed may be compressed to a specified stored value based on the second compression parameter, so as to obtain the target image, and optionally, the second compression parameter represents the specified stored value. In another implementation, if the image compression parameters include a first compression parameter and a second compression parameter, a storage size of the image after the image to be processed is compressed based on the first compression parameter may be estimated as a first storage size, optionally, the first compression parameter represents a compression ratio, and the second compression parameter represents a specified storage value; then, pre-compressing the image to be processed based on the second compression parameter to obtain an image storage size, and taking the image storage size as a second storage size; and then, compressing the image to be processed based on the compression parameter corresponding to the smaller storage size of the first storage size and the second storage size to obtain a target image.
Optionally, the electronic device may include a plurality of storage regions (for example, a plurality of folders may be divided according to actual requirements, each folder is configured to store different types of pictures or images), each storage region may correspond to one image compression parameter, for example, three storage regions are respectively folder 1, folder 2, and folder 3, a compression parameter corresponding to folder 1 is "5M", a compression parameter corresponding to folder 2 is "1 inch", and a compression parameter corresponding to folder 3 is "50%", and in this way, the compression processing module 630 may be specifically configured to acquire a storage region corresponding to the image to be processed; and compressing the image to be processed based on the image compression parameters corresponding to the storage area to obtain a target image.
A storage module 640, configured to store the target image.
Optionally, the apparatus 600 may further include a restoring module, configured to restore the target image to the image to be processed in response to an image restoring instruction.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and modules may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, the coupling or direct coupling or communication connection between the modules shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or modules may be in an electrical, mechanical or other form.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
Referring to fig. 12, based on the image compression method and apparatus, an embodiment of the present application further provides an electronic device 100 capable of performing the image compression method. The electronic device 100 includes a memory 102 and one or more processors 104 (only one shown) coupled to each other, the memory 102 and the processors 104 being communicatively coupled to each other. The memory 102 stores therein a program that can execute the contents of the foregoing embodiments, and the processor 104 can execute the program stored in the memory 102.
The processor 104 may include one or more processing cores, among other things. The processor 104 interfaces with various components throughout the electronic device 100 using various interfaces and circuitry to perform various functions of the electronic device 100 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 102 and invoking data stored in the memory 102. Alternatively, the processor 104 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 104 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing display content; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 104, but may be implemented by a communication chip.
The Memory 102 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). The memory 102 may be used to store instructions, programs, code sets, or instruction sets. The memory 102 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the foregoing embodiments, and the like. The data storage area may also store data created by the electronic device 100 during use (e.g., phone book, audio-video data, chat log data), and the like.
Referring to fig. 13, a block diagram of a computer-readable storage medium according to an embodiment of the present application is shown. The computer-readable storage medium 700 has stored therein program code that can be called by a processor to execute the methods described in the above-described method embodiments.
The computer-readable storage medium 700 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium 700 includes a non-transitory computer-readable storage medium. The computer readable storage medium 700 has storage space for program code 710 to perform any of the method steps of the method described above. The program code can be read from or written to one or more computer program products. The program code 710 may be compressed, for example, in a suitable form.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
To sum up, according to the image compression method, the image compression device, the electronic device and the storage medium provided by the embodiment of the application, the image to be processed acquired by the image acquisition device is acquired, then if the image compression function is detected to be started, the image compression parameters configured by a user are acquired, the image to be processed is compressed based on the image compression parameters, a target image is obtained, and then the target image is stored. Therefore, by the aid of the mode, the image to be processed is compressed based on the image compression parameters configured by the user under the condition that the image compression function is detected to be started, so that the user can define the storage size of the shot image according to needs, the occupancy rate of the storage space is reduced by compressing the image to be processed, and user experience is improved.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not necessarily depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.
Claims (11)
1. An image compression method applied to an electronic device, the method comprising:
acquiring an image to be processed acquired by an image acquisition device;
if the image compression function is detected to be started, acquiring image compression parameters configured by a user;
compressing the image to be processed based on the image compression parameters to obtain a target image;
and storing the target image.
2. The method according to claim 1, wherein the compressing the image to be processed based on the image compression parameter further comprises:
acquiring the size of the image to be processed;
comparing the image size with the image size corresponding to the image compression parameter;
and if the image size of the image to be processed is larger than the image size corresponding to the image compression parameter, executing the step of compressing the image to be processed based on the image compression parameter.
3. The method according to claim 1, wherein compressing the image to be processed based on the image compression parameter to obtain a target image comprises:
detecting compression parameters included in the image compression parameters;
and compressing the image to be processed based on the included compression parameters to obtain a target image.
4. The method according to claim 3, wherein the compressing the image to be processed based on the included compression parameters to obtain a target image comprises:
if the image compression parameters comprise first compression parameters, compressing the image to be processed based on the first compression parameters to obtain a target image, wherein the first compression parameters represent compression ratios.
5. The method according to claim 3, wherein the compressing the image to be processed based on the included compression parameters to obtain a target image comprises:
if the image compression parameters comprise second compression parameters, compressing the image to be processed to an appointed storage value based on the second compression parameters to obtain a target image, wherein the second compression parameters represent the appointed storage value.
6. The method according to claim 3, wherein the compressing the image to be processed based on the included compression parameters to obtain a target image comprises:
if the image compression parameters comprise first compression parameters and second compression parameters, estimating the image storage size after the image to be processed is compressed based on the first compression parameters as a first storage size, wherein the first compression parameters represent compression ratios, and the second compression parameters represent specified storage values;
pre-estimating the image storage size after pre-compressing the image to be processed based on the second compression parameter as a second storage size;
and compressing the image to be processed based on the compression parameter corresponding to the smaller storage size of the first storage size and the second storage size to obtain a target image.
7. The method according to claim 1, wherein the electronic device includes a plurality of storage areas, each storage area corresponds to an image compression parameter, and the compressing the image to be processed based on the image compression parameter to obtain the target image includes:
acquiring a storage area corresponding to the image to be processed;
and compressing the image to be processed based on the image compression parameters corresponding to the storage area to obtain a target image.
8. The method according to any one of claims 1-7, further comprising:
and responding to an image restoration instruction, and restoring the target image to the image to be processed.
9. An image compression apparatus, operable in an electronic device, the apparatus comprising:
the image acquisition module is used for acquiring the image to be processed acquired by the image acquisition device;
the compression parameter acquisition module is used for acquiring image compression parameters configured by a user if the image compression function is detected to be started;
the compression processing module is used for compressing the image to be processed based on the image compression parameters to obtain a target image;
and the storage module is used for storing the target image.
10. An electronic device comprising one or more processors and memory;
one or more programs stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the method of any of claims 1-8.
11. A computer-readable storage medium, having program code stored therein, wherein the program code when executed by a processor performs the method of any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010642564.0A CN111836052B (en) | 2020-07-06 | 2020-07-06 | Image compression method, image compression device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010642564.0A CN111836052B (en) | 2020-07-06 | 2020-07-06 | Image compression method, image compression device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111836052A true CN111836052A (en) | 2020-10-27 |
CN111836052B CN111836052B (en) | 2022-11-15 |
Family
ID=72900222
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010642564.0A Active CN111836052B (en) | 2020-07-06 | 2020-07-06 | Image compression method, image compression device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111836052B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112102320A (en) * | 2020-11-18 | 2020-12-18 | 粒子文化科技集团(杭州)股份有限公司 | Image compression method, image compression device, electronic device, and storage medium |
CN112770114A (en) * | 2020-12-29 | 2021-05-07 | 平安普惠企业管理有限公司 | Image data compression method and device, computer equipment and storage medium |
CN114302146A (en) * | 2021-12-30 | 2022-04-08 | 阿里巴巴新加坡控股有限公司 | Image processing method, image processing device, electronic equipment and computer storage medium |
CN115361369A (en) * | 2022-08-12 | 2022-11-18 | 中国联合网络通信集团有限公司 | Data processing method and device, electronic equipment and computer readable storage medium |
CN115543941A (en) * | 2022-12-01 | 2022-12-30 | 成都实时技术股份有限公司 | Data storage optimization processing method |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103795928A (en) * | 2014-02-12 | 2014-05-14 | Tcl通讯(宁波)有限公司 | Method and system for processing pictures with original data format |
WO2015027882A1 (en) * | 2013-08-28 | 2015-03-05 | Tencent Technology (Shenzhen) Company Limited | Method, apparatus and terminal for image processing |
CN105657422A (en) * | 2016-01-21 | 2016-06-08 | 航天恒星科技有限公司 | Multi-scene image compression processing method and system |
CN110930467A (en) * | 2019-11-19 | 2020-03-27 | 深圳传音控股股份有限公司 | Image processing method, electronic device and readable storage medium |
-
2020
- 2020-07-06 CN CN202010642564.0A patent/CN111836052B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2015027882A1 (en) * | 2013-08-28 | 2015-03-05 | Tencent Technology (Shenzhen) Company Limited | Method, apparatus and terminal for image processing |
CN104427341A (en) * | 2013-08-28 | 2015-03-18 | 腾讯科技(深圳)有限公司 | Image processing method and apparatus, and terminal |
CN103795928A (en) * | 2014-02-12 | 2014-05-14 | Tcl通讯(宁波)有限公司 | Method and system for processing pictures with original data format |
CN105657422A (en) * | 2016-01-21 | 2016-06-08 | 航天恒星科技有限公司 | Multi-scene image compression processing method and system |
CN110930467A (en) * | 2019-11-19 | 2020-03-27 | 深圳传音控股股份有限公司 | Image processing method, electronic device and readable storage medium |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112102320A (en) * | 2020-11-18 | 2020-12-18 | 粒子文化科技集团(杭州)股份有限公司 | Image compression method, image compression device, electronic device, and storage medium |
CN112770114A (en) * | 2020-12-29 | 2021-05-07 | 平安普惠企业管理有限公司 | Image data compression method and device, computer equipment and storage medium |
CN112770114B (en) * | 2020-12-29 | 2023-03-28 | 平安普惠企业管理有限公司 | Image data compression method and device, computer equipment and storage medium |
CN114302146A (en) * | 2021-12-30 | 2022-04-08 | 阿里巴巴新加坡控股有限公司 | Image processing method, image processing device, electronic equipment and computer storage medium |
CN115361369A (en) * | 2022-08-12 | 2022-11-18 | 中国联合网络通信集团有限公司 | Data processing method and device, electronic equipment and computer readable storage medium |
CN115361369B (en) * | 2022-08-12 | 2024-05-31 | 中国联合网络通信集团有限公司 | Data processing method, device, electronic equipment and computer readable storage medium |
CN115543941A (en) * | 2022-12-01 | 2022-12-30 | 成都实时技术股份有限公司 | Data storage optimization processing method |
CN115543941B (en) * | 2022-12-01 | 2023-02-17 | 成都实时技术股份有限公司 | Data storage optimization processing method |
Also Published As
Publication number | Publication date |
---|---|
CN111836052B (en) | 2022-11-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111836052B (en) | Image compression method, image compression device, electronic equipment and storage medium | |
CN109167931B (en) | Image processing method, device, storage medium and mobile terminal | |
CN109961453B (en) | Image processing method, device and equipment | |
CN111491102B (en) | Detection method and system for photographing scene, mobile terminal and storage medium | |
CN110072057B (en) | Image processing method and related product | |
CN105554372B (en) | Shooting method and device | |
CN112565599A (en) | Image shooting method and device, electronic equipment, server and storage medium | |
CN104580907A (en) | Anti-shake photographing method and device | |
CN112770059B (en) | Photographing method and device and electronic equipment | |
CN105320695A (en) | Picture processing method and device | |
CN107566746B (en) | Photographing method and user terminal | |
CN113810604B (en) | Document shooting method, electronic device and storage medium | |
CN107360366B (en) | Photographing method and device, storage medium and electronic equipment | |
CN105391940B (en) | A kind of image recommendation method and device | |
CN112950738B (en) | Rendering engine processing method and device, storage medium and electronic equipment | |
CN110191324B (en) | Image processing method, image processing apparatus, server, and storage medium | |
CN113343895B (en) | Target detection method, target detection device, storage medium and electronic equipment | |
CN109104633B (en) | Video screenshot method and device, storage medium and mobile terminal | |
CN108573044A (en) | A kind of photograph album processing method, device, terminal and storage medium | |
KR20210011404A (en) | Video processing method, device, terminal and storage medium | |
KR102501036B1 (en) | Method and device for shooting image, and storage medium | |
CN105611341A (en) | Image transmission method, device and system | |
CN110267011B (en) | Image processing method, image processing apparatus, server, and storage medium | |
CN110457264B (en) | Conference file processing method, device, equipment and computer readable storage medium | |
CN110266942B (en) | Picture synthesis method and related product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |