Image processing method and apparatus, and computer-readable storage medium
The image processing method addresses cache consumption and rendering time issues by converting page images into cache-stored file objects with link paths, enhancing screenshot efficiency and reducing browser workload.
Patent Information
- Application Number
- JP2023510486
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-09-01
- Filing Date
- 2021-03-29
- Publication Date
- 2024-08-22
- Estimated Expiration
- 2041-03-29
AI Technical Summary
Current screenshot methods for HTML web pages on mobile devices consume excessive browser cache and take a long time to render, leading to performance issues and out-of-memory errors due to the use of base64 coding format, which increases cache occupancy and requires repeated operations for saving screenshots.
An image processing method that converts page images into file objects with one-to-one link paths, storing them in the cache to allow direct retrieval for subsequent screenshots, reducing the need for repeated rendering and cache consumption.
This method improves screenshot performance by minimizing cache occupancy and reducing processing workload, allowing for quick and efficient screenshot retrieval without repeated operations.
Smart Images

Figure 0007538948000011 
Figure 0007538948000004 
Figure 0007538948000012
Abstract
Description
[Technical field]
[0001] (CROSS-REFERENCE TO RELATED APPLICATIONS) This application claims priority to a Chinese patent application filed with the China Patent Office on September 1, 2020, bearing application number 202010902786.1 and entitled "Image processing method and apparatus, and computer-readable storage medium," the entire contents of which are incorporated herein by reference. The present disclosure relates to the field of terminal technology, and in particular to an image processing method and apparatus, and a computer-readable storage medium. [Background technology]
[0002] Currently, a user can view the content of an entire webpage in HyperText Markup Language (HTML) using a browser on a mobile terminal. When it is necessary to save a screenshot of one or more screen pages of an entire webpage, the current screenshot method generally uses the canvas method of the HTML specification to take a screenshot of the specified page, converts the captured HTML page in the browser cache into a picture in base64 coding format, and saves the converted picture locally on the mobile terminal. However, the picture in base64 coding format consumes a lot of cache capacity, and the conversion of the HTML page into a base64 picture requires the use of a rendering method in webpage drawing, and the more complex the page, the longer it takes to render. Therefore, the current screenshot method consumes a large amount of browser cache and the taking process is long, which reduces the performance of the browser cache. Summary of the Invention
[0003] In view of this, the embodiments of the present disclosure provide an image processing method and apparatus, and a computer-readable storage medium, which can improve the performance of screenshots of web page applications. In order to achieve the above objective, the technical solution of the present disclosure is realized as follows: In a first aspect of an embodiment of the present disclosure, there is provided an image processing method, the image processing method comprising: obtaining at least one page image of a current full-screen page in a web page application; converting the at least one page image into at least one file object and creating at least one link path for the at least one file object, the at least one file object having a one-to-one correspondence with the at least one link path;
[0004] creating at least one picture object, and storing the at least one picture object in a web page application cache in association with the at least one link path, thereby completing a screenshot of the current full-screen page. In a second aspect of the embodiment of the present disclosure, there is provided an image processing device, the image processing device including an acquisition unit, a conversion unit, and a storage unit, The acquiring unit is configured to acquire at least one page image of a current full-screen page in a web page application; The conversion unit is configured to convert the at least one page image into at least one file object, and create at least one link path for the at least one file object, the at least one file object having a one-to-one correspondence with the at least one link path;
[0005] The storage unit is configured to create at least one picture object, associate the at least one picture object with the at least one link path, and store the at least one picture object in a web page application cache, thereby completing a screenshot of the current full-screen page. In a third aspect of an embodiment of the present disclosure, an image processing device is provided, the image processing device including a memory, a processor, and a communication bus, the memory communicating with the processor via the communication bus, the memory storing one or more programs executable by the processor, and the processor executing the one or more programs to perform any of the image processing methods described above. In a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, the computer-readable storage medium storing one or more computer programs, the one or more computer programs causing one or more processors to execute any of the image processing methods described above. Effect of the Invention
[0006] The embodiment of the present disclosure provides an image processing method and device, and a computer-readable storage medium, which includes the steps of: obtaining at least one page image of a current full-screen page in a web page application; converting the at least one page image into at least one file object, and creating at least one link path of the at least one file object, where the at least one file object corresponds one-to-one to the at least one link path; and creating at least one picture object, and associating the at least one picture object with the at least one link path and storing it in a web page application cache, thereby completing a screenshot of the current full-screen page. Through the method of the embodiment of the present disclosure, the image processing device can convert the at least one page image into at least one file object after obtaining the at least one page image, and associate the link path of the at least one file object with the at least one picture object and store it in a cache, thereby overcoming the technical problem of large cache occupancy caused by converting screenshots into other coding formats. And at least one picture object of the current full-screen page is stored in the cache, so that when the user wants to re-enter the current full-screen page to take a screenshot, the image processing device can directly retrieve at least one picture object from the cache and take a screenshot of the corresponding page, without needing to take a screenshot again, which reduces the workload of browser processing, and finally improves the screenshot performance of webpage applications. [Brief description of the drawings]
[0007] [Figure 1] 1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Diagram 2]1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Diagram 3] 1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Figure 4] 1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Diagram 5] 1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Figure 6] 1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Figure 7A] FIG. 1 is an interface schematic diagram of a process of taking a screenshot of a web page application provided by an embodiment of the present disclosure. [Figure 7B] FIG. 1 is an interface schematic diagram of a process of taking a screenshot of a web page application provided by an embodiment of the present disclosure. [Figure 7C] FIG. 1 is an interface schematic diagram of a process of taking a screenshot of a web page application provided by an embodiment of the present disclosure. [Figure 8] 1 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure. [Figure 9] FIG. 2 is a structural schematic diagram of an image processing device provided by an embodiment of the present disclosure; [Figure 10] FIG. 2 is a structural schematic diagram of an image processing device provided by an embodiment of the present disclosure; DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0008] Hereinafter, the technical solutions of the embodiments of the present disclosure will be described more clearly and completely with reference to the drawings of the embodiments of the present disclosure. Before describing the embodiments of the present disclosure in more detail, the nouns and terms related to the embodiments of the present disclosure will be explained. The nouns and terms related to the embodiments of the present disclosure are to be interpreted as follows. canvas: The canvas element in HTML allows JavaScript scripts to draw images onto a web page. Canvas has a variety of ways to draw paths, rectangles, circles, text, and add images. tag: is an HTML tag. The tag defines a hyperlink and is used to link from one page to another. Tag:HTML, The tag is used to embed an image in a web page. Images embedded in the tag are linked to the web page rather than inserted into the web page. The function of the tag is to create a placeholder for the referenced image.
[0009] Base64 coding: Base64 is a method of representing binary data based on 64 printable characters. Base64 requires converting every three 8-bit bytes into four 6-bit bytes (3*8=4*6=24), adding two zeros to the most significant bits of the converted 6-bit bytes to generate four 8-bit bytes, and looking up the corresponding value in an index table based on the decimal values of the four 8-bit bytes, the result of which is a Base64 value. Therefore, theoretically, the length of a base64 encoded string is 1 / 3 longer than the original string. Document Object Model (DOM): The DOM provides an access model for an entire document. It treats the document as a tree, where each node in the tree represents an HTML tag or a text term within a tag. The properties of the nodes in the DOM tree represent the basic content and structural information of the page. Progressive Web App (PWA): By using the workbox-sw framework standardized for mobile devices, web page applications can emulate some native features and provide an experience similar to that of native applications. Binary Large Object (Blob): A Blob is binary data similar to a file object and can be manipulated in the same way as a file object.
[0010] At present, generally, web promotion pages such as annual billing statements or survey reports of web applications or full-screen HTML 5 animation pages contain multiple scenes, each of which contains multiple picture elements, and need to be viewed by sliding operations on the terminal device. When a user is viewing a full-screen page containing multiple scenes and wants to take screenshots of each scene and save the pictures locally, the current screenshot method uses the canvas drawing method to take a screenshot of the page of the selected current scene, converts the picture into base64 coding format, and then adds a 3D effect around the picture. Wrap the tag and use a JavaScript script to simulate a click event and save the picture locally, or The tag invokes the browser's native method to suggest a long click on the picture to save the picture locally. However, if the local picture is lost and the user wants to save it again, they need to go to the currently viewed page and perform the above sequence of operations.
[0011] In the current method, canvas rendering is required in the process of converting a picture into base64 coding format, and the more complex the page, the longer the canvas rendering takes. Furthermore, base64 picture coding is a very long string, and the full size of the encoding exceeds the size of the picture itself, but the browser cookie or browser local cache has little capacity. From the above, it can be seen that the current browser screenshot saving method is slow, places heavy demands on the browser cache, and consumes a lot of browser performance. Therefore, in actual applications, the current screenshot method often causes memory capacity shortage errors due to the cache capacity limit, and cannot save screenshots of multiple pictures at the same time, and generally, browsers on mobile terminals cannot cache screenshots of more than nine web pages at the same time. Furthermore, if the screenshot taken by the current screenshot method is lost and the user wants to save the screenshot again, the user needs to go to the currently viewed page and perform the above series of operations, which further consumes browser performance.
[0012] Please refer to FIG. 1, which is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure, and the steps shown in FIG. 1 will be explained together. In step S101, at least one page image of a current full-screen page is obtained in a web page application. The image processing method provided by the embodiment of the present disclosure is applied to the scene of saving screenshots in a web page application, for example, the scene of saving screenshots for each scene in a full-screen page by a browser in a terminal, or the scene of taking screenshots of the content of a page displayed on multiple screens in one link by an application or client that supports HTML. In step S101, when a user is browsing a full-screen page of multiple scenes in a web page application such as a browser, the user can browse the multiple scenes in the full-screen page by sliding the page. After loading the current full-screen page, the image processing device can take screenshots of the scenes included in the current full-screen page according to demand, and use at least one captured image as at least one page image.
[0013] In an embodiment of the present disclosure, when an image processing device receives a screenshot command on a current full-screen page of a web page application, in response to the screenshot command, an image corresponding to at least one screenshot waiting scene specified by the screenshot command can be used as at least one page image. In the embodiment of the present disclosure, when the image processing device completes loading of the current full-screen page, it can obtain images corresponding to each scene in the current full-screen page and use them as at least one page image, so that the image processing device silently takes screenshots of each scene in the current full-screen page in the background before the user sends a screenshot command, so as to reduce the waiting time after the user sends a screenshot command. In some embodiments, the image processing device can take screenshots of all or some scenes in the current full-screen page through the canvas screenshot method of the browser, thereby obtaining at least one page image. Specifically, the image processing device can call the html2canvas() method to read the style and content information of each scene to be screenshotted, and render according to the style and content information of each scene to be screenshotted to create one picture, thereby obtaining at least one page image. In other embodiments, the image processing device can obtain at least one page image through the Flashcanvas or ExplorerCanvas method. Specifically, the method can be selected based on the actual situation, and the embodiments of the present disclosure are not limited thereto.
[0014] In the embodiment of the present disclosure, generally, the canvas screenshot method obtains a picture in PNG format, and can also generate pictures in other formats according to actual needs, which is specifically selected according to actual circumstances, and the embodiment of the present disclosure is not limited thereto. It is to be noted that in the embodiment of the present disclosure, the at least one page image is obtained after loading all full-screen page content in the current full-screen page, and therefore, the at least one page image is all a locally generated image of the web page application. In step S102, convert at least one page image into at least one file object, and create at least one link path for the at least one file object, where the at least one file object has a one-to-one correspondence with the at least one link path. In step S102, after obtaining at least one page image, the image processing device can convert the at least one page image in picture format into at least one file object, and realize access to the at least one page image and reading of the content by operating the file object on the HTML page.
[0015] In some embodiments, the image processing device can convert at least one page image into at least one blob object through the canvas.toBlob() method, and use the at least one blob object as at least one file object. In some other embodiments, the image processing device can convert at least one page image into a web page object of other file types through other methods. Specifically, the method is selected based on the actual situation, and the embodiments of the present disclosure are not limited thereto. In step S102, the image processing device converts at least one page image into at least one file object, and then creates one link path for each of the file objects. In some embodiments, if the at least one file object is at least one blob object, the image processing device can create a Uniform Resource Locator (URL) for each of the blob objects using the URL.createObjectURL() method, and use the URL as a link path corresponding to each of the blob objects, thereby obtaining at least one link path.
[0016] In the embodiment of the present disclosure, each link path in the at least one link path points to a corresponding file object, so that the image processing device can associate the at least one file object with other types of web page objects, such as picture objects, through the at least one link path, and allow the other types of web page objects to reference data in the at least one file object as original data by specifying the link path, thereby obtaining various processing methods for the at least one file object through operations on the other types of web page objects. In step S103, at least one picture object is created, and the at least one picture object is associated with at least one link path and stored in a web page application cache, thereby completing a screenshot of the current full-screen page.
[0017] In step S103, the image processing device creates at least one picture type object, i.e. at least one picture object, in the local cache of the web page application, and makes at least one link path point to the at least one picture object, thereby associating the at least one link path with the at least one picture object. The image processing device saves the at least one link path and the at least one picture object together in the web page application cache, thereby completing a screenshot of the current full-screen page. In some embodiments, the image processing device can create at least one picture object by a new Image() method. For the picture object created by new Image(), the image processing device assigns a link path to the src property of the picture object, so that when the picture object is loaded, the file object corresponding to the link path can be accessed by the corresponding link path, and the content in the file object is the content data of the picture loaded by the picture object, thereby realizing the correlation between the picture object, the link path and the file object.
[0018] In step S103, in order to further improve the speed of the screenshot taking process, the image processing device can store at least one link path in the cookie of the web page application, so that before taking a screenshot of the current full-screen page, the image processing device can check whether there is at least one link path of the page to be screenshotted in the cookie of the web page application, and directly obtain at least one picture object cached in the history according to the at least one link path, so as to avoid the need to process the screenshot of the same page again. It can be understood that in the embodiment of the present disclosure, after obtaining at least one page image, the image processing device can convert the at least one page image into at least one file object, and associate the link path of the at least one file object with at least one picture object and store it in a cache, thereby overcoming the technical problem of large cache occupancy caused by converting screenshots to other coding formats. And since the at least one picture object of the current full-screen page is stored in the cache, when a user wants to re-enter the current full-screen page to take a screenshot, the image processing device can directly obtain the at least one picture object from the cache and take the screenshot of the corresponding page, without needing to take a screenshot again, which reduces the workload of browser processing, and finally improves the performance of screenshots in webpage applications.
[0019] Referring to Fig. 2, Fig. 2 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure, and based on Fig. 1, step S101 shown in Fig. 1 can be realized by steps S1011-S1014. Each step will be described below. In step S1011, at least one scene is separated from the current full-screen page, and at least one node identifier is set for the at least one scene, where the at least one node identifier represents at least one data location corresponding to the current full-screen page in the at least one scene, and the at least one scene has a one-to-one correspondence with the at least one node identifier. In step S1011, for the current full-screen page that has been loaded, the image processing device can divide at least one scene according to the style or content shown in the page, and specify a scene that the user wants to take a screenshot from among the at least one scene later. Correspondingly, the image processing device sets at least one node identifier for the at least one scene, and the at least one scene corresponds to the at least one node identifier in a one-to-one manner.
[0020] In an embodiment of the present disclosure, the at least one scene is a page scene included in the current full-screen page, such as images or text at different locations included in the current full-screen page, or each screen page included in the current full-screen page. In an embodiment of the present disclosure, the at least one node identifier represents at least one data location corresponding to the current full-screen page in at least one scene. That is, the node identifier is a storage location of the content data of the corresponding web page object in the entire content data corresponding to the current full-screen page. Exemplarily, the entire content data corresponding to the current full-screen page may be an HTML text, and when the browser parses the HTML text, it constructs a DOM tree based on the association relationship of each web page object in the HTML text. Here, the at least one node identifier may be a document node in the DOM tree of the current full-screen page, and the content data corresponding to each web page object is stored in each DOM node, and each DOM node is interrelated with other DOM nodes in the DOM tree.
[0021] In some embodiments, the image processing device can set the DOM style to be displayed in one screen in the current full-screen page, that is, each screen page in the full-screen page is a scene. The image processing device sets a different DOM ID for each screen, and sets at least one node identifier. In step S1012, obtain at least one target node identifier corresponding to at least one screenshot waiting scene in the current full-screen page, where the at least one screenshot waiting scene is a target screenshot scene in the at least one scene. In step S1012, in the current full-screen page, the image processing device determines at least one screenshot waiting scene based on a screenshot command, or implicitly determines all scenes in the current full-screen page as at least one screenshot waiting scene, and obtains at least one target node identifier corresponding to the at least one screenshot waiting scene.
[0022] In step S1013, according to each target node identifier in the at least one target node identifier, content data corresponding to each target node identifier is read from the content data of the current full-screen page, thereby obtaining at least one target page data. In an embodiment of the present disclosure, for each node identifier among the at least one node identifier, the image processing device determines, according to each node identifier, a storage location of content data corresponding to a web page object represented by the node identifier in the entire content data of the current full-screen page, and reads, according to the storage location of data corresponding to each node identifier, each content data of the corresponding web page object, thereby obtaining at least one target page data. In step S1014, a web page rendering function generates at least one page image based on the at least one target page data. In an embodiment of the present disclosure, after the image processing device reads out at least one target page data, it creates at least one page image based on the at least one target page data through a web page rendering function such as a canvas drawing method. As can be understood, in the embodiments of the present disclosure, by presetting different style node identifiers, different forms of screenshot processing can be performed on the current full screen page, thereby increasing the flexibility of the process of taking screenshots of a page.
[0023] In an embodiment of the present disclosure, refer to Fig. 3, which is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure, in which step S102 shown in Fig. 1 can be realized by steps S1021-S1022. Each step will be described together. In step S1021, at least one page image is converted into at least one binary large object and used as the at least one file object. In step S1021, after obtaining at least one page image, the image processing device calls a picture to binary large object conversion method in the web page drawing method to realize conversion from the at least one page image to at least one binary large object, which can be used as at least one file object. In some embodiments, the image processing device performs a format conversion on at least one page image via the canvas.toBlob() method, converting it into at least one blob object, and using it as the at least one file object. In step S1021, compared with the current screenshot method, the image processing device converts the page image using canvas.toBlob() instead of the canvas.toDataURL method because the page image converted by canvas.toDataURL is in base64 coding format, the data size is larger than the data size of the original picture, and the occupancy rate of the web page application cache is large, which will cause screenshot taking errors. In step S1022, for each binary large object in the at least one binary large object, an object location path creation method in the web page application script is called to create the resource address of each binary large object as a link path, thereby obtaining at least one link path.
[0024] In step S1022, the image processing device converts at least one page image into at least one blob object, and then calls the URL.createObjectURL() method for each of the blob objects to create a URL address corresponding to each of the blob objects as a link path of the blob object, thereby obtaining at least one link path. In an embodiment of the present disclosure, invoking the URL.createObjectURL() method returns a url string that can be hashed to point to the corresponding blob object. It can be understood that in the embodiment of the present disclosure, the image processing device converts at least one page image into a blob object and a corresponding path through the canvas.toBlob() and URL.createObjectURL() methods, and the data size of the converted picture and path is small, so that the web page application cache occupancy is small and no errors such as insufficient memory occur, thereby improving the performance of taking screenshots in the web page application. In an embodiment of the present disclosure, refer to Fig. 4, which is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure, in which step S103 shown in Fig. 1 can be realized by S1031-S1033. Each step will be described together. In step S1031, a picture object creation method in the web page application script is called to create at least one picture object. In step S1031, the image processing device calls a picture object creation method in the web page application script, such as a new image() method, to create at least one picture object in the web page application cache.
[0025] In the embodiment of the present disclosure, a picture object created by the new image() method includes information such as a picture name and a src property, where the src property is required and the value of the src property is the URL of the picture object, i.e., the absolute path or relative path of the file that references the picture object. In some embodiments, the image processing device can generate at least one picture object through other methods supported by the web page application, which are specifically selected based on the actual situation, and the embodiments of the present disclosure are not limited thereto. In step S1032, for each picture object, use each link path in the at least one link path as an image source path of each picture object, and store the at least one picture object in a web page application cache. The image source path is a path from which content data is obtained when each picture object is loaded. In step S1032, after the image processing device creates at least one picture object, for each picture object, the image processing device sets the corresponding link path as the image source path of the picture object, i.e., the path from which the content data is obtained when each picture object is loaded on a web page, thereby realizing at least one file object as the content data of at least one picture object, and realizing the association between them.
[0026] In step S1032, the image processing device can set each of the link paths as an image source path for each picture object by assigning a value to each of the link paths. This is because in step S1032, the image processing device stores at least one picture object in the web page application cache, so that the corresponding picture object can be opened from the local cache of the web page application at the next access. In step S1033, the picture name and image source path of the at least one picture object are stored in the session data of the web page application cache, so as to realize the at least one picture object being associated with and stored in association with at least one link path through the session data, thereby completing a screenshot of the current full-screen page.
[0027] In step S1033, the image processing device can call a session data setting method to realize that the picture name and image source path of at least one picture object are stored in the session data of the web page application cache, such as cookies, thereby achieving obtaining at least one link path from the session data, and further obtaining at least one picture object associated therewith, thereby completing taking a screenshot of the current full-screen page and storing it in the cache. In some embodiments, the image processing device can store the picture name, URL and validity time of at least one picture object in a cookie by calling the setCookie() method. The corresponding code can be implemented as follows: canvas.toBlob(function(blobObj){ let imgs = new Image(); / / Create a picture object let src = window.URL.createObjectURL(blobObj); / / Create a link path for the blob object imgs.src = src; / / Use the link path to populate the image source path of the picture object screenShotCut[ary[i].component] = src; / / Save the link path in a cookie setCookie('imgSrc',JSON.stringify(screenShotCut)) }) In some embodiments, the above setCookie() method can be implemented by the following code: setCookie(name,value,iMinutes){ var oDate = new Date(); oDate.setMinutes(oDate.getMinutes()+iMinutes); document.cookie = name+'='+encodeURIComponent(value) +';expires='+oDate; },
[0028] It can be understood that in the embodiments of the present disclosure, the image processing device associates the link path of at least one file object with at least one picture object and stores it in a cache; after storing the at least one link path in the session data of the web page application cache, when the user re-enters the current full-screen page, the image processing device can directly retrieve the at least one picture object from the cache and take a screenshot of the corresponding page, without needing to take a screenshot again, which reduces the workload of browser processing, and finally improves the performance of screenshots of web page applications. In an embodiment of the present disclosure, refer to Fig. 5, which is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure, in which step S101 shown in Fig. 1 can be realized by S002-S003. Each step will be described together. In step S002, it is checked whether at least one picture object corresponding to the current full-screen page exists in the session data of the web page application cache. In step S002, before obtaining at least one page image, the image processing device checks the session data of the web page application cache to determine whether there is at least one picture object corresponding to the current full-screen page in the session data.
[0029] In an embodiment of the present disclosure, the process of an image processing device checking whether at least one picture object corresponding to a current full-screen page exists in the session data of a web page application cache can be realized as follows. In step S0021, a session data obtaining method is invoked according to the picture name of at least one picture object, and the method extracts at least one picture object from the session data. In some embodiments, when a user accesses a current full-screen page through a web page application, before calling the canvas screenshot method to obtain at least one page image, the image processing device can call the getCookie() method to obtain the cookie data of the web page application, and check whether at least one picture object already exists in the cookie data through the newImg.load method. In some embodiments, the process in which the image processing device checks whether at least one picture object corresponding to at least one link path exists in the web page application cache can be implemented as follows. async canShot() { let imgsrc = getCookie('imgsrc'); / / Check the picture if(imgSrc) { let imgAys = JSON.pase(imgSrc); imgAys.map(item => { let newImg = new Image(); newImg.src = item; newImg,load = ()=>{ / / Check if the picture is still in the cache } }) }else{ let ary = this.comps; / / Page ID to cut let i = ary,length; let shotCanvas = async()=>{ … } shotCanvas(); } }
[0030] In some embodiments, the above getCookie() method can be implemented by the following code: getCookie(name) { var arr = document.cookie.split(';'); var i = 0; for(var i=0;i <arr.length;i++){ var arr2 = arr[i].split('='); if(arr2[0]==name) { return decodeURIComponent(arr2[1]); } } return ''; }, In step S0022, if the call of the session data acquisition method is successful, it is confirmed that at least one picture object exists in the session data. In an embodiment of the present disclosure, if the invocation of the session data acquisition method is successful, illustratively, the above getCookie('imgsrc') method returns a picture object corresponding to imgsrc, indicating that the picture object already exists in the session data, and the image processing device verifies that at least one picture object exists in the session data. In step S0023, if the invocation of the session data acquisition method fails, it is confirmed that at least one picture object does not exist in the session data.
[0031] In an embodiment of the present disclosure, if the invocation of the get session data method fails, the imaging processing device verifies that at least one picture object does not exist in the session data. In step S003, if there is not at least one picture object in the session data, obtain at least one page image of the current full-screen page. In an embodiment of the present disclosure, if there is no at least one picture object in the session data, the image processing device obtains at least one page image from the current full-screen page, and realizes taking a screenshot of the current full-screen page through the method in steps S102-S103 above. In an embodiment of the present disclosure, as shown in FIG. 5, after step S002, step S004 may also be included. In step S004, if there is at least one picture object in the session data, obtain at least one link path corresponding to the at least one picture object from the session data, and complete a screenshot of the current full-screen page.
[0032] In step S004, if there is at least one picture object in the web page application cache, the image processing device completes a screenshot of the current full-screen page without obtaining at least one page image. As can be understood, in an embodiment of the present disclosure, the image processing device can quickly determine the location of at least one picture object to be screenshotted from the cookie of the web page application, eliminating the need to process screenshots of the same page again, and improving the reusability of cached pictures, thereby reducing the workload of taking screenshots of the web page application and improving the performance of taking screenshots of the web page application. In an embodiment of the present disclosure, referring to Fig. 6, Fig. 6 is an exemplary flowchart of an image processing method provided by an embodiment of the present disclosure, and steps S1034-S1035 can be performed after step S1033 or step S103 according to Fig. 4 or Fig. 5. Each step will be described together.
[0033] In step S1034, when receiving an access request for at least one target picture in the at least one picture object in the web page application, obtain at least one target file object corresponding to the at least one target picture object according to the image source path of the at least one target picture object, and the link path of the target file object is the same as the image source path of the target picture object. In step S1034, when a screenshot of a web page is displayed and further saved in the web page application, the image processing device can receive an access request for at least one target picture among at least one picture object in the web page application. In an embodiment of the present disclosure, the at least one target picture represents a screenshot waiting to be extracted in the at least one picture object, and the image processing device can determine the at least one target picture waiting to be extracted according to the picture name carried by the access request. In step S1034, the link path of the file object is the same as the image source path of the picture object, so that the image processing device can read the corresponding target file object from at least one file object according to the image source path of each target picture object.
[0034] In step S1035, load at least one target picture object based on the at least one target file object, thereby realizing display and storage for the at least one target picture object. In step S1035, the image processing device loads each of the target picture objects in the web page application according to the content data in the target file object corresponding to each of the target picture objects, thereby realizing the extraction, display and storage of each of the target picture objects. It can be understood that in the embodiment of the present disclosure, the image processing device can make at least one file object as content data of at least one picture object through at least one link path, so that the target picture object to be loaded can be relatedly loaded by accessing at least one target link path among the at least one link path, thereby realizing the display and storage of the scene to be screenshotted in the cache of the web page application, and improving the performance of the screenshot of the web page application. The following describes exemplary applications of the embodiments of the present disclosure to practical application scenarios.
[0035] In some embodiments of the present disclosure, when a user browses a page such as a summary report or an activity survey through a browser or a web page application, the interaction effect of the interface may be as shown in FIG. 7A-FIG. 7C. In FIG. 7A, the user can browse the contents displayed on each screen page in the entire web page by sliding the page up and down. When the user slides to the last page, as shown in FIG. 7B, the web page application creates rogue screenshots of at least one screen page in the entire web page, displays a save button control 2-1 on the interface, and prompts the user to save the created rogue screenshots of the entire web page through the save button control 2-1, or directly download and save the rogue screenshots in the background. As shown in FIG. 7C, the web page application can create screenshot preview pictures corresponding to each screen page in the entire web page, and display them on the current page in the form of thumbnails. The user can select and save one or more screenshot preview pictures by clicking on the thumbnails, and complete the selection through the confirmation button control 2-2. When the user completes the selection via the confirmation button control 2-2, he or she may further save the page picture corresponding to the one or more screenshot preview pictures confirming the selection by clicking the Save button 2-3. In an embodiment of the present disclosure, after a user clicks the save control 2-1 or the save control 2-3 in the interface shown in Fig. 7B or Fig. 7C, the image processing device can receive a screenshot command in a web page application. Exemplarily, if a user selects multiple page pictures in the interface shown in Fig. 7C and clicks the save control 2-3, the image processing device can take and save the selected multiple page pictures through steps S301-S307, as shown in Fig. 8.
[0036] In step S301, the page is loaded. In step S301, the image processing device loads an entire web page into the browser. In step S302, it is determined whether or not a link address array exists in the cache. In step S302, after loading the entire web page, the image processing device determines whether the link address array exists in the cache, and if so, executes steps S303-S308; if not, skips and executes step S309. In step S302, the link address array includes at least one link address, which is an original address of at least one picture object, and the at least one picture object can be at least one screenshot picture corresponding to an entire web page. The implementation process of step S302 is the same as that described in step S002, and is not repeated here. In step S303, a DOM ID corresponding to each screen page in the entire web page is obtained. In step S303, the image processing device can construct a DOM ID array from the DOM ID of each acquired screen page. In step S303, the image processing device sets at least one DOM ID included in the DOM ID array as at least one node identifier. The implementation process of step S303 is the same as that described in step S1011, and is not repeated here.
[0037] In step S304, a screenshot of the Canvas is taken for each DOM ID, and at least one screenshot picture is obtained. The implementation process of step S304 is the same as that described in steps S1012-1014, and is not repeated here. In step S305, at least one screenshot picture is converted into at least one blob object by the canvas.toBlob() method. The implementation process of step S305 is the same as that described in step S1021, and is not repeated here. In some embodiments, illustratively, the code corresponding to steps S303-S305 may be implemented as follows: async canShot() { let ary = this.comps; / / The array this.comps stores all the DOM IDs waiting for screenshots let i = ary.length; let shotCanvas = async ()=>{ i--; if(ary[i]) { / / Take a screenshot of the page content for each DOM ID. let canvas = await html2canvas (document.querySelector('.${ary[i].component}'), {useCORS;true}) canvas.toBlob(function(blobObj) {…}) shotCanvas() } } shotCanvas() }
[0038] In step S306, at least one link path for at least one blob object is created by the URL.createObjectURL() method. The implementation process of step S306 is the same as that described in step S1022, and is not repeated here. In step S307, at least one picture object img is created by the new Image() method, at least one img.src is valued using at least one link path, and at least one imgs is saved in the browser cache. The implementation process of step S307 is the same as that described in steps S1031-S1032, and is not repeated here. In step S308, at least one link path is stored in a cookie in the form of an array. The implementation process of step S308 is the same as that described in step S1033, and is not repeated here. In step S309, at least one link path is obtained from the cache.
[0039] In step S309, if there is at least one link path in the cache, the image processing device directly obtains the at least one link path without taking a screenshot again. In step S310, extract at least one picture object from the cache based on at least one link path, and further store the at least one picture object based on demand. The implementation process of step S310 is the same as that described in steps S1034-S1035, and is not repeated here. It can be understood that through the above operations, the image processing device can realize multi-screen screenshot taking and optional screenshot taking, overcome the technical problem of long time for taking and rendering pictures, improve the reusability of cached screenshots, and thereby improve the performance of screenshots in web page applications. In the embodiment of the present disclosure, the image processing device can further cache the page image of a specified type through the PWA technology. Specifically, the workbox-sw plugin is introduced to force caching the picture in the blob:null / path. An example code is as follows: importScripts('workbox-sw.prod.v1.1.0.js'); const workbox = new self.WorkboxSW(); / / Match and cache any request with a blob:null / path workBox.router.registerRoute('blob:null / (.*)',workbox.stragtegies.cacheFirst())
[0040] It is understandable that if the image processing device stores the captured pictures in a web page application cache such as a browser cache space, there may be unstable factors such as staleness or unpredictable user behavior. The image processing device caches the pictures in a Service Worker in the PWA technology to achieve a stable and controllable picture caching effect. An embodiment of the present disclosure provides an image processing device corresponding to the image processing method. Fig. 9 is a structural schematic diagram of the image processing device provided by the embodiment of the present disclosure. As shown in Fig. 9, the image processing device 100 includes an acquisition unit 10, a conversion unit 20, and a storage unit 30; The acquiring unit 10 is configured to acquire at least one page image of a current full-screen page in a web page application; The conversion unit 20 is configured to convert the at least one page image into at least one file object, and create at least one link path of the at least one file object, the at least one file object having a one-to-one correspondence with the at least one link path; The storage unit 30 is configured to create at least one picture object, associate the at least one picture object with the at least one link path, and store the at least one picture object in a web page application cache, thereby completing a screenshot of the current full-screen page.
[0041] In some embodiments of the present disclosure, the conversion unit 20 is further configured to convert the at least one page image into at least one binary large object as the at least one file object, and for each binary large object in the at least one binary large object, call an object location path creation method in a web page application script to create a resource address of each binary large object as a link path, thereby obtaining the at least one link path. In some embodiments of the present disclosure, the storage unit 30 is further configured to call a picture object creation method in a web page application script to create at least one picture object, and for each picture object, use each link path in the at least one link path as an image source path of each picture object, and store the at least one picture object in the web page application cache, where the image source path is a path for obtaining content data when loading each picture object, and store the picture name and image source path of the at least one picture object in the session data of the web page application cache, so as to realize the at least one picture object being associated with and stored in association with the at least one link path by the session data, thereby completing the screenshot of the current full-screen page.
[0042] In some embodiments of the present disclosure, the image processing device 100 further includes a checking unit configured to check whether at least one picture object corresponding to the current full-screen page exists in the session data of the web page application cache, and the acquiring unit 10 is further configured to acquire at least one page image of the current full-screen page if the at least one picture object does not exist in the session data. In some embodiments of the present disclosure, after the step of checking whether at least one picture object corresponding to the current full-screen page exists in the session data of the web page application cache, if the at least one picture object exists in the session data, obtain the at least one link path corresponding to the at least one picture object from the session data, and complete a screenshot of the current full-screen page.
[0043] In some embodiments of the present disclosure, the acquisition unit 10 is further configured to acquire an image corresponding to each scene in the current full-screen page and use it as at least one page image when the loading of the current full-screen page is completed. In some embodiments of the present disclosure, when the acquisition unit 10 receives a screenshot command for the current full-screen page, in response to the screenshot command, the acquisition unit 10 is further configured to use an image corresponding to at least one screenshot waiting scene specified by the screenshot command as the at least one page image. In some embodiments of the present disclosure, the image processing device 100 further includes an extracting unit, which is configured to, when receiving an access request for at least one target picture in the at least one picture object in the web page application after completing the screenshot of the current full-screen page, obtain at least one target file object corresponding to the at least one target picture object according to an image source path of the at least one target picture object, a link path of the target file object is the same as the image source path of the target picture object, and load the at least one target picture object according to the at least one target file object, thereby realizing display and saving of the at least one target picture object.
[0044] In some embodiments of the present disclosure, the image processing device 100 further includes a marking unit, which is configured to, before the step of acquiring at least one page image of a current full-screen page in the web page application, segment at least one scene from the current full-screen page and set at least one node identifier for the at least one scene, the at least one scene being a page scene included in the current full-screen page, the at least one node identifier representing at least one data location corresponding to the at least one scene in the current full-screen page, and the at least one scene having a one-to-one correspondence with the at least one node identifier. The acquisition unit 10 is further configured to acquire at least one target node identifier corresponding to at least one screenshot waiting scene in the current full-screen page, the at least one screenshot waiting scene being a target screenshot scene in the at least one scene, and read content data corresponding to each target node identifier from the content data of the current full-screen page based on each target node identifier in the at least one target node identifier, thereby acquiring at least one target page data, and creating the at least one page image based on the at least one target page data through a web page rendering function.
[0045] In some embodiments of the present disclosure, the conversion unit 20 is further configured to invoke a picture to binary large object conversion method in a web page drawing method to realize conversion from the at least one page image to at least one binary large object for use as the at least one file object. In some embodiments of the present disclosure, the storage unit 30 is further configured to invoke a set session data method to realize storing a picture name and an image source path of the at least one picture object in the web page application cache. In some embodiments of the present disclosure, the checking unit is further configured to invoke a session data obtaining method based on a picture name of the at least one picture object, perform extraction of the at least one picture object from the session data, and if the invocation of the session data obtaining method is successful, confirm that the at least one picture object exists in the session data, and if the invocation of the session data obtaining method is unsuccessful, confirm that the at least one picture object does not exist in the session data. An embodiment of the present disclosure provides an image processing device corresponding to an image processing method. Fig. 10 is a structural schematic diagram of an image processing device provided by an embodiment of the present disclosure. As shown in Fig. 10, the image processing device 200 includes a processor 715, a memory 716, and a communication bus 717. The memory 716 communicates with the processor 715 through the communication bus 717, and the memory 716 stores instructions executable by the processor 715, and when the instructions are executed, the processor 715 executes any of the image processing methods of the above embodiments.
[0046] An embodiment of the present disclosure provides a computer-readable storage medium for use in an image processing device. The storage medium stores one or more computer programs, and the one or more computer programs can be executed by one or more processors to implement any of the image processing methods of the above embodiments. It should be understood by those skilled in the art that the embodiments of the present disclosure can be provided as a method, a system, or a computer program product. Thus, the present disclosure can take the form of any of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present disclosure can take the form of a computer program product embodied in one or more computer usable storage media (including, but not limited to, disk memory, optical memory, etc.) containing computer usable program code. The present disclosure will be described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It will be understood that each of the flows and / or blocks in the flowcharts and / or block diagrams, and combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. The corresponding computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor, or other programmable data processing device to generate a machine, whereby the instructions executed by the processor of the computer or other programmable data processing device can generate an apparatus that can be used to implement the functions specified in one or more processes in the flowcharts and / or one or more blocks in the block diagrams.
[0047] The relevant computer program instructions may be stored in a computer-readable memory that can cause a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable memory generate an article of manufacture that includes an instruction apparatus, which implements the functions specified in one or more processes in the flowcharts and / or one or more blocks in the block diagrams. The relevant computer program instructions may be loaded into a computer or other programmable data processing device and cause the computer or other programmable device to perform a series of steps to generate a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide the steps used to implement the functions specified in one or more processes in the flowcharts and / or one or more blocks in the block diagrams. The above is merely a preferred embodiment of the present disclosure, and is not intended to limit the scope of protection of the present disclosure. [Industrial Applicability]
[0048] According to the method of the embodiment of the present disclosure, after obtaining at least one page image, the image processing device can convert the at least one page image into at least one file object, and associate the link path of the at least one file object with at least one picture object and store it in the cache, thereby overcoming the technical problem of large cache occupancy caused by converting screenshots to other coding formats. And since at least one picture object of the current full-screen page is stored in the cache, when a user wants to re-enter the current full-screen page to take a screenshot, the image processing device can directly obtain at least one picture object from the cache and take the screenshot of the corresponding page, without needing to take a screenshot again, which reduces the workload of browser processing, and finally improves the performance of screenshots of webpage applications.
Claims
1. 1. An image processing method, comprising: obtaining at least one page image of a current full-screen page in a web page application; converting the at least one page image into at least one file object and creating at least one link path for the at least one file object, the at least one file object having a one-to-one correspondence with the at least one link path; calling a picture object creation method in a web page application script to create at least one picture object, and storing the at least one picture object in a web page application cache in association with the at least one link path, thereby completing a screenshot of the current full-screen page; Image processing methods.
2. The step of converting the at least one page image into at least one file object and creating at least one link path for the at least one file object includes: converting said at least one page image into at least one binary large object and using said at least one file object; for each binary large object in the at least one binary large object, calling an object location path creation method in a web page application script to create a resource address of each binary large object as a link path, thereby obtaining the at least one link path; The image processing method according to claim 1 .
3. calling a picture object creation method in the web page application script to create at least one picture object, and storing the at least one picture object in a web page application cache in association with the at least one link path, thereby completing a screenshot of the current full-screen page; for each picture object, storing the at least one picture object in the web page application cache using each link path in the at least one link path as an image source path of the respective picture object, wherein the image source path is a path for obtaining content data when loading the respective picture object; storing a picture name and an image source path of the at least one picture object in the session data of the web page application cache, so as to realize the at least one picture object being associated with and stored in the at least one link path through the session data, thereby completing a screenshot of the current full-screen page; The image processing method according to claim 1 .
4. The step of obtaining at least one page image of the current full-screen page includes: checking whether there is at least one picture object corresponding to the current full-screen page in the session data of the web page application cache; if the at least one picture object is not present in the session data, obtaining at least one page image of the current full screen page. The image processing method according to claim 1 .
5. After the step of checking whether at least one picture object corresponding to the current full-screen page exists in the session data of the web page application cache, the image processing method further includes: if the at least one picture object exists in the session data, obtaining the at least one link path corresponding to the at least one picture object from the session data, and completing a screenshot of the current full-screen page; The image processing method according to claim 4.
6. The step of obtaining at least one page image of the current full-screen page includes: When the current full-screen page is completed to load, an image corresponding to each scene in the current full-screen page is obtained and used as at least one page image.
5. The image processing method according to claim 1.
7. In the web page application, obtaining at least one page image of a current full-screen page includes: and when a screenshot command is received for the current full-screen page, in response to the screenshot command, using an image corresponding to at least one screenshot waiting scene designated by the screenshot command as the at least one page image.
5. The image processing method according to claim 1.
8. After completing the screenshot of the current full-screen page, the image processing method further includes: When receiving an access request for at least one target picture object among the at least one picture object in the web page application, obtaining at least one target file object corresponding to the at least one target picture object according to an image source path of the at least one target picture object, where a link path of the target file object is the same as an image source path of the target picture object; loading the at least one target picture object based on the at least one target file object, thereby realizing display and storage for the at least one target picture object; 6. The image processing method according to claim 3.
9. In the web page application, obtaining at least one page image of a current full-screen page includes: splitting at least one scene from the current full-screen page and setting at least one node identifier for the at least one scene, the at least one node identifier representing at least one data location in the current full-screen page corresponding to the at least one scene, the at least one scene having a one-to-one correspondence with the at least one node identifier; obtaining at least one target node identifier corresponding to at least one screenshot waiting scene in the current full-screen page, the at least one screenshot waiting scene being a target screenshot scene in the at least one scene; According to each target node identifier among the at least one target node identifier, reading content data corresponding to each target node identifier from the content data of the current full-screen page, thereby obtaining at least one target page data; generating, by a web page rendering function, the at least one page image based on the at least one targeted page data; The image processing method according to claim 1 .
10. The step of converting the at least one page image into at least one binary large object and using the at least one file object includes: calling a picture to binary large object conversion method in a web page drawing method to realize the conversion from the at least one page image to at least one binary large object, and using the at least one file object as the at least one file object; The image processing method according to claim 2 .
11. Storing the picture name and the image source path of the at least one picture object in session data of the web page application cache includes: calling a session data setting method to realize storing a picture name and an image source path of the at least one picture object in the web page application cache; The image processing method according to claim 3.
12. The step of checking whether at least one picture object corresponding to the current full-screen page exists in the session data of the web page application cache includes: performing, based on a picture name of the at least one picture object, calling a session data obtaining method to extract the at least one picture object from the session data; if the invocation of the get session data method is successful, verifying that the at least one picture object exists in the session data; if the invocation of the get session data method fails, verifying that the at least one picture object is not present in the session data. The image processing method according to claim 4.
13. An image processing device, the image processing device including an acquisition unit, a conversion unit, and a storage unit, The obtaining unit is configured to obtain at least one page image of a current full-screen page in a web page application; The conversion unit is configured to convert the at least one page image into at least one file object and create at least one link path of the at least one file object, the at least one file object having a one-to-one correspondence with the at least one link path; The image processing device is configured such that the storage unit calls a picture object creation method in a web page application script to create at least one picture object, associates the at least one picture object with the at least one link path, and stores the at least one picture object in a web page application cache, thereby completing a screenshot of the current full-screen page.
14. An image processing device, the image processing device including a memory, a processor, and a communication bus; the memory is in communication with the processor via the communication bus, the memory storing one or more programs executable by the processor; The image processing apparatus according to claim 1 , wherein the processor executes the one or more programs to perform the image processing method according to any one of claims 1 to 12 .
15. 1. A computer-readable storage medium, comprising: A computer readable storage medium having stored thereon one or more computer programs for causing one or more processors to carry out the image processing method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Method and apparatus for converting page contents into picture, and computing device
CN107766359A
Communication equipment
JP2011048704A
