Picture compression method and device, storage medium and electronic equipment

By monitoring the target folder in real time and automatically identifying and compressing new image files, the problem of users needing to perform periodic operations in existing technologies is solved, realizing unattended automated image processing and improving efficiency.

CN121786010APending Publication Date: 2026-04-03成都安易迅科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In existing technologies, users have to periodically check the target directory and repeat the same operation process, resulting in a lot of repetitive labor and wasted time resources, making it impossible to achieve a truly automated and unattended image processing workflow.

Method used

By receiving the monitoring path configuration information input by the user, the system monitors the target folder in real time, automatically identifies new files, and determines whether they are image files and match the preset format based on the file attribute information. If they match, the system calls the compression algorithm to process them and generate compressed image files.

Benefits of technology

It has achieved an automated, unattended image processing workflow, reduced manual intervention, improved processing efficiency, and met the needs of continuous image compression.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121786010A_ABST
    Figure CN121786010A_ABST
Patent Text Reader

Abstract

The invention relates to a picture compression method and device, a storage medium and electronic equipment, and relates to the technical field of image processing, and the picture compression method comprises the steps that monitoring path configuration information input by a user is received, and real-time monitoring of a target folder is started according to the monitoring path configuration information, and the target folder comprises at least one specified folder; when a creation event representing storage of a new file in the target folder is monitored, obtaining file attribute information of the new file, judging whether the new file is a picture file or not according to the file attribute information, and judging whether a file format of the new file is matched with a preset format list or not; and if the new file is the picture file and the file format of the new file is matched with the preset format list, calling a compression algorithm to compress the new file according to the preset compression parameter, and generating a compressed picture file. Through the scheme of the invention, the storage event of the new image file is automatically sensed, and an automatic and unattended image processing workflow in a real sense is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, specifically to an image compression method, apparatus, storage medium, and electronic device. Background Technology

[0002] With the continuous evolution of digital image processing technology and the widespread adoption of internet applications, image files have become an important carrier of information storage and transmission. From social media sharing and e-commerce displays to professional photography and design, the application scenarios for high-definition images are becoming increasingly widespread. However, while high-definition images bring rich visual experiences, their massive data volume also poses serious technical challenges to storage system capacity, network bandwidth, and processing performance.

[0003] In traditional image processing workflows, image compression, as a fundamental technical operation, has long relied on manual processing with human intervention. Users need to select image files to be processed one by one through a graphical user interface, or import multiple files using batch selection functions, then configure compression parameters and start the processing flow. This manual image processing mode exposes significant technical limitations when faced with large-scale, continuous image compression demands.

[0004] First, traditional image compression tools generally employ a passive, manual triggering mechanism, lacking proactive sensing and automatic response capabilities. Users must explicitly start the compression program and manually select the objects to be processed, a mode of operation that is extremely inefficient when dealing with dynamically growing collections of images. Especially in application scenarios that require continuous monitoring of specific directories and processing of newly stored images, users are forced to periodically check the target directory and repeat the same operational procedures, resulting in a significant amount of repetitive work and wasted time.

[0005] Secondly, existing technical solutions generally lack real-time monitoring and event response capabilities for file system changes, and cannot automatically detect the storage of new image files. This technical deficiency forces users to actively poll or manually check for new processing objects, making it impossible to achieve a truly automated, unattended image processing workflow. Summary of the Invention

[0006] In view of this, this application provides an image compression method, apparatus, storage medium, and electronic device. The main purpose is to solve the technical problems in the prior art, where users have to periodically check the target directory and repeatedly perform the same operation process, resulting in a lot of repetitive labor and wasted time resources. The prior art also requires users to actively poll or manually check to find new processing objects, which makes it impossible to achieve a truly automated and unattended image processing workflow.

[0007] According to a first aspect of this application, an image compression method is provided, the method comprising: Receive monitoring path configuration information input by the user, and start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; When a creation event indicating that a new file has been stored in the target folder is detected, the file attribute information of the new file is obtained, and the file attribute information is used to determine whether the new file is an image file and whether the file format of the new file matches the preset format list. If the new file is an image file and its file format matches a preset format list, then a compression algorithm is called to compress the new file according to preset compression parameters, generating a compressed image file.

[0008] According to a second aspect of this application, an image compression apparatus is provided, the apparatus comprising: The monitoring module is used to receive monitoring path configuration information input by the user, and to start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; The judgment module is used to obtain the file attribute information of the new file when a creation event indicating that a new file has been stored in the target folder is detected, and to determine whether the new file is an image file based on the file attribute information, and whether the file format of the new file matches the preset format list. The compression module is used to compress the new file according to preset compression parameters if the new file is an image file and the file format of the new file matches a preset format list, thereby generating a compressed image file.

[0009] According to a third aspect of this application, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method of the first aspect described above.

[0010] According to a fourth aspect of this application, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of the first aspect described above.

[0011] Compared with existing technologies, the image compression method, apparatus, storage medium, and electronic device provided in this application can first receive monitoring path configuration information input by the user, and then initiate real-time monitoring of the target folder based on the monitoring path configuration information. The target folder includes at least one specified folder. When a creation event indicating the storage of a new file is detected in the target folder, the file attribute information of the new file is obtained, and it is determined whether the new file is an image file and whether its file format matches a preset format list based on the file attribute information. If the new file is an image file and its file format matches the preset format list, a compression algorithm is called to compress the new file according to preset compression parameters, generating a compressed image file. Through the scheme of this application, real-time monitoring of the target folder is initiated by receiving monitoring path information configured by the user. When a file creation event occurs in the target folder (including specified subfolders), the system immediately triggers a response, automatically detecting the storage of a new image file without manual intervention. If the file passes verification, the compression algorithm is automatically invoked and a compressed image file is generated based on preset parameters. The compressed file is then saved to the specified directory or overwritten. The entire compression process does not require manual triggering, achieving a truly automated and unattended image processing workflow.

[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description

[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0014] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1 This is a schematic flowchart of an image compression method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of an image compression device provided in an embodiment of this application. Detailed Implementation

[0016] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of this application, including various details to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0017] The image compression method, apparatus, storage medium, and electronic device of this application are described below with reference to the accompanying drawings.

[0018] To address the technical problems in existing technologies where users must periodically check target directories and repeatedly execute the same operation processes, resulting in a large amount of repetitive labor and wasted time resources, and where existing technologies require users to actively poll or manually check to discover new processing objects, thus failing to achieve a truly automated, unattended image processing workflow, embodiments of this application provide an image compression method, such as... Figure 1 As shown, the method includes: Step 101: Receive the monitoring path configuration information input by the user, and start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder.

[0019] In this embodiment of the application, the monitoring path configuration information input by the user can be received through an "Add Folder" button or input box in the user interface (such as a graphical user interface (GUI) or a command-line interface (CLI). The monitoring path configuration information may include the absolute or relative paths of one or more folders. For example, in the GUI, the user can select a target folder by clicking the "Browse" button, and the file system can obtain the absolute or relative path of that folder as the monitoring path configuration information.

[0020] The file system can initiate real-time monitoring of the target folder based on the received monitoring path configuration information, utilizing the computer system's file monitoring mechanism (such as the FileSystemWatcher class in Windows or the inotify mechanism in Linux) to monitor the target folder's status in real time. The target folder may include at least one specified folder, which can be a folder on the user's local computer or a network shared folder.

[0021] Step 102: When a creation event indicating that a new file has been added to the target folder is detected, obtain the file attribute information of the new file, and determine whether the new file is an image file and whether the file format of the new file matches the preset format list based on the file attribute information.

[0022] In this embodiment of the application, the file monitoring mechanism of the computer system can be used to continuously monitor the target folder. Once it is detected that a user has saved a new file into the monitored target folder, the file system can generate a creation event. After the image compression tool of this application captures the creation event, it can immediately obtain the file attribute information of the new file and perform a dual judgment mechanism. The dual judgment mechanism can first determine whether the file is an image, and if it is an image, then further determine whether its format is the format that the user has set to be compressed.

[0023] File attribute information may include the file extension and / or header information of the new file. The file extension may be a file type identifier, such as ".jpg" in "photo.jpg"; the header information may be the first few bytes of the file when it is stored, which contains specific data that identifies the true type of the file, i.e., the "file header magic number".

[0024] After obtaining the file extension and / or header information of a new file, one possible approach is to read the file extension and match it against a preset list of image extensions. If a match is found, the new file is determined to be an image file. For example, if the new file has the extension .jpg, and .jpg is in the preset list of image extensions, then the file is determined to be an image file. This preset list of image extensions may include image format extensions such as .jpg, .png, and .bmp.

[0025] As another possible approach, the file header information of the new file can be read, and the file header magic number can be obtained from the header information. This file header magic number is then matched against a preset list of image format magic numbers. If a match is found, the new file is determined to be an image file. The file header magic number is a specific sequence of bytes at the beginning of the file, and different file formats have different magic numbers. For example, the magic number for a JPEG file is "FF D8 FF," and matching this magic number can identify JPEG format files.

[0026] In this embodiment of the application, user-inputted format filtering configuration information can be received, and a preset format list can be generated based on the format filtering configuration information. For example, the user can select the image formats to be compressed on the interface, and the system will generate a preset format list of these selected formats. The preset format list can be a list generated based on user-defined filtering conditions and can be used to specify which specific image file formats the image compression tool needs to process. The preset format list includes at least one image format from JPEG, PNG, BMP, WEBP, GIF, and TIFF.

[0027] For example, in the format filtering interface of an image compression tool, users can enter format filtering configuration information (such as "JPEG" and "PNG") by checking checkboxes or entering labels. The image compression tool will then dynamically generate the above preset format list (such as ["JPEG", "PNG"]) based on the format filtering configuration information (such as "JPEG" and "PNG").

[0028] It can determine whether the file format of the new file matches the preset format list. If the new file is an image file and its file format is in the preset format list, then proceed to the next compression step; otherwise, ignore the new file.

[0029] Step 103: If the new file is an image file and its file format matches the preset format list, then according to the preset compression parameters, the compression algorithm is called to compress the new file and generate a compressed image file.

[0030] In this embodiment of the application, for image files that meet the format requirements, the built-in image compression algorithm can be invoked, and the compression parameters preset by the user can be read. The compression algorithm performs targeted processing on the image file according to the preset compression parameters to achieve the balance between the image quality and file size expected by the user.

[0031] The process of generating the preset compression parameters can be as follows: The system receives compression parameter configuration information input by the user through the user interface. The compression parameter configuration information can be set by the user on the user interface according to their different needs for image quality and file size. The parameters such as compression ratio and resolution can be flexibly adjusted according to the actual situation. Based on the compression parameter configuration information, preset compression parameters are generated. These preset compression parameters include at least one of the following: compression quality ratio, target resolution, and target file size threshold. For example, if the user sets the compression quality ratio to 70%, the target resolution to 1024x768 pixels, and the target file size threshold to 500KB, the generated preset compression parameters will include these settings.

[0032] The compression quality ratio is a value used to balance image quality and file size, typically an integer between 0 and 100 or a decimal between 0 and 1. A higher value results in better image quality but a larger file size.

[0033] The target resolution can be the user's desired maximum width and height of the compressed image, such as 1920x1080 pixels. If the original image resolution exceeds this value, it can be proportionally reduced during compression.

[0034] The target file size threshold can be the maximum storage size of the compressed file that the user expects, such as 500KB.

[0035] In this embodiment of the application, to meet the user's precise control over file size, an iterative compression algorithm can be used. The compression quality of the new file is dynamically adjusted according to the compression quality ratio. Initially, compression is performed at a high compression quality ratio. Then, the file size and resolution of the compressed image file are checked to see if they meet preset conditions. If the file size is still greater than the target file size threshold or the file resolution is greater than the target resolution, the compression quality ratio is reduced, and compression is performed again until the file size of the compressed image file is less than or equal to the target file size threshold, and / or the file resolution is less than or equal to the target resolution.

[0036] When multiple new files are detected being added within a preset time (e.g., within 1 second), to improve efficiency, the image compression tool can create a separate compression task for each new file and add these tasks to a task queue. Simultaneously, the tool can launch one or more worker threads. These threads can sequentially retrieve and execute compression tasks from the task queue. This multi-threaded concurrent processing mechanism allows multiple worker threads to process compression tasks in the queue simultaneously, efficiently achieving batch compression of multiple new files.

[0037] The preset compression parameters also include a preset output path. After generating the compressed image file, it can be stored in a specified location according to the preset output path, thus achieving separate management of the original image and the compressed image. The preset output path can be a target subfolder within the target folder, or a target subfolder specified by the user. The preset output path can be used to specify the save location of the compressed image file. For example, the user can specify the output path as "target folder / compressed_images" in the compression parameter configuration information, and the compressed image file will be stored in this subfolder.

[0038] In a specific application scenario, the user sets the image download folder as the monitoring target and enters the folder path in the monitoring path configuration information. The compression parameters are configured as medium quality (60% compression quality), the target resolution is not set, and the target file size threshold is 1MB. Only JPEG format images are selected for compression, and the JPEG format is specified in the format filtering configuration information. When new images are saved to this folder, the system automatically performs the above steps to detect and compress them, compressing eligible JPEG images to a file size less than or equal to 1MB and storing them in the preset output path.

[0039] In summary, according to the image compression method provided in this application, compared with the prior art, this application can first receive monitoring path configuration information input by the user, and start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; when a creation event indicating that a new file has been stored in the target folder is detected, the file attribute information of the new file is obtained, and it is determined whether the new file is an image file and whether the file format of the new file matches the preset format list according to the file attribute information; if the new file is an image file and the file format of the new file matches the preset format list, then the compression algorithm is called to compress the new file according to the preset compression parameters to generate a compressed image file. Through the solution of this application, this application starts real-time monitoring of the target folder by receiving the monitoring path information configured by the user. When a file creation event occurs in the target folder (including specified subfolders), the system immediately triggers a response, realizing automatic detection of the storage event of a new image file without manual intervention. If the file passes verification, the compression algorithm is automatically invoked and a compressed image file is generated based on preset parameters. The compressed file is then saved to the specified directory or overwritten. The entire compression process does not require manual triggering, achieving a truly automated and unattended image processing workflow.

[0040] Based on the above Figure 1 The specific implementation of the method shown in this embodiment provides an image compression device, such as... Figure 2 As shown, the device includes: a monitoring module 31, a judgment module 32, and a compression module 33; The monitoring module 31 is used to receive monitoring path configuration information input by the user, and start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; The judgment module 32 is used to obtain the file attribute information of the new file when a creation event indicating that a new file has been stored in the target folder is detected, and to determine whether the new file is an image file based on the file attribute information, and to determine whether the file format of the new file matches the preset format list. Compression module 33 is used to compress the new file according to preset compression parameters and call a compression algorithm to generate a compressed image file if the new file is an image file and the file format of the new file matches a preset format list.

[0041] In specific application scenarios, the file attribute information includes the file extension and / or file header information of the new file; the judgment module 32 can be used to read the file extension of the new file; The file extension is matched against a preset list of image extensions; if a match is found, the new file is determined to be an image file; and / or, Read the file header information of the new file and obtain the file header magic number from the file header information; The file header magic number is matched with a preset image format magic number list. If the match is successful, the new file is determined to be an image file.

[0042] In specific application scenarios, the judgment module 32 can be used to receive format filtering configuration information input by the user; Based on the format filtering configuration information, the preset format list is generated, wherein the preset format list includes at least one image format from JPEG, PNG, BMP, WEBP, GIF, and TIFF.

[0043] In specific application scenarios, compression module 33 can be used to receive compression parameter configuration information input by the user; Based on the compression parameter configuration information, the preset compression parameters are generated, wherein the preset compression parameters include at least one of the following: compression quality ratio, target resolution, and target file size threshold.

[0044] In specific application scenarios, the compression module 33 can be used to dynamically adjust the compression quality of the new file according to the compression quality ratio using an iterative compression algorithm until the file size of the compressed image file is less than or equal to the target file size threshold, and / or the file resolution of the image file is less than or equal to the target resolution.

[0045] In specific application scenarios, the compression module 33 can be used to create a corresponding independent compression processing task for each new file when multiple new files are detected to be stored within a preset time, and add the compression processing task to the task queue; One or more worker threads are started to sequentially retrieve and execute compression tasks from the task queue to achieve batch compression of multiple new files.

[0046] In specific application scenarios, such as Figure 2As shown, the device also includes: a storage module 34; Storage module 34 is used to store the compressed image file to a specified location according to the preset output path, wherein the preset output path is a target subfolder within the target folder, or a target subfolder specified by the user, and the preset compression parameters also include the preset output path.

[0047] It should be noted that other corresponding descriptions of the functional units involved in the image compression device provided in this embodiment can be found in [reference needed]. Figure 1 The corresponding descriptions in [the document] will not be repeated here.

[0048] Based on the above, Figure 1 Accordingly, this embodiment also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method. Figure 1 The method shown.

[0049] 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 CD-ROM, USB flash drive, mobile hard drive, etc.) and includes several instructions to cause a computer device (such as personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of this application.

[0050] Based on the above, Figure 1 The method shown, and Figure 2 To achieve the above objectives, the present application also provides an electronic device, comprising a storage medium and a processor; the storage medium for storing a computer program; and the processor for executing the computer program to implement the above-described virtual device embodiments. Figure 1 The method shown.

[0051] Optionally, the aforementioned physical devices may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB interfaces, card reader interfaces, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Wi-Fi interfaces), etc.

[0052] Those skilled in the art will understand that the physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or combine certain components, or have different component arrangements.

[0053] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the aforementioned physical device, supporting the operation of information processing programs and other software and / or programs. The network communication module is used to enable communication between the various components within the storage medium, as well as communication with other hardware and software in the information processing physical device.

[0054] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms, or it can be implemented by hardware. This application can first receive monitoring path configuration information input by the user, and start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; when a creation event indicating that a new file has been stored in the target folder is detected, the file attribute information of the new file is obtained, and it is determined whether the new file is an image file and whether the file format of the new file matches the preset format list according to the file attribute information; if the new file is an image file and the file format of the new file matches the preset format list, then the compression algorithm is called to compress the new file according to the preset compression parameters to generate a compressed image file. Through the solution of this application, this application starts real-time monitoring of the target folder by receiving the monitoring path information configured by the user. When a file creation event occurs in the target folder (including specified subfolders), the system immediately triggers a response, realizing automatic detection of the storage event of a new image file without manual intervention. If the file passes verification, the compression algorithm is automatically invoked and a compressed image file is generated based on preset parameters. The compressed file is then saved to the specified directory or overwritten. The entire compression process does not require manual triggering, achieving a truly automated and unattended image processing workflow.

[0055] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the term "comprising" or any other variations thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0056] The above are merely specific embodiments of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to these embodiments, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. An image compression method, characterized in that, include: Receive monitoring path configuration information input by the user, and start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; When a creation event indicating that a new file has been stored in the target folder is detected, the file attribute information of the new file is obtained, and the file attribute information is used to determine whether the new file is an image file and whether the file format of the new file matches the preset format list. If the new file is an image file and its file format matches a preset format list, then a compression algorithm is called to compress the new file according to preset compression parameters, generating a compressed image file.

2. The image compression method according to claim 1, characterized in that, The file attribute information includes the file extension and / or file header information of the new file; The step of determining whether the new file is an image file based on the file attribute information specifically includes: Read the file extension of the new file; The file extension is matched against a preset list of image extensions; if a match is found, the new file is determined to be an image file; and / or, Read the file header information of the new file and obtain the file header magic number from the file header information; The file header magic number is matched with a preset image format magic number list. If the match is successful, the new file is determined to be an image file.

3. The image compression method according to claim 1, characterized in that, The process of generating the preset format list includes: Receive formatted filtering configuration information input by the user; Based on the format filtering configuration information, the preset format list is generated, wherein the preset format list includes at least one image format from JPEG, PNG, BMP, WEBP, GIF, and TIFF.

4. The image compression method according to claim 1, characterized in that, The process of generating the preset compression parameters includes: Receive compression parameter configuration information input by the user; Based on the compression parameter configuration information, the preset compression parameters are generated, wherein the preset compression parameters include at least one of the following: compression quality ratio, target resolution, and target file size threshold.

5. The image compression method according to claim 4, characterized in that, The step of compressing the new file according to preset compression parameters and calling a compression algorithm to generate a compressed image file includes: An iterative compression algorithm is used to dynamically adjust the compression quality of the new file according to the compression quality ratio until the size of the compressed image file is less than or equal to the target file size threshold, and / or the file resolution of the image file is less than or equal to the target resolution.

6. The image compression method according to claim 5, characterized in that, The method further includes: When multiple new files are detected being stored within a preset time period, a corresponding independent compression processing task is created for each new file, and the compression processing task is added to the task queue. One or more worker threads are started to sequentially retrieve and execute compression tasks from the task queue to achieve batch compression of multiple new files.

7. The image compression method according to claim 6, characterized in that, The preset compression parameters also include a preset output path; After generating the compressed image file, the method further includes: According to the preset output path, the compressed image file is stored in the specified location, wherein the preset output path is a target subfolder within the target folder, or a target subfolder specified by the user.

8. An image compression device, characterized in that, include: The monitoring module is used to receive monitoring path configuration information input by the user, and to start real-time monitoring of the target folder according to the monitoring path configuration information, wherein the target folder includes at least one specified folder; The judgment module is used to obtain the file attribute information of the new file when a creation event indicating that a new file has been stored in the target folder is detected, and to determine whether the new file is an image file based on the file attribute information, and whether the file format of the new file matches the preset format list. The compression module is used to compress the new file according to preset compression parameters if the new file is an image file and the file format of the new file matches a preset format list, thereby generating a compressed image file.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the image compression method according to any one of claims 1 to 7.

10. An electronic device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, it implements the image compression method according to any one of claims 1 to 7.