AI format file processing method, device and storage medium
The browser processes Adobe Illustrator format files and converts them into HTML+CSS format DOM nodes, which solves the problem of being unable to open files without Adobe Illustrator software, achieves a cross-platform browsing experience, and saves software installation and Purchase Fees.
Patent Information
- Application Number
- CN202210418620.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-20
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-04-20
AI Technical Summary
In the existing technology, Adobe Illustrator format files can only be opened in an environment where the Adobe Illustrator software is installed, and are difficult to use on computers with lower performance configurations or devices without the software installed.
Through the processing method on the browser side, Adobe Illustrator format files are converted into code text, the information content is extracted, and converted into DOM nodes in HTML+CSS format, and rendered on the browser page to achieve file presentation.
You can open AI format files without installing Adobe Illustrator software, saving costs and achieving a cross-device and cross-platform browsing experience.
Smart Images

Figure CN114841125B
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the technical field of browser-side file processing, and in particular to a browser-based Adobe Illustrator format file processing method, device and storage medium. Background Art
[0002] In the prior art, if you want to view an Adobe Illustrator (AI) format file, you generally need to purchase Adobe Illustrator software, install the Adobe Illustrator software on a computer, and then open the AI format file in the Adobe Illustrator software. However, this greatly limits the use environment of AI format files, especially in some computer environments with low performance configurations. Even if Adobe Illustrator software is installed, it is difficult to run AI format files smoothly, and when switching to another computer that does not have Adobe Illustrator software installed, AI format files cannot be opened. Summary of the invention
[0003] The purpose of the embodiments of the present disclosure is to provide a browser-based Adobe Illustrator format file processing method, device and storage medium, which solves the problem that AI format files cannot be opened in an environment without Adobe Illustrator software, and realizes that AI format files can be browsed as long as there is a browser.
[0004] In order to achieve the above-mentioned purpose, on the one hand, an embodiment of the present disclosure provides a method for processing an AI format file, which is applied to a browser, and the method includes: obtaining an AI format file to be presented, and converting the AI format file into a code text; extracting information content in the code text according to the AI format specification and information identification; converting the information content into a DOM (Document Object Model) node described in the HTML (Hypertext Markup Language) + CSS (Cascading Style Sheets) format; rendering the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file.
[0005] Furthermore, converting the AI format file into code text includes: using the FileReader.readAsString function in the browser to convert the AI format file into code text.
[0006] Furthermore, extracting information content from the code text according to the AI format specification and information identifier includes: extracting canvas information, font information, media information and element information from the code text according to the AI format specification and information identifier; extracting text elements, vector elements and image elements from the element information layer by layer according to the element identifier in the element information.
[0007] Furthermore, when the element identifier indicates that the element information is a text element, extracting the text element from the element information includes: extracting the text identifier indicated in the text element; obtaining the text attribute corresponding to the text identifier in the font information, and associating the text attribute with the text element.
[0008] Further, when the element identifier indicates that the element information is a picture element, extracting the picture element in the element information includes: extracting the picture identifier indicated in the picture element; obtaining pixel data corresponding to the picture identifier in the media information, and associating the pixel data with the picture element.
[0009] Furthermore, when the element information is the text element or the vector element, converting the information content into a DOM node described in HTML+CSS format includes: converting the element type corresponding to the element information into a node type of the DOM node described in HTML, and converting the information attributes in the element information into description content in CSS format.
[0010] Furthermore, when the element information is a picture element, converting the information content into a DOM node described in HTML+CSS format includes: using the CanvasRenderingContext2D.putImageData function of the browser to draw the pixel data in the picture element on the HTMLCanvasElement canvas of the browser, and calling the HTMLCanvasElemen.toDataURL function of the browser to obtain the URL (UniformResource Locator) of the picture element; converting the URL into a node type of the DOM node described in HTML, and converting the image attributes in the picture element into description content in CSS format.
[0011] Furthermore, rendering the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file includes: calling the HTMLElement.appenChild function of the browser, rendering the DOM node to the page of the browser, and obtaining the presentation content corresponding to the AI format file.
[0012] Another aspect of an embodiment of the present disclosure provides a device for processing AI format files, which is applied to a browser, and includes: an acquisition module, used to acquire the AI format file to be presented; a text conversion module, used to convert the AI format file into a code text; a content extraction module, used to extract information content in the code text according to the AI format specification and information identification; a node conversion module, used to convert the information content into a DOM node described in HTML+CSS format; and a presentation module, used to render the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file.
[0013] Furthermore, the text conversion module is specifically used to: utilize the FileReader.readAsString function in the browser to convert the AI format file into code text.
[0014] Furthermore, the content extraction module is specifically used to: extract the drawing board information, font information, media information and element information in the code text according to the AI format specification and information identification; and extract the text elements, vector elements and image elements in the element information layer by layer according to the element identification in the element information.
[0015] Furthermore, when the element identifier indicates that the element information is a text element, the content extraction module is also used to: extract the text identifier indicated in the text element; obtain the text attribute corresponding to the text identifier in the font information, and associate the text attribute with the text element.
[0016] Furthermore, when the element identifier indicates that the element information is a picture element, the content extraction module is also used to: extract the picture identifier indicated in the picture element; obtain pixel data corresponding to the picture identifier in the media information, and associate the pixel data with the picture element.
[0017] Furthermore, when the element information is the text element or the vector element, the node conversion module is also used to: convert the element type corresponding to the element information into the node type of the DOM node described in HTML, and convert the information attributes in the element information into description content in CSS format.
[0018] Furthermore, when the element information is a picture element, the node conversion module is also used to: use the CanvasRenderingContext2D.putImageData function of the browser to draw the pixel data in the picture element on the HTMLCanvasElement canvas of the browser, and call the HTMLCanvasElemen.toDataURL function of the browser to obtain the uniform resource locator URL of the picture element; convert the URL into the node type of the DOM node described in HTML, and convert the picture attributes in the picture element into description content in CSS format.
[0019] Furthermore, the rendering module is specifically used to: call the HTMLElement.appenChild function of the browser, render the DOM node to the page of the browser, and obtain the rendering content corresponding to the AI format file.
[0020] In addition, another aspect of the embodiments of the present disclosure further provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the AI format file processing method as described above.
[0021] Through the disclosed embodiment, the AI format file is converted into a code text describing the content of the file, and the information content in the code text is extracted, and then the information content is converted into a DOM node in HTML+CSS format recognizable by the browser, and all DOM nodes are rendered on the browser page to obtain the presentation content corresponding to the AI format file. In the disclosed embodiment, for the presentation of AI format files, it is no longer necessary to install Adobe Illustrator software to open AI format files, nor is it limited to the terminal environment where Adobe Illustrator software is installed. Only a device with a browser (e.g., a mobile phone, a Pad, etc.) is required to open AI format files, which not only saves the cost of purchasing Adobe Illustrator software, but also avoids the trouble of installing software, and can better browse AI format files across devices and platforms.
[0022] Other features and advantages of the embodiments of the present disclosure will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the embodiments of the present disclosure but do not constitute a limitation on the embodiments of the present disclosure. In the accompanying drawings:
[0024] Figure 1It is a flowchart of a method for processing an AI format file provided by an embodiment of the present disclosure;
[0025] Figure 2 It is a schematic diagram of the architecture of a method for processing an AI format file provided by an embodiment of the present disclosure;
[0026] Figure 3 It is a structural diagram of an AI format file processing device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work also fall within the scope of protection of the present disclosure.
[0028] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art to which the subject matter of the present disclosure belongs. It will be further understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the specification and the relevant art, and will not be interpreted in an idealized or overly formal form unless otherwise explicitly defined herein.
[0029] Figure 1 FIG. 1 is a flowchart of a method for processing an AI format file provided by an embodiment of the present disclosure. Figure 1 As shown, the method is applied to a browser of a device, and the method comprises the following steps:
[0030] Step 101, obtaining an AI format file to be presented, and converting the AI format file into a code text.
[0031] Among them, when the browser obtains an AI format file to be presented, it will load the AI format file into the memory of the browser, and convert the AI format file into a code text that describes the content of the AI format file by using the FileReader.readAsString function in the browser.
[0032] Step 102: extracting information content from the code text according to the AI format specification and the information identifier.
[0033] Among them, AI format files must be written in accordance with the specifications and standards of this field, that is, written in accordance with the AI format specifications. Therefore, for an AI format file, if you want to extract the content therein, you need to extract it in accordance with its AI format specifications. In addition, in the converted code text, there are information identifiers indicating the content of each type of information, for example, there are information identifiers indicating file header information, information identifiers indicating font information, information identifiers indicating drawing board information, information identifiers indicating media information, and information identifiers indicating element information. After extracting the file header information, font information, drawing board information, media information, and element information in the code text according to the above-mentioned information identifiers, extract the content in the element information.
[0034] Among them, since the element information is sorted according to layer data layer by layer, the text elements, vector elements and picture elements in the element information can be extracted layer by layer according to the element identifiers in the element information.
[0035] In addition, the file header information includes the file name, creation time and other information of the AI format file. The font information includes all text attributes involved in the text elements in the AI format file. Since the text attribute content is large and there may be multiple identical text attributes, in order to avoid duplicate content, text attributes can be replaced by text identifiers in text elements. In addition, the font information includes the text attributes corresponding to the text identifier, so the font information includes the text attributes involved in all text elements. The canvas information is equivalent to a canvas, which is used to deploy the above information content on it. The media information includes pixel data in the picture element. Since the pixel data is relatively large, it is inconvenient to include it in the picture element. The indicated picture identifier can be extracted in the picture element, thereby extracting the pixel data corresponding to the picture identifier in the media information.
[0036] For the above three types of layer data, the specific content information can be obtained through the following methods respectively.
[0037] When the element identifier indicates that the element information is a text element, the text identifier indicated in the text element is extracted, and the text attribute corresponding to the text identifier is obtained in the font information, and then the text attribute is associated with the text element. An example of a text element after the associated configuration is given below:
[0038] Type: Text layer
[0039] Font: Alibaba Puhui-Heavy
[0040] Font color: Red
[0041] Font size: 40px
[0042] Text content: I am a cat
[0043] Distance from the left side of the canvas: 40px
[0044] Distance from top of canvas: 40px
[0045] As shown in the above example, the text element after association configuration has associated the text content "I am a cat" with text attributes (including font, font color, font size, font text position) for subsequent format conversion.
[0046] When the element identifier indicates that the element information is a picture element, the picture identifier indicated in the picture element is extracted, and the pixel data corresponding to the picture identifier is obtained in the media information, and the pixel data is associated with the picture element. An example of a picture element after the associated configuration is given below:
[0047] Type: Image layer
[0048] Distance from the left side of the canvas: 100px
[0049] Distance from top of canvas: 100px
[0050] Width: 200px
[0051] Height: 200px
[0052] Pixel data: [binary image data]
[0053] As shown in the above example, the associated configured picture element has associated the pixel data, that is, the binary image data, with the position and size attributes of the picture for subsequent format conversion.
[0054] For the vector element, wherein the shape node data representing the path information of the vector element is directly stored in the vector element, the extracted vector layer may be as follows:
[0055] Type: Vector layer
[0056] Distance from the left side of the canvas: 200px
[0057] Distance from top of canvas: 200px
[0058] Width: 100px
[0059] Height: 100px
[0060] Shape node data: [shape node data]
[0061] As shown in the above example, the vector layer includes shape node data and the position and size attributes of the vector, so as to facilitate subsequent format conversion.
[0062] The above element information is only shown as an example and is not used to limit the actual order of the data included in the element information. In practical applications, the corresponding element information is extracted layer by layer according to the actual layers in the element information, and the association configuration of attributes and element contents is performed for text elements and image elements.
[0063] Step 103: convert the information content into a DOM node described in HTML+CSS format.
[0064] The above-mentioned drawing board information, text elements, vector elements and picture elements are converted into DOM nodes described in HTML+CSS format.
[0065] Specifically, the artboard information may be directly converted, as shown in the following example:
[0066] Artboard information:
[0067] Width: 400px
[0068] Height: 400px
[0069] Color Mode: RGB
[0070] Background color: transparent
[0071] The DOM node converted to HTML+CSS format is as follows:
[0072] The DOM nodes described by HTML are: Artboard Information
[0073] The artboard properties described in CSS format are:
[0074]
[0075] When the element information is the text element or the vector element, the element type corresponding to the element information is converted into the node type of the DOM node described in HTML, and the information attributes in the element information are converted into description content in CSS format.
[0076] Taking the text element provided in step 102 as an example, the text element includes the following content:
[0077] Type: Text layer
[0078] Font: Alibaba Puhui-Heavy
[0079] Font color: Red
[0080] Font size: 40px
[0081] Text content: I am a cat
[0082] Distance from the left of the canvas: 40px
[0083] Distance from the top of the canvas: 40px
[0084] Converted to a DOM node described in HTML+CSS format as follows:
[0085] DOM node described by HTML: I am a cat
[0086] Text attributes described in CSS format:
[0087]
[0088] For the vector element, direct conversion can be performed. Taking the vector element provided in step 102 as an example, the vector element includes the following content:
[0089] Type: Vector layer
[0090] Distance from the left of the canvas: 200px
[0091] Distance from the top of the canvas: 200px
[0092] Width: 100px
[0093] Height: 100px
[0094] Shape node data: [Shape node data]
[0095] Converted to a DOM node described in HTML+CSS format as follows:
[0096] DOM node described by HTML:
[0097] <svg viewBox="0 0 100 100">
[0098] <path d="[Shape node data]" / >
[0099] Among them, "0 0 100 100" represents the range of the vector element, that is, the coordinate point "0 0" at the upper left corner and the coordinate point "100 100" at the lower right corner.
[0100] Vector attributes described in CSS format:
[0101]
[0102] When the element information is a picture element, the CanvasRenderingContext2D.putImageData function of the browser is used to draw the pixel data in the picture element on the HTMLCanvasElement canvas of the browser, and the HTMLCanvasElemen.toDataURL function of the browser is called to obtain the URL of the picture element, and then the URL is converted into the node type of the DOM node described in HTML, and the picture attributes in the picture element are converted into description content in CSS format.
[0103] Taking the picture element provided in step 102 as an example, the picture element includes the following content:
[0104] Type: Image layer
[0105] Distance from the left side of the canvas: 100px
[0106] Distance from top of canvas: 100px
[0107] Width: 200px
[0108] Height: 200px
[0109] Pixel data: [Binary image data]
[0110] The DOM node converted to HTML+CSS format is as follows:
[0111] The DOM nodes described by HTML are: <img src=”URL”>
[0112] Image properties described in CSS format:
[0113]
[0114] Through step 103, all element information included in the AI format file is converted into DOM nodes in HTML+CSS format that can be recognized by the browser.
[0115] Step 104: render the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file.
[0116] Specifically, the HTMLElement.appenChild function of the browser is called to render the DOM node to the page of the browser to obtain the presentation content corresponding to the AI format file.
[0117] In addition, the file header information can be directly displayed on the browser page.
[0118] like Figure 2 As shown, the disclosed embodiment converts the AI format file into a code text describing the content of the file, and extracts the file header information, drawing board information, media information, font information, text elements, picture elements and vector elements in the code text, extracts the element information and associates the element content with the attribute, and then converts it into a DOM node in HTML+CSS format recognizable by the browser, and renders all DOM nodes on the browser page. In the disclosed embodiment, for the presentation of AI format files, it is no longer necessary to install Adobe Illustrator software to open AI format files, nor is it limited to the terminal environment where Adobe Illustrator software is installed. Only a device with a browser (e.g., mobile phone, Pad, etc.) is required to open AI format files, which not only saves the cost of purchasing Adobe Illustrator software, but also avoids the trouble of installing software, and can better browse AI format files across devices and platforms.
[0119] Accordingly, Figure 3 Schematic diagram of a device for processing AI format files provided by an embodiment of the present disclosure. Figure 3 As shown, the device is applied to a browser, and the device 30 includes: an acquisition module 31, used to acquire the AI format file to be presented; a text conversion module 32, used to convert the AI format file into a code text; a content extraction module 33, used to extract the information content in the code text according to the AI format specification and the information identifier; a node conversion module 34, used to convert the information content into a DOM node described in HTML+CSS format; a presentation module 35, used to render the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file.
[0120] Furthermore, the text conversion module is specifically used to: utilize the FileReader.readAsString function in the browser to convert the AI format file into code text.
[0121] Furthermore, the content extraction module is specifically used to: extract the drawing board information, font information, media information and element information in the code text according to the AI format specification and information identification; and extract the text elements, vector elements and image elements in the element information layer by layer according to the element identification in the element information.
[0122] Furthermore, when the element identifier indicates that the element information is a text element, the content extraction module is also used to: extract the text identifier indicated in the text element; obtain the text attribute corresponding to the text identifier in the font information, and associate the text attribute with the text element.
[0123] Furthermore, when the element identifier indicates that the element information is a picture element, the content extraction module is also used to: extract the picture identifier indicated in the picture element; obtain pixel data corresponding to the picture identifier in the media information, and associate the pixel data with the picture element.
[0124] Furthermore, when the element information is the text element or the vector element, the node conversion module is also used to: convert the element type corresponding to the element information into the node type of the DOM node described in HTML, and convert the information attributes in the element information into description content in CSS format.
[0125] Furthermore, when the element information is a picture element, the node conversion module is also used to: use the CanvasRenderingContext2D.putImageData function of the browser to draw the pixel data in the picture element on the HTMLCanvasElement canvas of the browser, and call the HTMLCanvasElemen.toDataURL function of the browser to obtain the URL of the picture element; convert the URL into the node type of the DOM node described in HTML, and convert the picture attributes in the picture element into description content in CSS format.
[0126] Furthermore, the rendering module is specifically used to: call the HTMLElement.appenChild function of the browser, render the DOM node to the page of the browser, and obtain the rendering content corresponding to the AI format file.
[0127] The specific working principle and benefits of the AI format file processing device provided in the embodiment of the present disclosure are similar to the specific working principle and benefits of the AI format file processing method provided in the embodiment of the present disclosure, and will not be repeated here.
[0128] In addition, another aspect of the embodiments of the present disclosure further provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the AI format file processing method described in the above embodiments.
[0129] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0130] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These 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, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0131] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0133] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0134] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0135] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0136] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0137] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for processing AI format files. It is characterized in that The method is applied to a browser, and the method comprises: Obtain an AI format file to be presented, load the AI format file into the browser memory, and convert the AI format file into code text using the FileReader.readAsString function in the browser; Extracting information content from the code text according to AI format specifications and information identifiers; Convert the information content into a Document Object Model (DOM) node described in a Hypertext Markup Language (HTML) + Cascading Style Sheet (CSS) format; Render the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file, The extracting of information content from the code text according to the AI format specification and the information identifier includes: Extracting the drawing board information, font information, media information and element information in the code text according to the AI format specification and information identifier; Extracting text elements, vector elements and picture elements from the element information layer by layer according to element identifiers in the element information; Wherein, when the element identifier indicates that the element information is a text element, extracting the text element from the element information includes: Extracting a text identifier indicated in the text element; Acquire a text attribute corresponding to the text identifier in the font information, and associate the text attribute with the text element; and When the element identifier indicates that the element information is a picture element, extracting the picture element from the element information includes: Extracting the picture identifier indicated in the picture element; Pixel data corresponding to the picture identifier is obtained in the media information, and the pixel data is associated with the picture element.
2. The method for processing AI format files according to claim 1, It is characterized in that When the element information is the text element or the vector element, converting the information content into a DOM node described in HTML+CSS format includes: The element type corresponding to the element information is converted into the node type of the DOM node described in HTML, and the information attributes in the element information are converted into description content in CSS format.
3. The method for processing AI format files according to claim 1, It is characterized in that When the element information is a picture element, converting the information content into a DOM node described in HTML+CSS format includes: Using the CanvasRenderingContext2D.putImageData function of the browser to draw the pixel data in the image element on the HTMLCanvasElement canvas of the browser, and calling the HTMLCanvasElemen.toDataURL function of the browser to obtain the uniform resource locator URL of the image element; The URL is converted into the node type of the DOM node described in HTML, and the image attributes in the image element are converted into description content in CSS format.
4. The method for processing AI format files according to claim 1, It is characterized in that The rendering of the DOM node on the page of the browser to obtain the presentation content corresponding to the AI format file includes: The HTMLElement.appenChild function of the browser is called to render the DOM node to the page of the browser to obtain the presentation content corresponding to the AI format file.
5. A device for processing AI format files, It is characterized in that The device is applied to a browser, and comprises: An acquisition module, used to acquire the AI format file to be presented; A text conversion module, used for loading the AI format file into the browser memory, and converting the AI format file into code text using the FileReader.readAsString function in the browser; A content extraction module, used to extract information content in the code text according to AI format specifications and information identifiers; A node conversion module, used for converting the information content into a document object model DOM node described in a hypertext markup language HTML+cascading style sheet CSS format; A rendering module is used to render the DOM node on the page of the browser to obtain the rendering content corresponding to the AI format file, Wherein, the content extraction module is also used for: Extracting the drawing board information, font information, media information and element information in the code text according to the AI format specification and information identifier; Extracting text elements, vector elements and picture elements from the element information layer by layer according to element identifiers in the element information; Wherein, when the element identifier indicates that the element information is a text element, the content extraction module is further used to: Extracting a text identifier indicated in the text element; Acquire a text attribute corresponding to the text identifier in the font information, and associate the text attribute with the text element; and When the element identifier indicates that the element information is a picture element, the content extraction module is further used to: Extracting the picture identifier indicated in the picture element; Pixel data corresponding to the picture identifier is obtained in the media information, and the pixel data is associated with the picture element.
6. A machine-readable storage medium, It is characterized in that The machine-readable storage medium stores instructions, which are used to enable a machine to execute the AI format file processing method described in any one of claims 1-4.
Citation Information
Patent Citations
Icon library display method and device
CN113918861A
