Progress bar control method and device for picture compression package uploading
By dividing the image compressed package upload progress bar into two parts—segmented upload and image verification—and creating separate storage folders based on timestamps, the problem of inaccurate progress bar display and chaotic merging in existing technologies is solved, resulting in a more user-friendly experience and an accurate upload process.
Patent Information
- Application Number
- CN202211095678.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-09-06
AI Technical Summary
In existing technologies, the progress bar for uploading image compressed packages cannot accurately display the progress, resulting in a poor user experience and potentially causing confusion or accidental deletion of fragment files during the merging of fragments.
The progress bar for uploading compressed image packages is divided into two parts, which control the segmented upload time and image verification time respectively. A separate storage folder is created using timestamps to achieve step-by-step control of segmented upload and verification.
It improves the accuracy and user experience of the upload process, resolves the chaos during merging, and provides a more user-friendly image compressed package upload function.
Smart Images

Figure CN116320637B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, and in particular relates to a method and system for controlling the progress bar of uploading compressed image packages. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] In image uploading, there are many scenarios where compressed image files are uploaded. In such scenarios, the uploaded compressed files may be very large, and a progress bar needs to be displayed to inform the user of the upload progress in real time. Therefore, whether the progress bar can accurately display the progress is a criterion for judging the quality of progress bar control.
[0004] In addition to accurately displaying the upload progress, uploading compressed image packages also requires verifying the files within the package, such as whether the image type meets the requirements and whether the image resolution meets the requirements. This provides users with a more user-friendly image package upload function and improves the user experience of uploading compressed image packages.
[0005] Current image archive upload progress bars only calculate the upload progress based on the upload time of each archive segment, without considering the verification time of the images within the archive. When an image archive contains many images, even if the upload of each segment is complete, the image verification is not yet finished, and the progress bar will be stuck at a certain point in the process for a long time until all images are verified before closing the progress bar and displaying the upload result, providing a poor user experience. Moreover, when one user is uploading a large image archive in segments, another user is also uploading the same image archive in segments. This may cause confusion during segment merging, resulting in a corrupted archive. Alternatively, when deleting segments after merging an archive, segment information of another archive may be accidentally deleted, causing errors when merging the other archive.
[0006] Therefore, how to effectively control the progress bar during image archive uploads, solve the problem of accidental file deletion, improve upload accuracy, and enhance the user upload experience is a topic worthy of research. Summary of the Invention
[0007] To overcome the shortcomings of the prior art, this invention provides a progress bar control method and system for uploading compressed image packages. The progress bar for uploading compressed image packages is divided into two parts: the first part is the upload, and the second part is the verification. The verification time is included in the calculation of the progress bar. A separate storage folder is created for each compressed image package using a timestamp, thereby providing users with a more user-friendly and accurate compressed image package upload function and improving the user experience of uploading compressed image packages.
[0008] To achieve the above object, one or more embodiments of the present invention provide the following technical solutions:
[0009] In the first aspect of the present invention, a method for controlling the progress bar of uploading a picture compression package is provided;
[0010] A method for controlling the progress bar of uploading a picture compression package includes:
[0011] When starting to upload, display the progress bar, which is controlled by two parts of time. The first part is the time for piecemeal uploading, and the second part is the time for picture inspection;
[0012] According to the preset piecemeal uploading rule, perform piecemeal uploading operations on the picture compression package to be uploaded, and update the display position of the first part of the progress bar in real time according to the progress of piecemeal uploading;
[0013] After finishing the uploading of the entire compression package, according to the preset batch inspection rule, conduct batch inspections on all successfully uploaded pictures, and update the display position of the second part of the progress bar in real time according to the progress of batch inspection;
[0014] After finishing the inspection of all pictures, close the progress bar.
[0015] Furthermore, the progress bar does not distinguish between uploading and inspection in appearance, and displays a unified progress bar. When actually calculating the progress, uploading and inspection are distinguished.
[0016] Preferably, the first fifty percent of the progress bar is controlled by the time for piecemeal uploading, and the latter fifty percent of the progress bar is controlled by the time for picture inspection.
[0017] Furthermore, the preset piecemeal uploading rule sets the size of each piece, and performs piecemeal operations on the picture compression package to be uploaded to obtain multiple piecemeal files.
[0018] Furthermore, according to the number n of piecemeal files, the length of the progress bar controlled by the first part is evenly divided into n progress segments. When the i-th (0 <= i < n) piecemeal file is uploaded, the display position of the progress bar is fixed at the (i + 1)-th segment of the first part.
[0019] Furthermore, the preset batch inspection rule sets the number of pictures inspected in each batch, and performs batch operations on all successfully uploaded pictures to obtain multiple batch inspection picture groups.
[0020] Furthermore, according to the number m of batch inspection picture groups, the length of the progress bar controlled by the second part is evenly divided into m progress segments. When the j-th (0 <= j < m) group of pictures finishes inspection, the display position of the progress bar is fixed at the (j + 1)-th segment of the second part.
[0021] A second aspect of the present invention provides a progress bar control device for uploading image compressed packages.
[0022] A progress bar control device for uploading compressed image packages, applied to a browser, includes an initialization module, a segmented upload module, a batch verification module, and a closing module;
[0023] The initialization module is configured to initialize and display a progress bar when uploading begins. The progress bar is controlled by two time components: the first is the time for uploading chunks, and the second is the time for image verification.
[0024] The chunked upload module is configured to: perform chunked upload operations on the image compressed package to be uploaded according to the preset chunked upload rules, and update the display position of the first part of the progress bar in real time according to the progress of the chunked upload;
[0025] The batch inspection module is configured to: after the entire compressed package upload is completed, inspect all successfully uploaded images in batches according to the preset batch inspection rules, and update the display position of the second part of the progress bar in real time according to the progress of the batch inspection.
[0026] The module is configured to close the progress bar after all image checks are completed.
[0027] A third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps of a progress bar control method for uploading an image compressed package as described in the first aspect of the present invention.
[0028] The fourth aspect of the present invention provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a progress bar control method for uploading a compressed image package as described in the first aspect of the present invention.
[0029] The above one or more technical solutions have the following beneficial effects:
[0030] This invention divides the entire image compressed package upload process into two steps. The first step involves uploading, receiving, and merging the image compressed package in segments. After merging, the image information within the compressed package file is obtained and returned to the front end. The second step involves batch-checking the images pointed to by the image address name array according to the number of images. After all checks are completed, the upload status information is obtained and returned to the front end, thereby improving the accuracy of the upload and enhancing the user's upload experience.
[0031] This invention creates a separate storage folder for each uploaded compressed file based on its timestamped filename, and a separate storage folder for the image files after each compressed file is decompressed. It also categorizes the import process of each compressed file, thus solving the problem of accidental deletion after merging and providing users with a more user-friendly and accurate image compressed file upload function.
[0032] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0033] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0034] Figure 1 This is a flowchart of the method in the first embodiment.
[0035] Figure 2 This is a system structure diagram of the second embodiment. Detailed Implementation
[0036] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0037] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0038] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0039] Example 1
[0040] This embodiment discloses a progress bar control method for uploading image compressed packages;
[0041] like Figure 1 As shown, a method for controlling the progress bar of uploading a compressed image file includes:
[0042] Step S1: When uploading begins, a progress bar is displayed. The progress bar is controlled by two parts of time: the first part is the time for uploading segments, and the second part is the time for image verification.
[0043] For the progress bar described in this embodiment, there is no distinction between uploading and inspection in terms of appearance, and a unified progress bar is displayed. When actually calculating the progress, uploading and inspection are distinguished. The first part is controlled by the time of piecemeal uploading, and the second part is controlled by the time of image inspection.
[0044] For the division ratio between the first part and the second part, it can be adjusted according to the actual situation, such as network speed, image size, etc. As an implementation manner of this embodiment, the first fifty percent of the progress bar is controlled by the time of piecemeal uploading, that is, piecemeal uploading, receiving, and merging account for fifty percent of the total progress; the latter fifty percent of the progress bar is controlled by the time of image inspection.
[0045] Step S2: According to the preset piecemeal uploading rule, perform a piecemeal uploading operation on the image compression package to be uploaded, and update the display position of the first part of the progress bar in real time according to the piecemeal uploading progress. The specific steps are as follows:
[0046] Step S2-1: According to the preset piece size, perform a piecemeal operation on the image compression package to be uploaded to obtain multiple piece files.
[0047] Step S2-2: According to the number n of piece files, evenly divide the length of the progress bar controlled by the first part into n progress segments. When the uploading of the i-th (0 <= i < n) piece file ends, fix the display position of the progress bar at the (i + 1)-th segment of the first part.
[0048] The process of uploading piece files is encapsulated as the doSliceUpload() method, and the steps are as follows:
[0049] (1) Receive the piece file information passed in from the front end
[0050] Receive the parameter data passed in from the front end, including: the file name name with a timestamp added, the piece index i of the current piece, the total number of pieces n, the file size total_size, and the piece file information file.
[0051] (2) Save a single piece file and merge it
[0052] According to the file name name with a timestamp added and the file size total_size, determine whether the type and size of the image compression package to be uploaded are within the specified range.
[0053] Determine the target upload address dir of the compression package and the temporary folder address tmp_dir of the piece files of the compression package. If they do not exist, create them through the mkdir function.
[0054] Remove ".zip" from the name string of the timestamped filename and obtain the filename identifier (sign) with the timestamped name.
[0055] The specific steps for actually performing a save operation are as follows:
[0056] First, it is necessary to check whether a file with the same name (name) already exists in the target upload address dir of the compressed package. If so, delete it to prevent merging the split files into an old file with the same name when merging them into the compressed image file.
[0057] Then, create a new name for the uploaded split files (add the split index i after the filename with the timestamp) new_file_name, and determine the storage folder address zip_tmp for the split files of each image archive. This folder address is the temporary folder address tmp_dir for the split files of the archive.
[0058] Finally, the `move_uploaded_file` function saves the uploaded file segments to the temporary folder `zip_tmp` and converts it into a new file segment name `new_file_name`. The `file_get_contents` function retrieves the content information blob of this file segment, and the `file_put_contents` function inserts the retrieved content information blob into the final file `name` in the compressed image file upload address `dir` to merge the file segments.
[0059] (3) Decompress
[0060] Based on the fragment index i and the total number of fragments n, determine whether the current fragment file is the last fragment file. If so, decompress it, specifically as follows:
[0061] First, determine the file path (file_path) of the merged file and the path where the decompressed image files will be stored;
[0062] Then, the getZipOriginalSize() method is called, with the input parameters file_path and path, to decompress the merged compressed file, store the decompressed images in the corresponding folder, and return the decompression result data;
[0063] Finally, the `unlink()` function deletes all the fragment files in the temporary folder `zip_tmp` of this image archive, and the `rmdir()` function deletes the temporary folder `zip_tmp` of the fragment files of this image archive.
[0064] (4) Finally, check whether the decompressed file result data is an array. If it is, it means the file decompression is successful, and the returned result is an array of picture address names, which is returned to the front end. If not, it means the file decompression fails, and the returned result is the error reason, which is returned to the front end.
[0065] Step S3: After the upload of the entire compressed package is completed, according to the preset batch inspection rules, batch inspection is performed on all successfully uploaded pictures, and the display position of the second part of the progress bar is updated in real time according to the progress of the batch inspection. The specific steps are as follows:
[0066] Step S3-1: According to the preset batch inspection rules, set the number of pictures to be inspected in each batch, and perform batch operations on all successfully uploaded pictures to obtain multiple groups of pictures for batch inspection.
[0067] In this embodiment, the "array of picture address names" returned in step S2 represents all successfully uploaded pictures. The array is batched, and the picture objects to be inspected are obtained through the picture address names.
[0068] Step S3-2: According to the number m of groups of pictures for batch inspection, evenly divide the length of the progress bar controlled by the second part into m progress segments. When the inspection of the jth (0 <= j < m) group of pictures is completed, fix the display position of the progress bar at the (j + 1)th segment of the second part.
[0069] The process of batch inspection is encapsulated as the testUserPhoto() method, including:
[0070] (1) Receive the batch inspection information passed in by the front end
[0071] The batch inspection information includes: the address name of the batch of pictures face_photo, the batch index j, the total number of batches m, the total number of pictures to be inspected number, and the upload timestamp upload_time.
[0072] (2) Inspect the pictures
[0073] Through the foreach loop, each picture information element value in the address name of the batch of pictures face_photo is used as a parameter to call the checkRule() method to determine whether the name type of this picture file meets the format requirements, and obtain the judgment result check_result. In the checkRule() method, a series of inspections such as file type verification, picture pixel size inspection, picture face inspection, picture name format inspection, and user matching inspection are performed on the corresponding pictures according to the passed-in picture address name parameter information value.
[0074] (3) Process the inspection results
[0075] Determine whether the test passes. If it passes, rename the image, move the image from the original address to the new address and rename it. Finally, save the new address and name of the image to the database, output the image address and name parameter information, and save the returned result to the image importable array success_data.
[0076] If a failure fails, the failure count is incremented by 1, and the array of failure reasons is saved to an Excel file. The Excel file containing the array of failure reasons is then returned to the front end.
[0077] (4) Return results
[0078] Determine whether the image URL name "face_photo" in this batch is the last batch by using the batch number index j:
[0079] If not, return the result of the current batch inspection to the front end, update the progress bar, and continue to inspect the next batch of images;
[0080] If so, it means that all images pointed to by the batch image address name face_photo have been verified. The unlink() function is used to delete all image files in the temporary folder of these image files, and the rmdir() function is used to delete the temporary folder of this image file to prevent invalid image files from accumulating. The upload result data is returned to the front end (total number of uploaded items n, success_total number of successful uploads, failure_total number of failed uploads, and the URL of the Excel file containing the reason for the failure).
[0081] Step S4: After completing the inspection of all images, close the progress bar.
[0082] The purpose of this invention is to provide a progress bar control scheme for receiving, merging, and verifying image fragments in an image compressed package. This scheme aims to achieve smoother display of the image compressed package upload progress and to resolve the issue of confusion during the import of multiple image compressed packages by classifying and processing the imported images. The method involves sequentially calling the `doSliceUpload()` method to receive, merge, and decompress the image fragments, ultimately obtaining an array of image address names within the compressed package. Then, the `testUserPhoto()` method is called sequentially in batches to verify the images, ultimately obtaining import status data for all images.
[0083] Example 2
[0084] This embodiment discloses a progress bar control device for uploading image compressed packages;
[0085] like Figure 2As shown, a progress bar control device for uploading compressed image packages, applied to a browser, includes an initialization module, a segmented upload module, a batch verification module, and a closing module;
[0086] The initialization module is configured to initialize and display a progress bar when uploading begins. The progress bar is controlled by two time components: the first is the time for uploading chunks, and the second is the time for image verification.
[0087] The chunked upload module is configured to: perform chunked upload operations on the image compressed package to be uploaded according to the preset chunked upload rules, and update the display position of the first part of the progress bar in real time according to the progress of the chunked upload;
[0088] The batch inspection module is configured to: after the entire compressed package upload is completed, perform batch inspection on all successfully uploaded images according to the preset batch inspection rules, and update the display position of the second part of the progress bar in real time according to the progress of the batch inspection.
[0089] The module is configured to close the progress bar after all image checks are completed.
[0090] Example 3
[0091] The purpose of this embodiment is to provide a computer-readable storage medium.
[0092] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a progress bar control method for uploading a compressed image package as described in Embodiment 1 of this disclosure.
[0093] Example 4
[0094] The purpose of this embodiment is to provide an electronic device.
[0095] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in a progress bar control method for uploading a compressed image package as described in Embodiment 1 of this disclosure.
[0096] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for controlling the progress bar of uploading a compressed image file, characterized in that, Including: When starting to upload, display a progress bar, which is controlled by two parts of time. The first part is the time for piecemeal uploading, and the second part is the time for image verification. According to the preset piecemeal uploading rule, perform piecemeal uploading operations on the image compression package to be uploaded, and update the display position of the first part of the progress bar in real time according to the progress of piecemeal uploading. After finishing the uploading of the entire compression package, according to the preset batch verification rule, perform batch verification on all successfully uploaded images, and update the display position of the second part of the progress bar in real time according to the progress of batch verification. After finishing the verification of all images, close the progress bar. Among them, the preset piecemeal uploading rule sets the size of each piece, and performs piecemeal operations on the image compression package to be uploaded to obtain multiple piecemeal files. According to the number n of piecemeal files, evenly divide the length of the progress bar controlled by the first part into n progress segments. When the uploading of the i-th (0 <= i < n) piecemeal file is completed, fix the display position of the progress bar at the (i + 1)-th segment of the first part. The preset batch verification rule sets the number of images to be verified in each batch, and performs batch operations on all successfully uploaded images to obtain multiple batch verification image groups. According to the number m of batch verification image groups, evenly divide the length of the progress bar controlled by the second part into m progress segments. When the verification of the j-th (0 <= j < m) group of images is completed, fix the display position of the progress bar at the (j + 1)-th segment of the second part.
2. The progress bar control method for uploading image compressed packages as described in claim 1, characterized in that, 3. The progress bar control method for uploading image compressed packages as described in claim 1, characterized in that, The progress bar does not distinguish between uploading and verification in appearance, and displays a unified progress bar. When actually calculating the progress, it distinguishes between uploading and verification.
4. A progress bar control device for uploading compressed image files, characterized in that, The first fifty percent of the progress bar is controlled by the time for piecemeal uploading, and the last fifty percent of the progress bar is controlled by the time for image verification. Adopt a method for controlling the progress bar of uploading an image compression package according to any one of claims 1 - 3, which is applied to a browser and includes an initialization module, a piecemeal uploading module, a batch verification module, and a closing module. The initialization module is configured to: when starting to upload, initialize and display a progress bar, which is controlled by two parts of time. The first part is the time for piecemeal uploading, and the second part is the time for image verification. The piecemeal uploading module is configured to: according to the preset piecemeal uploading rule, perform piecemeal uploading operations on the image compression package to be uploaded, and update the display position of the first part of the progress bar in real time according to the progress of piecemeal uploading. The batch verification module is configured to: after finishing the uploading of the entire compression package, according to the preset batch verification rule, perform batch verification on all successfully uploaded images, and update the display position of the second part of the progress bar in real time according to the progress of batch verification.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that, The closing module is configured to: after finishing the verification of all images, close the progress bar.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by a processor, it implements the steps in a method for controlling the progress bar of uploading an image compression package according to any one of claims 1 - 3. When the processor executes the computer program, it implements the steps in a method for controlling the progress bar of uploading an image compression package according to any one of claims 1 - 3.
Citation Information
Patent Citations
Picture processing method and device
CN105763578A
Import method of bulk data and system thereof
CN106302581A