Picture data processing method and device, equipment and medium

Through the custom command v-compress and the cross observer, the image is monitored in the visible area, and the createImageBitmap and webWorker technologies are used to compress the image, which solves the problems of low image processing efficiency and page lag in the existing technology, and achieves a more efficient Image processing and better user experience.

CN118568282AInactive Publication Date: 2024-08-30CHENGDU AJIAXI INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202410727050.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-08-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing image processing methods are inefficient, causing page lags and affecting user experience.

Method used

By creating a custom instruction v-compress, the cross observer is used to monitor whether the image is within the visible area, and when it appears, the createImageBitmap and webWorker technologies are used to convert the image into a compressed preview image for lazy loading and image compression. Avoid unnecessary consumption of resources.

Benefits of technology

It significantly reduces CPU and memory usage, improves image processing efficiency, avoids page freezes, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568282A
    Figure CN118568282A
Patent Text Reader

Abstract

The invention discloses a picture data processing method and device, equipment and a medium, relates to the technical field of data processing, and is used for solving the problems that an existing picture processing method is relatively low in efficiency and a page jamming phenomenon is easy to occur. The method comprises the following steps of: creating a user-defined instruction v-press; monitoring a target picture by adopting a cross observer in a mount stage of the custom instruction v-compression, and determining whether the target picture appears in a visual area or not; if it is determined that the target picture appears in the visual area, the target picture is converted into a compressed small preview picture according to the user-defined instruction v-press; and performing preview display on the compressed small preview image, thereby greatly reducing the occupation of a CPU and a memory, improving the image processing efficiency, and avoiding a page jamming phenomenon.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology and provides a method, device, equipment and medium for processing image data. Background Art

[0002] In the current Internet era, images play an important role in various applications and websites. Images can not only display rich visual content, but also effectively convey information and enhance user experience. Under normal circumstances, since uploading image files requires displaying all local images, in existing implementations, all files are directly obtained and rendered, and base64 or blob technology is used to convert the files into temporary previewable images. However, this file conversion to preview image solution not only takes up a lot of memory and CPU resources, but also has a low efficiency in converting files to images, which can easily cause page freezes or even crashes, seriously affecting user experience.

[0003] Therefore, how to improve image processing efficiency and avoid page freezes has become a problem that needs to be solved urgently. Summary of the invention

[0004] The present application provides a method, device, equipment and medium for processing image data, which are used to solve the problems of low efficiency and easy page jamming in existing image processing methods.

[0005] On the one hand, a method for processing image data is provided, the method comprising:

[0006] Create a custom directive v-compress;

[0007] In the mounted phase of the custom instruction v-compress, a cross observer is used to monitor the target image to determine whether the target image appears in the visible area;

[0008] If it is determined that the target image appears in the visible area, convert the target image into a compressed preview thumbnail according to the custom instruction v-compress;

[0009] The compressed preview thumbnail is previewed and displayed.

[0010] Optionally, before creating a custom directive v-compress, the method further includes:

[0011] Select at least one picture through the HTML upload control;

[0012] According to the v-for instruction in the Vue framework, create an image preview list; wherein one preview item in the image preview list corresponds to one image.

[0013] Optionally, the step of creating a custom instruction v-compress includes:

[0014] Create a custom instruction v-compress, and obtain the at least one picture from the picture preview list;

[0015] The at least one image is stored in the custom instruction v-compress.

[0016] Optionally, if it is determined that the target image appears in the visible area, the step of converting the target image into a compressed preview thumbnail according to the custom instruction v-compress includes:

[0017] If it is determined that the target image appears in the visible area, the createImageBitmap technology is used according to the Transferableobjects feature of webWorker to adjust the target image to a bitmap image ImageBitmap that meets the size of the thumbnail preview;

[0018] The bitmap image ImageBitmap is transferred from the main thread to the child thread through the webWorker.

[0019] Optionally, after transmitting the bitmap image ImageBitmap from the main thread to the child thread through the webWorker, the method further includes:

[0020] In the child thread, the width and height attributes of the bitmap image ImageBitmap are used to create an off-screen canvas OffscreenCanvas, and the bitmap image ImageBitmap is drawn into the off-screen canvas OffscreenCanvas through the image drawing method drawImage;

[0021] By converting the convertToBlob method and the specified compression quality value, the off-screen canvas OffscreenCanvas is exported as a compressed blob object, and the compressed blob object is passed from the child thread to the main thread.

[0022] Optionally, after transferring the compressed blob object from the child thread to the main thread, the method further includes:

[0023] Determine whether the main thread obtains the compressed blob object;

[0024] If it is determined that the main thread obtains the compressed blob object, assigning the compressed blob object to the src attribute of the img tag;

[0025] The cross observer is used to cancel monitoring of the target picture.

[0026] Optionally, if it is determined that the target image appears in the visible area, then after converting the target image into a compressed preview thumbnail according to the custom instruction v-compress, the method further includes:

[0027] Determine whether the cumulative amount of converted images exceeds a preset amount;

[0028] If it is determined that the cumulative amount of converted images exceeds the preset amount, the images to be converted are added to the queue of images to be converted;

[0029] After the custom instruction v-compress is processed, the step of taking out a picture to be converted from the picture queue to be converted for processing is executed in a loop until the picture queue to be converted is cleared.

[0030] In one aspect, a picture data processing device is provided, the device comprising:

[0031] Instruction customization unit, used to create a custom instruction v-compress;

[0032] A picture monitoring unit, used to monitor the target picture using a cross observer in the mounted phase of the custom instruction v-compress, and determine whether the target picture appears in the visible area;

[0033] A picture conversion unit, configured to convert the target picture into a compressed preview thumbnail according to the custom instruction v-compress if it is determined that the target picture appears in the visible area;

[0034] The image display unit is used to preview and display the compressed preview thumbnails.

[0035] On the one hand, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein any one of the above methods is implemented when the processor executes the computer program.

[0036] In one aspect, a computer storage medium is provided, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, any of the above methods is implemented.

[0037] Compared with the prior art, the beneficial effects of this application are:

[0038] In an embodiment of the present application, when processing image data, first, a custom instruction v-compress can be created; then, in the mounted stage of the custom instruction v-compress, a cross observer can be used to monitor the target image to determine whether the target image appears in the visible area; next, if it is determined that the target image appears in the visible area, the target image can be converted into a compressed preview thumbnail according to the custom instruction v-compress; finally, the compressed preview thumbnail can be previewed and displayed. Therefore, in an embodiment of the present application, since the target image is lazy loaded and compressed by the custom instruction v-compress in order to display the target image, compared with the prior art, the present application can obviously not only greatly reduce the CPU and memory usage, improve image processing efficiency, and avoid page jams, but also make it more convenient to upload and manage images, greatly improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0040] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0041] Figure 2 A schematic diagram of a flow chart of a method for processing image data provided in an embodiment of the present application;

[0042] Figure 3 A schematic diagram of a picture data processing device provided in an embodiment of the present application.

[0043] Markings in the figure: 10 - picture data processing device, 101 - processor, 102 - memory, 103 - I / O interface, 104 - database, 30 - picture data processing device, 301 - instruction customization unit, 302 - picture monitoring unit, 303 - picture conversion unit, 304 - picture display unit, 305 - preview list creation unit. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other arbitrarily. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0045] In the current Internet era, images play an important role in various applications and websites. Images can not only display rich visual content, but also effectively convey information and enhance user experience. Under normal circumstances, since uploading image files requires displaying all local images, in existing implementations, all files are directly obtained and rendered, and base64 or blob technology is used to convert the files into temporary previewable images. However, this file conversion to preview image solution not only takes up a lot of memory and CPU resources, but also has a low efficiency in converting files to images, which can easily cause page freezes or even crashes, seriously affecting user experience.

[0046] Based on this, an embodiment of the present application provides a method for processing image data, in which, first, a custom instruction v-compress can be created; then, in the mounted stage of the custom instruction v-compress, a cross observer can be used to monitor the target image to determine whether the target image appears in the visible area; next, if it is determined that the target image appears in the visible area, the target image can be converted into a compressed preview thumbnail according to the custom instruction v-compress; finally, the compressed preview thumbnail can be previewed and displayed. Therefore, in an embodiment of the present application, since the target image is lazy loaded and compressed by the custom instruction v-compress in order to display the target image, compared with the prior art, the present application can obviously not only greatly reduce the CPU and memory usage, improve image processing efficiency, and avoid page jams, but also upload and manage images more conveniently, greatly improving the user experience.

[0047] After introducing the design ideas of the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions of the embodiments of the present application can be applied. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limited. In the specific implementation process, the technical solutions provided by the embodiments of the present application can be flexibly applied according to actual needs.

[0048] like Figure 1 FIG. 1 is a schematic diagram of an application scenario provided by an embodiment of the present application. The application scenario may include an image data processing device 10 .

[0049] The image data processing device 10 can be used to process image data, for example, it can be a personal computer (PC), a server and a laptop. The image data processing device 10 may include one or more processors 101, a memory 102, an I / O interface 103 and a database 104. Specifically, the processor 101 may be a central processing unit (CPU) or a digital processing unit. The memory 102 may be a volatile memory, such as a random-access memory (RAM); the memory 102 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 102 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 102 may be a combination of the above memories. The memory 102 may store some program instructions of the image data processing method provided in the embodiment of the present application, and these program instructions can be used to implement the steps of the image data processing method provided in the embodiment of the present application when executed by the processor 101, so as to solve the problems of low efficiency and easy page jamming in the existing image processing method. The database 104 may be used to store data such as the custom instruction v-compress, target image, preview thumbnail, image preview list, bitmap image, blob object, and image queue to be converted involved in the solution provided in the embodiment of the present application.

[0050] In the embodiment of the present application, the image data processing device 10 can obtain at least one image selected by the user through the I / O interface 103, and then the processor 101 of the image data processing device 10 will improve the image processing efficiency and avoid page jamming according to the program instructions of the image data processing method provided in the embodiment of the present application in the memory 102. In addition, the data such as the custom instruction v-compress, the target image, the preview thumbnail, the image preview list, the bitmap image, the blob object and the queue of images to be converted can also be stored in the database 104.

[0051] Of course, the method provided in the embodiment of the present application is not limited to Figure 1 The application scenarios shown can also be used in other possible application scenarios, and the embodiments of the present application are not limited thereto. Figure 1 The functions that can be realized by each device in the application scenario shown will be described in the subsequent method embodiments, and will not be described in detail here. Below, the method of the embodiment of the present application will be introduced in conjunction with the accompanying drawings.

[0052] like Figure 2 FIG. 1 is a flow chart of a method for processing image data provided by an embodiment of the present application. The method can be performed by Figure 1 The method is executed by the image data processing device 10 in the embodiment. Specifically, the process of the method is described as follows.

[0053] Step 201: Create a custom directive v-compress.

[0054] In order to provide users with a concise and intuitive upload interface so that users can easily upload their own pictures, in the embodiment of the present application, first, the user can select at least one picture through the HTML upload control and read the at least one picture from the user's computer; then, according to the at least one picture selected by the user, a picture preview list can be created according to the v-for instruction in the Vue framework, thereby creating a preview item for each picture, that is, one preview item in the picture preview list corresponds to one picture. Based on this, the user can see the thumbnail of each picture on the interface to facilitate the preview and management of the pictures.

[0055] Furthermore, in order to prevent the page from freezing due to the picture preview list being too long, in an embodiment of the present application, a fixed height can be set for each picture in the picture preview list, and all pictures in the picture preview list can be displayed using a scroll bar when necessary.

[0056] Furthermore, after the preparation is completed, in order to achieve lazy loading of images, in the embodiment of the present application, a custom instruction v-compress can be created and at least one image can be obtained from the image preview list; then, at least one image can be stored in the custom instruction v-compress. Furthermore, when the user scrolls the page, the intersection observer IntersectionObserver can be used to monitor whether each image appears in the visible area. Once a certain image enters the visible area, the custom instruction v-compress can be activated and the image currently entering the visible area can be bound to the custom instruction v-compress.

[0057] Step 202: In the mounted phase of the custom instruction v-compress, a cross observer is used to monitor the target image to determine whether the target image appears in the visible area.

[0058] In the embodiment of the present application, in the mounted phase of the custom instruction v-compress initialization, the IntersectionObserver target image can be used to start monitoring to determine whether the target image appears in the visible area, and the monitoring of the target image can be canceled after the unmounted phase and the target image processing is completed. Based on this, only when the image is actually displayed in the user's field of view will the subsequent data processing operations be performed, thereby greatly reducing unnecessary calculations and resource consumption.

[0059] Step 203: If it is determined that the target image appears in the visible area, the target image is converted into a compressed preview thumbnail according to the custom instruction v-compress.

[0060] Specifically, if it is determined that the target image appears in the visible area, then during the compression process of the target image, the createImageBitmap technology can be used according to the Transferable objects feature of webWorker to adjust the target image to a bitmap image ImageBitmap that meets the thumbnail preview size (for example, quality is 0.2); and the bitmap image ImageBitmap is transferred from the main thread to the child thread through webWorker. In this way, the compression process can be performed in the background thread without blocking the response of the user interface.

[0061] Then, after transferring the bitmap image ImageBitmap from the main thread to the child thread through webWorker, in the child thread, the width and height attributes of the bitmap image ImageBitmap can be used to create an off-screen canvas OffscreenCanvas, and the bitmap image ImageBitmap can be drawn to the off-screen canvas OffscreenCanvas through the drawing image drawImage method; next, the off-screen canvas OffscreenCanvas can be exported to a compressed blob object through the convertToBlob method and the specified compression quality value, and the compressed blob object can be passed from the child thread to the main thread.

[0062] Then, after passing the compressed blob object from the child thread to the main thread, it can be determined whether the main thread obtains the compressed blob object; if it is determined that the main thread obtains the compressed blob object, the compressed blob object can be assigned to the src attribute of the img tag to facilitate subsequent preview display of the target image; at the same time, in order to avoid unnecessary resource occupation, the intersection observer IntersectionObserver can also be used to cancel the monitoring of the target image.

[0063] Step 204: Preview and display the compressed preview thumbnail.

[0064] In an embodiment of the present application, after obtaining the compressed preview thumbnail, the compressed preview thumbnail can be directly previewed and displayed to show the preview effect to the user on the interface.

[0065] In a possible implementation, in order to control the resource usage of the system, in the embodiment of the present application, the cumulative amount of converted pictures may also be limited.

[0066] Specifically, if it is determined that the target image appears in the visible area, then according to the custom instruction v-compress, after converting the target image into a compressed preview thumbnail, first, it can be determined whether the cumulative amount of converted images exceeds the preset number; then, if it is determined that the cumulative amount of converted images exceeds the preset number, the image to be converted can be added to the queue of images to be converted; finally, after the custom instruction v-compress is processed, the step of taking out a picture to be converted from the queue of images to be converted for processing can be executed cyclically until the queue of images to be converted is cleared. Furthermore, in this way, a large number of image files can be processed efficiently while ensuring the smoothness and response speed of the user interface.

[0067] In a possible implementation, in the embodiments of the present application, the performance indicators can also be optimized and improved. Thus, through reasonable resource management and task scheduling, the CPU and memory usage can be effectively reduced. For example, by setting an upper limit on the number of "image files converted simultaneously" (for example, the upper limit can be set to 3 images), excessive resource consumption can be avoided, wherein the upper limit on the number of "image files converted simultaneously" can be changed according to the hardware conditions of the user's device. The better the hardware, the more files can be processed at the same time. At the same time, webWorker is used to send the compression task to the background thread to ensure the responsiveness and fluency of the user interface.

[0068] In a possible implementation, in the embodiment of the present application, the image compression algorithm can also be optimized. Thus, by adopting differentiated compression strategies for images of different sizes, the image file size can be minimized while ensuring the quality of the preview image. Based on this, not only can the speed of image loading be improved, but also the cost of network transmission can be reduced.

[0069] To sum up, since the target image is lazy loaded and compressed through the custom instruction v-compress to display the target image, compared with the existing technology, this application can obviously not only greatly reduce the CPU and memory usage, improve image processing efficiency, and avoid page freezes, but also upload and manage images more conveniently, greatly improving the user experience.

[0070] Based on this, with the continuous development of Internet applications, the efficient image data processing method of this application will be widely used in various fields. Whether it is an e-commerce platform, a social network, or a content sharing website, it can refer to the technical solution of this application to optimize the image processing process and improve the user experience. At the same time, with the continuous improvement of computing power and network bandwidth, the image data processing method of this application will also play a more important role in processing larger-scale image data and provide users with better services.

[0071] Based on the same inventive concept, the embodiment of the present application provides an image data processing device 30, which is applied to an automatic lawn mower scene, such as Figure 3 As shown, the image data processing device 30 includes:

[0072] The instruction customization unit 301 is used to create a custom instruction v-compress;

[0073] The image monitoring unit 302 is used to monitor the target image using a cross observer in the mounted phase of the custom instruction v-compress to determine whether the target image appears in the visible area;

[0074] The image conversion unit 303 is used to convert the target image into a compressed preview thumbnail according to the custom instruction v-compress if it is determined that the target image appears in the visible area;

[0075] The picture display unit 304 is used to preview and display the compressed preview thumbnails.

[0076] Optionally, the image data processing device 30 further includes a preview list creating unit 305, which is used to:

[0077] Select at least one picture through the HTML upload control;

[0078] According to the v-for instruction in the Vue framework, create an image preview list; in which one preview item in the image preview list corresponds to one image.

[0079] Optionally, the instruction customization unit 301 is further used to:

[0080] Create a custom directive v-compress and get at least one image from the image preview list;

[0081] Store at least one image in the custom directive v-compress.

[0082] Optionally, the picture conversion unit 303 is further used for:

[0083] If it is determined that the target image appears in the visible area, the createImageBitmap technology is used according to the Transferable objects feature of webWorker to adjust the target image to a bitmap image ImageBitmap that meets the size of the thumbnail preview;

[0084] Transfer the bitmap image ImageBitmap from the main thread to the child thread through webWorker.

[0085] Optionally, the picture conversion unit 303 is further used for:

[0086] In the child thread, the width and height attributes of the bitmap image ImageBitmap are used to create an off-screen canvas OffscreenCanvas, and the bitmap image ImageBitmap is drawn to the off-screen canvas OffscreenCanvas through the drawImage method;

[0087] By converting the convertToBlob method and the specified compression quality value, the off-screen canvas OffscreenCanvas is exported as a compressed blob object, and the compressed blob object is passed from the child thread to the main thread.

[0088] Optionally, the picture display unit 304 is further used for:

[0089] Determine whether the main thread obtains the compressed blob object;

[0090] If it is determined that the main thread obtains the compressed blob object, the compressed blob object is assigned to the src attribute of the img tag;

[0091] Use the cross observer to cancel the monitoring of the target image.

[0092] Optionally, the picture conversion unit 303 is further used for:

[0093] Determine whether the cumulative amount of converted images exceeds a preset amount;

[0094] If it is determined that the cumulative amount of converted images exceeds the preset amount, the images to be converted are added to the queue of images to be converted;

[0095] After the custom instruction v-compress is processed, the step of taking out a picture to be converted from the picture queue to be converted for processing is executed in a loop until the picture queue to be converted is cleared.

[0096] The image data processing device 30 can be used to perform Figure 2 The method executed in the embodiment shown in FIG. 1 is a method for executing a method in the embodiment shown in FIG. 1 . Therefore, for the functions that can be realized by each functional module of the image data processing device 30, reference can be made to FIG. Figure 2 The description of the illustrated embodiment is not repeated in detail.

[0097] In some possible implementations, various aspects of the method provided in the present application may also be implemented in the form of a program part, which includes a program code. When the program part is run on a computer device, the program code is used to enable the computer device to execute the steps of the method according to various exemplary embodiments of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 2 The method performed in the illustrated embodiment.

[0098] It can be understood by those skilled in the art that all or part of the steps of the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiment are executed; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk. Alternatively, if the above integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent part, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present invention can be essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software part, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. And the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disk or optical disk.

[0099] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0100] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for processing image data, characterized in that: The method comprises: Create a custom directive v-compress; In the mounted phase of the custom instruction v-compress, a cross observer is used to monitor the target image to determine whether the target image appears in the visible area; If it is determined that the target image appears in the visible area, convert the target image into a compressed preview thumbnail according to the custom instruction v-compress; The compressed preview thumbnail is previewed and displayed.

2. The method according to claim 1, characterized in that Before creating a custom directive v-compress, the method further includes: Select at least one picture through the HTML upload control; According to the v-for instruction in the Vue framework, create an image preview list; wherein one preview item in the image preview list corresponds to one image.

3. The method according to claim 2, characterized in that The steps to create a custom directive v-compress include: Create a custom instruction v-compress, and obtain the at least one picture from the picture preview list; The at least one image is stored in the custom instruction v-compress.

4. The method according to claim 1, characterized in that If it is determined that the target image appears in the visible area, the step of converting the target image into a compressed preview thumbnail according to the custom instruction v-compress includes: If it is determined that the target image appears in the visible area, then according to the Transferable objects feature of webWorker, the createImageBitmap technology is used to adjust the target image to a bitmap image ImageBitmap that meets the size of the thumbnail preview; The bitmap image ImageBitmap is transferred from the main thread to the child thread through the webWorker.

5. The method according to claim 4, characterized in that After transmitting the bitmap image ImageBitmap from the main thread to the child thread through the webWorker, the method further includes: In the child thread, the width and height attributes of the bitmap image ImageBitmap are used to create an off-screen canvas OffscreenCanvas, and the bitmap image ImageBitmap is drawn into the off-screen canvas OffscreenCanvas through the image drawing method drawImage; By converting the convertToBlob method and the specified compression quality value, the off-screen canvas OffscreenCanvas is exported as a compressed blob object, and the compressed blob object is passed from the child thread to the main thread.

6. The method according to claim 5, characterized in that After transferring the compressed blob object from the child thread to the main thread, the method further includes: Determine whether the main thread obtains the compressed blob object; If it is determined that the main thread obtains the compressed blob object, assigning the compressed blob object to the src attribute of the img tag; The cross observer is used to cancel monitoring of the target picture.

7. The method according to claim 1, characterized in that If it is determined that the target image appears in the visible area, then after converting the target image into a compressed preview thumbnail according to the custom instruction v-compress, the method further includes: Determine whether the cumulative amount of converted images exceeds a preset amount; If it is determined that the cumulative amount of converted images exceeds the preset amount, the images to be converted are added to the queue of images to be converted; After the custom instruction v-compress is processed, the step of taking out a picture to be converted from the picture queue to be converted for processing is executed in a loop until the picture queue to be converted is cleared.

8. A picture data processing device, characterized in that: The device comprises: Instruction customization unit, used to create a custom instruction v-compress; A picture monitoring unit, used to monitor the target picture using a cross observer in the mounted phase of the custom instruction v-compress, and determine whether the target picture appears in the visible area; A picture conversion unit, configured to convert the target picture into a compressed preview thumbnail according to the custom instruction v-compress if it is determined that the target picture appears in the visible area; The image display unit is used to preview and display the compressed preview thumbnails.

9. An electronic device, characterized in that: The device comprises: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute any method according to claims 1-7 according to the obtained program instructions.

10. A storage medium, characterized in that: The storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute any one of the methods of claims 1-7.

Citation Information

Patent Citations

  • Lazy picture loading method and device, medium and electronic equipment

    CN112395535A

  • Method and device for sharing image acquisition device and storage medium

    CN116033256A

  • Webpage generation method and device, storage medium and electronic equipment

    CN116578795A

  • Image lazy loading method and device, computer equipment and storage medium

    CN116796088A

Cited By

  • Method for uploading and displaying AI training big data set

    CN119293001A