A method and storage medium for generating PSD files without relying on PS software
By converting data into contents of PSD file format specifications and directly generating PSD files, the problem of installing Adobe Photoshop software in the existing technology is solved, and the cross-platform capability of generating PSD files on various devices and platforms is realized.
Patent Information
- Application Number
- CN202210535442.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2042-05-17
AI Technical Summary
The existing technology requires the installation of Adobe Photoshop software to generate PSD format files, which limits the environment and performance of file generation, and is especially inconvenient to run on low-configured computers.
By representing the content to be written to the PSD file in the form of data, and converting and writing according to the PSD file format specifications, the PSD file is directly generated without relying on PS software.
It realizes the generation of PSD files on electronic terminals such as computers, tablets, mobile phones, etc. that do not have Adobe Photoshop software installed, and is used across devices and across platforms, avoiding software dependencies and performance limitations.
Smart Images

Figure CN114998455B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and more specifically, to a method and storage medium for generating PSD files without relying on PS software. Background Art
[0002] Currently, to generate (or save) an Adobe Photoshop format file, the conventional method is to purchase Adobe Photoshop software (abbreviated as PS software) and install it on a computer, then use Adobe Photoshop to create a new PSD format file, edit (add content), and finally save the file. Therefore, on a computer without the corresponding software installed, it is impossible to generate a PSD format file, which is greatly limited by the usage environment. Moreover, in some computer environments with relatively low performance configurations, even if the corresponding software is installed, it is difficult to run smoothly, causing inconvenience to operations. Summary of the Invention
[0003] The present invention provides a method and storage medium for generating PSD files without relying on PS software, aiming to solve the above problems existing in the prior art.
[0004] The present invention adopts the following technical solutions:
[0005] A method for generating a PSD file without relying on PS software, including the following steps:
[0006] (1) Represent the content to be written into the PSD file in the form of data;
[0007] (2) According to the PSD file format specification, convert the data in step (1) into the layer data corresponding to the PSD file;
[0008] (3) According to the data in step (1), set the file header data and color mode data according to the PSD file format specification;
[0009] (4) Write the file header data, color mode data, and layer data into a file in sequence in binary format to obtain a PSD file.
[0010] Further, if the content to be written into the PSD file in step (1) is text, then in step (2), directly map the data into layer data to form at least one text layer corresponding to the PSD file.
[0011] If the content to be written into the PSD file in step (1) is a picture, then in step (2), the data other than the pixel data is mapped into layer data to form at least one picture layer corresponding to the PSD file, and then the pixel data is stored in the pixel data mapping table, and the ID of the pixel data mapping table is associated with the layer data; in step (4), the file header data, color mode data, layer data, and pixel data mapping table are written into the file in sequence in binary format to obtain a PSD file.
[0012] If the content to be written into the PSD file in step (1) includes text and pictures, then in step (2),
[0013] For the text, the data of the text is directly mapped into layer data to form at least one text layer corresponding to the PSD file;
[0014] For the picture, the data other than the pixel data is mapped into layer data to form at least one picture layer corresponding to the PSD file, and then the pixel data is stored in the pixel data mapping table, and the ID of the pixel data mapping table is associated with the layer data;
[0015] In step (4), the file header data, color mode data, layer data, and pixel data mapping table are written into the file in sequence in binary format to obtain a PSD file.
[0016] Specifically, the data of the text includes font, font color, font size, text content, and distance from the canvas edge.
[0017] Specifically, the data of the picture includes the distance from the left side of the canvas, the distance from the top of the canvas, width, height, and pixel data.
[0018] A computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed, any of the methods for generating a PSD file without relying on Adobe Photoshop software is implemented.
[0019] As can be seen from the above description of the structure of the present invention, the present invention has the following advantages:
[0020] The present invention represents the content to be written into the PSD file in the form of data, and then processes the data through file header data mapping, layer data mapping, pixel data mapping table, ID association, etc., and directly outputs a PSD file, which can generate a PSD file on electronic terminals such as computers, tablets, and mobile phones without installing Adobe Photoshop software, and can run on any operating system or platform (mobile phones, PCs, Pad browsers, etc. are all acceptable), and can better cross devices and platforms. Description of the Drawings
[0021] Figure 1 This is a flowchart of a specific embodiment of the present invention.
[0022] Figure 2 This is a schematic diagram of an embodiment of writing content in the present invention.
[0023] Figure 3 This is a simple schematic diagram of the PSD file format specification. Among them, File Header is the file header data, ColorMode Data is the color mode data, Image Resources is the content including additional information of the PSD file (this part is not the data that needs to be concerned in the present invention), Layer and Mask Information is the layer data, and Image Data is the pixel data mapping table. Specific Embodiments
[0024] The following describes the specific embodiments of the present invention with reference to the accompanying drawings.
[0025] Embodiment 1
[0026] As Figure 1 , Figure 2 and Figure 3 shown, a method for generating a PSD file without relying on PS software includes the following:
[0027] (1) Represent the content to be written into the PSD file in the form of data.
[0028] The above data includes canvas data, and the canvas data includes but is not limited to width, height, color mode, and background color.
[0029] The content to be written into the PSD file is mainly divided into two types: text and graphics. Among them, if the content to be written into the PSD file is text, the data that needs to be provided includes but is not limited to font, font color, font size, text content, and the distance from the canvas edge; if the content to be written into the PSD file is a picture, the data that needs to be provided includes but is not limited to the distance from the canvas edge, width, height, and pixel data, etc.
[0030] The ways to provide the above data include but are not limited to manual editing.
[0031] Taking Figure 2 shown as an example of the content to be written into the PSD file, the specific representation in the form of data is:
[0032] I. Canvas:
[0033] Width: 400px
[0034] Height: 400px
[0035] Color mode: RGB
[0036] Background color: Transparent
[0037] II. Content:
[0038] Layer 1:
[0039] Type: Text layer
[0040] Font: Alibaba-PuhuiTi-Heavy
[0041] Font color: Red
[0042] Font size: 40px
[0043] Text content: I am a cat
[0044] Distance from the left of the canvas: 40px
[0045] Distance from the top of the canvas: 40px
[0046] Layer 2:
[0047] Type: Image layer
[0048] Distance from the left of the canvas: 100px
[0049] Distance from the top of the canvas: 100px
[0050] Width: 200px
[0051] Height: 200px
[0052] Pixel data: [Binary image data].
[0053] Since generating pixel pictures from binary image data belongs to the prior art, it is omitted here Figure 2 The detailed binary image data corresponding to the shown picture.
[0054] (2) According to the PSD file format specification, convert the data in step (1) into the layer data corresponding to the PSD file.
[0055] Specifically, for the data of the text part, directly map the text data into layer data to form a text layer corresponding to the PSD file.
[0056] For the data of the picture part, map the data other than the pixel data into layer data to form an image layer corresponding to the PSD file, then store the pixel data in the pixel data mapping table, and associate the ID of the pixel data mapping table with the layer data.
[0057] (3) According to the canvas data in step (1), set the file header data and color mode data in accordance with the PSD file format specification.
[0058] (4) As Figure 3 shown, write the above file header data, color mode data, layer data, and pixel data mapping table into the file in sequence in binary form to obtain a PSD file.
[0059] Since Figure 2 the content shown in only includes a set of text and a picture, in the first embodiment, it is finally mapped into a text layer and a picture layer. If it includes multiple sets of text or multiple pictures, it may need to be correspondingly mapped into multiple text layers or multiple picture layers.
[0060] Embodiment 2
[0061] A method for generating a PSD file without relying on PS software, including the following:
[0062] (a) Represent the content to be written into the PSD file in the form of data.
[0063] The above data includes canvas data, which includes but is not limited to width, height, color mode, and background color.
[0064] Specifically, if the content written into the PSD file is only text, the data that also needs to be provided includes but is not limited to font, font color, font size, text content, distance from the canvas edge, etc. The distance from the canvas edge is used to determine the position of the text content in the canvas, usually including the distance from the left side of the canvas and the distance from the top of the canvas.
[0065] The way to provide the above data includes but is not limited to manual editing.
[0066] (b) According to the PSD file format specification, convert the data in step (a) into the layer data corresponding to the PSD file.
[0067] Specifically, directly map the data representing text into layer data to form at least one text layer corresponding to the PSD file.
[0068] (c) According to the canvas data in step (a), set the file header data and color mode data in accordance with the PSD file format specification.
[0069] (d) Write the above file header data, color mode data, and layer data into the file in sequence in binary form to obtain a PSD file.
[0070] Embodiment 3
[0071] A method for generating a PSD file without relying on Photoshop software, including the following:
[0072] (1) Represent the picture to be written into the PSD file in the form of data.
[0073] The above data also includes canvas data, which includes but is not limited to width, height, color mode, and background color.
[0074] If the content written into the PSD file is only a picture, the data that also needs to be provided includes but is not limited to font, font color, font size, text content, distance from the canvas edge, etc. The distance from the canvas edge is used to determine the position of the picture content in the canvas, usually including the distance from the left side of the canvas and the distance from the top of the canvas.
[0075] The way to provide the above data includes but is not limited to manual editing.
[0076] (2) According to the PSD file format specification, convert the data in step (1) into the layer data corresponding to the PSD file.
[0077] Specifically, map the data other than pixel data into layer data to form at least one picture layer corresponding to the PSD file, then store the pixel data in a pixel data mapping table, and associate the ID of the pixel data mapping table with the layer data.
[0078] (3) According to the canvas data in step (1), set the file header data and color mode data according to the PSD file format specification.
[0079] (4) Write the above file header data, color mode data, layer data, and pixel data mapping table in order in binary format into a file to obtain a PSD file.
[0080] The present utility model also discloses a computer-readable storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed, the method for generating a PSD file without relying on Photoshop software as described above is implemented.
[0081] The above is only the specific implementation manner of the present invention, but the design concept of the present invention is not limited thereto. Any non-substantive modification made to the present invention using this concept shall fall within the scope of infringement of the protection scope of the present invention.
Claims
1. A method for generating PSD files without relying on PS software, characterized in that, The following are included: (1) Represent the content to be written into the PSD file in the form of data; (2) According to the PSD file format specification, convert the data in step (1) into the layer data corresponding to the PSD file. Specifically: If the content to be written into the PSD file in step (1) is text, then in step (2), directly map the data into layer data to form at least one text layer corresponding to the PSD file; If the content to be written into the PSD file in step (1) is a picture, then in step (2), map the data other than pixel data into layer data to form at least one picture layer corresponding to the PSD file, then store the pixel data into the pixel data mapping table, and associate the ID of this pixel data mapping table with the layer data; (3) According to the data in step (1), set the file header data and color mode data according to the PSD file format specification; (4) If the content written into the PSD file does not include a picture, write the file header data, color mode data, and layer data in sequence in binary format into the file to obtain a PSD file; if the content written into the PSD file includes a picture, write the file header data, color mode data, layer data, and pixel data mapping table in sequence in binary format into the file to obtain a PSD file.
2. The method for generating PSD files without relying on PS software according to claim 1, characterized in that: If the content to be written into the PSD file in step (1) includes text and pictures, then in step (2), For text, directly map the text data into layer data to form at least one text layer corresponding to the PSD file; For pictures, map the data other than pixel data into layer data to form at least one picture layer corresponding to the PSD file, then store the pixel data into the pixel data mapping table, and associate the ID of this pixel data mapping table with the layer data; In step (4), write the file header data, color mode data, layer data, and pixel data mapping table in sequence in binary format into the file to obtain a PSD file.
3. The method for generating PSD files without relying on PS software according to claim 1 or 2, characterized in that: The data of the text includes font, font color, font size, text content, and the distance from the canvas edge.
4. The method for generating PSD files without relying on PS software according to claim 1 or 2, characterized in that: The data of the picture includes the distance from the left side of the canvas, the distance from the top of the canvas, width, height, and pixel data.
5. A storage medium storing computer-readable instructions therein, characterized in that: When the computer-readable instruction is executed, it implements the method for generating a PSD file without relying on PS software according to any one of claims 1 - 4.
Citation Information
Patent Citations
Automatic establishing method of GUI interface and system
CN107977205A
Effect picture processing method and device thereof, electronic equipment and readable storage medium
CN111659121A