Cross-platform watermark picture dynamic uploading method, system and device and medium
The cross-platform watermark image dynamic uploading method addresses server burden and cross-platform inconsistency by enabling real-time preview and dynamic watermark adjustment on the client, enhancing user experience and reducing server load.
Patent Information
- Application Number
- CN202411167873.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-06
AI Technical Summary
Current image uploading methods in mobile applications face issues of increased server burden, lack of real-time watermark preview and dynamic adjustment, and poor cross-platform consistency, leading to reduced user experience and increased development complexity.
A cross-platform watermark image dynamic uploading method based on the uni-app framework, which enables real-time watermark preview and dynamic parameter adjustment on the client, using canvas manipulation and image conversion to ensure consistent watermark application across different platforms.
The method improves user experience by allowing real-time watermark preview and dynamic adjustment, reduces server burden, and ensures cross-platform consistency, while reducing development complexity and maintenance costs.
Smart Images

Figure CN119094665A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically to a cross-platform watermark image dynamic uploading method, system, device and medium. Background Art
[0002] With the rapid development of mobile Internet technology, mobile applications (APP) have penetrated into every aspect of people's daily life and become an indispensable part. In the field of industrial Internet, mobile applications are particularly important. They not only improve work efficiency, but also optimize production processes through digital means. Among them, uploading pictures is a key link in recording and confirming work progress and results. Its effectiveness, security and copyright protection have become urgent issues to be solved.
[0003] Currently, in order to ensure the validity, security and copyright protection of uploaded images, the common practice is to add watermarks to images on the server side. However, this method has the following significant defects: 1. Increased server burden: Each uploaded image needs to be processed by the server, which increases the server's computing burden and reduces the system's response speed and stability.
[0004] 2. Unable to achieve real-time preview and dynamic adjustment: Users cannot see the watermark effect in real time on the front end of the application, nor can they dynamically adjust the watermark position and style according to the preview results, which reduces the user experience.
[0005] 3. Poor cross-platform consistency: Due to the significant differences in the development frameworks and technology stacks of different mobile platforms, the traditional server-side watermarking method is difficult to achieve cross-platform consistency and compatibility, which increases development difficulty and maintenance costs.
[0006] In addition, in the current popular APP front-end technology stack, most of the functional components for uploading pictures do not directly support adding watermarks. This means that developers need to add additional processing logic between the front-end and back-end, which not only increases the complexity of the system, but may also introduce new security and performance issues. Summary of the invention
[0007] In view of the above problems, the purpose of the present invention is to provide a cross-platform watermark image dynamic uploading method, system, device and medium, based on the uni-app framework, to achieve real-time preview of watermark effects on the client, support dynamic adjustment of watermark parameters, and achieve consistent watermark image uploading function on different platforms.
[0008] In order to achieve the above object, the present invention is implemented through the following technical solutions: In a first aspect, the present invention discloses a cross-platform watermark image dynamic uploading method, comprising: In the uni-app project, define the canvas tag to create a canvas; Get the picture uploaded by the user and adjust the canvas tag size according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent; Get the watermark parameters, draw the watermark on the canvas according to the watermark parameters, and draw the user image on the canvas to overlay the watermark to generate a watermark image; Convert the watermark image on the canvas into an image of a specified size and display it to the user for preview; In response to obtaining the upload instruction, the watermark image is optimized, the upload is started and the upload progress is displayed; After the upload is completed, the upload result is returned.
[0009] Furthermore, in the uni-app project, the canvas tag is defined to create a canvas, including: In the uni-app project, define a canvas tag to draw watermarks and pictures; Style the canvas tag to be absolutely positioned and hidden outside the viewport.
[0010] Further, the step of obtaining the picture uploaded by the user and adjusting the size of the canvas tag according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent includes: Get the picture uploaded by the user and get the height and width of the picture through the function uni.getImageInfo(); Dynamically adjust the canvas tag size according to the ratio of the image's height and width.
[0011] Furthermore, the watermark parameters include: text information, picture information, position parameter, size parameter, transparency parameter and hidden parameter of the watermark.
[0012] Furthermore, the watermark image on the canvas is converted into an image of a specified size and displayed to the user for preview, including: Get resizing information; According to the size adjustment information, use the function uni.canvasToTempFilePath() to convert the watermark image on the canvas into an image of the corresponding size and return the file path; Generate a watermarked image on the client and display it to the user for preview; Generate a modification button on the image preview interface to modify the watermark parameters during the preview process.
[0013] Further, in response to obtaining the upload instruction, optimizing the watermark image, starting the upload and displaying the upload progress, including: In response to obtaining the upload instruction, compressing the watermark image and optimizing the image; Start uploading and upload the watermark image to the preset storage location of the server.
[0014] Further, after the upload is completed, the upload result is returned, including: After the upload is completed, the upload success information is returned to the client; In response to receiving the upload success information, the upload success information is displayed and the current page status is updated. In a second aspect, the present invention also discloses a cross-platform watermark image dynamic uploading system, including: a watermark image processing module and an image uploading module; The watermark image processing module is used for: In the uni-app project, define the canvas tag to create a canvas; Get the picture uploaded by the user and adjust the canvas tag size according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent; Get the watermark parameters, draw the watermark on the canvas according to the watermark parameters, and draw the user image on the canvas to overlay the watermark to generate a watermark image; Convert the watermark image on the canvas into an image of a specified size and display it to the user for preview; The picture upload module is used for: In response to obtaining the upload instruction, the watermark image is optimized, the upload is started and the upload progress is displayed; After the upload is completed, the upload result is returned.
[0015] In a third aspect, the present invention further discloses a cross-platform watermark image dynamic uploading device, comprising: Storage device, used to store cross-platform watermark image dynamic upload program; A processor is used to implement the steps of the cross-platform watermark image dynamic uploading method as described in any one of the above items when executing the cross-platform watermark image dynamic uploading program.
[0016] In a fourth aspect, the present invention further discloses a readable storage medium, on which is stored a cross-platform watermark image dynamic upload program, which, when executed by a processor, implements the steps of the cross-platform watermark image dynamic upload method as described in any of the above items.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: The present invention discloses a cross-platform watermark image dynamic uploading method, system, device and medium. By adopting the cross-platform watermark image dynamic uploading technology based on uni-app, the watermark image uploading function that can preview the watermark effect in real time on the client and support dynamic adjustment of watermark parameters is realized. The present invention not only improves the user experience, ensures the effectiveness, security and copyright protection of uploaded images, but also reduces the server burden and traffic consumption. At the same time, the present invention also has the advantages of good cross-platform consistency, easy integration and maintenance, etc.
[0018] The present invention is developed based on uni-app, can run on multiple platforms, has good cross-platform compatibility, can meet the needs of different devices, and is easy to integrate and maintain. The present invention has rich watermark adding effects, supports customizing watermark content, position, size and other attributes, and meets the needs of different businesses. The present invention adopts technical means such as dynamic adjustment of canvas size and image format conversion to improve upload speed and success rate. The present invention realizes adding watermarks on the client, previewing watermark effects in real time, and supports dynamic adjustment of watermark parameters, which not only improves user experience, but also reduces server burden and traffic consumption.
[0019] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0021] Figure 1 It is a method flow chart of a specific implementation mode of the present invention.
[0022] Figure 2 It is a system structure diagram of a specific implementation mode of the present invention.
[0023] In the figure, 1. Watermark image processing module; 2. Image upload module. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0025] See also Figure 1 As shown, this embodiment provides a cross-platform watermark image dynamic uploading method, including the following steps: S1: In the uni-app project, define the canvas tag to create a canvas.
[0026] In a specific implementation, firstly, in the uni-app project, a canvas tag is defined for drawing watermarks and pictures; then the style of the canvas tag is set to absolute positioning and hidden outside the viewport to avoid affecting the user interface.
[0027] S2: Get the picture uploaded by the user and adjust the canvas tag size according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent.
[0028] In a specific implementation, firstly, the picture uploaded by the user is obtained, and the height and width of the picture are obtained through the function uni.getImageInfo(); then, the size of the canvas tag is dynamically adjusted according to the ratio of the height and width of the picture.
[0029] For example, after a user uploads a picture from an album or takes a photo directly, uni.getImageInfo() is used to obtain relevant information about the picture, such as the height and width of the picture. The size of the canvas is dynamically adjusted according to the information and aspect ratio of the picture to ensure that the size ratio of the watermark and the picture is consistent and can be displayed normally in the field of view.
[0030] S3: Obtain watermark parameters, draw a watermark on the canvas according to the watermark parameters, and draw the user image on the canvas to overlay the watermark to generate a watermark image.
[0031] In a specific implementation, a watermark is first drawn according to watermark parameters, and then the picture uploaded by the user is drawn on the canvas and superimposed with the watermark, wherein the watermark parameters include text, picture, position, size, transparency, shadow, etc.
[0032] S4: Convert the watermark image on the canvas into an image of a specified size and display it to the user for preview.
[0033] In a specific implementation, first, the size adjustment information is obtained, and the watermark image on the canvas is converted into an image of a corresponding size using the function uni.canvasToTempFilePath() according to the size adjustment information, and the file path is returned. At this time, a watermarked image is generated on the client and displayed to the user for preview. In addition, a modification button is generated on the image preview interface for modifying the watermark parameters during the preview process.
[0034] As an example, use uni.canvasToTempFilePath() to convert the watermark image on the canvas into an image of a specified size, return the file path, and finally generate a watermarked image on the client and display it to the user for preview. The user can modify the watermark parameters at any time during the preview process by clicking the Modify button until they are satisfied.
[0035] S5: In response to obtaining the upload instruction, the watermark image is optimized, the upload is started and the upload progress is displayed.
[0036] In a specific implementation, in response to obtaining the upload instruction, the watermark image is compressed and image optimized. At this time, the upload is started and the watermark image is uploaded to a preset storage location of the server.
[0037] As an example, after the user clicks the upload button, the processed watermarked image is uploaded to the server or other storage location. During the upload process, the image will be compressed and optimized to reduce the upload time and traffic consumption. At the same time, the upload progress will also be displayed to improve the user experience.
[0038] S6: After the upload is completed, the upload result is returned.
[0039] In a specific implementation, after the image is uploaded, the server returns the upload result to the client. The client performs subsequent operations based on the upload result, such as displaying the upload result, updating the page status, etc.
[0040] The present invention provides a cross-platform watermark image dynamic uploading method, which realizes the watermark image uploading function of real-time preview of watermark effect on the client and supports dynamic adjustment of watermark parameters by adopting the cross-platform watermark image dynamic uploading technology based on uni-app.
[0041] See also Figure 2 As shown, the present invention also discloses a cross-platform watermark image dynamic uploading system, including: a watermark image processing module 1 and a image uploading module 2.
[0042] The watermark image processing module 1 is used for: In the uni-app project, define the canvas tag to create a canvas; Get the picture uploaded by the user and adjust the canvas tag size according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent; Get the watermark parameters, draw the watermark on the canvas according to the watermark parameters, and draw the user image on the canvas to overlay the watermark to generate a watermark image; Convert the watermark image on the canvas into an image of a specified size and display it to the user for preview.
[0043] In a specific implementation, the watermark image processing module 1 uses a canvas to generate a watermarked image in real time on the client according to the watermark parameters set by the user (such as text, image, position, size, transparency, shadow, etc.). At the same time, the watermark image processing module 1 also supports dynamic adjustment of watermark parameters, and the user can modify the watermark effect at any time during the preview process.
[0044] Image upload module 2 is used to: In response to obtaining the upload instruction, the watermark image is optimized, the upload is started and the upload progress is displayed; After the upload is completed, the upload result is returned.
[0045] In a specific implementation, the picture upload module 2 is tightly integrated with the watermark picture processing module 1, and the processed watermark picture can be uploaded to a server or other storage location. During the upload process, the picture upload module 2 will compress and optimize the picture to reduce the upload time and traffic consumption. At the same time, the picture upload module 2 also supports functions such as upload progress display to improve the user experience.
[0046] The specific implementation of the cross-platform watermark image dynamic uploading system of this embodiment is basically the same as the specific implementation of the cross-platform watermark image dynamic uploading method described above, and will not be repeated here.
[0047] It should be noted that this system is developed based on the uni-app framework and is compatible with multiple mobile platforms, including iOS, Android, H5, etc., achieving code reuse and consistency on different platforms.
[0048] The present invention also discloses a cross-platform watermark image dynamic uploading device, comprising a processor and a memory; wherein, when the processor executes the cross-platform watermark image dynamic uploading program stored in the memory, the steps of the cross-platform watermark image dynamic uploading method as described in any one of the above items are implemented.
[0049] Furthermore, the cross-platform watermark image dynamic uploading device in this embodiment may also include: The input interface is used to obtain the cross-platform watermark image dynamic upload program imported from the outside, and save the obtained cross-platform watermark image dynamic upload program to the memory, and can also be used to obtain various instructions and parameters transmitted by the external terminal device, and transmit them to the processor, so that the processor can use the above various instructions and parameters to carry out corresponding processing. In this embodiment, the input interface can specifically include but is not limited to a USB interface, a serial interface, a voice input interface, a fingerprint input interface, a hard disk reading interface, etc.
[0050] The output interface is used to output various data generated by the processor to the terminal device connected thereto, so that other terminal devices connected to the output interface can obtain various data generated by the processor. In this embodiment, the output interface may specifically include but is not limited to a USB interface, a serial interface, etc.
[0051] The communication unit is used to establish a remote communication connection between the cross-platform watermark image dynamic upload device and the external server, so that the cross-platform watermark image dynamic upload device can mount the image file to the external server. In this embodiment, the communication unit may specifically include but is not limited to a remote communication unit based on wireless communication technology or wired communication technology.
[0052] The keyboard is used to obtain various parameter data or instructions input by the user by tapping the keycaps in real time.
[0053] The display is used to display the relevant information of the dynamic upload process of the cross-platform watermark image in real time.
[0054] The mouse can be used to assist users in inputting data and simplify user operations.
[0055] The present invention also discloses a readable storage medium, wherein the readable storage medium includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable hard disk, a CD-ROM or any other form of storage medium known in the technical field. The readable storage medium stores a cross-platform watermark image dynamic upload program, and when the cross-platform watermark image dynamic upload program is executed by a processor, the steps of the cross-platform watermark image dynamic upload method described in any one of the above items are implemented.
[0056] In summary, the present invention is based on the uni-app framework, realizes real-time preview of watermark effects on the client, supports dynamic adjustment of watermark parameters, and can implement consistent watermark image uploading function on different platforms.
[0057] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. As for the method disclosed in the embodiment, since it corresponds to the system disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0058] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0059] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, systems and methods can be implemented in other ways. For example, the system 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, such as 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 through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0060] 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.
[0061] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit.
[0062] Similarly, each processing unit in each embodiment of the present invention may be integrated into one functional module, or each processing unit may exist physically, or two or more processing units may be integrated into one functional module.
[0063] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0064] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0065] The above is a detailed introduction to the cross-platform watermark image dynamic uploading method, system, device and readable storage medium provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A cross-platform watermark image dynamic uploading method, characterized in that: include: In the uni-app project, define the canvas tag to create a canvas; Get the picture uploaded by the user and adjust the canvas tag size according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent; Get the watermark parameters, draw the watermark on the canvas according to the watermark parameters, and draw the user image on the canvas to overlay the watermark to generate a watermark image; Convert the watermark image on the canvas into an image of a specified size and display it to the user for preview; In response to obtaining the upload instruction, the watermark image is optimized, the upload is started and the upload progress is displayed; After the upload is completed, the upload result is returned.
2. The cross-platform watermark image dynamic uploading method according to claim 1 is characterized in that: In the uni-app project, define the canvas tag to create a canvas, including: In the uni-app project, define a canvas tag to draw watermarks and pictures; Style the canvas tag to be absolutely positioned and hidden outside the viewport.
3. The cross-platform watermark image dynamic uploading method according to claim 1 is characterized in that: The step of obtaining the picture uploaded by the user and adjusting the size of the canvas tag according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent includes: Get the picture uploaded by the user and get the height and width of the picture through the function uni.getImageInfo(); Dynamically adjust the canvas tag size according to the ratio of the image's height and width.
4. The cross-platform watermark image dynamic uploading method according to claim 1 is characterized in that: The watermark parameters include: Watermark text information, image information, position parameters, size parameters, transparency parameters and hidden parameters.
5. The cross-platform watermark image dynamic uploading method according to claim 1 is characterized in that: The process of converting the watermark image on the canvas into an image of a specified size and displaying it to the user for preview includes: Get resizing information; According to the size adjustment information, use the function uni.canvasToTempFilePath() to convert the watermark image on the canvas into an image of the corresponding size and return the file path; Generate a watermarked image on the client and display it to the user for preview; Generate a modification button on the image preview interface to modify the watermark parameters during the preview process.
6. The cross-platform watermark image dynamic uploading method according to claim 5 is characterized in that: In response to obtaining the upload instruction, optimizing the watermark image, starting the upload and displaying the upload progress, including: In response to obtaining the upload instruction, compressing the watermark image and optimizing the image; Start uploading and upload the watermark image to the preset storage location of the server.
7. The cross-platform watermark image dynamic uploading method according to claim 6, characterized in that: After the upload is completed, the upload result is returned, including: After the upload is completed, the upload success information is returned to the client; In response to receiving the upload success information, the upload success information is displayed and the current page status is updated.
8. A cross-platform watermark image dynamic uploading system, characterized in that: include: Watermark image processing module and image upload module; The watermark image processing module is used for: In the uni-app project, define the canvas tag to create a canvas; Get the picture uploaded by the user and adjust the canvas tag size according to the size of the picture to ensure that the size ratio of the watermark and the picture is consistent; Get the watermark parameters, draw the watermark on the canvas according to the watermark parameters, and draw the user image on the canvas to overlay the watermark to generate a watermark image; Convert the watermark image on the canvas into an image of a specified size and display it to the user for preview; The picture upload module is used for: In response to obtaining the upload instruction, the watermark image is optimized, the upload is started and the upload progress is displayed; After the upload is completed, the upload result is returned.
9. A cross-platform watermark image dynamic uploading device, characterized in that: include: Storage device, used to store cross-platform watermark image dynamic upload program; A processor is used to implement the steps of the cross-platform watermark image dynamic uploading method as described in any one of claims 1 to 7 when executing the cross-platform watermark image dynamic uploading program.
10. A readable storage medium, characterized in that: The readable storage medium stores a cross-platform watermark image dynamic uploading program, and when the cross-platform watermark image dynamic uploading program is executed by the processor, the steps of the cross-platform watermark image dynamic uploading method according to any one of claims 1 to 7 are implemented.
