Disclosure of Invention
In view of the foregoing, it is necessary to provide a method, a device, an apparatus and a storage medium for generating hidden watermarks of a web page system, so as to solve the problems that the hidden watermark scheme in the prior art can only be applied to image anti-counterfeiting, is not applicable to a web page information system based on characters, and has a narrow application range.
In order to achieve the technical purpose, the invention adopts the following technical scheme:
in a first aspect, the present invention provides a method for generating a hidden watermark in a web page system, including:
generating a first canvas and a second canvas with preset sizes, and writing user information into the second canvas;
modifying the pixel value of the first canvas by taking the second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas;
and fusing the hidden watermark picture to the background of all pages of the webpage information system.
In some possible implementations, generating a first canvas and a second canvas of a preset size, writing user information to the second canvas, includes:
generating a first canvas and a second canvas with preset sizes through a preset webpage script;
setting the background of the first canvas as a preset background color, and setting the background of the second canvas as transparent;
and writing the user information into the second canvas in a preset text color.
In some possible implementations, modifying the pixel value of the first canvas with reference to the second canvas, generating the hidden watermark picture according to the modified first canvas includes:
traversing all pixel points in the second canvas, and judging whether the transparency of the pixel points is zero or not;
when the transparency of the pixel points is zero, processing the pixel points at the corresponding positions in the first canvas according to a first preset rule;
when the transparency of the pixel points is not zero, processing the pixel points at the corresponding positions in the first canvas according to a second preset rule;
and converting the modified first canvas into a hidden watermark picture through a preset method.
In some possible implementations, when the transparency of the pixel point is zero, processing the pixel point at the corresponding position in the first canvas according to a first preset rule includes:
if the sum of the pixel values of the pixel points at the corresponding positions in the first canvas can be divided by the preset integer, the pixel values of the pixel points at the corresponding positions are increased or decreased by the preset value randomly, so that the sum of the pixel values of the pixel points at the corresponding positions can not be divided by the preset integer.
In some possible implementations, when the transparency of the pixel point is not zero, processing the pixel point at the corresponding position in the first canvas according to a second preset rule includes:
if the sum of the pixel values of the pixel points at the corresponding positions in the first canvas cannot be divided by the preset integer, randomly increasing or decreasing the pixel values of the pixel points at the corresponding positions by the preset value, so that the sum of the pixel values of the pixel points at the corresponding positions can be divided by the preset integer.
In some possible implementations, fusing the hidden watermark picture to the background of all pages of the web page information system includes:
deleting the background colors of the root elements of all pages in the webpage information system;
tiling the hidden watermark picture to the background of all pages of the webpage information system;
and deleting the background colors of the sub-elements of all pages of the webpage information system.
In some possible implementations, generating a first canvas and a second canvas of a preset size, writing user information to the second canvas, previously includes:
and verifying the user login information, and collecting the user information after the user logs in the webpage information system.
In a second aspect, the present invention further provides a hidden watermark generating device of a web page system, including:
the generating module is used for generating a first canvas and a second canvas with preset sizes and writing user information into the second canvas;
the modification module is used for modifying the pixel value of the first canvas by taking the second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas;
and the fusion module is used for fusing the hidden watermark pictures to the backgrounds of all pages of the webpage information system.
In a third aspect, the invention also provides an electronic device comprising a memory and a processor, wherein,
a memory for storing a program;
and the processor is coupled with the memory and is used for executing the program stored in the memory to realize the steps in the hidden watermark generation method of the webpage system in any implementation mode.
In a fourth aspect, the present invention further provides a computer readable storage medium, configured to store a computer readable program or instructions, where the program or instructions, when executed by a processor, implement the steps in a hidden watermark generating method of a web page system in any of the above implementations.
The beneficial effects of adopting the embodiment are as follows: the invention relates to a hidden watermark generation method, a device, equipment and a storage medium of a webpage system, wherein the method comprises the following steps: generating a first canvas and a second canvas with preset sizes, and writing user information into the second canvas; modifying the pixel value of the first canvas by taking the second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas; and fusing the hidden watermark picture to the background of all pages of the webpage information system. The hidden watermark generation method, the device, the equipment and the storage medium of the webpage system provided by the invention generate the first canvas and the second canvas, write the user information into the second canvas, determine the hidden watermark pictures through the first canvas and the second canvas, fuse the hidden watermark pictures to the backgrounds of all pages of the webpage information system, finally set hidden watermarks in the backgrounds of the webpage information system, set hidden watermarks for any form of webpage information system, and have wide application range.
Detailed Description
Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form a part hereof, and together with the description serve to explain the principles of the invention, and are not intended to limit the scope of the invention.
In the description of the present application, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the invention. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The invention provides a hidden watermark generation method, device and equipment of a webpage system and a storage medium, and the hidden watermark generation method, device and equipment and the storage medium are respectively described below.
Referring to fig. 1, fig. 1 is a flowchart illustrating an embodiment of a hidden watermark generating method of a web page system according to the present invention, and a specific embodiment of the present invention discloses a hidden watermark generating method of a web page system, including:
s101, generating a first canvas and a second canvas with preset sizes, and writing user information into the second canvas;
s102, modifying pixel values of a first canvas by taking a second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas;
s103, fusing the hidden watermark pictures to the backgrounds of all pages of the webpage information system.
In the above embodiment, the pixel dot size with the preset size of 250×90 is completely the same as the size of the generated first canvas and the second canvas, but the colors are different, after the user information is obtained, the user information is written into the second canvas, that is, the pixel value of the second canvas is changed according to the user information.
Because the user information is on the second canvas, the second canvas is traversed by taking the second canvas as a reference, the pixel values of the pixel points at the corresponding positions in the first canvas are modified according to the pixel values in the second canvas, the modified first canvas has the user information, and then the modified first canvas is converted into the hidden watermark picture.
The background of all pages of the webpage information system is queried, and hidden watermark pictures are fused into the background of the page, and whether the webpage information system is text or pictures are provided with the background, so that the hidden watermark is fused into the background of the page, the watermark can be arranged on any kind of webpage information system, and the problem that the hidden watermark cannot be arranged on the webpage system with the text as a main part in the prior art is solved.
Compared with the prior art, the hidden watermark generation method of the webpage system provided by the embodiment comprises the following steps: generating a first canvas and a second canvas with preset sizes, and writing user information into the second canvas; modifying the pixel value of the first canvas by taking the second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas; and fusing the hidden watermark picture to the background of all pages of the webpage information system. The hidden watermark generation method, the device, the equipment and the storage medium of the webpage system provided by the invention generate the first canvas and the second canvas, write the user information into the second canvas, determine the hidden watermark pictures through the first canvas and the second canvas, fuse the hidden watermark pictures to the backgrounds of all pages of the webpage information system, finally set hidden watermarks in the backgrounds of the webpage information system, set hidden watermarks for any form of webpage information system, and have wide application range.
Referring to fig. 2, fig. 2 is a flowchart of an embodiment of step S101 in fig. 1, in a possible embodiment of the present invention, generating a first canvas and a second canvas with preset dimensions, and writing user information into the second canvas, including:
s201, generating a first canvas and a second canvas with preset sizes through preset webpage scripts;
s202, setting the background of the first canvas as a preset background color, and setting the background of the second canvas as transparent;
s203, writing the user information into the second canvas in a preset text color.
In the above embodiment, the preset web script may be outside the visible area of the browser, and the first canvas and the second canvas of 250×90 are temporarily drawn, and since the color of the web information system is generally white, the preset background color in the present invention is also set to be white, and it can be understood that the preset background color in the present invention may also be other colors, and may be adjusted according to the color of the web information system.
It should be noted that, the preset webpage script is in the prior art, and only the canvas with the preset size is drawn outside the visible area of the browser through the preset webpage script, which is not described in detail in the present invention.
As a preferred embodiment, the preset text color in the scheme is black, and writing the user information into the second canvas can also be realized by calling a browser canvas to write text through a webpage script in the prior art, which is not repeated in the invention. After the user information is written into the second canvas, the color of the text is black, and the background outside the text is kept transparent.
Referring to fig. 3, fig. 3 is a flowchart of an embodiment of step S102 in fig. 1, in a possible embodiment of the present invention, modifying pixel values of a first canvas based on a second canvas, and generating a hidden watermark picture according to the modified first canvas includes:
s301, traversing all pixel points in the second canvas, and judging whether the transparency of the pixel points is zero or not;
s302, when the transparency of the pixel points is zero, processing the pixel points at the corresponding positions in the first canvas according to a first preset rule;
s303, when the transparency of the pixel points is not zero, processing the pixel points at the corresponding positions in the first canvas according to a second preset rule;
s304, converting the modified first canvas into a hidden watermark picture through a preset method.
In the above embodiment, according to the RGB three-primary principle, the pixel color value of each point in any canvas can be decomposed into 4 channel values: r (Red), G (Green), B (Blue), A (Alpha) represent Red, green, blue, transparency, respectively. Wherein the value range of R, G, B is 0-255, and the value range of A is 0-1. That is, the pixel color value of any one pixel point can be represented by an object of (r, g, b, a). For example, the color value of one white pixel may be expressed as (255, 255, 255, 1), the color value of one black pixel may be expressed as (0, 0,0, 1), and the color value of one transparent pixel may be expressed as (0, 0,0, 0). Where V_A (x, y) is used to represent the pixel color value of any point in the first canvas and V_B (x, y) is used to represent the color value of any point in the second canvas, where 0.ltoreq.x <250,0.ltoreq.y <90.
The color of the first canvas is white, the pixel value of the pixel point of the first canvas is (255, 255, 255, 1), the second canvas is a transparent canvas written with user information, the pixel value of the pixel point of the second canvas is the pixel value (0, 0,0, 1) of the black pixel point written with the user information part or the pixel value (0, 0,0, 0) of the transparent pixel point, and each pixel point pixel value in the second canvas is traversed in sequence by taking the second canvas as a reference.
And when traversing the second canvas, firstly determining whether the transparency value of the current pixel point is 0 or 1, and processing the pixel point at the corresponding position in the first canvas in different modes according to different transparency values of the pixel point.
After traversing all pixel points of the second canvas, obtaining a modified first canvas, wherein the color value of each pixel point in the first canvas is represented to contain watermark information if R+G+B can be divided by 3; if R+G+B is not divisible by 3, it indicates that the watermark information is not contained. The content of the first canvas is converted into a hidden watermark picture by using a browser provided method and is stored in an information system foreground page.
It may be appreciated that the preset method is to convert the content of the first canvas into the hidden watermark picture by using a method provided by the browser, which is not further limited by the present invention.
In a possible embodiment of the present invention, when the transparency of the pixel point is zero, processing the pixel point at the corresponding position in the first canvas according to a first preset rule includes:
if the sum of the pixel values of the pixel points at the corresponding positions in the first canvas can be divided by the preset integer, the pixel values of the pixel points at the corresponding positions are increased or decreased by the preset value randomly, so that the sum of the pixel values of the pixel points at the corresponding positions can not be divided by the preset integer.
In the above embodiment, when the transparency of the pixel color value of v_b (x, y) in the second canvas is 0, that is, v_b (x, y) is (0, 0,0, 0), it is described that there is no text watermark information, whether the sum of r+g+b in the pixel value of v_a (x, y) is divisible by a preset integer is determined first, and if divisible by a preset integer, the pixel color value (R, G, B) of v_a (x, y) is randomly increased by a preset value (guaranteed to not exceed 255) or decreased by a preset value (guaranteed to be greater than 0) to ensure that the sum of r+g+b of the corresponding pixel color value v_a (x, y) of the first canvas is not divisible by the preset integer.
As a preferred embodiment, the preset integer is 3 and the preset value is 1 or 2. In this embodiment, the first canvas is white, and its pixel value is (255, 255, 255, 1), and since 255+255+255 can be divided by 3, v_a (j, k) = (255, 254, 255, 1), or v_a (j, k) = (254, 255, 255, 1), or v_a (j, k) = (255, 255, 254, 1) is obtained through the above random operation.
In a possible embodiment of the present invention, when the transparency of the pixel point is not zero, processing the pixel point at the corresponding position in the first canvas according to the second preset rule includes:
if the sum of the pixel values of the pixel points at the corresponding positions in the first canvas cannot be divided by the preset integer, randomly increasing or decreasing the pixel values of the pixel points at the corresponding positions by the preset value, so that the sum of the pixel values of the pixel points at the corresponding positions can be divided by the preset integer.
In the above embodiment, when the transparency in the pixel color value of v_b (x, y) in the second canvas is not 0, i.e., v_b (x, y) is (0, 0,0, 1), then it is explained that text watermark information is contained therein, and the same operation (randomly adding 1 plus 2 minus 1 minus 2) is performed on the corresponding pixel color value of v_a (x, y) to ensure that the sum of r+g+b of the pixel color value v_a (x, y) of the a canvas can be divided by 3. The first canvas in the present invention is white, v_a (x, y) = (255, 255, 255, 1), no operation is necessary because 255+255+255 is already divisible by 3.
Referring to fig. 4, fig. 4 is a flowchart of an embodiment of step S103 in fig. 1, in a possible embodiment of the present invention, fusing hidden watermark pictures to the background of all pages of the web page information system includes:
s401, deleting the background colors of the root elements of all pages in the webpage information system;
s402, tiling the hidden watermark picture to the background of all pages of the webpage information system;
s403, deleting the sub-element background colors of all pages of the webpage information system.
In the above embodiment, after the pixel value of the first canvas is adjusted to obtain the hidden watermark picture, a web script is used to call a browser method to remove the background color of the root elements of all pages of the web information system, and then the background is changed into the generated hidden watermark picture to be tiled repeatedly. And finally deleting the background color of the sub-element in the webpage of the webpage information system to finish the fusion process of the hidden watermark. At this time, the background color is still white (because of the slight difference of the values of RGB, the naked eyes of the human cannot distinguish), but the hidden watermark picture is tiled repeatedly in the real background.
In a possible embodiment of the present invention, generating a first canvas and a second canvas of a preset size, writing user information into the second canvas, includes:
and verifying the user login information, and collecting the user information after the user logs in the webpage information system.
In the above embodiment, after the user logs in the webpage information system by using the mobile phone number, the password and the mobile phone verification code, the webpage information system is checked in the background, the user information (such as the user name) is matched through the mobile phone number of the user, then the user information is transferred to the foreground page of the webpage information system in an interface calling mode, and after the foreground page obtains the user information (such as the user name and the mobile phone number), a first canvas and a second canvas are generated, and the user information is written into the second canvas.
It should be noted that, the user information in the present solution may take different other information capable of identifying the uniqueness of the user according to the need, which is not further limited by the present invention.
In order to better implement the hidden watermark generation method of the web page system in the embodiment of the present invention, referring to fig. 5 correspondingly on the basis of the hidden watermark generation method of the web page system, fig. 5 is a schematic structural diagram of an embodiment of the hidden watermark generation device of the web page system provided by the present invention, and the embodiment of the present invention provides a hidden watermark generation device 500 of the web page system, including:
a generating module 510, configured to generate a first canvas and a second canvas with preset sizes, and write user information into the second canvas;
the modification module 520 is configured to modify a pixel value of the first canvas with the second canvas as a reference, and generate a hidden watermark picture according to the modified first canvas;
and the fusion module 530 is used for fusing the hidden watermark pictures to the backgrounds of all pages of the webpage information system.
What needs to be explained here is: the apparatus 500 provided in the foregoing embodiments may implement the technical solutions described in the foregoing method embodiments, and the specific implementation principles of the foregoing modules or units may be referred to the corresponding content in the foregoing method embodiments, which is not described herein again.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the invention. Based on the hidden watermark generation method of the webpage system, the invention also correspondingly provides hidden watermark generation equipment of the webpage system, and the hidden watermark generation equipment of the webpage system can be computing equipment such as a mobile terminal, a desktop computer, a notebook computer, a palm computer, a server and the like. The hidden watermark generating device of the web page system includes a processor 610, a memory 620, and a display 630. Fig. 6 shows only some of the components of the electronic device, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may alternatively be implemented.
The memory 620 may in some embodiments be an internal storage unit of the hidden watermark generating device of the web page system, such as a hard disk or a memory of the hidden watermark generating device of the web page system. The memory 620 may also be an external storage device of the hidden watermark generating device of the web page system, for example, a plug-in hard disk, smart Media Card (SMC), secure Digital (SD) Card, flash Card (Flash Card) or the like. Further, the memory 620 may also include both an internal storage unit and an external storage device of the hidden watermark generating device of the web page system. The memory 620 is used for storing application software of the hidden watermark generating apparatus installed in the web page system and various data, such as program codes of the hidden watermark generating apparatus installed in the web page system. The memory 620 may also be used to temporarily store data that has been output or is to be output. In an embodiment, the memory 620 stores a hidden watermark generating program 640 of the web page system, where the hidden watermark generating program 640 of the web page system is executable by the processor 610, so as to implement the hidden watermark generating method of the web page system according to embodiments of the present application.
The processor 610 may be a central processing unit (Central Processing Unit, CPU), microprocessor or other data processing chip in some embodiments for executing program code or processing data stored in the memory 620, such as performing the hidden watermark generation method of a web page system, etc.
The display 630 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like in some embodiments. The display 630 is used to display information at the hidden watermark generating device of the web page system and to display a visual user interface. The components 610-630 of the hidden watermark generating device of the netpage system communicate with each other via a system bus.
In one embodiment, the steps in the hidden watermark generation method for a web page system as described above are implemented when the processor 610 executes the hidden watermark generation program 640 for a web page system in the memory 620.
The present embodiment also provides a computer-readable storage medium having stored thereon a hidden watermark generation program of a web page system, which when executed by a processor, implements the steps of:
generating a first canvas and a second canvas with preset sizes, and writing user information into the second canvas;
modifying the pixel value of the first canvas by taking the second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas;
and fusing the hidden watermark picture to the background of all pages of the webpage information system.
In summary, the method, device, equipment and storage medium for generating hidden watermarks in a web page system provided in this embodiment include: generating a first canvas and a second canvas with preset sizes, and writing user information into the second canvas; modifying the pixel value of the first canvas by taking the second canvas as a reference, and generating a hidden watermark picture according to the modified first canvas; and fusing the hidden watermark picture to the background of all pages of the webpage information system. The hidden watermark generation method, the device, the equipment and the storage medium of the webpage system provided by the invention generate the first canvas and the second canvas, write the user information into the second canvas, determine the hidden watermark pictures through the first canvas and the second canvas, fuse the hidden watermark pictures to the backgrounds of all pages of the webpage information system, finally set hidden watermarks in the backgrounds of the webpage information system, set hidden watermarks for any form of webpage information system, and have wide application range.
The present invention is not limited to the above-mentioned embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention.