CN111914226A - Background picture generation method and device - Google Patents
Background picture generation method and device Download PDFInfo
- Publication number
- CN111914226A CN111914226A CN202010784957.5A CN202010784957A CN111914226A CN 111914226 A CN111914226 A CN 111914226A CN 202010784957 A CN202010784957 A CN 202010784957A CN 111914226 A CN111914226 A CN 111914226A
- Authority
- CN
- China
- Prior art keywords
- target element
- watermark information
- picture
- generating
- background picture
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/10—Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
- G06F21/16—Program or content traceability, e.g. by watermarking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/0021—Image watermarking
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Technology Law (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- General Engineering & Computer Science (AREA)
- Editing Of Facsimile Originals (AREA)
- Image Processing (AREA)
Abstract
Description
技术领域technical field
本发明涉及图像处理技术领域,具体而言,涉及一种背景图片的生成方法和装置。The present invention relates to the technical field of image processing, and in particular, to a method and device for generating a background picture.
背景技术Background technique
目前网页中很多页面为了防止非法截图,会在网页中添加水印信息来标识该截图来源,以便泄漏出去后进行追溯。其中,常见的水印生成方法一般是在前端将水印信息传给服务器端,在服务器端将水印信息嵌入到图片中再返回给前端,前端使用该图片作为背景来展示水印;或者是在前端利用JavaScript将水印信息作为文本放到一个元素中,然后利用CSS将该元素层级放到真正的内容之下以达到水印效果。At present, in order to prevent illegal screenshots, many pages in the webpage will add watermark information to the webpage to identify the source of the screenshot, so that the leak can be traced back. Among them, the common watermark generation method is generally to transmit the watermark information to the server at the front end, embed the watermark information into the picture on the server side and return it to the front end, and the front end uses the picture as the background to display the watermark; or use JavaScript in the front end Put the watermark information as text in an element, and then use CSS to place the element hierarchy below the actual content to achieve the watermark effect.
然而,目前通过服务器端生成水印的方法需要先将信息传递给服务器端,然后再等待其返回数据,需要依赖于后端才能生成,在网络条件不好时,信息往返的交互时间会比较长。而前端利用JavaScript生成水印的方法,由于水印信息存在于元素中,会影响对正常内容的复制;如果内容区域较大,水印需要重复展示时不能自动重复,需要根据水印大小和内容大小手动处理。However, the current method of generating watermarks on the server side needs to transmit the information to the server side first, and then wait for the data to be returned. It needs to rely on the backend to generate watermarks. When the network conditions are not good, the interaction time of the information round trip will be relatively long. The front-end method of generating watermarks using JavaScript, because the watermark information exists in the element, will affect the copying of normal content; if the content area is large, the watermark cannot be automatically repeated when it needs to be displayed repeatedly, and it needs to be manually processed according to the watermark size and content size.
针对上述相关技术中生成水印需要依赖服务器端或者浏览器端生成水印方法不够完善的问题,目前尚未提出有效的解决方案。Aiming at the problem that the watermark generation method in the above-mentioned related art needs to rely on the server side or the browser side to generate the watermark, the method is not perfect, and an effective solution has not yet been proposed.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供了一种背景图片的生成方法和装置,以至少解决相关技术中生成水印需要依赖服务器端或者浏览器端生成水印方法不够完善的技术问题。Embodiments of the present invention provide a method and device for generating a background picture, so as to at least solve the technical problem in the related art that the watermark generation method needs to rely on the server side or the browser side to generate the watermark.
根据本发明实施例的一个方面,提供了一种背景图片的生成方法,包括:获取浏览器页面的目标元素;将水印信息写入所述目标元素;依据包含所述水印信息的目标元素,生成所述浏览器页面的背景图片。According to an aspect of the embodiments of the present invention, there is provided a method for generating a background image, comprising: acquiring a target element of a browser page; writing watermark information into the target element; generating a method according to the target element containing the watermark information The background image of the browser page.
可选地,在获取浏览器页面的目标元素之前,所述方法还包括:在所述浏览器页面插入所述目标元素;设置所述目标元素的显示参数,其中,所述显示参数包括以下至少之一:宽度、高度。Optionally, before acquiring the target element of the browser page, the method further includes: inserting the target element in the browser page; setting display parameters of the target element, wherein the display parameters include at least the following One: width, height.
可选地,在设置所述目标元素的显示参数之后,所述方法还包括:将所述目标元素的样式设置为隐藏状态。Optionally, after setting the display parameters of the target element, the method further includes: setting the style of the target element to a hidden state.
可选地,在将水印信息写入所述目标元素之前,所述方法还包括:设置所述水印信息的样式,其中,所述样式包括以下至少之一:字体、字号、颜色、旋转、背景图片。Optionally, before writing the watermark information into the target element, the method further includes: setting a style of the watermark information, wherein the style includes at least one of the following: font, font size, color, rotation, background picture.
可选地,将水印信息写入所述目标元素包括:获取所述目标元素的调用对象;基于所述调用对象,将所述水印信息写入所述目标元素。Optionally, writing the watermark information into the target element includes: obtaining a call object of the target element; and writing the watermark information into the target element based on the call object.
可选地,依据包含所述水印信息的目标元素,生成所述浏览器页面的背景图片包括:确定所述浏览器页面中的目标区域;获取预定编码方式的包含所述水印信息的目标元素的图片;将所述图片作为所述目标区域的背景图片,其中,所述背景图片用于展示所述水印信息。Optionally, generating the background picture of the browser page according to the target element containing the watermark information includes: determining a target area in the browser page; picture; using the picture as a background picture of the target area, wherein the background picture is used to display the watermark information.
可选地,将所述图片作为所述目标区域的背景图片包括:获取所述图片的第一显示参数以及所述目标区域的第二显示参数;在所述第一显示参数等于所述第二显示参数的情况下,直接将所述图片作为所述目标区域的背景图片;在所述第一显示参数小于或者大于所述第二显示参数的情况下,调整所述第一显示参数,并将调整后的所述第一显示参数的图片作为所述目标区域的背景图片。Optionally, using the picture as the background picture of the target area includes: acquiring a first display parameter of the picture and a second display parameter of the target area; when the first display parameter is equal to the second display parameter In the case of display parameters, the picture is directly used as the background picture of the target area; when the first display parameter is smaller or larger than the second display parameter, the first display parameter is adjusted, and the The adjusted picture of the first display parameter is used as the background picture of the target area.
可选地,在获取所述图片的第一显示参数以及所述目标区域的第二显示参数之后,所述方法还包括:在所述第二显示参数包括N倍数量的所述第一显示参数的情况下,将N倍数量的所述图片作为所述目标区域的背景图片,其中,N为大于等于1的整数。Optionally, after acquiring the first display parameter of the picture and the second display parameter of the target area, the method further includes: when the second display parameter includes N times the number of the first display parameter In the case of , use N times the number of the pictures as the background pictures of the target area, where N is an integer greater than or equal to 1.
根据本发明实施例的另一方面,还提供了一种背景图片的生成装置,包括:获取模块,用于获取浏览器页面的目标元素;写入模块,用于将水印信息写入所述目标元素;生成模块,用于依据包含所述水印信息的目标元素,生成所述浏览器页面的背景图片。According to another aspect of the embodiments of the present invention, an apparatus for generating a background picture is also provided, including: an acquisition module, used for acquiring a target element of a browser page; a writing module, used for writing watermark information into the target element; the generating module is configured to generate the background picture of the browser page according to the target element containing the watermark information.
根据本发明实施例的另一方面,还提供了一种计算机可读存储介质,所述计算机可读存储介质包括存储的程序,其中,在所述程序运行时控制所述计算机可读存储介质所在设备执行上述中任意一项所述的背景图片的生成方法。According to another aspect of the embodiments of the present invention, a computer-readable storage medium is further provided, the computer-readable storage medium includes a stored program, wherein when the program is executed, the computer-readable storage medium is controlled The device executes the method for generating a background picture described in any one of the above.
根据本发明实施例的另一方面,还提供了一种处理器,所述处理器用于运行程序,其中,所述程序运行时执行上述中任意一项所述的背景图片的生成方法。According to another aspect of the embodiments of the present invention, a processor is further provided, and the processor is configured to run a program, wherein when the program runs, any one of the above-mentioned methods for generating a background picture is executed.
在本发明实施例中,采用获取浏览器页面的目标元素;将水印信息写入所述目标元素;依据包含所述水印信息的目标元素,生成所述浏览器页面的背景图片的方式,通过将水印信息写入浏览器页面的目标元素,进而生成该浏览器页面的背景图片,达到了不需要与服务端交互,即可在前端浏览器灵活生成背景图片的目的,从而实现了快速、高效地生成背景图片的技术效果,进而解决了相关技术中生成水印需要依赖服务器端或者浏览器端生成水印方法不够完善的技术问题。In the embodiment of the present invention, the target element of the browser page is acquired; the watermark information is written into the target element; the background picture of the browser page is generated according to the target element containing the watermark information, by adding The watermark information is written into the target element of the browser page, and then the background image of the browser page is generated, which achieves the purpose of flexibly generating the background image in the front-end browser without interacting with the server, thus realizing the fast and efficient operation. The technical effect of generating the background picture further solves the technical problem that the watermark generation method in the related art needs to rely on the server side or the browser side to generate the watermark.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the attached image:
图1是根据本发明实施例的背景图片的生成方法的流程图;1 is a flowchart of a method for generating a background image according to an embodiment of the present invention;
图2是根据本发明可选实施例的背景图片的生成方法的流程图;2 is a flowchart of a method for generating a background picture according to an optional embodiment of the present invention;
图3是根据本发明实施例的背景图片的生成装置的示意图。FIG. 3 is a schematic diagram of an apparatus for generating a background picture according to an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to make those skilled in the art better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only Embodiments are part of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second" and the like in the description and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used may be interchanged under appropriate circumstances such that the embodiments of the invention described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having" and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed Rather, those steps or units may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.
为了便于描述,下面对本发明中出现的部分名词或术语进行详细说明。For the convenience of description, some nouns or terms appearing in the present invention are described in detail below.
应用程序编程接口:Application Programming Interface,简称为API。Application programming interface: Application Programming Interface, referred to as API.
canvas:一种HTML标签,一般用来在浏览器中进行绘图。canvas: An HTML tag generally used for drawing in browsers.
层叠样式表:(Cascading Style Sheets,简称为CSS),一种用来控制HTML标签展示样式的语言Cascading Style Sheets: (Cascading Style Sheets, referred to as CSS), a language used to control the display style of HTML tags
文档对象模型:(Document Object Mode,简称为DOM),一种与平台和语言无关的应用程序接口。Document Object Model: (Document Object Mode, referred to as DOM), a platform- and language-independent application programming interface.
Base64:一种编码方式,可以用来存放图片信息并直接被浏览器识别。Base64: An encoding method that can be used to store image information and be directly recognized by browsers.
实施例1Example 1
根据本发明实施例,提供了一种背景图片的生成方法的实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。According to an embodiment of the present invention, an embodiment of a method for generating a background picture is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings may be executed in a computer system such as a set of computer-executable instructions, and , although a logical order is shown in the flowcharts, in some cases steps shown or described may be performed in an order different from that herein.
图1是根据本发明实施例的背景图片的生成方法的流程图,如图1所示,该背景图片的生成方法包括如下步骤:1 is a flowchart of a method for generating a background image according to an embodiment of the present invention. As shown in FIG. 1 , the method for generating a background image includes the following steps:
步骤S102,获取浏览器页面的目标元素;Step S102, acquiring the target element of the browser page;
上述浏览器页面包括但不限于计算机的浏览器页面、平板的浏览器页面、智能手机的浏览器页面等。上述目标元素是存在于浏览器页面中的,可以通过预先设置、浏览器默认等多种方式得到,例如,可以预先在浏览器页面插入一个目标元素等。需要说明的是,该目标元素包括但不限于canvas元素。The above-mentioned browser pages include, but are not limited to, computer browser pages, tablet browser pages, and smart phone browser pages. The above-mentioned target element exists in the browser page, and can be obtained in various ways such as pre-setting and browser default. For example, a target element can be inserted in the browser page in advance. It should be noted that the target element includes but is not limited to the canvas element.
步骤S104,将水印信息写入目标元素;Step S104, write the watermark information into the target element;
上述水印信息至少包括文字信息和图片信息,其中,文字信息至少包括水印信息的字体、字号、颜色、旋转等,图片信息至少包括背景图片等。The above watermark information includes at least text information and picture information, wherein the text information at least includes the font, font size, color, rotation, etc. of the watermark information, and the picture information at least includes a background picture and the like.
步骤S106,依据包含水印信息的目标元素,生成浏览器页面的背景图片。Step S106, generating a background image of the browser page according to the target element containing the watermark information.
需要说明的是,浏览器页面的背景图片是由包含水印信息的目标元素生成的,该背景图片可用于展示水印信息。It should be noted that the background image of the browser page is generated by the target element containing the watermark information, and the background image can be used to display the watermark information.
通过上述步骤,可以先获取浏览器页面的目标元素,再将水印信息写入目标元素,进而依据包含水印信息的目标元素,生成浏览器页面的背景图片的,在本申请的上述实施例中,通过将水印信息写入浏览器页面的目标元素,进而生成该浏览器页面的背景图片,达到了不需要与服务端交互,即可在前端浏览器灵活生成背景图片的目的,从而实现了快速、高效地生成背景图片的技术效果,进而解决了相关技术中生成水印需要依赖服务器端或者浏览器端生成水印方法不够完善的技术问题。Through the above steps, it is possible to obtain the target element of the browser page first, then write the watermark information into the target element, and then generate the background image of the browser page according to the target element containing the watermark information. In the above-mentioned embodiment of the present application, By writing the watermark information into the target element of the browser page, and then generating the background image of the browser page, the purpose of flexibly generating the background image in the front-end browser without interacting with the server is achieved, thus realizing the fast, The technical effect of efficiently generating the background picture, thereby solving the technical problem that the watermark generation method in the related art needs to rely on the server side or the browser side to generate the watermark is not perfect.
可选地,在获取浏览器页面的目标元素之前,上述方法还包括:在浏览器页面插入目标元素;设置目标元素的显示参数,其中,显示参数包括以下至少之一:宽度、高度。Optionally, before acquiring the target element of the browser page, the above method further includes: inserting the target element on the browser page; setting display parameters of the target element, wherein the display parameters include at least one of the following: width and height.
作为一个可选的实施例,在获取浏览器页面的目标元素之前,需要在浏览器页面插入至少一个目标元素,需要说明的是,通过该目标元素可以在浏览器页面中进行绘图。然后,可以对上述目标元素的显示参数进行设置,例如,可以设置上述目标元素的宽度、高度等。通过上述实施方式可以得到满足需求的浏览器页面的目标元素。As an optional embodiment, before acquiring the target element of the browser page, at least one target element needs to be inserted into the browser page. It should be noted that drawing can be performed on the browser page through the target element. Then, the display parameters of the above-mentioned target element can be set, for example, the width and height of the above-mentioned target element can be set. The target element of the browser page that meets the requirements can be obtained through the above-mentioned implementation manner.
可选地,在设置目标元素的显示参数之后,上述方法还包括:将目标元素的样式设置为隐藏状态。Optionally, after setting the display parameters of the target element, the above method further includes: setting the style of the target element to a hidden state.
作为一个可选的实施例,可以将目标元素的样式设置为隐藏状态,具体地,利用CSS将目标元素的样式中的display属性进行设置,比如,none表示隐藏,其他值表示不隐藏,设置display属性为none,就可以将目标元素隐藏起来。通过该实施方式,使得在后续操作过程中,目标元素不会在页面中展示,用户正常使用页面不受影响。As an optional embodiment, the style of the target element can be set to a hidden state. Specifically, CSS is used to set the display attribute in the style of the target element. For example, none means hidden, other values mean not hidden, set display If the attribute is none, the target element can be hidden. Through this implementation, in the subsequent operation process, the target element will not be displayed on the page, and the user's normal use of the page will not be affected.
可选地,在将水印信息写入目标元素之前,上述方法还包括:设置水印信息的样式,其中,样式包括以下至少之一:字体、字号、颜色、旋转、背景图片。Optionally, before writing the watermark information into the target element, the above method further includes: setting a style of the watermark information, wherein the style includes at least one of the following: font, font size, color, rotation, and background image.
作为一个可选的实施例,上述水印信息的样式包括但不限于字体、字号、颜色、旋转、背景图片等。其中,上述字体包括多种类型,比如,宋体、黑体、楷体等,除此以外,还可以对水印信息的样式中的字号、颜色、旋转等进行修改。因此,上述水印信息的样式可以根据应用需求进行调整。另外,对于背景图片可以根据需要进行设置,背景图片的颜色也是可以灵活调整的。As an optional embodiment, the style of the above watermark information includes, but is not limited to, font, font size, color, rotation, background image, and the like. Wherein, the above-mentioned fonts include various types, for example, Song, Hei, Kai, etc. In addition, the font size, color, rotation, etc. in the style of the watermark information can also be modified. Therefore, the style of the above watermark information can be adjusted according to application requirements. In addition, the background image can be set as required, and the color of the background image can also be flexibly adjusted.
可选地,将水印信息写入目标元素包括:获取目标元素的调用对象;基于调用对象,将水印信息写入目标元素。Optionally, writing the watermark information into the target element includes: obtaining a calling object of the target element; and writing the watermark information into the target element based on the calling object.
作为一个可选的实施例,可以基于目标元素的调用对象,将水印信息写入目标元素。需要说明的是,上述目标元素的调用对象可以是预先设置的,也可以是系统默认的,用于实现将水印信息写入目标元素。As an optional embodiment, the watermark information may be written into the target element based on the calling object of the target element. It should be noted that the calling object of the above target element may be preset or default by the system, which is used to write the watermark information into the target element.
可选地,依据包含水印信息的目标元素,生成浏览器页面的背景图片包括:确定浏览器页面中的目标区域;获取预定编码方式的包含水印信息的目标元素的图片;将图片作为目标区域的背景图片,其中,背景图片用于展示水印信息。Optionally, generating the background picture of the browser page according to the target element containing the watermark information includes: determining the target area in the browser page; obtaining the picture of the target element containing the watermark information in a predetermined encoding manner; Background image, where the background image is used to display watermark information.
上述目标区域为浏览器页面中需要添加水印的区域,在具体实施过程中,该目标区域可以是全部的浏览器页面,也可以是局部的浏览器页面。The above-mentioned target area is the area in the browser page that needs to be added with a watermark. In the specific implementation process, the target area may be all browser pages or a partial browser page.
上述预定编码方式在具体实施过程中不作任何限定,可选地,预定编码方式可以为Base64编码。The above-mentioned predetermined encoding manner is not limited in the specific implementation process, and optionally, the predetermined encoding manner may be Base64 encoding.
作为一个可选的实施例,首先需要确定浏览器页面中的目标区域,然后获取预定编码方式的包含水印信息的目标元素的图片,进而将预定编码方式的包含水印信息的目标元素的图片作为目标区域的背景图片。需要说明的是,在实际应用中,该背景图片可用于展示水印信息。As an optional embodiment, it is necessary to first determine the target area in the browser page, then obtain the picture of the target element containing the watermark information in the predetermined encoding method, and then use the picture of the target element containing the watermark information in the predetermined encoding method as the target Background image for the area. It should be noted that, in practical applications, the background image can be used to display watermark information.
可选地,将图片作为目标区域的背景图片包括:获取图片的第一显示参数以及目标区域的第二显示参数;在第一显示参数等于第二显示参数的情况下,直接将图片作为目标区域的背景图片;在第一显示参数小于或者大于第二显示参数的情况下,调整第一显示参数,并将调整后的第一显示参数的图片作为目标区域的背景图片。Optionally, using the picture as the background picture of the target area includes: obtaining the first display parameter of the picture and the second display parameter of the target area; when the first display parameter is equal to the second display parameter, directly using the picture as the target area. When the first display parameter is smaller or larger than the second display parameter, adjust the first display parameter, and use the adjusted picture of the first display parameter as the background image of the target area.
作为一个可选的实施例,上述第一显示参数和第二显示参数均包括宽度和高度(或者长度),而且,第一显示参数和第二显示参数可以采用多种表示方式,例如,可以长度单位表示,可以采用像素单位表示,在具体实施过程中不作任何限定。需要说明的是,为了便于两者比较,一般在同一种表示方式下进行比较。As an optional embodiment, the above-mentioned first display parameter and second display parameter both include width and height (or length), and the first display parameter and the second display parameter can be expressed in various ways, for example, the length can be The unit representation can be expressed in pixel units, which is not limited in the specific implementation process. It should be noted that, in order to facilitate the comparison between the two, the comparison is generally performed under the same representation.
作为一个可选的实施例,分别获取图片的第一显示参数以及目标区域的第二显示参数。如果第一显示参数等于第二显示参数,则直接将图片作为目标区域的背景图片;如果第一显示参数小于或者大于第二显示参数,可以先调整第一显示参数,再将调整后的第一显示参数的图片作为目标区域的背景图片。具体地,当第一显示参数小于或者大于第二显示参数时,可以将第一显示参数调整至与第二显示参数一样大小,此时由于第一显示参数调整相应的图片也会作出调整,进而将该图片作为目标区域的背景图片。通过上述实施方式,可以自动实现图片尺寸与目标区域相适应,生成与目标区域匹配的背景图片。As an optional embodiment, the first display parameter of the picture and the second display parameter of the target area are obtained respectively. If the first display parameter is equal to the second display parameter, the image is directly used as the background image of the target area; if the first display parameter is less than or greater than the second display parameter, the first display parameter can be adjusted first, and then the adjusted first display parameter can be adjusted. The image of the display parameter is used as the background image of the target area. Specifically, when the first display parameter is smaller than or larger than the second display parameter, the first display parameter can be adjusted to the same size as the second display parameter. At this time, the corresponding picture will also be adjusted due to the adjustment of the first display parameter. Use this image as the background image for the target area. Through the above-mentioned embodiments, it can be automatically realized that the size of the picture is adapted to the target area, and a background picture matching the target area is generated.
可选地,在获取图片的第一显示参数以及目标区域的第二显示参数之后,上述方法还包括:在第二显示参数包括N倍数量的第一显示参数的情况下,将N倍数量的图片作为目标区域的背景图片,其中,N为大于等于1的整数。Optionally, after acquiring the first display parameter of the picture and the second display parameter of the target area, the method further includes: in the case that the second display parameter includes N times the number of first display parameters, The image is used as the background image of the target area, where N is an integer greater than or equal to 1.
作为一个可选的实施例,在第二显示参数包括N倍数量的第一显示参数的情况下,将N倍数量的图片作为目标区域的背景图片,其中,N为大于等于1的整数。具体地,可以按照预设规则将图片布局到目标区域的多个位置,其中,预设规则可以是从上到下,从左到右的布局方式。比如,第二显示参数包括4倍数量的第一显示参数,可以按照1*4,2*2,4*1中的任一中的布局方式,将4张图片作为目标区域的背景图片。通过上述实施方式可以自动实现水印图片的重复展示。As an optional embodiment, when the second display parameter includes N times the number of first display parameters, N times the number of pictures is used as the background picture of the target area, where N is an integer greater than or equal to 1. Specifically, the pictures may be laid out to multiple positions in the target area according to a preset rule, wherein the preset rule may be a top-to-bottom, left-to-right layout manner. For example, the second display parameter includes 4 times the number of the first display parameter, and four pictures may be used as the background pictures of the target area according to any one of 1*4, 2*2, and 4*1 layouts. Repeated display of watermarked pictures can be automatically realized through the above-mentioned embodiments.
下面对本发明可选的实施方式进行详细说明。The optional embodiments of the present invention will be described in detail below.
本发明可选的实施方式中提供了一种实现在浏览器端灵活生成水印的方法,图2是根据本发明可选实施例的背景图片的生成方法的流程图,如图2所示,该背景图片的生成方法包括如下步骤:An optional embodiment of the present invention provides a method for flexibly generating a watermark on a browser side. FIG. 2 is a flowchart of a method for generating a background image according to an optional embodiment of the present invention. As shown in FIG. 2 , the The generation method of the background image includes the following steps:
首先,在浏览器页面中插入一个canvas元素,根据具体需求设置其宽度和高度参数,并使用DOM API获取到该元素。First, insert a canvas element into the browser page, set its width and height parameters according to specific requirements, and use the DOM API to get the element.
其次,通过CSS设置其样式将其隐藏,这样后续操作过程就不会在页面中展示,用户正常使用页面便不受影响。Secondly, set its style through CSS to hide it, so that the subsequent operation process will not be displayed on the page, and the user's normal use of the page will not be affected.
然后,通过canvas API getContext获取到它的上下文,接着使用上下文的APIfillText将水印信息写入canvas中,在写入水印信息之前也可以根据需求设置水印的样式。例如,通过font设置字体、字号,通过fillStyle设置颜色,通过rotate设置旋转,通过drawImage设置背景图片等。Then, obtain its context through the canvas API getContext, and then use the context's APIfillText to write the watermark information into the canvas. Before writing the watermark information, you can also set the style of the watermark as required. For example, set the font and font size through font, set the color through fillStyle, set the rotation through rotate, set the background image through drawImage, etc.
在水印信息写入canvas之后,调用canvas API toDataURL即可获得到包含水印信息的图片的Base64编码。After the watermark information is written to the canvas, call the canvas API toDataURL to obtain the Base64 encoding of the picture containing the watermark information.
最后,找到页面中需要添加水印信息的元素,将上一步获取到的Base64编码作为该元素的背景图片,即可展示水印信息,同时可以方便的使用CSS来调整水印的重复展示。Finally, find the element in the page that needs to add watermark information, and use the Base64 code obtained in the previous step as the background image of the element to display the watermark information. At the same time, CSS can be easily used to adjust the repeated display of the watermark.
通过上述实施步骤,可以将生成图片的步骤放到了浏览器端,无需向后端请求即可实现,由于实现了与后端的解耦,在网络较差时也能快速生成。Through the above implementation steps, the step of generating pictures can be placed on the browser side, and can be implemented without requesting the backend. Since the decoupling from the backend is realized, it can be generated quickly even when the network is poor.
实施例2Example 2
根据本发明实施例的另外一个方面,还提供了一种背景图片的生成装置,图3是根据本发明实施例的背景图片的生成装置的示意图,如图3所示,该背景图片的生成装置包括:获取模块32、写入模块34和生成模块36。下面对该背景图片的生成装置进行详细说明。According to another aspect of the embodiment of the present invention, an apparatus for generating a background image is also provided. FIG. 3 is a schematic diagram of an apparatus for generating a background image according to an embodiment of the present invention. As shown in FIG. 3 , the apparatus for generating a background image It includes: acquiring module 32 , writing module 34 and generating module 36 . The device for generating the background image will be described in detail below.
获取模块32,用于获取浏览器页面的目标元素;写入模块34,连接至上述获取模块32,用于将水印信息写入目标元素;生成模块36,连接至上述写入模块34,用于依据包含水印信息的目标元素,生成浏览器页面的背景图片。The obtaining module 32 is used to obtain the target element of the browser page; the writing module 34 is connected to the above-mentioned obtaining module 32, and is used to write the watermark information into the target element; the generating module 36 is connected to the above-mentioned writing module 34, used for Generate the background image of the browser page according to the target element containing the watermark information.
由上述可知,该实施例中的操作处理装置,可以先通过获取模块32获取浏览器页面的目标元素,再通过写入模块34将水印信息写入目标元素,进而生成模块36依据包含水印信息的目标元素,生成浏览器页面的背景图片的,在本申请的上述实施例中,通过将水印信息写入浏览器页面的目标元素,进而生成该浏览器页面的背景图片,达到了不需要与服务端交互,即可在前端浏览器灵活生成背景图片的目的,从而实现了快速、高效地生成背景图片的技术效果,进而解决了相关技术中生成水印需要依赖服务器端或者浏览器端生成水印方法不够完善的技术问题。As can be seen from the above, the operation processing device in this embodiment can first obtain the target element of the browser page through the obtaining module 32, and then write the watermark information into the target element through the writing module 34, and then the generating module 36 according to the information containing the watermark information. The target element generates the background picture of the browser page, in the above-mentioned embodiment of the present application, by writing the watermark information into the target element of the browser page, and then generating the background picture of the browser page, it achieves the requirement of no need and service. The purpose of flexibly generating background images in the front-end browser, thus realizing the technical effect of generating background images quickly and efficiently, thus solving the problem that the watermark generation method in the related art needs to rely on the server side or the browser side to generate watermarks. Perfect technical issues.
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,例如,对于后者,可以通过以下方式实现:上述各个模块可以位于同一处理器中;或者,上述各个模块以任意组合的方式位于不同的处理器中。It should be noted that the above modules can be implemented by software or hardware. For example, the latter can be implemented in the following ways: the above modules can be located in the same processor; or, the above modules can be arbitrarily combined. in different processors.
此处需要说明的是,上述获取模块32、写入模块34和生成模块36对应于实施例1中的步骤S102至S106,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述实施例1所公开的内容。需要说明的是,上述模块作为装置的一部分可以在诸如一组计算机可执行指令的计算机系统中执行。It should be noted here that the acquisition module 32, the writing module 34 and the generation module 36 above correspond to steps S102 to S106 in Embodiment 1, and the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but not limited to The content disclosed in Example 1 above. It should be noted that the above-mentioned modules may be executed in a computer system such as a set of computer-executable instructions as part of an apparatus.
可选地,在获取浏览器页面的目标元素之前,上述装置还包括:插入模块,用于在浏览器页面插入目标元素;第一设置模块,用于设置目标元素的显示参数,其中,显示参数包括以下至少之一:宽度、高度。Optionally, before acquiring the target element of the browser page, the above device further includes: an inserting module for inserting the target element on the browser page; a first setting module for setting display parameters of the target element, wherein the display parameters Include at least one of the following: width, height.
可选地,在设置目标元素的显示参数之后,上述装置还包括:第二设置模块,用于将目标元素的样式设置为隐藏状态。Optionally, after setting the display parameters of the target element, the above apparatus further includes: a second setting module, configured to set the style of the target element to a hidden state.
可选地,在将水印信息写入目标元素之前,上述装置还包括:第三设置模块,用于设置水印信息的样式,其中,样式包括以下至少之一:字体、字号、颜色、旋转、背景图片。Optionally, before the watermark information is written into the target element, the above-mentioned apparatus further includes: a third setting module for setting a style of the watermark information, wherein the style includes at least one of the following: font, font size, color, rotation, background picture.
可选地,上述写入模块包括:第一获取单元,用于获取目标元素的调用对象;写入单元,用于基于调用对象,将水印信息写入目标元素。Optionally, the above-mentioned writing module includes: a first obtaining unit, configured to obtain a calling object of the target element; and a writing unit, configured to write the watermark information into the target element based on the calling object.
可选地,上述生成模块包括:确定单元,用于确定浏览器页面中的目标区域;第二获取单元,用于获取预定编码方式的包含水印信息的目标元素的图片;处理单元,用于将图片作为目标区域的背景图片,其中,背景图片用于展示水印信息。Optionally, the above-mentioned generating module includes: a determining unit for determining a target area in a browser page; a second acquiring unit for acquiring a picture of a target element containing watermark information in a predetermined encoding manner; a processing unit for converting The image is used as the background image of the target area, wherein the background image is used to display the watermark information.
可选地,上述处理单元包括:获取子单元,用于获取图片的第一显示参数以及目标区域的第二显示参数;第一处理子单元,用于在第一显示参数等于第二显示参数的情况下,直接将图片作为目标区域的背景图片;第二处理子单元,用于在第一显示参数小于或者大于第二显示参数的情况下,调整第一显示参数,并将调整后的第一显示参数的图片作为目标区域的背景图片。Optionally, the above-mentioned processing unit includes: an acquisition subunit, used to acquire the first display parameter of the picture and the second display parameter of the target area; the first processing subunit, used for when the first display parameter is equal to the second display parameter. In this case, the picture is directly used as the background picture of the target area; the second processing subunit is used to adjust the first display parameter when the first display parameter is less than or greater than the second display parameter, and adjust the adjusted first display parameter. The image of the display parameter is used as the background image of the target area.
可选地,在获取图片的第一显示参数以及目标区域的第二显示参数之后,上述装置还包括:第三处理子单元,用于在第二显示参数包括N倍数量的第一显示参数的情况下,将N倍数量的图片作为目标区域的背景图片,其中,N为大于等于1的整数。Optionally, after acquiring the first display parameter of the picture and the second display parameter of the target area, the above-mentioned apparatus further includes: a third processing subunit, configured to include N times the number of first display parameters in the second display parameter. In this case, N times of pictures are used as background pictures of the target area, where N is an integer greater than or equal to 1.
实施例3Example 3
根据本发明实施例的另一方面,还提供了一种计算机可读存储介质,计算机可读存储介质包括存储的程序,其中,在程序运行时控制计算机可读存储介质所在设备执行上述中任意一项的背景图片的生成方法。According to another aspect of the embodiments of the present invention, a computer-readable storage medium is also provided, where the computer-readable storage medium includes a stored program, wherein when the program is run, a device where the computer-readable storage medium is located is controlled to execute any one of the above How to generate the item's background image.
可选地,在本实施例中,上述计算机可读存储介质可以位于计算机网络中计算机终端群中的任意一个计算机终端中,或者位于移动终端群中的任意一个移动终端中,上述计算机可读存储介质包括存储的程序。Optionally, in this embodiment, the above-mentioned computer-readable storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group, and the above-mentioned computer-readable storage medium The medium includes a stored program.
可选地,在程序运行时控制计算机可读存储介质所在设备执行以下功能:获取浏览器页面的目标元素;将水印信息写入目标元素;依据包含水印信息的目标元素,生成浏览器页面的背景图片。Optionally, control the device where the computer-readable storage medium is located to perform the following functions when the program is running: obtain the target element of the browser page; write the watermark information into the target element; generate the background of the browser page according to the target element containing the watermark information picture.
实施例4Example 4
根据本发明实施例的另一方面,还提供了一种处理器,处理器用于运行程序,其中,程序运行时执行上述中任意一项的背景图片的生成方法。According to another aspect of the embodiments of the present invention, a processor is further provided, where the processor is used to run a program, wherein, when the program runs, any one of the foregoing methods for generating a background image is executed.
本申请实施例提供了一种设备,该设备包括处理器、存储器及存储在存储器上并可在处理器上运行的程序,处理器执行程序时实现以下步骤:获取浏览器页面的目标元素;将水印信息写入目标元素;依据包含水印信息的目标元素,生成浏览器页面的背景图片。An embodiment of the present application provides a device, the device includes a processor, a memory, and a program stored in the memory and running on the processor. When the processor executes the program, the following steps are implemented: acquiring a target element of a browser page; The watermark information is written into the target element; the background image of the browser page is generated according to the target element containing the watermark information.
本申请还提供了一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序:获取浏览器页面的目标元素;将水印信息写入目标元素;依据包含水印信息的目标元素,生成浏览器页面的背景图片。The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program initialized with the following method steps: obtaining a target element of a browser page; writing watermark information into the target element; The target element of the information, which generates the background image of the browser page.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments.
在本发明的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are only illustrative, for example, the division of the units may be a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components may be combined or Integration into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of units or modules, and may be in electrical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes .
以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。The above are only the preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, without departing from the principles of the present invention, several improvements and modifications can be made. It should be regarded as the protection scope of the present invention.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010784957.5A CN111914226A (en) | 2020-08-06 | 2020-08-06 | Background picture generation method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010784957.5A CN111914226A (en) | 2020-08-06 | 2020-08-06 | Background picture generation method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111914226A true CN111914226A (en) | 2020-11-10 |
Family
ID=73287961
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010784957.5A Pending CN111914226A (en) | 2020-08-06 | 2020-08-06 | Background picture generation method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111914226A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112306619A (en) * | 2020-12-02 | 2021-02-02 | 广州橙行智动汽车科技有限公司 | Screenshot method and device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110276175A (en) * | 2019-06-27 | 2019-09-24 | 北京金山云网络技术有限公司 | Method, device, client and server for generating watermark in web page |
CN111191414A (en) * | 2019-11-11 | 2020-05-22 | 苏州亿歌网络科技有限公司 | Page watermark generation method, identification method, device, equipment and storage medium |
CN111488559A (en) * | 2020-04-10 | 2020-08-04 | 腾讯科技(深圳)有限公司 | Webpage watermark generation method and device, computer equipment and storage medium |
-
2020
- 2020-08-06 CN CN202010784957.5A patent/CN111914226A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110276175A (en) * | 2019-06-27 | 2019-09-24 | 北京金山云网络技术有限公司 | Method, device, client and server for generating watermark in web page |
CN111191414A (en) * | 2019-11-11 | 2020-05-22 | 苏州亿歌网络科技有限公司 | Page watermark generation method, identification method, device, equipment and storage medium |
CN111488559A (en) * | 2020-04-10 | 2020-08-04 | 腾讯科技(深圳)有限公司 | Webpage watermark generation method and device, computer equipment and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112306619A (en) * | 2020-12-02 | 2021-02-02 | 广州橙行智动汽车科技有限公司 | Screenshot method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5967614B2 (en) | Method, apparatus and system for displaying web pages | |
US9652553B2 (en) | Method and device for displaying a web page | |
US8924251B2 (en) | Systems and methods for providing one or more pages from an electronic document | |
CN107256259B (en) | Page display method and device, electronic equipment and storage medium | |
US20130339139A1 (en) | System and method for nonstandard creative content auctioning | |
CN110489943B (en) | Page watermark tamper-proofing method and system | |
US9117314B2 (en) | Information output apparatus, method, and recording medium for displaying information on a video display | |
JPWO2014155742A1 (en) | Information processing system, information processing system control method, information processing apparatus, information processing apparatus control method, information storage medium, and program | |
WO2023155712A1 (en) | Page generation method and apparatus, page display method and apparatus, and electronic device and storage medium | |
US20170168997A1 (en) | System and computer-implemented method for incorporating an image into a page of content for transmission from a web-site | |
US20160224554A1 (en) | Search methods, servers, and systems | |
CN112100583A (en) | Method and device for generating Web visual watermark | |
CN111767488A (en) | Article display method, electronic device and storage medium | |
CN111914226A (en) | Background picture generation method and device | |
CN116483492A (en) | Mobile device resolution adaptation method and device, electronic device and storage medium | |
CN104182394B (en) | Server, terminal and layout files display methods | |
CN114756794A (en) | Webpage information anti-leakage method and device | |
CN107391519B (en) | Method for accelerating display of Asian language family fonts on webpage, font server and browser end | |
CN112306619A (en) | Screenshot method and device | |
CN113297859A (en) | Table information translation method and device and electronic equipment | |
CN118466807B (en) | Control method and device based on jQuery full-screen carousel map | |
CN110717950A (en) | Method and device for reading medical images | |
CN118798996B (en) | Advertisement display management method and device, electronic equipment and storage medium | |
US20130185625A1 (en) | System and method for intelligently sizing content for display | |
CN118228212A (en) | Watermark processing method, device, electronic device, storage medium and program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 100094 101, floors 1-5, building 7, courtyard 3, fengxiu Middle Road, Haidian District, Beijing Applicant after: Beijing Xingchen Tianhe Technology Co.,Ltd. Address before: 100097 room 806-1, block B, zone 2, Jinyuan times shopping center, indigo factory, Haidian District, Beijing Applicant before: XSKY BEIJING DATA TECHNOLOGY Corp.,Ltd. |
|
CB02 | Change of applicant information | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20201110 |
|
RJ01 | Rejection of invention patent application after publication |