Picture compression method and device based on file monitoring mechanism, electronic equipment and storage medium
By real-time monitoring and automatic identification of image file formats, combined with multi-objective optimization functions and dynamic adjustment algorithms, the problems of cumbersome operation and poor flexibility in traditional image compression technology have been solved, realizing intelligent and personalized image compression and improving efficiency and adaptability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU LUYI TECH CO LTD
- Filing Date
- 2026-01-08
- Publication Date
- 2026-05-15
AI Technical Summary
Existing image compression technologies are cumbersome to operate, requiring users to frequently select images and set compression parameters manually, which is inefficient. Furthermore, the fixed compression parameters cannot meet the diverse needs of different users, resulting in poor flexibility.
By monitoring the storage of new images in the target folder in real time, automatically identifying the file format, and combining the user's pre-set compression parameter configuration, the system uses a multi-objective optimization function to solve for the optimal compression parameters, dynamically adjusting the compression algorithm and strategy to achieve intelligent and personalized image compression.
It simplifies user operations, improves compression efficiency, and can achieve refined and adaptive compression effects based on image content characteristics and user needs, meeting the personalized needs of different scenarios.
Smart Images

Figure CN122053835A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer software technology, and in particular to an image compression method, apparatus, electronic device and storage medium based on a file monitoring mechanism. Background Technology
[0002] In recent years, computer software technology has been widely applied in various fields. Images, as an important carrier of information transmission and storage, have seen rapid growth in quantity. Whether it's sharing photos in daily life, organizing materials for work and study, or publishing content on online platforms, images are indispensable. With the continuous improvement of image resolution and the increasing sophistication of shooting equipment, the storage space occupied by image files is also growing larger. This not only puts enormous pressure on storage devices but also leads to problems such as slower transmission speeds and increased bandwidth consumption during image transmission. Therefore, image compression technology has emerged. It can effectively reduce the size of image files while maintaining image quality as much as possible, improving storage and transmission efficiency, and has become one of the key technologies attracting much attention in the field of computer software.
[0003] In related technologies, image compression tools are typically used for image compression. Users need to manually open the image compression tool, browse the file directory in the image compression tool's interface, select the image files to be compressed one by one, set the corresponding compression parameters, such as compression quality and resolution, and finally start the image compression tool's compression function to complete the image compression operation.
[0004] In the process of implementing the relevant technologies, the applicant recognized that the relevant technologies have at least the following problems: When users need to compress a large number of newly saved images in a specified folder, they have to manually operate frequently, repeatedly selecting images and setting parameters. This process is cumbersome and inefficient, consuming a lot of users' time and energy. Moreover, the fixed compression parameters cannot meet the diverse needs of different users, resulting in poor flexibility. Summary of the Invention
[0005] In view of this, this application provides an image compression method, apparatus, electronic device and storage medium based on a file monitoring mechanism. The main purpose is to solve the problems of cumbersome and inefficient operation, which consumes a lot of users' time and energy, and the fixed compression parameters cannot meet the diverse needs of different users, resulting in poor flexibility.
[0006] According to the first aspect of this application, an image compression method based on a file monitoring mechanism is provided, the method comprising: The system monitors in real time whether new image files are stored in the target folder, and identifies the file format of the new image files when they are detected. When the file format of the new image file matches the preset target format, the preset multi-objective optimization function is solved in combination with the user's preset compression parameter configuration, under the premise of satisfying the preset constraints, to obtain the optimal compression parameters. The multi-objective optimization function is used to balance the image quality score and the size of the output compressed file. A target image compression algorithm is determined, and based on the optimal compression parameters, the target image compression algorithm is called to compress the new image file. During the compression process, the compression process is dynamically adjusted based on the feature information of the new image file to obtain and output the compressed image file.
[0007] According to a second aspect of this application, an image compression device based on a file monitoring mechanism is provided, the device comprising: The monitoring module is used to monitor in real time whether new image files are stored in the target folder, and to identify the file format of the new image files when they are detected. The calculation module is used to solve a preset multi-objective optimization function to obtain the optimal compression parameters when the file format of the new image file matches the preset target format, in combination with the compression parameter configuration preset by the user and under the premise of satisfying preset constraints. The multi-objective optimization function is used to balance the image quality score and the size of the output compressed file. The compression module is used to determine the target image compression algorithm, call the target image compression algorithm to compress the new image file according to the optimal compression parameters, and dynamically adjust the compression process based on the feature information of the new image file during the compression process to obtain and output the compressed image file.
[0008] According to a third aspect of this application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in any of the first aspects above.
[0009] According to a fourth aspect of this application, a storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the steps of the method described in any one of the first aspects above.
[0010] By employing the above technical solutions, this application provides an image compression method, apparatus, electronic device, and storage medium based on a file monitoring mechanism. This application effectively solves the tedious problem of users having to frequently manually select images and repeatedly set compression parameters in traditional methods by real-time monitoring of the storage of new images in the target folder and automatically identifying their file formats. When an image that meets the preset target format is detected, it can solve a multi-objective optimization function that takes into account both image quality score and compressed file size based on the user-configured compression parameter constraints, thereby dynamically generating the optimal compression parameters and automatically performing compression processing and dynamically adjusting the compression strategy. This not only fully adapts to the personalized trade-offs between image quality and file size required by different users, but also ensures that the compression results meet the efficiency requirements of efficient and automated processing of a large number of newly added images, while achieving a refined and adaptive compression effect based on the content characteristics of each image, demonstrating good intelligence and flexibility.
[0011] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0012] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A schematic diagram of an image compression method based on a file monitoring mechanism provided in an embodiment of this application is shown. Figure 2 A schematic diagram of the structure of an image compression device based on a file monitoring mechanism provided in an embodiment of this application is shown; Figure 3 A schematic diagram of the device structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0013] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.
[0014] This application provides an image compression method based on a file monitoring mechanism, such as... Figure 1 As shown, the method includes: S10: Monitor in real time whether new image files are stored in the target folder, and identify the file format of the new image files when they are detected.
[0015] This application embodiment can be applied to a computer system. The computer system can be equipped with a file monitoring mechanism that continuously monitors the dynamic changes of a specified folder. Once a new file is stored in that folder, the computer system immediately triggers an event response. During this response, the system first determines whether the newly stored file is an image. This can be achieved by checking the file header information or the file extension. The file header information is a specific piece of data at the beginning of the file that identifies the file type, while the file extension is the period and a few characters following the filename, such as ".jpg" or ".png," indicating the file format. If it is confirmed to be an image file, its specific format, such as JPEG or PNG, is further analyzed to determine whether it meets the user's preset compressible image format requirements.
[0016] In this way, real-time monitoring and automatic identification simplify the process of manually selecting images for users. Especially when processing a large number of new images, this mechanism can significantly improve work efficiency, reduce human error and omissions, and ensure that all new images that meet the criteria are captured in a timely manner and prepared for subsequent compression processing. For example, suppose a user sets up a monitoring folder " / Images / Incoming" and configures it to compress only JPEG format images. When the user saves a new image named "photo1.jpg" into this folder, the file monitoring mechanism immediately detects the new image file, identifies the file type as JPEG, and triggers the subsequent compression process.
[0017] S20: When the file format of a new image file matches the preset target format, the preset multi-objective optimization function is solved in combination with the user's preset compression parameter configuration, under the premise of satisfying the preset constraints, to obtain the optimal compression parameters.
[0018] In this embodiment, when the file format of a new image file matches a preset target format, the computer system accesses a user-defined compression parameter configuration. This configuration may include the target format, desired image quality range, and output file size constraints. Subsequently, the computer system uses a multi-objective optimization function to balance the image quality score with the compressed file size, and solves this function under given constraints to find the optimal combination of compression parameters.
[0019] In this way, the introduction of multi-objective optimization functions makes the compression process more intelligent and personalized. It can dynamically adjust the compression strategy according to the specific needs and application scenarios of different users, ensuring that while maintaining image quality, file size is effectively controlled to meet diverse usage needs.
[0020] S30: Determine the target image compression algorithm, call the target image compression algorithm to compress the new image file based on the optimal compression parameters, and dynamically adjust the compression process based on the feature information of the new image file during the compression process to obtain and output the compressed image file.
[0021] In this embodiment, based on the obtained optimal compression parameters, the computer system selects the compression algorithm most suitable for the current image characteristics and user needs, such as lossy compression (JPEG quantization, WebP lossy) or lossless compression (PNG optimization). During the compression process, the computer system also utilizes image complexity, color distribution, texture features, and other characteristic information to dynamically adjust the compression strategy, such as adjusting the quantization table and filter selection, to further optimize the compression effect, thereby obtaining the compressed image file and outputting it to the specified location.
[0022] In this way, through the above process, the dynamic adjustment of the compression strategy ensures that each image receives optimal compression based on its unique content characteristics. This preserves key information while effectively reducing file size, improving storage and transmission efficiency. This refined and adaptive compression method can meet the personalized needs for image quality and file size in different scenarios. For example, for "photo1.jpg", the computer system selects the JPEG quantization compression algorithm based on optimal compression parameters and dynamically adjusts the quantization table according to the complexity of the image during compression. This results in a final compressed image that maintains good visual quality while reducing file size by 60% compared to the original image, making it suitable for fast network transmission.
[0023] Optionally, in this embodiment of the application, before real-time monitoring of whether new image files are stored in the target folder, and identifying the file format of the new image files when they are detected, the method further includes: when a user instructs the user to configure parameters for the image compression process, using the folder selected by the user as the target folder; obtaining and storing the compression parameter configuration set by the user to complete the parameter configuration for the image compression process according to the user's instructions, wherein the compression parameter configuration includes the target format, the expected range of image quality, and the output file size constraint.
[0024] In this embodiment, to achieve automatic image file compression and meet users' personalized needs, the computer system first provides a flexible parameter configuration process. Specifically, when the computer system detects a user's instruction to configure parameters for the image compression process, it launches an interactive interface or command-line tool to guide the user to specify a folder as the target folder for subsequent automatic monitoring. This ensures that users can choose a specific location to store the images to be compressed according to their actual needs, enhancing the system's applicability and flexibility.
[0025] Next, the computer system will prompt the user to set a series of compression parameter configurations. These compression parameter configurations include, but are not limited to, the target format (such as JPEG, PNG, or other image formats desired by the user after compression), the expected range of image quality (defined by the minimum and maximum values of the quality score Q to ensure that the quality of the compressed image is within the user's acceptable range), and the output file size constraint (setting the maximum or target size of the compressed image file to meet storage or transmission needs). After the user enters these parameters according to their own needs, the computer system will store this configuration information for use during the automatic compression process.
[0026] In this way, the above process gives users full control over the image compression process, making the compression results more closely match their actual needs. For example, a user might want to compress a batch of high-resolution photographs into smaller files suitable for online sharing while maintaining high visual quality. Therefore, by configuring the target format to JPEG, setting the desired image quality range to 80-90 (assuming a maximum score of 100), and limiting the output file size to no more than 500KB, the user can ensure that the compressed image meets the requirements for online transmission while retaining sufficient detail and color information. This not only improves work efficiency but also ensures the personalization and optimization of the compression results.
[0027] In this embodiment of the application, under the condition of satisfying preset constraints, a preset multi-objective optimization function is solved to obtain the optimal compression parameters, including: defining the multi-objective optimization function shown in Formula 1 below. Formula 1:
[0028] In Formula 1, Indicates image quality score. This indicates the size of the compressed file output after compression. This represents the maximum value of the image quality score. Indicates the expected size of the compressed output file. and Represents the dynamic weighting coefficient; where, when determined and When a new image file is collected, query the application type of the target application and obtain the dynamic weight coefficient that matches the application type. Set the preset constraints for Formula 2 as follows: Formula 2:
[0029] In Formula 2, Indicates image quality score. This represents the minimum value of the image quality score. This represents the maximum value of the image quality score. This indicates the size of the compressed file output after compression. This indicates the maximum value of the compressed file output after compression. Indicates the compression processing time. This represents the maximum compression processing time; under preset constraints, the calculation makes... Take the smallest value and The compression parameters are determined to obtain the optimal compression parameters.
[0030] In this embodiment, to achieve a good balance between image quality and compressed file size during automatic image compression, the computer system employs a multi-objective optimization function to solve for the optimal compression parameters. The multi-objective optimization function is shown in Formula 1 above, where... The value ranges from 0 to 100 and is used to measure the visual quality of the compressed image; The unit can be bytes, etc. This represents the maximum value of the image quality score, which can be 100. Users can pre-set these settings according to their actual needs; and The value will be adjusted according to different application scenarios to reflect different levels of importance attached to image quality and file size.
[0031] Among them, in determining and At this time, the computer system will query the application type of the target application that has acquired the new image file. For example, if the target application is a network transfer, since network transfer prioritizes file size to reduce transmission time and bandwidth usage, then... and The value of will tend to place more emphasis on the weighting of file size, such as , If the target application is file backup, image quality may be more important, and the weighting may be adjusted accordingly. , For real-time processing scenarios, both factors will be considered comprehensively, and a balanced weighting will be adopted, such as... , .
[0032] Meanwhile, to ensure the rationality and feasibility of the compression results, this application embodiment also sets preset constraints as shown in Formula 2, where Formula 2... This is the minimum requirement to ensure that the image quality is basically acceptable; As mentioned earlier, this is the maximum value of the image quality score; To prevent files from becoming too large and taking up too much storage space; Indicates the compression processing time. This represents the maximum compression processing time, ensuring that the compression process is not excessively time-consuming and affects overall efficiency. Under the aforementioned preset constraints, the computer system will calculate the value in Formula 1. Take the smallest value and By determining the optimal compression parameters, and then setting multi-objective optimization functions and constraints, the compression strategy can be dynamically adjusted according to different application scenarios and user needs. Under the premise of ensuring that the image quality meets certain standards, the size of the compressed file is reduced as much as possible, while controlling the compression processing time and improving compression efficiency.
[0033] For example, in the application scenario of a photo-sharing social platform, if a user uploads a large number of high-resolution images, the computer system first determines the appropriate method based on the application type of the platform (related to network transmission). , They place more emphasis on file size; then they set constraints, such as... To ensure that the image quality is not too low and affects the user experience, Based on platform storage limits Based on the platform's requirements for upload response time, the system is configured to solve a multi-objective optimization function to obtain the optimal image quality score while meeting these constraints. and compressed file size The corresponding compression parameters automatically compress user-uploaded images, ensuring that the images maintain a certain visual quality when displayed on the platform while effectively reducing file size, improving image upload and loading speed, and enhancing user experience.
[0034] In this embodiment, a target image compression algorithm is determined, and based on the optimal compression parameters, the target image compression algorithm is invoked to compress the new image file. During the compression process, the compression process is dynamically adjusted based on the feature information of the new image file to obtain and output the compressed image file. This includes: selecting an image compression algorithm matching the file format of the new image file as the target image compression algorithm; invoking a complexity evaluation function to evaluate the complexity of the feature information of the new image file to obtain its image complexity; determining the image file size of the new image file based on the feature information; querying a preset dynamic adjustment strategy; invoking the target image compression algorithm to compress the new image file based on the optimal compression parameters; and during the compression process, dynamically adjusting the compression process according to the dynamic adjustment strategy, combined with the image complexity or image file size. After the compression process is completed, the compressed image file is obtained and output.
[0035] In this embodiment, when compressing a new image file, a suitable target image compression algorithm is first determined based on its file format. Different image file formats have different characteristics and compression principles. For example, JPEG format is suitable for continuous-tone image compression and is commonly used for photographic images; while PNG format is more suitable for images containing large areas of the same color, such as icons and charts, and supports lossless compression. Therefore, accurately matching the file format with the compression algorithm is a crucial prerequisite for ensuring compression effectiveness and efficiency. This allows each algorithm to fully leverage its advantages and avoids problems such as poor compression results or excessively long processing times caused by algorithm mismatch.
[0036] After determining the target compression algorithm, the computer system calls a complexity evaluation function to assess the complexity of the feature information of the new image file, thus obtaining the image complexity. The complexity evaluation is performed from multiple dimensions, including edge density detection, which analyzes the density of image edges to understand the richness of image detail; texture complexity analysis, which determines the complexity of textures in the image; and color distribution complexity calculation, which considers the types and distribution of colors in the image. The computer system integrates these factors to arrive at a comprehensive complexity score, which fully reflects the complexity of the image and provides an important reference for subsequent compression processing. Simultaneously, the computer system also determines the file size of the new image file based on the feature information, clarifying the size of the original file.
[0037] During compression, the computer system queries a preset dynamic adjustment strategy and, based on the previously obtained optimal compression parameters, calls the target image compression algorithm to compress the new image file. The dynamic adjustment strategy dynamically adjusts the compression process according to the image complexity or file size. For example, if the image is highly complex, meaning it has rich detail, the compression quality parameters may be appropriately increased to retain more detail after compression. Simultaneously, parameters such as the quantization table may be adjusted to achieve a better balance between file size and quality. If the image file itself is large, and the user has specific requirements for the compressed file size, the compression may be further increased, such as by reducing the resolution or adjusting the compression ratio, while still meeting certain quality standards.
[0038] In this way, by precisely matching compression algorithms, the advantages of each algorithm can be fully utilized to improve compression efficiency and effectiveness. Complexity assessment and dynamic adjustment strategies make the compression process more intelligent and adaptive, enabling personalized processing based on the specific characteristics of each image. This ensures image quality meets requirements while minimizing file size. For example, for a large number of images of different formats and complexities, the computer system can automatically select a suitable compression algorithm for each image and dynamically adjust compression parameters based on its complexity and size. For a high-resolution, detail-rich photograph (JPEG format), the computer system will choose the JPEG quantization compression algorithm and appropriately increase the quality parameters based on its higher complexity, while adjusting the quantization table to reasonably control the file size while ensuring visual quality. For a simple icon image (PNG format), the computer system will choose the PNG optimized compression algorithm and, based on its lower complexity and smaller file size, employ a suitable compression strategy to achieve efficient lossless compression. Finally, after processing, a compressed image file that meets the requirements is obtained and output for convenient storage, transmission, and use.
[0039] In this embodiment, during the compression process, the compression process is dynamically adjusted according to a dynamic control strategy, taking into account image complexity or image file size. This includes: when the dynamic control strategy instructs that the compression process be dynamically adjusted according to image complexity, querying preset maximum and minimum complexity thresholds; when the image complexity is greater than the maximum threshold, improving image quality during compression and sampling the new image file using a preset fine-grained quantization table and complete chroma; and when the image complexity is less than or equal to the minimum threshold, reducing image quality during compression and sampling the new image using a preset coarse quantization table and stronger chroma. When the dynamic control strategy instructs that the compression process be dynamically adjusted according to image file size, calculating the ratio between the size of the compressed image and the original size of the new image; when the ratio is lower than a preset ratio threshold, adjusting the size of the compressed image to increase it based on image complexity during compression; and when the ratio is not lower than the ratio threshold, adjusting the size of the compressed image to decrease it based on image complexity during compression.
[0040] In this embodiment, the dynamic adjustment mechanism during the compression process is a key step in ensuring that the image compression effect meets diverse needs. It flexibly adjusts based on a dynamic control strategy and in conjunction with image complexity or file size. When the dynamic control strategy instructs the compression process to be dynamically adjusted according to image complexity, the computer system first queries preset maximum and minimum complexity thresholds. These thresholds, determined through extensive experimentation and data analysis, define different ranges of image complexity. If the image complexity exceeds the maximum threshold, it indicates that the image contains rich details, complex textures, or diverse color distributions. In this case, to preserve this important information as much as possible and ensure the visual quality of the compressed image, the computer system enhances image quality parameters during compression. Simultaneously, a preset refined scale with more detailed quantization levels is used to process image data more accurately and reduce information loss. Furthermore, complete chromaticity sampling is employed to ensure the complete preservation of color information, thus maintaining a high-quality image effect after compression. Conversely, when the image complexity is less than or equal to the minimum complexity threshold, it means that the image is relatively simple with fewer details and color variations. In this case, in order to further reduce the size of the compressed file, the computer system will reduce the image quality parameters during the compression process; at the same time, a preset coarse quantization table is used, which has a relatively coarse quantization level, to further simplify the image data; and strong chromaticity sampling reduction is performed to reduce the amount of color information stored, thereby achieving effective compression of the file size within an acceptable visual quality range.
[0041] When the dynamic adjustment strategy instructs the compression process to be dynamically adjusted according to the image file size, the computer system first calculates the ratio between the size of the compressed image and the original size. This ratio reflects the degree of compression. If this ratio is lower than a preset threshold, it means that the compressed file size is not significantly reduced relative to the original size and may not meet the user's file size requirements. In this case, the computer system will adjust the compression parameters appropriately based on the image complexity to increase the size of the compressed image, i.e., further increase the compression intensity, minimizing the file size while maintaining a certain image quality. For example, if the image complexity is low, the computer system may adjust the quantization parameters or sampling method more significantly to achieve a substantial reduction in file size. Conversely, when the ratio is not lower than the threshold, it means that the compressed file size has reached a relatively ideal level. However, to balance file size and image quality, the computer system will also adjust the compression parameters based on the image complexity to appropriately reduce the size of the compressed image, i.e., reduce the compression intensity, avoiding excessive compression that could lead to a significant drop in image quality. For example, for highly complex images, the computer system may appropriately increase the quality parameters to ensure the preservation of image details.
[0042] In this way, the dynamic adjustment mechanism makes the compression process more intelligent and adaptive, flexibly adjusting the compression strategy according to the actual situation of the image and user needs. For example, in the image upload function of a mobile application, the computer system can automatically adjust the compression process according to the dynamic control strategy for images of different complexities and sizes uploaded by users. For a highly complex landscape photo, if the user wants to reduce the file size while maintaining a certain level of clarity, the computer system uses a refined quantization table and complete chromaticity sampling according to the image complexity adjustment strategy to reasonably control the file size while improving quality. For a simple icon image with low complexity, the computer system uses a coarse quantization table and chromaticity sampling reduction to effectively reduce the file size. If the file size ratio is found to be insufficient during the compression process, the computer system can further optimize according to the image file size adjustment strategy to ensure that the final compressed image file meets the file size limit and has good visual quality, improving user experience and application performance.
[0043] In this embodiment, the method further includes: evaluating the quality and size of the image compressed file to obtain a compressed file quality score and a compressed file size score; comparing the compressed file quality score with a preset quality score threshold and comparing the compressed file size score with a preset size score threshold; when the compressed file quality score is lower than the quality score threshold, determining that the quality of the image compressed file is substandard; adaptively adjusting the optimal compression parameters in relation to image quality; and, based on the adaptively adjusted optimal compression parameters, re-invoking the target image compression algorithm to compress the new image file; and, during the compression process, dynamically adjusting the compression process based on the feature information of the new image file to obtain and output a new image compressed file. In this process, the adaptively adjusted optimal compression parameters related to image quality are used to increase the quality factor, increase the resolution scaling ratio, and switch to a fine quantization table. When the compressed file size score is lower than the size score threshold, it is determined that the size of the compressed image file does not meet the standard. The optimal compression parameters are then adaptively adjusted according to the image size. Based on the adaptively adjusted optimal compression parameters, the target image compression algorithm is called again to compress the new image file. During the compression process, the compression process is dynamically adjusted again based on the feature information of the new image file to obtain a new compressed image file and output it. The adaptively adjusted optimal compression parameters related to image size are used to reduce the quality factor, reduce the resolution scaling ratio, and switch to a coarser quantization table.
[0044] In this embodiment, to ensure that the final output image compressed file meets the expected standards in both quality and size, a feedback optimization algorithm is introduced. After obtaining the image compressed file, the computer system evaluates its quality and size. For quality evaluation, the computer system calculates objective quality indicators such as Peak Signal-to-Noise Ratio (PSNR) and Structural Similarity (SSIM). These indicators can measure the similarity between the compressed image and the original image from different perspectives, thus obtaining a compressed file quality score. Simultaneously, the compressed file size is evaluated by calculating the ratio of the compressed file size to the original file size, resulting in a compressed file size score. Then, the compressed file quality score is compared with a preset quality score threshold, and the compressed file size score is compared with a preset size score threshold.
[0045] When a compressed file's quality score falls below a certain threshold, it indicates that the image compression file's quality is substandard. In this case, the computer system adaptively adjusts the optimal compression parameters to reflect the image quality. Specifically, the system increases the quality factor, which means more image details and information are preserved during compression, thus improving the quality of the compressed image. Simultaneously, it increases the resolution scaling ratio, resulting in a clearer visual effect after compression. It also switches to a finer quantization table, which has more quantization levels, allowing for more detailed processing of image data and reducing information loss. After parameter adjustments, the computer system, based on the adaptively adjusted optimal compression parameters, re-applies the previously determined target image compression algorithm to compress the new image file. Furthermore, during this re-compression process, it dynamically adjusts the compression process again based on the new image file's features, such as image complexity and color distribution, to obtain a new compressed image file for output.
[0046] When the compressed file size score falls below the size score threshold, it indicates that the image compressed file size does not meet the requirements. The computer system will then adaptively adjust the optimal compression parameters based on the image size. Specifically, the computer system will reduce the quality factor, decreasing the amount of image information retained during compression, thereby reducing the file size; it will also reduce the resolution scaling ratio, making the image size relatively smaller after compression, further reducing the file size; and it will switch to a coarse quantization table, which has fewer quantization levels, simplifying the processing of image data and effectively reducing file size. Subsequently, based on the adjusted optimal compression parameters, the target image compression algorithm is called again for compression processing, and similarly, dynamic adjustments are made based on the new image file feature information during the processing, ultimately outputting a new compressed image file.
[0047] In this way, a closed-loop optimization mechanism is formed through the above process. This mechanism allows for dynamic adjustment and optimization of compression parameters based on the actual compression results. For example, in an online image storage service platform, if a user uploads a large number of images for compression and storage, the computer system, after the initial compression, might evaluate and find that some images, due to their complex content, have a quality score below the threshold after compression. In this case, the computer system automatically adjusts quality-related parameters and recompresses the images, improving their quality while still meeting storage space requirements. Conversely, for images that are already large and have low quality requirements, if the size score after compression is insufficient, the computer system adjusts size-related parameters and recompresses them, further reducing file size and improving storage efficiency. This approach ensures a balance between image compression quality and size, meeting the diverse needs of different users and scenarios.
[0048] In this embodiment, the quality and size of the image compressed file are evaluated to obtain a compressed file quality score and a compressed file size score. This includes: calculating the mean squared error of the new image file and the image compressed file to obtain the peak signal-to-noise ratio (PSNR); calculating the visual similarity of the new image file and the image compressed file on multiple preset dimensions to obtain a structural similarity index; and using the average of the PSNR and the structural similarity index as the compressed file quality score; calculating the ratio between the size of the image compressed file and the size of the new image file; and comparing the ratio with the output file size constraint included in the compression parameter configuration to obtain a compressed file size score.
[0049] In this embodiment, evaluating the quality and size of the compressed image file is a crucial step, directly affecting whether the compression result meets user needs and expected standards. Regarding quality evaluation, the mean squared error (MSE) is first calculated between the new image file (i.e., the original image) and the compressed image file. The mean squared error (MSE) is calculated by averaging the squared differences in the grayscale values of corresponding pixels in the original and compressed images to measure the degree of difference between them. Based on the MSE, the peak signal-to-noise ratio (PSNR) is further calculated. Its calculation formula can be as follows: Formula 3. Formula 3:
[0050] In Formula 3 Representing the maximum pixel value, for an 8-bit image, the grayscale value or color component value of each pixel is usually represented by an 8-bit binary number, with a value range of 0 to 255. Therefore, in this embodiment of the application, The value can be 255, representing the maximum intensity value that a pixel in the image can reach, used to account for the mean square error (MSE). Normalize to a standard range to more reasonably calculate the signal-to-noise ratio; This represents the calculated mean square error. Formula 3, [is used to...] and Divide the results, take the logarithm to base 10, and multiply by 10 to convert the mean squared error into a signal-to-noise ratio (SNR) metric in decibels (dB). A higher value means a larger ratio of peak signal to noise in the compressed image compared to the original image, indicating better image quality and less difference from the original image. Generally speaking, When the value is above 30dB, the human eye has difficulty perceiving a significant difference between the compressed image and the original image; when When the value is below 20dB, the quality of the compressed image may degrade significantly, resulting in noticeable distortion.
[0051] In addition to Peak Signal-to-Noise Ratio (PSNR), the computer system calculates visual similarity between new image files and compressed image files across multiple preset dimensions, resulting in the Structural Similarity Index (SSIM). The SSIM measures the similarity between two images from three dimensions: brightness comparison, contrast comparison, and structural comparison. Brightness comparison considers the average brightness similarity of the images; contrast comparison focuses on the similarity of the magnitude of brightness changes; and structural comparison focuses on the similarity of structural information. By combining the comparison results from these three dimensions, the SSIM more closely approximates the human visual system's perception of image similarity, more accurately assessing the quality of compressed images. Finally, the average of the PSNR and SSIM is used as the quality score for the compressed file, comprehensively and objectively reflecting the quality level of the compressed image.
[0052] In terms of size evaluation, the computer system calculates the ratio between the size of the compressed image file and the size of the new image file. This ratio visually reflects the degree of file size reduction after compression. This ratio is then compared to the output file size constraints included in the compression parameter configuration. These output file size constraints are set by the user based on their actual needs; for example, the user might want the compressed image file size to not exceed 50% of the original file size. A compression file size score is generated based on the comparison results. If the compressed file size meets the constraints, a higher score is given; if it exceeds the constraints, a lower score is given.
[0053] In this way, by combining peak signal-to-noise ratio (PSNR) and structural similarity index for quality assessment, the quality of compressed images can be comprehensively evaluated from both objective numerical and human visual perception perspectives, ensuring the accuracy and reliability of the assessment results. Size assessment, on the other hand, is directly related to the user's actual needs, ensuring that the compressed file size meets user expectations. For example, on an e-commerce platform, merchants need to upload a large number of product images. These images need to be of good quality to showcase product details while controlling file size to ensure page loading speed. The assessment method described above can accurately evaluate the quality and size of the compressed product images. If the evaluation results are unsatisfactory, compression parameters can be adjusted and recompressed in a timely manner to ensure that the final displayed product images achieve the best balance between quality and size, improving user experience and platform performance.
[0054] In practical applications, the technical solution described in this application embodiment can be implemented by writing code. The specific logic of the code can be as follows: The file monitoring trigger algorithm can be called. The IntelligentCompressionMonitor class in the file monitoring trigger algorithm sets the folder to be monitored and the compression algorithm configuration during initialization, and creates a compression balancing engine instance. When a new file is detected to be created in the folder, if the file format passes the verification, the compression balancing engine is used to optimize the compression parameters according to the algorithm configuration. Then, compression processing is performed using these parameters, and the compression result is verified. If the result is valid, the compressed image is saved; otherwise, the parameters are adjusted and the process is retried.
[0055] Meanwhile, in order to achieve parallel processing of batch images, this embodiment can also call a multi-threaded compression algorithm. The ParallelCompressionProcessor class in the multi-threaded concurrent compression algorithm is initialized with the maximum number of worker threads in the thread pool and a compression balancing engine instance is created. When processing batch images, the processing task of each image is submitted to the thread pool for execution, and the processing results are collected. When processing a single image, the parameters are first optimized through the compression balancing engine, then compression is performed, and finally the compression result is verified and feedback is adjusted. If the quality does not meet the standard, the parameters are adjusted and recompressed, and finally the compression result is returned.
[0056] In practical applications, a hierarchical decision-making architecture can be set up in the computer system. In this architecture, the decision-making process algorithm first performs requirements analysis, clarifying compression requirements by analyzing user configurations; then it conducts image analysis to extract image feature information; next, it enters the strategy selection stage, selecting a compression strategy based on image features and user requirements; finally, it performs parameter optimization, determining the optimal compression parameters based on the information obtained in the previous steps. For the fast decision-making algorithm in real-time decision-making mode, suitable for monitoring scenarios, it first quickly extracts key image features, then obtains basic parameters from a lookup table based on image type and user-configured priority. If the image feature size exceeds the maximum size set by the user, it adjusts the quality and scaling ratio in the basic parameters and returns the result. Furthermore, the precise decision-making algorithm is used for batch scenarios. It first performs comprehensive feature analysis on the images, then simulates compression using multiple algorithms, and then uses a multi-objective optimization method to comprehensively consider multiple objectives such as quality, size, and speed, as well as user-defined weights, selecting the best parameter combination from the simulated compression results and returning it.
[0057] The method provided in this application effectively solves the tedious problem of users having to frequently manually select images and repeatedly set compression parameters in traditional methods by real-time monitoring of the storage of new images in the target folder and automatically identifying their file formats. When an image that meets the preset target format is detected, it can solve a multi-objective optimization function that takes into account both image quality score and compressed file size based on the user's pre-configured compression parameter constraints, thereby dynamically generating the optimal compression parameters and automatically performing compression processing and dynamically adjusting the compression strategy. This not only fully adapts to the personalized trade-offs between image quality and file size of different users, but also ensures that the compression results meet the efficiency requirements of efficient and automated processing of a large number of newly added images, while achieving a refined and adaptive compression effect based on the content characteristics of each image, demonstrating good intelligence and flexibility.
[0058] Furthermore, as Figure 1 To specifically implement the method, this application provides an image compression device based on a file monitoring mechanism, such as... Figure 2 As shown, the device includes: a monitoring module 201, a calculation module 202, and a compression module 203.
[0059] The monitoring module 201 is used to monitor in real time whether new image files are stored in the target folder, and to identify the file format of the new image files when the new image files are detected. The calculation module 202 is used to solve a preset multi-objective optimization function to obtain the optimal compression parameters when the file format of the new image file matches the preset target format, in combination with the compression parameter configuration preset by the user and under the condition of satisfying preset constraints. The multi-objective optimization function is used to balance the image quality score and the size of the output compressed file. Compression module 203 is used to determine the target image compression algorithm, call the target image compression algorithm to compress the new image file according to the optimal compression parameters, and dynamically adjust the compression process based on the feature information of the new image file during the compression process to obtain and output the image compressed file.
[0060] In specific application scenarios, the device further includes: The parameter configuration module is used to, when the user instructs to configure parameters for the image compression process, use the folder selected by the user as the target folder; obtain and store the compression parameter configuration set by the user, so as to complete the parameter configuration for the image compression process according to the user's instructions, wherein the compression parameter configuration includes the target format, the expected range of image quality, and the output file size constraint.
[0061] In specific application scenarios, the calculation module 202 is used to define the multi-objective optimization function shown in Formula 1 below. Formula 1:
[0062] In Formula 1, Indicates image quality score. This indicates the size of the compressed file output after compression. This represents the maximum value of the image quality score. Indicates the expected size of the compressed output file. and Represents the dynamic weighting coefficient; where, when determined and At that time, query the application type of the target application that collected the new image file, obtain the dynamic weight coefficient that matches the application type, and set the preset constraint conditions described in Formula 2 below. Formula 2:
[0063] In Formula 2, Indicates image quality score. This represents the minimum value of the image quality score. This represents the maximum value of the image quality score. This indicates the size of the compressed file output after compression. This indicates the maximum value of the compressed file output after compression. Indicates the compression processing time. This represents the maximum compression processing time; under the premise of satisfying the preset constraints, the calculation is performed to... Take the smallest value and The compression parameters are determined to obtain the optimal compression parameters.
[0064] In a specific application scenario, the compression module 203 is used to select an image compression algorithm that matches the file format of the new image file as the target image compression algorithm; call a complexity evaluation function to evaluate the complexity of the feature information of the new image file to obtain the image complexity of the new image file; determine the image file size of the new image file based on the feature information; query a preset dynamic adjustment strategy; call the target image compression algorithm to compress the new image file according to the optimal compression parameters; and dynamically adjust the compression process according to the dynamic adjustment strategy, combined with the image complexity or the image file size, and obtain and output the compressed image file after the compression process is completed.
[0065] In specific application scenarios, the compression module 203 is used to: query preset maximum and minimum complexity thresholds when the dynamic adjustment strategy instructs the compression process to be dynamically adjusted according to the image complexity; improve image quality during compression when the image complexity is greater than the maximum complexity threshold, and sample the new image file using a preset fine quantization table and complete chroma; and reduce image quality during compression when the image complexity is less than or equal to the minimum complexity threshold, and sample and reduce the new image using a preset coarse quantization table and stronger chroma; and calculate the ratio between the size of the compressed image and the original size of the new image when the dynamic adjustment strategy instructs the compression process to be dynamically adjusted according to the image file size. When the ratio is lower than a preset ratio threshold, increase the size of the compressed image during compression with reference to the image complexity; and decrease the size of the compressed image during compression with reference to the image complexity when the ratio is not lower than the ratio threshold.
[0066] In specific application scenarios, the device further includes: A compression evaluation module is used to evaluate the quality and size of the compressed image file, obtaining a compressed file quality score and a compressed file size score. The compressed file quality score is compared with a preset quality score threshold, and the compressed file size score is compared with a preset size score threshold. When the compressed file quality score is lower than the quality score threshold, the quality of the compressed image file is determined to be substandard. The optimal compression parameters are then adaptively adjusted according to image quality. Based on the adaptively adjusted optimal compression parameters, the target image compression algorithm is re-invoked to compress the new image file. During the compression process, the compression process is dynamically adjusted based on the feature information of the new image file to obtain a new compressed image file and output it. The optimal compression parameters, adaptively adjusted to be related to image quality, are used to increase the quality factor, increase the resolution scaling ratio, and switch to a fine quantization table. When the size score of the compressed file is lower than the size score threshold, it is determined that the size of the compressed image file does not meet the standard. The optimal compression parameters are then adaptively adjusted to be related to the image size. Based on the adaptively adjusted optimal compression parameters, the target image compression algorithm is called again to compress the new image file. During the compression process, the compression process is dynamically adjusted based on the feature information of the new image file to obtain a new compressed image file and output it. The optimal compression parameters, adaptively adjusted to be related to the image size, are used to decrease the quality factor, decrease the resolution scaling ratio, and switch to a coarse quantization table.
[0067] In specific application scenarios, the compression evaluation module is used to calculate the mean squared error of the new image file and the compressed image file to obtain the peak signal-to-noise ratio (PSNR), and to calculate the visual similarity of the new image file and the compressed image file on multiple preset dimensions to obtain a structural similarity index. The average of the PSNR and the structural similarity index is used as the quality score of the compressed file. The module also calculates the ratio between the size of the compressed image file and the size of the new image file, and compares the ratio with the output file size constraint included in the compression parameter configuration to obtain the compressed file size score.
[0068] The device provided in this application embodiment effectively solves the tedious problem of users having to frequently manually select images and repeatedly set compression parameters in traditional methods by monitoring the storage of new images in the target folder in real time and automatically identifying their file formats. When an image that meets the preset target format is detected, it can solve a multi-objective optimization function that takes into account both image quality score and compressed file size based on the compression parameter constraints pre-configured by the user, thereby dynamically generating the optimal compression parameters and automatically performing compression processing and dynamically adjusting the compression strategy. This not only fully adapts to the personalized trade-offs between image quality and file size of different users, but also ensures that the compression results meet the efficiency requirements of efficient and automated processing of a large number of newly added images, while also achieving a refined and adaptive compression effect based on the content characteristics of each image, demonstrating good intelligence and flexibility.
[0069] It should be noted that other corresponding descriptions of the functional units involved in the image compression device based on a file monitoring mechanism provided in this application embodiment can be found in the following references. Figure 1 The corresponding descriptions in [the document] will not be repeated here.
[0070] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0071] The above embodiments and the technical features in the embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0072] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
[0073] In an exemplary embodiment, see Figure 3 Furthermore, an electronic device is provided, comprising a bus, a processor, a memory, and a communication interface. It may also include an input / output interface and a display device, wherein the various functional units can communicate with each other via the bus. The memory stores a computer program, and the processor executes the program stored in the memory to perform the image compression method based on the file monitoring mechanism described in the above embodiments.
[0074] A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the image compression method based on a file monitoring mechanism.
[0075] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented in hardware or by using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) and includes several instructions to cause an electronic device (such as a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0076] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application.
[0077] Those skilled in the art will understand that the modules in the apparatus of the implementation scenario can be distributed within the apparatus of the implementation scenario as described, or they can be located in one or more apparatuses different from this implementation scenario, with corresponding changes. The modules of the above-described implementation scenario can be combined into one module, or they can be further divided into multiple sub-modules.
[0078] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of the implementation scenario.
[0079] The above disclosures are only a few specific implementation scenarios of this application. However, this application is not limited to these. Any variations that can be conceived by those skilled in the art should fall within the protection scope of this application.
Claims
1. An image compression method based on a file monitoring mechanism, characterized in that, include: The system monitors in real time whether new image files are stored in the target folder, and identifies the file format of the new image files when they are detected. When the file format of the new image file matches the preset target format, the preset multi-objective optimization function is solved in combination with the user's preset compression parameter configuration, under the premise of satisfying the preset constraints, to obtain the optimal compression parameters. The multi-objective optimization function is used to balance the image quality score and the size of the output compressed file. A target image compression algorithm is determined, and based on the optimal compression parameters, the target image compression algorithm is called to compress the new image file. During the compression process, the compression process is dynamically adjusted based on the feature information of the new image file to obtain and output the compressed image file.
2. The method according to claim 1, characterized in that, The method further includes, before real-time monitoring of whether new image files are stored in the target folder, and before identifying the file format of the new image files when they are detected, the method also includes: When the user's instruction to configure parameters for the image compression process is detected, the folder selected by the user is used as the target folder; The compression parameter configuration set by the user is obtained and stored to complete the parameter configuration for the image compression process according to the user's instructions. The compression parameter configuration includes the target format, the expected range of image quality, and the output file size constraint.
3. The method according to claim 1, characterized in that, The step of solving a preset multi-objective optimization function under preset constraints to obtain optimal compression parameters includes: Define the multi-objective optimization function as shown in Equation 1 below. Official 1: In Formula 1, Indicates image quality score. This indicates the size of the compressed file output after compression. This represents the maximum value of the image quality score. Indicates the expected size of the compressed output file. and Represents the dynamic weighting coefficient; where, when determined and When the new image file is collected, query the application type of the target application and obtain the dynamic weight coefficient that matches the application type. Set the preset constraint conditions as described in Formula 2 below. Official 2: In Formula 2, Indicates image quality score. This represents the minimum value of the image quality score. This represents the maximum value of the image quality score. This indicates the size of the compressed file output after compression. This indicates the maximum value of the compressed file output after compression. Indicates the compression processing time. This indicates the maximum value of the compression processing time; Under the condition that the preset constraints are met, the calculation makes Take the smallest value and The compression parameters are determined to obtain the optimal compression parameters.
4. The method according to claim 1, characterized in that, The determination of the target image compression algorithm, based on the optimal compression parameters, involves calling the target image compression algorithm to compress the new image file, and dynamically adjusting the compression process based on the feature information of the new image file during the compression process to obtain and output the compressed image file, including: The image compression algorithm that matches the file format of the new image file is used as the target image compression algorithm. The complexity evaluation function is called to evaluate the complexity of the feature information of the new image file in order to obtain the image complexity of the new image file. Based on the aforementioned feature information, the file size of the new image file is determined. The system queries the preset dynamic adjustment strategy, calls the target image compression algorithm to compress the new image file based on the optimal compression parameters, and dynamically adjusts the compression process according to the dynamic adjustment strategy, combined with the image complexity or the image file size. After the compression process is completed, the compressed image file is obtained and output.
5. The method according to claim 4, characterized in that, During the compression process, the dynamic adjustment strategy, combined with the image complexity or the image file size, dynamically adjusts the compression process, including: When the dynamic control strategy instructs the compression process to be dynamically adjusted according to the image complexity, the preset maximum and minimum complexity thresholds are queried. When the image complexity is greater than the maximum complexity threshold, the image quality is improved during the compression process, and the new image file is sampled using a preset fine quantization table and complete chroma. When the image complexity is less than or equal to the minimum complexity threshold, the image quality is reduced during the compression process, and the new image is sampled and reduced using a preset coarse quantization table and stronger chroma. When the dynamic adjustment strategy instructs the compression process to be dynamically adjusted according to the image file size, the ratio between the size of the image obtained after compression and the original size of the new image is calculated. When the ratio is lower than a preset ratio threshold, the size of the image obtained after compression is increased by referring to the image complexity during the compression process. When the ratio is not lower than the ratio threshold, the size of the image obtained after compression is decreased by referring to the image complexity during the compression process.
6. The method according to claim 1, characterized in that, The method further includes: The image compressed file is evaluated for quality and size to obtain a compressed file quality score and a compressed file size score. The compressed file quality score is compared with a preset quality score threshold, and the compressed file size score is compared with a preset size score threshold. When the quality score of the compressed file is lower than the quality score threshold, it is determined that the quality of the image compressed file is substandard. The optimal compression parameters are adaptively adjusted in relation to the image quality. Based on the adaptively adjusted optimal compression parameters, the target image compression algorithm is called again to compress the new image file. During the compression process, the compression process is dynamically adjusted based on the feature information of the new image file to obtain a new image compressed file and output it. The adaptively adjusted optimal compression parameters related to the image quality are used to increase the quality factor, increase the resolution scaling ratio, and switch to a fine quantization table. When the size score of the compressed file is lower than the size score threshold, it is determined that the size of the image compressed file does not meet the standard. The optimal compression parameters are adaptively adjusted in relation to the image size. Based on the adaptively adjusted optimal compression parameters, the target image compression algorithm is called again to compress the new image file. During the compression process, the compression process is dynamically adjusted again based on the feature information of the new image file to obtain a new image compressed file and output it. The adaptively adjusted optimal compression parameters related to the image size are used to reduce the quality factor, reduce the resolution scaling ratio, and switch to a coarse quantization table.
7. The method according to claim 6, characterized in that, The process of evaluating the quality and size of the compressed image file to obtain a compressed file quality score and a compressed file size score includes: The mean squared error is calculated for the new image file and the compressed image file to obtain the peak signal-to-noise ratio. Visual similarity is calculated for the new image file and the compressed image file on multiple preset dimensions to obtain the structural similarity index. The average value of the peak signal-to-noise ratio and the structural similarity index is used as the quality score of the compressed file. Calculate the ratio between the size of the compressed image file and the size of the new image file, and compare the ratio with the output file size constraint included in the compression parameter configuration to obtain the compressed file size score.
8. An image compression device based on a file monitoring mechanism, characterized in that, include: The monitoring module is used to monitor in real time whether new image files are stored in the target folder, and to identify the file format of the new image files when they are detected. The calculation module is used to solve a preset multi-objective optimization function to obtain the optimal compression parameters when the file format of the new image file matches the preset target format, in combination with the compression parameter configuration preset by the user and under the premise of satisfying preset constraints. The multi-objective optimization function is used to balance the image quality score and the size of the output compressed file. The compression module is used to determine the target image compression algorithm, call the target image compression algorithm to compress the new image file according to the optimal compression parameters, and dynamically adjust the compression process based on the feature information of the new image file during the compression process to obtain and output the compressed image file.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.