Image watermark generation method and device, image forming equipment and storage medium
By adjusting the text angle and/or font size of the watermark text, the problem of incomplete display of the watermark text entered by the user exceeding the page boundary, achieving complete display of the watermark text and improving the user experience.
Patent Information
- Application Number
- CN202311262822.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2025-03-28
AI Technical Summary
In an image forming scene, the watermark text entered by the user may exceed the page boundary, resulting in incomplete display of the watermark and affecting the user experience.
Make sure that the watermark text can be fully displayed on the page by adjusting the text angle and/or font size of the watermark text. Specific methods include adjusting the text angle and font size based on priority until the watermark text is within the page boundary.
It realizes the complete display of watermark text, improves the user experience, and solves the problem of incomplete display of watermarks.
Smart Images

Figure CN119722425A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image generation technology, and in particular to an image watermark generation method and device, an image forming device and a storage medium. Background Art
[0002] In some image forming (such as printing or copying) scenarios, users may need to generate a watermark on the background of a page.
[0003] In some watermarking scenarios, the watermark added by the user may not be displayed completely, affecting the user experience. Summary of the invention
[0004] The embodiments of the present application provide an image watermark generation method and apparatus, an image forming device and a storage medium. The method can determine whether the watermark text input by the user exceeds the page boundary. If it exceeds the page boundary, the watermark text can be fully displayed on the page by adjusting the text angle and / or font size of the watermark text, thereby improving the user experience.
[0005] In a first aspect, an embodiment of the present application provides an image watermark generation method, comprising obtaining watermark text to be added to a file page; generating a first watermark image based on the watermark text and watermark preset parameters, wherein the watermark preset parameters include at least a preset text angle and a preset font size; when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the file page, adjusting the text angle and / or font size of the watermark text, wherein the boundary of the file page is determined based on the file page width and the file page height of the file page; when the adjusted watermark text is within the boundary of the file page, generating a second watermark image.
[0006] In one possible implementation, the watermark preset parameters also include the address of the watermark text font source file; generating the first watermark image based on the watermark text to be added and the preset parameters includes: generating a corresponding font source file based on the watermark text to be added and the address of the watermark text font source file, and generating the first watermark image according to the font source file and the text angle and font size.
[0007] In one possible implementation, when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text based on priority; wherein, adjusting only the text angle is the first priority, adjusting only the font size is the second priority, and adjusting both the text angle and the font size is the third priority, and the priority order is the first priority higher than the second priority higher than the third priority.
[0008] In one possible implementation, when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text based on the priority includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle of the watermark text based on the first priority so that the adjusted watermark text is within the boundary of the document page.
[0009] In one possible implementation, adjusting the text angle of the watermark text based on the first priority so that the adjusted watermark text is within the boundary of the file page includes: calculating the page bevel angle based on the file page width and the file page height; increasing the preset text angle toward the page bevel angle so that the adjusted watermark text is within the boundary of the file page; or adjusting the preset text angle to the page bevel angle for increasing adjustment; wherein the preset text angle is smaller than the page bevel angle.
[0010] In one possible implementation, when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, if adjusting the text angle of the watermark text fails, then based on the second priority, reducing the font size of the watermark text within a preset font size range so that the adjusted watermark text is within the boundary of the document page.
[0011] In one possible implementation, when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, if the adjustments by the first priority and the second priority fail, then performing the following steps based on the third priority: calculating the page bevel angle based on the document page width and the document page height; adjusting the preset text angle to increase the page bevel angle; reducing the font size of the watermark text within the preset font size range so that the adjusted watermark text is within the boundary of the document page.
[0012] In one possible implementation, after adjusting the text angle and / or font size of the watermark text based on the priority, it also includes: confirming whether the adjusted watermark text is within the boundary of the document page, and if not, executing the following steps: calculating the page bevel length based on the document page width and the document page height; calculating the watermark image bevel length based on the image width and the image height of the first watermark image; calculating the bevel length ratio by dividing the smaller of the page bevel length and the watermark image bevel length by the other; and proportionally reducing the first watermark image based on the bevel length ratio to obtain a third watermark image.
[0013] In a second aspect, an embodiment of the present application further provides an image watermark generating device, comprising: a text acquisition module, used to acquire watermark text to be added to a file page; an image output module, used to generate a first watermark image based on the watermark text and watermark preset parameters, wherein the watermark preset parameters at least include a preset text angle and a preset font size; a text adjustment module, when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the file page, adjusts the text angle and / or font size of the watermark text, wherein the boundary of the file page is determined based on the file page width and the file page height of the file page; the image output module is also used to generate a second watermark image when the adjusted watermark text is within the boundary of the file page.
[0014] In a third aspect, an embodiment of the present application further provides an image watermark generation device, comprising a processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the image watermark generation method provided in the first aspect is implemented.
[0015] In a fourth aspect, the present application also provides an electronic device, including the image watermark generation device provided in the third aspect. In some implementations, the electronic device may be an image forming device or a terminal device connected to the image forming device, such as a PC, a mobile phone, or a tablet computer.
[0016] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the image watermark generation method provided in the first aspect is implemented.
[0017] In a sixth aspect, an embodiment of the present application further provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the image watermark generation method provided in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 Schematic diagram of incomplete display of watermark provided for this application;
[0020] Figure 2 A schematic diagram of a flow chart of an image watermark generation method provided by an embodiment of the present application;
[0021] Figure 3 A schematic diagram of watermark preset parameters provided by an embodiment of the present application;
[0022] Figure 4 A schematic diagram of watermark image reduction processing provided by an embodiment of the present application;
[0023] Figure 5 A schematic diagram of the structure of an image watermark generation device provided in one embodiment of the present application;
[0024] Figure 6 A schematic diagram of the structure of an image watermark generation device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] When an image forming device (such as a printer) uses the printing and copying functions, it often generates a need to generate a watermark in the background of a document page, and the user enters the corresponding text as the watermark content. Among them, when a watermark image is generated based on the text entered by the user, a corresponding watermark image is generated according to the watermark preset parameters. Exemplarily, the watermark preset parameters may include the text angle and the font size. That is, the watermark image can be generated by the initial text angle and the initial font size. However, the number of texts entered by each user is different. When the user enters too much text, the watermark may not be fully displayed.
[0027] Figure 1 Schematic diagram of the incomplete display of the watermark provided for this application.
[0028] Reference Figure 1 As shown, the user needs to add a watermark to the background of the file page 10 and enters the corresponding watermark text content "Confidential document of this company, do not distribute without permission". After the user completes the input, the corresponding watermark image can be generated based on the text entered by the user and the watermark preset parameters, and then the watermark 101 is set in the background of the file page 10. However, the watermark 101 generated based on the number of words entered by the user and the watermark preset parameters cannot be fully displayed.
[0029] In order to overcome the above technical problems, an embodiment of the present application provides an image watermark generation method. Through this method, when the user inputs too much text and the watermark cannot be fully displayed, the watermark text can be adjusted accordingly, so that the watermark text can be fully displayed in the background of the file page, thereby improving the user experience.
[0030] The image watermark generation method provided in the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0031] Figure 2 A flowchart of an image watermark generation method provided in one embodiment of the present application.
[0032] Reference Figure 2 As shown, the method may include the following steps:
[0033] S201: Obtain the watermark text to be added to the file page.
[0034] S202: Generate a first watermark image based on the watermark text and watermark preset parameters.
[0035] S203: When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjust the text angle and / or font size of the watermark text.
[0036] S204: When the adjusted watermark text is within the boundary of the document page, a second watermark image is generated.
[0037] About S201
[0038] In some embodiments, the watermark text to be added to the file page can be a pre-set watermark text, that is, a historical watermark. For example, the user can pre-enter the corresponding text as the watermark text and set it as a common watermark. When the user adds a watermark to the file page, the common watermark can be automatically added.
[0039] In other embodiments, the watermark text to be added to the file page may also be the watermark text currently input by the user. For example, when adding a watermark to the file page, the user can select Add a watermark and input the watermark text that the user wants to add, and the text input by the user is obtained as the watermark text to be added to the file page. The embodiment of the present application does not limit the method of obtaining the watermark text.
[0040] About S202
[0041] After acquiring the watermark text to be added to the file page, a first watermark image can be generated based on the watermark text and watermark preset parameters. In some embodiments, the watermark preset parameters include at least a preset text angle and a preset font size. Figure 3 A schematic diagram of watermark preset parameters provided by an embodiment of the present application. Figure 3 As shown, for example, the preset text angle may be 45°, and the preset font size may be font size 1. Then, a first text printing image with a text angle of 45° and a font size of font size 1 may be generated.
[0042] In other embodiments, the watermark preset parameters may also include one or more of the watermark color, font color component value, and image type. The watermark color may be color or black and white. When the watermark color is color, the font color component value is the font red color component value, the green color component value, and the blue color component value. When the watermark color is black and white, the font color component value is the gray color component value. The image type may include PNG format and RAW format. In other embodiments, the image format may also include other formats, and this application does not limit the image format.
[0043] Reference Figure 3 As shown, the watermark preset parameters include, for example, a preset text angle of 45°, a font size of 1, a watermark color of color, font color component values of R:X1, G:X2, and B:X3, and a picture format of PNG. Then, based on the acquired watermark text to be added to the file page and Figure 3The watermark preset parameters provided in the illustrated embodiment generate a corresponding first watermark image.
[0044] In some application scenarios, some watermarks may involve copyright restrictions after being generated, which may lead to some unnecessary disputes. To overcome the above font copyright issues, the image watermark generation method provided in the embodiment of the present application can use an open source library to extract character atlas information to solve the above problem.
[0045] In some embodiments, the watermark preset parameters may also include the address of the watermark text font source file. Thus, the Free_type font function library may be directly called through the address of the watermark text font source file to read the font file. By calling the font file in the open source database, the above-mentioned copyright restriction problem is overcome, and the font diversity of the watermark text is improved, thereby improving the user experience.
[0046] In some embodiments, a watermark text generation tool (watermark-generator) can be used to start and parse the command line, automatically select a mode according to the input value, use the cairo_image_surface_create_for_data function to create an input source canvas (Surface); use the cairo_create function to create an input source cr. The source canvas is a data structure that carries text display; the input source is a source data structure that carries all the content to be input.
[0047] About S203
[0048] After generating the first watermark image, it can be further determined whether the watermark text in the first watermark image exceeds the boundary of the document page. If it exceeds the boundary, the text angle and / or font size of the watermark text is adjusted so that the adjusted watermark text is within the boundary of the document page, so that the watermark text input by the user can be completely displayed in the background of the document page.
[0049] In some embodiments, the boundary of the document page can be determined based on the document page width and the document page height of the document page. Similarly, after generating the first watermark image, the watermark image width and the watermark image height of the first watermark image can be determined. Then, the watermark image width can be compared with the document page width, and the watermark image height can be compared with the document page height. Figure 1 As shown, when the watermark image width is greater than the document page width or the watermark image height is greater than the document page height, it is determined that the watermark text in the first watermark image exceeds the boundary of the document page, and then the text angle and / or font size of the watermark text is adjusted.
[0050] In some embodiments, the text angle and / or font size of the watermark text can be adjusted based on the priority, wherein only adjusting the text angle is the first priority, only adjusting the font size is the second priority, and adjusting the text angle and font size is the third priority, and the priority order is that the first priority is higher than the second priority and higher than the third priority.
[0051] In one implementation, the text angle can be adjusted based on the first priority. In some embodiments, the text angle is preset to 45°, and the text angle rotation direction can be determined based on the aspect ratio of the file page, wherein when the aspect ratio of the file page is less than 1, the bevel angle of the file page is greater than 45°, and the watermark text can be rotated counterclockwise, so that the text angle of the watermark text is adjusted to increase the bevel angle of the page.
[0052] In some embodiments, when the text angle is adjusted, the text angle adjustment is stopped when the adjusted watermark text is completely within the document page boundary. For example, the bevel angle of the page is 60°, and the text angle of the watermark text is adjusted from 45°. When it is adjusted to 54°, the adjusted watermark text is completely within the document page boundary, and the text angle adjustment is stopped, so that the adjusted text angle is 54°.
[0053] In some embodiments, when the text angle is increased, the text angle of the watermark text can be directly adjusted to the same angle as the bevel angle of the page. For example, if the bevel angle of the page is 60°, the text angle of the watermark text will be adjusted from 45° to 60°. Thus, the adjusted text angle is 60°.
[0054] In one embodiment, if the adjustment of the text angle of the watermark text fails (i.e., when the adjusted text angle is the same as the angle of the hypotenuse of the page, part of the watermark text is still outside the document page boundary), the font size of the watermark text can be adjusted based on the second priority. In some embodiments, the font size of the watermark text can be reduced within the preset font size range so that the adjusted watermark text is within the boundary of the document page. Exemplarily, the smallest font in the preset font size range is size 5, and the adjusted font size should not be less than size 5. In other embodiments, the smallest font in the preset font size range can be other values, and this application does not limit this.
[0055] In one embodiment, if the adjustment by the first priority and the second priority fails (i.e., after adjusting only the text angle or only the font size, part of the watermark text is still outside the document page boundary), adjustment can be performed based on the adjustment method corresponding to the third priority.
[0056] In some embodiments, the adjustment method corresponding to the third priority may include the following steps:
[0057] S1: Calculate the page bevel angle based on the file page width and the file page height.
[0058] S2: Adjust the preset text angle to the angle of the bevel of the page and increase it.
[0059] S3: reducing the font size of the watermark text within a preset font size range so that the adjusted watermark text is within the boundary of the document page.
[0060] The implementation methods corresponding to the above S1 to S3 may be a combination of the adjustment methods corresponding to the first priority and the second priority, and the specific implementation method will not be repeated here.
[0061] About S204
[0062] When the adjusted watermark text is within the boundary of the document page, a second watermark image is generated, so that the watermark text in the second watermark image can be completely displayed in the background of the document page.
[0063] In some embodiments, after the adjustment is completed based on any of the above priority corresponding adjustment methods, it can be confirmed again whether the adjusted watermark text is within the boundary of the file page, and the adjustment can be performed through the following steps:
[0064] S11: Calculating the length of the page bevel based on the document page width and the document page height.
[0065] S12: Calculate the hypotenuse length of the watermark image based on the image width and image height of the first watermark image.
[0066] S13: Calculate the hypotenuse length ratio by taking the smaller one of the hypotenuse length of the page and the hypotenuse length of the watermark image as the quotient of the other.
[0067] S14: Proportionally reduce the first watermark image based on the ratio of the lengths of the hypotenuses to obtain a third watermark image.
[0068] Figure 4 A schematic diagram of watermark image reduction processing provided for one embodiment of the present application.
[0069] Reference Figure 4 As shown, the page height of the document page 10 is H1, and the page width is W1, so the page hypotenuse length L1 can be calculated based on the page height H1 and the page width W1.
[0070] The image height of the first watermark image 20 is h2, and the image width is w2. Then, the hypotenuse length L2 of the watermark image can be calculated based on the image height h2 and the image width w2.
[0071] Determine the smaller of the length of the page hypotenuse L1 and the length of the watermark image hypotenuse L2. For example, the length of the watermark image hypotenuse L2 is the smaller one, and the ratio of L2 to L1 is calculated to be 0.7. Then the first watermark image can be reduced to 0.7 times of the original size, thereby obtaining a third watermark image. The watermark text in the third watermark image is within the document page boundary.
[0072] Figure 5 A schematic diagram of the structure of an image watermark generation device provided in one embodiment of the present application.
[0073] Reference Figure 5 As shown, the device may include a text acquisition module 501, which is used to acquire watermark text to be added to a file page, an image output module 502, which is used to generate a first watermark image based on the watermark text and watermark preset parameters, wherein the watermark preset parameters at least include a preset text angle and a preset font size, and a text adjustment module 503, which adjusts the text angle and / or font size of the watermark text when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the file page, wherein the boundary of the file page is determined based on the file page width and the file page height of the file page; the image output module is also used to generate a second watermark image when the adjusted watermark text is within the boundary of the file page.
[0074] In some embodiments, the watermark preset parameters of the watermark image generated by the image output module 502 also include the watermark text font source file address, wherein generating a first watermark image based on the watermark text to be added and the preset parameters includes: generating a corresponding font source file based on the watermark text to be added and the watermark text font source file address, and generating the first watermark image according to the font source file, the text angle and the font size.
[0075] In some embodiments, when the text adjustment module 503 confirms that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text based on the priority; wherein, adjusting only the text angle is the first priority, adjusting only the font size is the second priority, and adjusting both the text angle and the font size is the third priority, and the priority order is the first priority higher than the second priority higher than the third priority.
[0076] In some embodiments, when the text adjustment module 503 confirms that the watermark text in the first watermark image exceeds the boundary of the document page, the text angle and / or font size of the watermark text is adjusted based on the priority, including: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, the text angle of the watermark text is adjusted based on the first priority so that the adjusted watermark text is within the boundary of the document page.
[0077] In some embodiments, the text adjustment module 503 adjusts the text angle of the watermark text based on the first priority so that the adjusted watermark text is within the boundary of the file page, including: calculating the page bevel angle based on the file page width and the file page height; increasing the preset text angle toward the page bevel angle so that the adjusted watermark text is within the boundary of the file page; or adjusting the preset text angle to the page bevel angle for increasing adjustment; wherein the preset text angle is smaller than the page bevel angle.
[0078] In some embodiments, when the text adjustment module 503 confirms that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, if adjusting the text angle of the watermark text fails, then based on the second priority, reducing the font size of the watermark text within a preset font size range so that the adjusted watermark text is within the boundary of the document page.
[0079] In some embodiments, when the text adjustment module 503 confirms that the watermark text in the first watermark image exceeds the boundary of the file page, adjusting the text angle and / or font size of the watermark text includes: when it is confirmed that the watermark text in the first watermark image exceeds the boundary of the file page, if the adjustments through the first priority and the second priority fail, then based on the third priority, perform the following steps: calculate the page bevel angle based on the file page width and the file page height; adjust the preset text angle to increase the page bevel angle; reduce the font size of the watermark text within the preset font size range, so that the adjusted watermark text is within the boundary of the file page.
[0080] In some embodiments, after the text adjustment module 503 adjusts the text angle and / or font size of the watermark text based on the priority, it also includes: confirming whether the adjusted watermark text is within the boundary of the file page, if not, executing the following steps: calculating the page bevel length based on the file page width and the file page height; calculating the watermark image bevel length based on the image width and the image height of the first watermark image; calculating the bevel length ratio by dividing the smaller of the page bevel length and the watermark image bevel length by the other; after proportionally reducing the first watermark image based on the bevel length ratio, the image output module 502 outputs the third watermark image.
[0081] Figure 6 A schematic diagram of the structure of an image watermark generation device provided in one embodiment of the present application.
[0082] Reference Figure 6 As shown, the device may include a processor 601 and a memory 602, where the memory 602 is used to store at least one instruction, and when the instruction is loaded and executed by the processor 601, the image watermark generation method provided in any embodiment of the present application is implemented.
[0083] The present application also provides an electronic device, which may include Figure 6 The image watermark generation device provided by the illustrated embodiment. In some embodiments, the electronic device may be an image forming device or a terminal device such as a PC, a mobile phone or a tablet computer connected to the image forming device.
[0084] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the image watermark generation method provided in any embodiment of the present application is implemented.
[0085] An embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the image watermark generation method provided in any embodiment of the present application.
[0086] It should be noted that the terminals involved in the embodiments of the present application may include but are not limited to personal computers (PCs), personal digital assistants (PDAs), wireless handheld devices, tablet computers, mobile phones, MP3 players, MP4 players, etc.
[0087] It is understandable that the application may be an application program (nativeApp) installed on the terminal, or may be a web page program (webApp) of a browser on the terminal, and this embodiment of the present application does not limit this.
[0088] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0089] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0090] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0091] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0092] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0093] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for generating an image watermark, characterized in that: The method comprises: Get the watermark text to be added to the file page; Generate a first watermark image based on the watermark text and watermark preset parameters, wherein the watermark preset parameters at least include a preset text angle and a preset font size; When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text, wherein the boundary of the document page is determined based on the document page width and the document page height of the document page; When the adjusted watermark text is within the boundary of the document page, a second watermark image is generated.
2. The method according to claim 1, characterized in that The watermark preset parameters also include the source file address of the watermark text font; The generating of the first watermark image based on the watermark text to be added and the preset parameters comprises: A corresponding font source file is generated based on the watermark text to be added and the address of the watermark text font source file, and a first watermark image is generated according to the font source file and the text angle and font size.
3. The method according to claim 1, characterized in that When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text based on the priority; Among them, only adjusting the text angle is the first priority, only adjusting the font size is the second priority, and adjusting the text angle and font size is the third priority. The priority order is that the first priority is higher than the second priority, which is higher than the third priority.
4. The method according to claim 3, characterized in that When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text based on the priority includes: When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, the text angle of the watermark text is adjusted based on the first priority so that the adjusted watermark text is within the boundary of the document page.
5. The method according to claim 4, characterized in that Adjusting the text angle of the watermark text based on the first priority so that the adjusted watermark text is within the boundary of the document page includes: Calculating the page hypotenuse angle based on the file page width and the file page height; The preset text angle is adjusted to increase toward the angle of the bevel of the page, so that the adjusted watermark text is within the boundary of the document page; or The preset text angle is adjusted to the angle of the bevel of the page to increase the angle; Wherein, the preset text angle is smaller than the bevel angle of the page.
6. The method according to claim 3, characterized in that When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, if adjusting the text angle of the watermark text fails, the font size of the watermark text is reduced within a preset font size range based on the second priority level so that the adjusted watermark text is within the boundary of the document page.
7. The method according to claim 3, characterized in that When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, adjusting the text angle and / or font size of the watermark text includes: When it is confirmed that the watermark text in the first watermark image exceeds the boundary of the document page, if the adjustment by the first priority and the second priority fails, the following steps are performed based on the third priority: Calculating the page hypotenuse angle based on the file page width and the file page height; The preset text angle is adjusted to the angle of the bevel of the page to increase the angle; The font size of the watermark text is reduced within a preset font size range so that the adjusted watermark text is within the boundary of the document page.
8. The method according to any one of claims 3 to 7, characterized in that: After adjusting the text angle and / or font size of the watermark text based on the priority, the method further includes: Confirm whether the adjusted watermark text is within the boundary of the document page. If not, perform the following steps: Calculate the length of the hypotenuse of the page based on the document page width and the document page height; Calculate the length of the hypotenuse of the watermark image based on the image width and image height of the first watermark image; Calculate the hypotenuse length ratio by taking the smaller of the hypotenuse length of the page and the hypotenuse length of the watermark image as the quotient of the other; The first watermark image is proportionally reduced based on the hypotenuse length ratio to obtain a third watermark image.
9. An image watermark generation device, characterized in that: The device comprises: A text acquisition module, used to acquire watermark text to be added to a file page; An image output module, used to generate a first watermark image based on the watermark text and watermark preset parameters, wherein the watermark preset parameters at least include a preset text angle and a preset font size a text adjustment module, which adjusts the text angle and / or font size of the watermark text when it is determined that the watermark text in the first watermark image exceeds the boundary of the document page, wherein the boundary of the document page is determined based on the document page width and the document page height of the document page; The image output module is also used to generate a second watermark image when the adjusted watermark text is within the boundary of the document page.
10. An image watermark generation device, characterized in that: The device comprises: A processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the image watermark generation method according to any one of claims 1 to 8 is implemented.
11. An electronic device, characterized in that: The electronic device comprises the image watermark generating device according to claim 10.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image watermark generation method according to any one of claims 1 to 8 is implemented.