Image generation method and device, electronic equipment and storage medium
By acquiring image templates and replacing elements, and automatically replacing visual elements with pre-configured correspondence, the problems of low image generation efficiency and high learning threshold in the prior art are solved, and efficient and automatic image generation is achieved.
Patent Information
- Application Number
- CN202311340657.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-16
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, the efficiency of generating images by manually editing image templates is low, and has a certain learning threshold, making it difficult to meet the growing information transmission needs.
An image generation method is provided to automatically replace the visual element to generate a target image by acquiring the image template and the replacement element, using the preconfigured correspondence between the replacement element and the visual element in the image template.
This method does not require manual participation, significantly improves the efficiency of image generation, reduces learning costs, and can quickly generate images that meet the needs.
Smart Images

Figure CN119850759A_ABST
Abstract
Description
Background Art
[0002] With the development of Internet technology, images, as a medium for information transmission, have been widely used on the Internet, for example, in e-commerce marketing, content sharing, media operations, etc.
[0003] Since the requirements for images are similar in similar application scenarios, designers often prepare image templates corresponding to various application scenarios in advance in related technologies. Users can manually edit the content in the image templates to obtain images that meet their needs. However, in the face of the increasing demand for information transmission, manual editing is inefficient and has a certain learning threshold. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides an image generating method, an apparatus, an electronic device and a storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image generating method, comprising:
[0006] Acquire an image template and at least one replacement element, wherein the at least one replacement element has a corresponding relationship with at least part of the visual elements in the image template;
[0007] At least part of the visual elements are replaced with corresponding replacement elements to generate at least one target image.
[0008] In some embodiments, the image template includes at least one layer, each layer is used to display a different visual element;
[0009] Replacing at least part of the visual elements with corresponding replacement elements to generate at least one target image, comprising:
[0010] In at least one layer, determining a target layer corresponding to at least one replacement element;
[0011] Replace the visual elements displayed in the target layer with corresponding replacement elements to generate at least one target image.
[0012] In some embodiments, replacing the visual element displayed in the target layer with the corresponding replacement element includes:
[0013] When the visual element displayed in the target layer is an image element, the image element is replaced with a corresponding replacement element, and the center position of the replacement element corresponding to the image element is aligned with the center position of the image element.
[0014] In some embodiments, the method further comprises:
[0015] The replacement element corresponding to the image element is scaled so that the outline size of the scaled replacement element is less than or equal to the outline size of the image element, and the length and / or width of the scaled replacement element is equal to that of the image element.
[0016] In some embodiments, replacing the visual element displayed in the target layer with the corresponding replacement element includes:
[0017] When the visual element displayed in the target layer is a text element, the first text in the text element is replaced with the second text in the corresponding replacement element.
[0018] In some embodiments, the method further comprises:
[0019] The spacing between text elements in the target image is adjusted so that the vertical spacing between the text elements remains unchanged before and after the text elements are replaced.
[0020] In some embodiments, the method further comprises:
[0021] The size and / or position of each text element in the target image is adjusted so that all text elements in the target image are located within the text area pre-configured in the image template.
[0022] In some embodiments, each text element is configured with a maximum word count limit, the method further comprising:
[0023] When the number of characters in the second text is greater than the maximum character limit, the size of the second text is adjusted so that the second text is located within the outline range of the first text preconfigured in the image template.
[0024] In some embodiments, each text element is configured with a maximum word count limit, the method further comprising:
[0025] When the number of words in the second text is greater than the maximum word limit, semantic extraction is performed on the second text to generate a third text, where the number of words in the third text meets the maximum word limit;
[0026] Replaces the first text in a text element with the third text.
[0027] In some embodiments, each layer is configured with a layer label, and the layer label is used to indicate the visual elements in the layer;
[0028] In at least one layer, determining a target layer corresponding to at least one replacement element, respectively, includes:
[0029] For each replacement element in the at least one replacement element, perform the following processing respectively:
[0030] According to the correspondence between the replacement element and the visual element, determining a target layer label corresponding to the replacement element in the layer labels of at least one layer;
[0031] The layer corresponding to the target layer label is used as the target layer corresponding to the replacement element.
[0032] According to a second aspect of an embodiment of the present disclosure, there is provided an image generating device, including:
[0033] An acquisition module, used for acquiring an image template and at least one replacement element, wherein the at least one replacement element has a corresponding relationship with at least part of the visual elements in the image template;
[0034] A generating module is used to replace at least part of the visual elements with corresponding replacement elements to generate at least one target image.
[0035] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method of the first aspect of the embodiment of the present disclosure by executing the executable instructions.
[0036] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method of the first aspect of the embodiment of the present disclosure is implemented.
[0037] The image generation method provided by the embodiment of the present disclosure can replace at least part of the visual elements in the image template with corresponding replacement elements after acquiring the image template and at least one replacement element, thereby generating at least one target image. Wherein, a corresponding relationship is pre-configured between the replacement element and the visual element. The embodiment of the present disclosure can use the replacement element to replace the corresponding visual element in the image template, and no human intervention is required in the replacement process, which can effectively improve the efficiency of image generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of a system architecture in an embodiment of the present disclosure is shown.
[0039] Figure 2 A schematic flow chart of an image generating method in an embodiment of the present disclosure is shown.
[0040] Figure 3 A flowchart of a visual element replacement method in an embodiment of the present disclosure is shown.
[0041] Figure 4 A schematic diagram of an image template in an embodiment of the present disclosure is shown.
[0042] Figure 5A schematic structural diagram of an image generating device in an embodiment of the present disclosure is shown.
[0043] Figure 6 A schematic structural diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0044] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0045] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0046] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0047] In the related art, in order to improve the efficiency of image generation, related technicians usually use manual editing of templates to generate similar images. However, when a large number of images need to be generated, the method of manually editing image templates one by one is inefficient, and the image editing technology itself has a certain threshold for use, which requires users to have a certain learning cost.
[0048] In view of this, the solution provided by the embodiment of the present disclosure can replace at least part of the visual elements in the image template with corresponding replacement elements after acquiring the image template and at least one replacement element, thereby generating at least one target image. Among them, a corresponding relationship is pre-configured between the replacement element and the visual element. The embodiment of the present disclosure can use the replacement element to replace the corresponding visual element in the image template, and no human intervention is required in the replacement process, which can effectively improve the efficiency of image generation.
[0049] The application scenarios of the embodiments of the present disclosure are introduced below.
[0050] The method provided in the embodiment of the present disclosure can be implemented by an electronic device such as a processor executing corresponding software codes, or can be implemented by an electronic device executing corresponding software codes while interacting with a user through a terminal device. For example, the terminal device is provided with an operating system capable of running an image generation client, such as Windows, Linux, Android, etc.
[0051] Please refer to Figure 1 , Figure 1 A schematic diagram of an exemplary system architecture that can be applied to a text processing method or a text processing device in an embodiment of the present disclosure is shown.
[0052] like Figure 1 As shown, the system architecture 100 includes a terminal device 101 and a server 102. The terminal device 101 is connected to the server 102 via a network, and the network may be a wide area network or a local area network, or a combination of the two.
[0053] In some embodiments, the user can send any one or more of the selection instructions, upload instructions, and input instructions for the image template and the replacement element to the server 102 by operating the terminal device 101. After receiving the above instructions, the server 102 can obtain the corresponding image template and replacement element. Then, the server 102 can replace at least part of the visual elements in the image template with the corresponding replacement elements in response to the image generation instruction to generate a target image. The generated target image can be displayed to the user through the terminal device 101.
[0054] Exemplarily, the terminal device 101 may include a mobile phone, a smart TV, a tablet computer, a laptop computer, or a personal computer (PC), etc. A client may also be provided on the terminal device 101, and the client may be an application client or a browser client, etc.
[0055] Exemplarily, the server 102 may be a single server configured to support various services, or may be configured as a server cluster.
[0056] Those skilled in the art will know that Figure 1 The number of terminals and servers shown in the figure is only for illustration. Any number of terminals and servers may be provided according to actual needs, and the present disclosure does not impose any limitation on this.
[0057] Next, exemplary embodiments of the present disclosure will be described in detail in conjunction with the above application scenarios.
[0058] First, an image generating method is provided in an embodiment of the present disclosure, and the method can be executed by any electronic device.
[0059] Figure 2 A schematic diagram of a process of generating an image in an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the image generation method provided in the embodiment of the present disclosure includes the following steps.
[0060] S201, acquiring an image template and at least one replacement element, wherein the at least one replacement element corresponds to at least part of the visual elements in the image template.
[0061] It should be noted that the image template is a template used to generate a target image. The image template includes at least one visual element, and the target image and the image template have the same type and number of visual elements, and by properly configuring the visual elements in the target image during the image generation process, the target image can present a visual effect similar to that of the image template. Among them, the "visual element" referred to in the embodiments of the present disclosure can be text or an image, and the image here can be a static image or a dynamic image, which is not limited in the embodiments of the present disclosure.
[0062] The replacement element is a material used to replace the visual element. A corresponding relationship is pre-configured between the replacement element and the visual element so that the replacement element can be matched to the visual element that it can replace during the image generation process.
[0063] The correspondence between the replacement element and the visual element can be one-to-one, one-to-many, or many-to-one. For example, assuming that there are multiple visual elements in the image template, a replacement element can be used to replace a specific visual element in the image template, the same replacement element can be used to replace multiple visual elements, or multiple different replacement elements can be used to replace a specific visual element in the image template.
[0064] It is worth noting that each replacement element must have a corresponding visual element, but each visual element does not necessarily have a corresponding replacement element. During the image generation process, if a visual element in the image template does not have a corresponding replacement element, the visual element will not be replaced, that is, the original visual element in the image template is retained.
[0065] In some embodiments, the image template can be selected by the user from a preset template library. Exemplarily, the user can browse the template library pre-stored in the server through the terminal device. Among them, the template library can include at least one image template. In the embodiment of the present disclosure, since the target image finally generated has a similar style and visual effect to the image target, the user can select an image template that can meet the needs in the template library according to his own needs for the target image. The server can obtain the image template selected by the user in response to the user's selection operation on the image template.
[0066] It is understandable that the image template can also be edited by the user through the terminal device and uploaded to the server, thereby realizing the customization function of the template and improving the flexibility of image generation.
[0067] In some embodiments, the replacement element (eg, image element) may be uploaded to the server by the user via a terminal device, and the server may obtain the replacement element uploaded by the user in response to the user's upload operation on the replacement element.
[0068] In some embodiments, the replacement element (e.g., image element and / or text element) can be selected by the user from a preset material library. For example, the user can browse the material library pre-stored in the server through the terminal device. The material library may include at least one replacement element. The server can obtain the replacement element selected by the user in response to the user's selection operation on the replacement element.
[0069] In some embodiments, the replacement element may also be directly input by the user through a terminal device (eg, text), and the terminal device may send the content input by the user as the replacement element to the server, so that the server may obtain the replacement element input by the user.
[0070] In some embodiments, after the server obtains the image template, it can display a replacement element acquisition interface on the terminal device according to the type of visual element included in the image template. The replacement element acquisition interface is used to prompt the user to provide a corresponding replacement element. For example, when there is an image element in the image template, the user can be prompted to select or upload a replacement element to replace the image element. When there is a text element in the image template, the user can be prompted to select or input a replacement element to replace the text element.
[0071] It should be noted that the user can only provide replacement elements corresponding to some visual elements in the image template, thereby replacing only some visual elements in the image template, and the original visual elements in the image template are still retained for the visual elements for which no replacement elements are provided.
[0072] Exemplarily, the correspondence between the replacement element and the visual element can be established when the user replaces the element. For example, in the above replacement element acquisition interface, the user can be prompted to provide a replacement element corresponding to a specific visual element. If the user provides the corresponding replacement element, the correspondence between the replacement element provided by the user and the specific visual element is automatically established.
[0073] In some embodiments, the image template and replacement element may also be provided or automatically generated by a specific upstream application. For example, a large language model may be used to automatically generate text-like visual elements, and artificial intelligence may be used to draw image-like visual elements, which is not limited in the embodiments of the present disclosure.
[0074] S202: Replace at least part of the visual elements with corresponding replacement elements to generate at least one target image.
[0075] It should be noted that the number of replacement elements corresponding to the same visual element may be one or more. Specifically, when each visual element corresponds to one replacement element, each visual element may be replaced with a corresponding replacement element to generate a target image.
[0076] When a visual element corresponds to multiple replacement elements, the multiple replacement elements may be used to replace the visual element in sequence, thereby generating multiple target images corresponding to the multiple replacement elements respectively.
[0077] Similarly, when the image template has multiple visual elements corresponding to multiple replacement elements, the replacement elements of each visual element can be combined in a permutation and combination manner to obtain multiple target images corresponding to each combination. For example, when the image template includes visual element A and visual element B, visual element A corresponds to replacement element A1 and replacement element A2, and visual element B corresponds to replacement element B1 and replacement element B2. The target images generated at this time are a target image containing replacement element A1 and replacement element B1, a target image containing replacement element A1 and replacement element B2, a target image containing replacement element A2 and replacement element B1, and a target image containing replacement element A2 and replacement element B2.
[0078] In some embodiments, replacement elements of different visual elements may be pre-configured with a combination relationship, and replacement elements configured with a combination relationship can only be used to replace corresponding visual elements at the same time. For example, when the image template includes visual element A and visual element B, visual element A corresponds to replacement element A1 and replacement element A2, and visual element B corresponds to replacement element B1 and replacement element B2. Among them, a combination relationship is configured between replacement element A1 and replacement element B1, and a combination relationship is configured between replacement element A2 and replacement element B2. The target image generated at this time is a target image containing replacement element A1 and replacement element B1 and a target image containing replacement element A2 and replacement element B2.
[0079] In some embodiments, the generated target image can be displayed to the user through the terminal device, so that the user can browse and select the target image that meets his or her needs through the terminal device.
[0080] In some application scenarios, the generated target image is used for product marketing, and the click-through rate of the target image can reflect the marketing effect of the target image to a certain extent. At this time, before using the terminal device to display the generated target image, the server can input the at least one generated target image into a pre-trained click-through rate (CTR) prediction model to predict the click-through rate of the at least one target image. The server can then sort the at least one target image in descending order according to the click-through rate of the at least one target image to obtain a sorting result. The terminal device can display at least one target image according to the sorting result, so that the target image with better marketing effect is displayed to the user first, so that the user can quickly select the target image that meets his needs from a large number of target images.
[0081] Among them, the CTR prediction model can be trained by constructing a sample set including visual elements and click-through rates, which is not elaborated in the embodiments of the present disclosure.
[0082] After acquiring the image template and the replacement element, the disclosed embodiment can automatically replace the visual elements in the image template with the replacement element. No human intervention is required during the replacement process, which can effectively improve the efficiency of image generation.
[0083] The above describes the overall concept of the image generation method provided by the embodiment of the present disclosure. The following will specifically describe the method for replacing visual elements in the target template of the embodiment of the present disclosure.
[0084] Figure 3 A flow chart of a visual element replacement method according to an embodiment of the present disclosure is shown as follows: Figure 3 As shown, the visual element replacement method provided in the embodiment of the present disclosure includes the following steps.
[0085] S301: Determine, in at least one layer, a target layer to which at least one replacement element corresponds.
[0086] It should be noted that the image template may include at least one layer, and each layer is used to display different visual elements.
[0087] In some embodiments, each layer is configured with a layer label, and the layer label is used to indicate the visual elements in the layer. For example, an image template may include visual elements such as a background image, a main image, and text, and the layer labels of these visual elements may be "background image", "main image", and "text", respectively.
[0088] Exemplarily, the layer label may be recorded in the name of the layer. For example, if the layer label of a layer is “background image”, the name of the layer may be directly named “background image”.
[0089] In some embodiments, through layer tags, replacement elements can be matched to corresponding layers during the image generation process, thereby replacing visual elements in the layer.
[0090] For example, since each layer displays a different visual element, the layer label of each layer is different, so that each layer label can eventually correspond to a unique visual element. For example, an image template may include multiple text visual elements, and the layer label can be set to "text 1", "text 2", etc., in order to distinguish different visual elements.
[0091] Specifically, the following processing may be performed for each replacement element in the at least one replacement element:
[0092] According to the correspondence between the replacement element and the visual element, a target layer label corresponding to the replacement element is determined in the layer label of at least one layer. The layer corresponding to the target layer label is the target layer corresponding to the replacement element.
[0093] For example, if a replacement element corresponds to the background image in an image template, then "background image" is the target layer label corresponding to the replacement element, and the layer with the layer label "background image" is the target layer.
[0094] S302: Replace the visual elements displayed in the target layer with corresponding replacement elements to generate at least one target image.
[0095] It should be noted that when the visual element displayed in the target layer is an image element, the image element can be replaced with a corresponding replacement element, and the center position of the replacement element corresponding to the image element can be aligned with the center position of the image element, thereby achieving automatic positioning of the replacement element.
[0096] Of course, users can also select the position of the replacement element. For example, you can specify to place the replacement element in the upper left corner or upper right corner of the image template, where "upper left corner" and "upper right corner" are preset positions in the image template. You can also manually enter the distance between the replacement element and the edge of the image template to position it at any position in the image template.
[0097] In some embodiments, the replacement element corresponding to the image element can be scaled so that the outline size of the scaled replacement element is less than or equal to the outline size of the image element, and the length and / or width of the scaled replacement element is equal to that of the image element.
[0098] By scaling the replacement element, the replacement element can be made as close as possible to the size of the original image element in the image template while maintaining the original aspect ratio and not exceeding the outline range of the original image element, so that the replaced image element can present a similar visual effect to the image template.
[0099] In some embodiments, the replacement element corresponding to the image element may be preprocessed according to the requirements for the image element in the image template. For example, edge cropping, cutout, edge sharpening, and upsampling operations may be performed on the replacement element, so that the replacement element meets the requirements for the image element in the image template, so that the generated target image presents a better visual effect.
[0100] It should be noted that, when the visual element displayed in the target layer is a text element, the first text in the text element can be replaced by the second text in the corresponding replacement element.
[0101] In some embodiments, the spacing between the text elements in the target image is adjusted so that the vertical spacing between the text elements remains unchanged before and after the text elements are replaced.
[0102] In the layout of text elements, since the vertical spacing between each text element greatly affects the visual effect presented by the text element, by limiting the vertical spacing between each text element to be fixed, the replaced text element can present a visual effect similar to the original text element in the image template.
[0103] In some embodiments, the size and / or position of each text element in the target image is adjusted so that all text elements in the target image are located within the text area preconfigured in the image template.
[0104] The text area range is a pre-set area range in the image template for displaying text elements. Exemplarily, the width, height and position of the text area range can be pre-configured according to the layout and size of the image template.
[0105] For example, when the text elements and image elements in the image template are arranged horizontally, the text area range can be configured to be no less than 7% of the total width from the left and / or right margins of the image template, and no less than 10px from the margins of the image elements. At the same time, the width of the text area range itself can be configured to be 35%W to 50%W of the total width of the image template, and the length can be 10% to 60% of the total length of the image template.
[0106] When the text elements and image elements in the image template are arranged vertically, the text area range can be configured to be no less than 7% of the total width from the left and / or right margins of the image template, and no less than 10px from the margins of the image elements. At the same time, the width of the text area range itself can be configured to be 25%W to 75%W of the total width of the image template, and the length can be 5% to 45% of the total length of the image template.
[0107] The above-mentioned length refers to the side length of the image template in the longitudinal direction, and the width refers to the side length of the image template in the transverse direction.
[0108] Since the text element contains several words, by limiting the display of the text element to the text area, when the number of words in the second text is too large, the impact of a large amount of words on other visual elements can be minimized, avoiding problems such as the replaced text elements overlapping with image elements or exceeding the image template range.
[0109] For example, the sizes of the various text elements can be adjusted in the same proportion, so as to maintain similar visual effects during the adjustment process. As mentioned above, the vertical spacing between the various text elements can be kept unchanged during the adjustment process to improve the overall aesthetics.
[0110] In some embodiments, each text element is configured with a maximum character limit.
[0111] It is understandable that some text elements may have a cooperative relationship with other visual elements. For example, for an interactive text element configured with a hyperlink, an image element that cooperates with it can be set to make it eye-catching and enable users to perceive that the text element is a clickable text element. At this time, since there is a cooperative relationship between the text element and the image element, a maximum word limit can be set for the number of words in the text element, so as to avoid the area covered by the text element being too large due to too many words, causing the text element and the image element to lose coordination.
[0112] In some embodiments, when the number of words in the second text in the replacement element is greater than the maximum word limit, the size of the second text can be adjusted so that the second text is located within the outline of the first text pre-configured in the image template, thereby ensuring the coordination between the text element and other visual elements.
[0113] In some embodiments, when the number of words in the second text in the replacement element is greater than the maximum word limit, semantic extraction can also be performed on the second text to generate a third text, and the number of words in the third text meets the maximum word limit; the first text in the text element is replaced with the third text. Among them, semantic extraction can be understood as abbreviating the second text without changing the meaning of the second text to generate a third text that can meet the maximum word limit. Semantic extraction can be achieved by inputting the second text into a pre-trained natural language processing model or a large language model, which is not elaborated in the embodiments of the present disclosure.
[0114] Exemplarily, for a text element configured with a maximum word limit, when the number of words in the second text in the replacement element is greater than the maximum word limit, the size of the second text can be adjusted to ensure the coordination between the text element and other visual elements. If the second text still cannot be located within the outline of the first text after the size of the second text is adjusted to a preset minimum value, semantic extraction is performed on the second text, and the third text obtained by the semantic extraction is used to replace the first text. In this way, the replaced text element can be guaranteed to be consistent with the original input of the user as much as possible.
[0115] The solution of the disclosed embodiment can realize automatic layout of each replaced visual element, so that the generated target image can maintain the image style of the original image template as much as possible. The process does not require manual parameters, thereby reducing the workload of relevant technical personnel and effectively improving the quality and efficiency of image generation.
[0116] The application process of the image generation method in the embodiment of the present disclosure will be described in detail below in combination with specific application scenarios.
[0117] For example, assuming that the user wants to use the generated target image for product marketing, the user may select Figure 4 Specifically, the image template may include visual elements such as a first text element (marketing text) 401, a second text element (button text) 402, a first picture element (product picture) 403, and a second picture element (background picture) 404. Among them, the button text is a text element with a hyperlink added and can be triggered by clicking.
[0118] The terminal device may display a replacement element acquisition interface, and first prompt the user to upload a replacement element corresponding to the first image element 403. Subsequently, the user is prompted to input a first text element 401 and a second text element 402 for describing the first image element 403. As for the second image element 404, since the processing of the background image is relatively complex and has a low relevance to the product, the user may be prompted to select a corresponding replacement element from a preset material library. Exemplarily, the background image may be classified by industry in the material library, and the user may select the industry corresponding to the product, thereby completing the selection of the background image replacement element.
[0119] After the user confirms that the replacement element is correct, the terminal device can send an image generation instruction to the server. After receiving the image generation instruction, the server can replace the replacement element provided by the user with the visual element corresponding to the image template in the manner described above, thereby generating a target image.
[0120] The generated target image can be displayed to the user through the terminal device, and the user can perform a selection operation on the target image through the terminal device to complete the selection and saving of the target image.
[0121] Based on the same inventive concept, the present disclosure also provides an image generation device in the following embodiments. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0122] Figure 5 A schematic diagram of the structure of an image generating device in an embodiment of the present disclosure is shown. Figure 5 As shown, the image generating device 500 includes: an acquisition module 501 and a generation module 502 .
[0123] The acquisition module 501 is used to acquire an image template and at least one replacement element, and there is a corresponding relationship between the at least one replacement element and at least part of the visual elements in the image template;
[0124] The generating module 502 is configured to replace at least part of the visual elements with corresponding replacement elements to generate at least one target image.
[0125] In some embodiments, the image template includes at least one layer, each layer is used to display different visual elements. The generation module 502 is specifically used to, in the at least one layer, determine a target layer corresponding to at least one replacement element; replace the visual element displayed in the target layer with the corresponding replacement element to generate at least one target image.
[0126] In some embodiments, the generation module 502 is specifically used to, when the visual element displayed in the target layer is an image element, replace the image element with a corresponding replacement element, and align the center position of the replacement element corresponding to the image element with the center position of the image element.
[0127] In some embodiments, the generation module 502 is further used to scale the replacement element corresponding to the image element so that the outline size of the scaled replacement element is less than or equal to the outline size of the image element, and the length and / or width of the scaled replacement element is equal to the image element.
[0128] In some embodiments, the generating module 502 is specifically used to replace the visual element displayed in the target layer with the corresponding replacement element, including:
[0129] When the visual element displayed in the target layer is a text element, the first text in the text element is replaced with the second text in the corresponding replacement element.
[0130] In some embodiments, the generating module 502 is further used to adjust the spacing between the text elements in the target image so that the vertical spacing between the text elements remains unchanged before and after the text elements are replaced.
[0131] In some embodiments, the generating module 502 is further used to adjust the size and / or position of each text element in the target image so that all text elements in the target image are located within the text area preconfigured in the image template.
[0132] In some embodiments, each text element is configured with a maximum word limit, and the generation module 502 is also used to adjust the size of the second text when the number of words in the second text is greater than the maximum word limit so that the second text is located within the outline of the first text pre-configured in the image template.
[0133] In some embodiments, each text element is configured with a maximum word limit, and the generation module 502 is also used to, when the number of words in the second text is greater than the maximum word limit, perform semantic extraction on the second text to generate a third text, and the number of words in the third text meets the maximum word limit; replace the first text in the text element with the third text.
[0134] In some embodiments, each layer is configured with a layer label, and the layer label is used to indicate the visual element in the layer. The generation module 502 is also used to perform the following processing on each replacement element in the at least one replacement element: according to the correspondence between the replacement element and the visual element, determine the target layer label corresponding to the replacement element in the layer label of at least one layer; and use the layer corresponding to the target layer label as the target layer corresponding to the replacement element.
[0135] It should be noted that, when the image generation device provided in the above embodiment is used for image generation, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the image generation device provided in the above embodiment and the image generation method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0136] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0137] Refer to the following Figure 6 hereinafter, an electronic device 600 capable of implementing the embodiments of the present disclosure is described. Figure 6 The electronic device 600 shown is only an example and should not bring any limitation to the functions and applicable scope of the embodiments of the present disclosure.
[0138] like Figure 6 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).
[0139] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 executes the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of the present disclosure.
[0140] In some embodiments, the processing unit 610 can perform the following steps of the above-mentioned method embodiment: obtain an image template and at least one replacement element, and there is a corresponding relationship between the at least one replacement element and at least part of the visual elements in the image template; replace at least part of the visual elements with corresponding replacement elements to generate at least one target image.
[0141] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0142] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0143] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0144] The electronic device 600 may also communicate with one or more external devices 640 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 600, and / or any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 660. Figure 6 As shown, the network adapter 660 communicates with other modules of the electronic device 600 via the bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0145] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0146] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the above-mentioned method of the present disclosure is stored thereon. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above-mentioned "Exemplary Method" section of the present disclosure.
[0147] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0148] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0149] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0150] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0151] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0152] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0153] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0154] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. An image generation method, characterized in that: include: Acquire an image template and at least one replacement element, wherein the at least one replacement element has a corresponding relationship with at least part of the visual elements in the image template; The at least part of the visual elements are replaced with corresponding replacement elements to generate at least one target image.
2. The method according to claim 1, characterized in that The image template includes at least one layer, each layer is used to display different visual elements; The replacing at least part of the visual elements with corresponding replacement elements to generate at least one target image comprises: In the at least one layer, determining a target layer to which the at least one replacement element corresponds respectively; Replace the visual elements displayed in the target layer with corresponding replacement elements to generate at least one target image.
3. The method according to claim 2, characterized in that The step of replacing the visual elements displayed in the target layer with corresponding replacement elements includes: When the visual element displayed in the target layer is an image element, the image element is replaced with a corresponding replacement element, and the center position of the replacement element corresponding to the image element is aligned with the center position of the image element.
4. The method according to claim 3, characterized in that The method further comprises: The replacement element corresponding to the image element is scaled so that the outline size of the scaled replacement element is smaller than or equal to the outline size of the image element, and the length and / or width of the scaled replacement element is equal to that of the image element.
5. The method according to claim 2, characterized in that: The step of replacing the visual elements displayed in the target layer with corresponding replacement elements includes: When the visual element displayed in the target layer is a text element, the first text in the text element is replaced with the second text in the corresponding replacement element.
6. The method according to claim 5, characterized in that The method further comprises: The spacing between text elements in the target image is adjusted so that the vertical spacing between the text elements remains unchanged before and after the text elements are replaced.
7. The method according to claim 5, characterized in that The method further comprises: The size and / or position of each text element in the target image is adjusted so that all text elements in the target image are located within the text area preconfigured in the image template.
8. The method according to claim 5, characterized in that Each text element is configured with a maximum character limit, and the method further comprises: When the number of characters in the second text is greater than the maximum character limit, the size of the second text is adjusted so that the second text is located within the contour range of the first text pre-configured in the image template.
9. The method according to claim 5, characterized in that Each text element is configured with a maximum character limit, and the method further comprises: When the number of words in the second text is greater than the maximum word limit, semantic extraction is performed on the second text to generate a third text, where the number of words in the third text meets the maximum word limit; The first text in the text element is replaced by the third text.
10. The method according to claim 2, characterized in that Each layer is configured with a layer label, wherein the layer label is used to indicate a visual element in the layer; The step of determining, in the at least one layer, a target layer corresponding to each of the at least one replacement element comprises: For each replacement element in the at least one replacement element, the following processing is performed respectively: According to the correspondence between the replacement element and the visual element, determining a target layer label corresponding to the replacement element in the layer label of the at least one layer; The layer corresponding to the target layer label is used as the target layer corresponding to the replacement element.
11. An image generating device, characterized in that: include: An acquisition module, configured to acquire an image template and at least one replacement element, wherein the at least one replacement element corresponds to at least part of the visual elements in the image template; A generating module is used to replace at least part of the visual elements with corresponding replacement elements to generate at least one target image.
12. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 10 by executing the executable instructions.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.