HK40070017B - Image processing method and apparatus, device, and storage medium - Google Patents
Image processing method and apparatus, device, and storage mediumInfo
- Publication number
- HK40070017B HK40070017B HK42022059855.1A HK42022059855A HK40070017B HK 40070017 B HK40070017 B HK 40070017B HK 42022059855 A HK42022059855 A HK 42022059855A HK 40070017 B HK40070017 B HK 40070017B
- Authority
- HK
- Hong Kong
- Prior art keywords
- image
- image data
- size
- data
- target
- Prior art date
Links
Description
技术领域Technical Field
本申请涉及多媒体技术领域,特别涉及一种图像处理方法、装置、设备及存储介质。This application relates to the field of multimedia technology, and in particular to an image processing method, apparatus, device and storage medium.
背景技术Background Technology
随着多媒体技术的发展,多媒体技术的应用越来越广泛,也给生活带来了便利。图像处理技术即为一种多媒体技术,通过编辑操作,对图像的内容进行编辑,然后生成图像,以图像作为宣传媒介,能够达到较好的宣传效果。With the development of multimedia technology, its applications are becoming increasingly widespread, bringing convenience to our lives. Image processing technology is a type of multimedia technology. Through editing operations, the content of images is modified and then generated into a new image. Using images as a promotional medium can achieve good promotional results.
目前,图像处理方法通常由用户将模板图像以及制作的一些物料元素上传至服务器,设定好图像内容的编辑需求,由服务器生成图像后反馈给用户。用户看到服务器生成的图片后,如果不满意,可以再修改编辑需求,再由服务器生成新的图像,直至用户满意为止。Currently, image processing typically involves users uploading a template image and some material elements they've created to a server, specifying their editing requirements, and then the server generates the image and sends it back to the user. If the user is not satisfied with the image generated by the server, they can modify their editing requirements, and the server will generate a new image again, until the user is satisfied.
上述图像处理方法中,用户设置编辑需求由服务器生成图像,用户在设置编辑需求时无法获知处理效果,因而需要反复修改,终端与服务器之间需要进行多次通信,生成一个图像需要执行多次生成步骤,因而,上述图像处理方法的成本高,处理效率很低,且不能很好的满足用户需求,处理效果差。且上述方法仅涉及到对图像内容的编辑处理,如果用户想要打印服务器生成的图像进行宣传时,上述图像无法直接用于打印,打印效果很模糊,还需要用户从服务器下载该图像,通过图像处理软件,再对该图像进行进一步处理,因而,上述图像处理方法的实用性和适用性也很差。In the aforementioned image processing methods, the user sets editing requirements, and the server generates the image. The user cannot see the processing effect when setting these requirements, thus necessitating repeated modifications. Multiple communications are required between the terminal and the server, and generating a single image requires multiple generation steps. Therefore, these image processing methods are costly, inefficient, and fail to adequately meet user needs, resulting in poor processing quality. Furthermore, these methods only involve editing the image content. If a user wants to print the server-generated image for advertising, the image cannot be directly used for printing; the printed result will be blurry. The user must then download the image from the server and further process it using image processing software. Therefore, the practicality and applicability of these image processing methods are also poor.
发明内容Summary of the Invention
本申请实施例提供了一种图像处理方法、装置、设备及存储介质,能够降低成本,提高图像处理效率,提高实用性和适用性。所述技术方案如下:This application provides an image processing method, apparatus, device, and storage medium, which can reduce costs, improve image processing efficiency, and enhance practicality and applicability. The technical solution is as follows:
一方面,提供了一种图像处理方法,所述方法包括:On the one hand, an image processing method is provided, the method comprising:
响应于模板选择指令,显示选中的模板图像;In response to a template selection command, display the selected template image;
响应于对所述模板图像的编辑操作,基于第一图像数据,显示第一图像,所述第一图像数据基于所述编辑操作对所述模板图像的图像数据处理得到;In response to an editing operation on the template image, a first image is displayed based on first image data, wherein the first image data is obtained by processing the image data of the template image based on the editing operation;
响应于图像生成指令,基于目标分辨率,对所述第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,所述第二图像的分辨率为所述目标分辨率。In response to the image generation instruction, the resolution field data in the first image data is updated based on the target resolution to obtain the second image data of the second image, wherein the resolution of the second image is the target resolution.
在一种可能实现方式中,所述模板图像包括标题、背景、文本、图标、横幅中的至少一项元素,所述对所述模板图像的编辑操作为对所述至少一项元素中任一项元素的拖拽操作、缩放操作、颜色设置操作、更换操作中的任一项。In one possible implementation, the template image includes at least one element selected from title, background, text, icon, and banner, and the editing operation on the template image is any one of dragging, scaling, color setting, or changing any of the at least one elements.
一方面,提供了一种图像处理装置,所述装置包括:On one hand, an image processing apparatus is provided, the apparatus comprising:
显示模块,用于响应于模板选择指令,显示选中的模板图像;The display module is used to display the selected template image in response to the template selection command;
所述显示模块,还用于响应于对所述模板图像的编辑操作,基于第一图像数据,显示第一图像,所述第一图像数据基于所述编辑操作对所述模板图像的图像数据处理得到;The display module is further configured to, in response to an editing operation on the template image, display a first image based on first image data, wherein the first image data is obtained by processing the image data of the template image based on the editing operation;
更新模块,用于响应于图像生成指令,基于目标分辨率,对所述第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,所述第二图像的分辨率为所述目标分辨率。An update module is used to update the resolution field data in the first image data based on the target resolution in response to an image generation instruction, so as to obtain the second image data of the second image, wherein the resolution of the second image is the target resolution.
在一种可能实现方式中,所述更新模块用于将所述第一图像数据中分辨率字段数据替换为所述目标分辨率对应的数据,得到第二图像的第二图像数据。In one possible implementation, the update module is used to replace the resolution field data in the first image data with the data corresponding to the target resolution to obtain the second image data of the second image.
在一种可能实现方式中,所述更新模块包括绘制单元、获取单元和更新单元;In one possible implementation, the update module includes a drawing unit, an acquisition unit, and an update unit;
所述绘制单元用于基于所述目标分辨率,将所述显示的所述第一图像绘制到画布上;The drawing unit is used to draw the displayed first image onto the canvas based on the target resolution;
所述获取单元用于获取所述画布的图像数据;The acquisition unit is used to acquire image data of the canvas;
所述更新单元用于基于所述画布的图像数据,执行所述分辨率字段数据更新的步骤。The update unit is used to perform the step of updating the resolution field data based on the image data of the canvas.
在一种可能实现方式中,所述获取单元用于基于浏览器应用的目标应用程序接口,获取所述画布的图像数据。In one possible implementation, the acquisition unit is used to acquire the image data of the canvas based on the target application programming interface of the browser application.
在一种可能实现方式中,所述第一图像数据为基于base64的编码数据;In one possible implementation, the first image data is base64-encoded data;
所述更新模块用于将所述第一图像的编码数据中分辨率字段数据替换为所述目标分辨率对应的十六进制数据,得到第二图像的第二图像数据。The update module is used to replace the resolution field data in the encoded data of the first image with hexadecimal data corresponding to the target resolution, so as to obtain the second image data of the second image.
在一种可能实现方式中,所述显示模块用于:In one possible implementation, the display module is used for:
响应于模板选择指令,获取选中的模板图像的图像数据和第一尺寸;In response to the template selection command, obtain the image data and first size of the selected template image;
基于所述目标分辨率、所述第一尺寸和所述模板图像的图像数据,获取预览图像的图像数据;Based on the target resolution, the first size, and the image data of the template image, obtain the image data of the preview image;
基于所述预览图像的图像数据,显示所述预览图像。The preview image is displayed based on the image data of the preview image.
在一种可能实现方式中,所述显示模块用于:In one possible implementation, the display module is used for:
基于目标分辨率对应的目标转换关系,获取所述第一尺寸对应的第二尺寸,所述第一尺寸的单位为第一单位,所述第二尺寸的单位为第二单位,所述目标转换关系为第一单位为第二单位之间的转换关系;Based on the target transformation relationship corresponding to the target resolution, the second size corresponding to the first size is obtained, where the unit of the first size is the first unit, the unit of the second size is the second unit, and the target transformation relationship is the transformation relationship between the first unit and the second unit;
根据所述第二尺寸和预览显示区域的第三尺寸,对所述模板图像的图像数据进行缩放处理,得到所述预览图像的图像数据,所述预览图像的尺寸为所述第三尺寸;Based on the second size and the third size of the preview display area, the image data of the template image is scaled to obtain the image data of the preview image, wherein the size of the preview image is the third size;
在一种可能实现方式中,所述显示模块用于基于所述预览图像的图像数据,在所述预览显示区域中显示所述预览图像。In one possible implementation, the display module is used to display the preview image in the preview display area based on the image data of the preview image.
在一种可能实现方式中,所述更新模块用于:In one possible implementation, the update module is used to:
基于所述目标转换关系,获取所述第三尺寸对应的第四尺寸,所述第三尺寸的单位为所述第二单位,第四尺寸的单位为所述第一单位;Based on the target transformation relationship, the fourth dimension corresponding to the third dimension is obtained, wherein the unit of the third dimension is the second unit and the unit of the fourth dimension is the first unit;
根据所述第四尺寸和所述第一尺寸,对所述第一图像数据进行缩放处理,得到第三图像的第三图像数据,所述第三图像的尺寸为所述第一尺寸;Based on the fourth size and the first size, the first image data is scaled to obtain the third image data of the third image, wherein the size of the third image is the first size;
基于所述目标分辨率,对所述第三图像的第三图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,所述第二图像的尺寸为所述第一尺寸。Based on the target resolution, the resolution field data in the third image data of the third image is updated to obtain the second image data of the second image, and the size of the second image is the first size.
在一种可能实现方式中,所述装置还包括:In one possible implementation, the device further includes:
第一存储模块,用于将所述第二图像数据发送至目标服务器进行存储,所述目标服务器用于对图像数据进行存储管理。The first storage module is used to send the second image data to the target server for storage, and the target server is used to manage the storage of the image data.
在一种可能实现方式中,所述显示模块用于响应于对所述预览图像的编辑操作,基于第一图像数据,显示第一图像,所述第一图像的尺寸为所述第三尺寸;In one possible implementation, the display module is configured to display a first image based on first image data in response to an editing operation on the preview image, wherein the size of the first image is the third size;
所述更新模块用于基于所述目标分辨率,对所述第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,所述第二图像数据中所述第二图像的尺寸为第三尺寸;The update module is used to update the resolution field data in the first image data based on the target resolution to obtain the second image data of the second image, wherein the size of the second image in the second image data is the third size;
所述装置还包括:The device further includes:
第二存储模块,用于将所述第二图像数据以及第一尺寸发送至服务器进行存储;The second storage module is used to send the second image data and the first size to the server for storage;
获取模块,用于响应于对所述第二图像的获取指令,从所述服务器中获取所述第二图像数据和所述第一尺寸;An acquisition module is configured to, in response to an acquisition instruction for the second image, acquire the second image data and the first size from the server;
绘制模块,用于基于所述第二图像数据和所述第一尺寸,绘制所述第二图像,得到所述第一尺寸的第四图像。A drawing module is used to draw the second image based on the second image data and the first size, thereby obtaining a fourth image of the first size.
在一种可能实现方式中,所述装置还包括:In one possible implementation, the device further includes:
修改模块,用于响应于对目标接口的配置修改指令,将所述目标接口的数据传输限制阈值从第一阈值修改为第二阈值,所述第二阈值大于所述第一阈值,所述目标接口用于传输所述第二图像数据。The modification module is used to modify the data transmission restriction threshold of the target interface from a first threshold to a second threshold in response to a configuration modification instruction for the target interface. The second threshold is greater than the first threshold, and the target interface is used to transmit the second image data.
在一种可能实现方式中,所述装置还包括:In one possible implementation, the device further includes:
压缩模块,用于对所述第二图像数据进行压缩处理,得到所述第二图像的压缩数据;A compression module is used to compress the second image data to obtain compressed data of the second image;
第三存储模块,用于将所述压缩数据发送至服务器进行存储。The third storage module is used to send the compressed data to the server for storage.
在一种可能实现方式中,所述模板图像包括标题、背景、文本、图标、横幅中的至少一项元素,所述对所述模板图像的编辑操作为对所述至少一项元素中任一项元素的拖拽操作、缩放操作、颜色设置操作、更换操作中的任一项。In one possible implementation, the template image includes at least one element selected from title, background, text, icon, and banner, and the editing operation on the template image is any one of dragging, scaling, color setting, or changing any of the at least one elements.
一方面,提供了一种电子设备,所述电子设备包括一个或多个处理器和一个或多个存储器,所述一个或多个存储器中存储有至少一条程序代码,所述至少一条程序代码由所述一个或多个处理器加载并执行以实现上述图像处理方法的各种可选实现方式。On one hand, an electronic device is provided, comprising one or more processors and one or more memories, wherein at least one piece of program code is stored in the one or more memories, and the at least one piece of program code is loaded and executed by the one or more processors to implement various optional implementations of the above-described image processing method.
一方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条程序代码,所述至少一条程序代码由处理器加载并执行以实现上述图像处理方法的各种可选实现方式。On the one hand, a computer-readable storage medium is provided, wherein at least one piece of program code is stored therein, the at least one piece of program code being loaded and executed by a processor to implement various optional implementations of the above-described image processing method.
一个方面,提供了一种计算机程序产品或计算机程序,所述计算机程序产品或所述计算机程序包括一条或多条程序代码,所述一条或多条程序代码存储在计算机可读存储介质中。电子设备的一个或多个处理器能够从计算机可读存储介质中读取所述一条或多条程序代码,所述一个或多个处理器执行所述一条或多条程序代码,使得电子设备能够执行上述任一种可能实施方式的图像处理方法。In one aspect, a computer program product or computer program is provided, the computer program product or computer program comprising one or more lines of program code stored in a computer-readable storage medium. One or more processors of an electronic device are capable of reading the one or more lines of program code from the computer-readable storage medium, and the one or more processors execute the one or more lines of program code, enabling the electronic device to perform the image processing method of any of the above possible embodiments.
本公开实施例提供了一种在线编辑图像的方法,能够显示选中的模板图像,且能够根据用户的编辑操作对编辑结果进行显示,实现了所见即所得,生成的图像更容易符合用户需求,无需反复修改,终端与服务器之间无需多次通信,能够有效减少图像处理方法的成本,提高处理效率。且在生成第二图像时,能够将编辑操作后的图像的分辨率进行更新,生成目标分辨率的图像,这样设备自动生成分辨率符合要求的图像,无需用户下载服务器生成的图像再手动编辑,因而,减少了用户操作,进一步提高了图像处理效率,该图像处理方法的实用性和适用性也更好。This disclosure provides a method for online image editing, capable of displaying selected template images and showing editing results based on user actions, achieving a WYSIWYG (What You See Is What You Get) experience. The generated images more readily meet user needs, eliminating the need for repeated modifications. Multiple communications between the terminal and server are unnecessary, effectively reducing the cost of image processing and improving efficiency. Furthermore, when generating a second image, the resolution of the edited image is updated to the target resolution. This allows the device to automatically generate an image with the required resolution, eliminating the need for users to download and manually edit images generated by the server. This reduces user operations, further improving image processing efficiency and enhancing the practicality and applicability of the image processing method.
附图说明Attached Figure Description
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还能够根据这些附图获得其他的附图。To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
图1是本申请实施例提供的一种图像处理方法的实施环境的示意图;Figure 1 is a schematic diagram of the implementation environment of an image processing method provided in an embodiment of this application;
图2是本申请实施例提供的一种图像处理方法的流程图;Figure 2 is a flowchart of an image processing method provided in an embodiment of this application;
图3是本申请实施例提供的一种图像处理方法的流程图;Figure 3 is a flowchart of an image processing method provided in an embodiment of this application;
图4是本申请实施例提供的一种图像生成页面的示意图;Figure 4 is a schematic diagram of an image generation page provided in an embodiment of this application;
图5是本申请实施例提供的一种目标转换关系的示意图;Figure 5 is a schematic diagram of a target transformation relationship provided in an embodiment of this application;
图6是本申请实施例提供的一种度量单位计算器的示意图;Figure 6 is a schematic diagram of a unit of measurement calculator provided in an embodiment of this application;
图7是本申请实施例提供的一种模板图像的示意图;Figure 7 is a schematic diagram of a template image provided in an embodiment of this application;
图8是本申请实施例提供的一种模板图像的示意图;Figure 8 is a schematic diagram of a template image provided in an embodiment of this application;
图9是本申请实施例提供的一种图像处理方法的流程图;Figure 9 is a flowchart of an image processing method provided in an embodiment of this application;
图10是本申请实施例提供的一种编码数据的示意图;Figure 10 is a schematic diagram of encoded data provided in an embodiment of this application;
图11是本申请实施例提供的一种编码数据的示意图;Figure 11 is a schematic diagram of encoded data provided in an embodiment of this application;
图12是本申请实施例提供的一种图像处理方法的流程图;Figure 12 is a flowchart of an image processing method provided in an embodiment of this application;
图13是本申请实施例提供的一种图像处理方法的流程图;Figure 13 is a flowchart of an image processing method provided in an embodiment of this application;
图14是本申请实施例提供的一种本申请和传统方案的对比图;Figure 14 is a comparison diagram of an embodiment of this application and a conventional solution;
图15是本申请实施例提供的一种图像处理装置的结构示意图;Figure 15 is a schematic diagram of the structure of an image processing device provided in an embodiment of this application;
图16是本申请实施例提供的一种终端的结构框图;Figure 16 is a structural block diagram of a terminal provided in an embodiment of this application;
图17是本申请实施例提供的一种服务器的结构示意图。Figure 17 is a schematic diagram of the structure of a server provided in an embodiment of this application.
具体实施方式Detailed Implementation
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
本申请中术语“第一”“第二”等字样用于对作用和功能基本相同的相同项或相似项进行区分,应理解,“第一”、“第二”、“第n”之间不具有逻辑或时序上的依赖关系,也不对数量和执行顺序进行限定。还应理解,尽管以下描述使用术语第一、第二等来描述各种元素,但这些元素不应受术语的限制。这些术语只是用于将一元素与另一元素区别分开。例如,在不脱离各种示例的范围的情况下,第一图像能够被称为第二图像,并且类似地,第二图像能够被称为第一图像。第一图像和第二图像都能够是图像,并且在某些情况下,能够是单独且不同的图像。In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have substantially the same function and purpose. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another. For example, without departing from the scope of various examples, a first image can be referred to as a second image, and similarly, a second image can be referred to as a first image. Both the first image and the second image can be images, and in some cases, they can be separate and distinct images.
本申请中术语“至少一个”的含义是指一个或多个,本申请中术语“多个”的含义是指两个或两个以上,例如,多个数据包是指两个或两个以上的数据包。In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple data packets means two or more data packets.
应理解,在本文中对各种示例的描述中所使用的术语只是为了描述特定示例,而并非旨在进行限制。如在对各种示例的描述和所附权利要求书中所使用的那样,单数形式“一个(“a”“an”)”和“该”旨在也包括复数形式,除非上下文另外明确地指示。It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing the particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise.
还应理解,本文中所使用的术语“和/或”是指并且涵盖相关联的所列出的项目中的一个或多个项目的任何和全部可能的组合。术语“和/或”,是一种描述关联对象的关联关系,表示能够存在三种关系,例如,A和/或B,能够表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本申请中的字符“/”,一般表示前后关联对象是一种“或”的关系。It should also be understood that the term "and/or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items. The term "and/or" describes an association between related objects, indicating that three relationships can exist; for example, A and/or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character "/" in this application generally indicates that the preceding and following related objects are in an "or" relationship.
还应理解,在本申请的各个实施例中,各个过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
还应理解,根据A确定B并不意味着仅仅根据A确定B,还能够根据A和/或其它信息确定B。It should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and/or other information.
还应理解,术语“包括”(也称“inCludes”、“inCluding”、“Comprises”和/或“Comprising”)当在本说明书中使用时指定存在所陈述的特征、整数、步骤、操作、元素、和/或部件,但是并不排除存在或添加一个或多个其他特征、整数、步骤、操作、元素、部件、和/或其分组。It should also be understood that the term “comprising” (also referred to as “inCludes”, “inCluding”, “Comprises”, and/or “Comprising”) as used in this specification specifies the presence of the stated features, integers, steps, operations, elements, and/or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
还应理解,术语“如果”可被解释为意指“当...时”(“when”或“upon”)或“响应于确定”或“响应于检测到”。类似地,根据上下文,短语“如果确定...”或“如果检测到[所陈述的条件或事件]”可被解释为意指“在确定...时”或“响应于确定...”或“在检测到[所陈述的条件或事件]时”或“响应于检测到[所陈述的条件或事件]”。It should also be understood that the term "if" can be interpreted as meaning "when" or "upon" or "in response to determination" or "in response to detection". Similarly, depending on the context, the phrases "if determination..." or "if detection [the stated condition or event]" can be interpreted as meaning "when determination..." or "in response to determination..." or "when detection [the stated condition or event]" or "in response to detection [the stated condition or event]".
下面对本申请的实施环境进行说明。The implementation environment of this application is described below.
图1是本申请实施例提供的一种图像处理方法的实施环境的示意图。该实施环境包括终端101,或者该实施环境包括终端101和图像处理平台102。终端101通过无线网络或有线网络与图像处理平台102相连。Figure 1 is a schematic diagram of an implementation environment for an image processing method provided in an embodiment of this application. The implementation environment includes a terminal 101, or it includes a terminal 101 and an image processing platform 102. The terminal 101 is connected to the image processing platform 102 via a wireless network or a wired network.
终端101能够是智能手机、游戏主机、台式计算机、平板电脑、电子书阅读器、MP3(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)播放器或MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器,膝上型便携计算机中的至少一种。终端101安装和运行有支持图像处理的应用程序,例如,该应用程序能够是系统应用、即时通讯应用、新闻推送应用、购物应用、在线视频应用、社交应用。Terminal 101 can be at least one of a smartphone, game console, desktop computer, tablet computer, e-book reader, MP3 (Moving Picture Experts Group Audio Layer III) player or MP4 (Moving Picture Experts Group Audio Layer IV) player, or laptop computer. Terminal 101 has an application that supports image processing installed and running; for example, the application can be a system application, an instant messaging application, a news push application, a shopping application, an online video application, or a social application.
示例性地,该终端101能够具有图像处理功能,能够对图像进行处理,并根据处理结果执行相应的功能。该终端101能够独立完成该工作,也能够通过图像处理平台102为其提供图像处理服务。本申请实施例对此不作限定。For example, the terminal 101 can have image processing capabilities, enabling it to process images and execute corresponding functions based on the processing results. The terminal 101 can perform this task independently or can be provided with image processing services by the image processing platform 102. This application embodiment does not limit this aspect.
终端101通过安装的客户端实现图像处理功能,或该终端101访问该图像处理平台102的门户网站,在该门户网站中实现图像处理功能。Terminal 101 implements image processing functions through an installed client, or terminal 101 accesses the portal website of the image processing platform 102 and implements image processing functions in the portal website.
示例性地,该终端101安装有浏览器应用,通过在浏览器应用中访问图像处理平台102的网站,也即是终端101显示图像处理平台102提供的页面,根据用户在页面中的编辑操作,由图像处理平台102提供图像处理服务。For example, the terminal 101 is equipped with a browser application. By accessing the website of the image processing platform 102 through the browser application, that is, the terminal 101 displays the page provided by the image processing platform 102. Based on the user's editing operations on the page, the image processing platform 102 provides image processing services.
图像处理平台102包括一台服务器、多台服务器、云计算平台和虚拟化中心中的至少一种。图像处理平台102用于为支图像处理的应用程序提供后台服务。可选地,图像处理平台102承担主要处理工作,终端101承担次要处理工作;或者,图像处理平台102承担次要处理工作,终端101承担主要处理工作;或者,图像处理平台102或终端101分别能够单独承担处理工作。或者,图像处理平台102和终端101两者之间采用分布式计算架构进行协同计算。Image processing platform 102 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. Image processing platform 102 provides background services for image processing applications. Optionally, image processing platform 102 undertakes the primary processing task, and terminal 101 undertakes secondary processing tasks; or, image processing platform 102 undertakes secondary processing tasks, and terminal 101 undertakes primary processing tasks; or, image processing platform 102 or terminal 101 can each independently undertake processing tasks. Alternatively, image processing platform 102 and terminal 101 can collaborate using a distributed computing architecture.
可选地,该图像处理平台102包括至少一台服务器1021以及数据库1022,该数据库1022用于存储数据,在本申请实施例中,该数据库1022中能够存储模板图像,为至少一台服务器1021提供数据服务。Optionally, the image processing platform 102 includes at least one server 1021 and a database 1022. The database 1022 is used to store data. In this embodiment, the database 1022 can store template images to provide data services to at least one server 1021.
服务器能够是独立的物理服务器,也能够是多个物理服务器构成的服务器集群或者分布式系统,还能够是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN、以及大数据和人工智能平台等基础云计算服务的云服务器。终端能够是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表等,但并不局限于此。Servers can be standalone physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminals can be smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, etc., but are not limited to these.
本领域技术人员能够知晓,上述终端101、服务器1021的数量能够更多或更少。比如上述终端101、服务器1021能够仅为一个,或者上述终端101、服务器1021为几十个或几百个,或者更多数量,本申请实施例对终端或服务器的数量和设备类型不加以限定。Those skilled in the art will understand that the number of terminals 101 and servers 1021 can be more or less. For example, there may be only one terminal 101 and server 1021, or there may be dozens or hundreds of terminals 101 and servers 1021, or even more. The embodiments of this application do not limit the number or type of terminals or servers.
图2是本申请实施例提供的一种图像处理方法的流程图,该方法应用于电子设备中,该电子设备为终端或服务器,参见图2,该方法包括以下步骤。Figure 2 is a flowchart of an image processing method provided in an embodiment of this application. The method is applied in an electronic device, which is a terminal or a server. Referring to Figure 2, the method includes the following steps.
201、电子设备响应于模板选择指令,显示选中的模板图像。201. The electronic device responds to the template selection command and displays the selected template image.
该模板是指作图或设计方案的固定格式。模板是将一个事物的结构规律予以固定化、标准化的成果,它体现的是结构形式的标准化。模板图像是指用于制作图像的模板。在该模板图像包括图像的一些元素,例如,标题、背景、文本、图标、横幅等。A template refers to a fixed format for drawing or design schemes. A template is the result of fixing and standardizing the structural rules of something; it embodies the standardization of structural form. A template image refers to a template used to create an image. This template image includes elements such as titles, backgrounds, text, icons, and banners.
根据图像包括的元素种类的不同,或者图像中元素的位置或样式的不同,可以制作一些模板图像,后续制作图像时,选择一个模板图像,对其进行编辑处理以改变图像内容,即可快速生成需求的图像。Depending on the types of elements included in the image, or the position or style of the elements in the image, some template images can be created. When creating an image later, a template image can be selected and edited to change the image content, thus quickly generating the image you need.
202、电子设备响应于对该模板图像的编辑操作,基于第一图像数据,显示第一图像,该第一图像数据基于该编辑操作对该模板图像的图像数据处理得到。202. In response to an editing operation on the template image, the electronic device displays a first image based on first image data, the first image data being obtained by processing the image data of the template image based on the editing operation.
用户选择模板图像后,能够根据自己的需求对模板图像进行编辑,以生成个性化的图像。在一种可能实现方式中,该编辑操作是对模板图像中任一元素的编辑操作,例如,可以是更换背景操作,或者编辑标题操作,或者对图标位置的拖拽操作等。After selecting a template image, users can edit it according to their needs to generate a personalized image. In one possible implementation, this editing operation can be an operation on any element in the template image, such as changing the background, editing the title, or dragging the icon.
可以理解地,上述模板图像在电子设备以图像数据的方式存在,在执行该编辑操作时,电子设备可以对图像数据进行处理。编辑操作结束后,该模板图像的图像数据则变成第一图像数据。Understandably, the aforementioned template image exists as image data on the electronic device, and the electronic device can process the image data during the editing operation. After the editing operation is completed, the image data of the template image becomes the first image data.
203、电子设备响应于图像生成指令,基于目标分辨率,对该第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,该第二图像的分辨率为该目标分辨率。203. In response to the image generation instruction, the electronic device updates the resolution field data in the first image data based on the target resolution to obtain the second image data of the second image, wherein the resolution of the second image is the target resolution.
目标分辨率为该第二图像使用所需求的分辨率,例如,该目标分辨率为打印该第二图像所需求的分辨率,也即是该目标分辨率为满足该第二图像的打印需求的分辨率。The target resolution is the resolution required for the use of the second image. For example, the target resolution is the resolution required for printing the second image, that is, the target resolution is the resolution that meets the printing requirements of the second image.
在经过编辑处理后,第一图像数据中图像内容符合用户需求,用户确定生成图像时,能够进行图像生成操作以触发该图像生成指令。电子设备接收到该图像生成指令,能够自动执行基于目标分辨率进行图像数据更新的步骤,而不是直接基于第一图像数据生成图像,再由用户下载生成的图像后,使用图像处理软件手动对图像进行二次处理。这样通过该步骤201至步骤203,电子设备能够自动生成符合使用需求的第二图像,无需用户进行过多操作,有效地减少了用户操作,提高了图像处理效率,提高了图像处理方法的实用性和适用性。After editing, the image content in the first image data meets the user's requirements. When the user confirms the generation of the image, an image generation operation can be performed to trigger the image generation instruction. Upon receiving the image generation instruction, the electronic device can automatically execute the step of updating the image data based on the target resolution, instead of directly generating an image from the first image data and then having the user download the generated image and manually process it using image processing software. Thus, through steps 201 to 203, the electronic device can automatically generate a second image that meets the user's requirements, requiring minimal user intervention, effectively reducing user operations, improving image processing efficiency, and enhancing the practicality and applicability of the image processing method.
具体地,电子设备能够对第一图像数据中的分辨率字段数据进行更新,使得第二图像的分辨率符合使用需求。Specifically, the electronic device can update the resolution field data in the first image data so that the resolution of the second image meets the usage requirements.
本公开实施例提供了一种在线编辑图像的方法,能够显示选中的模板图像,且能够根据用户的编辑操作对编辑结果进行显示,实现了所见即所得,生成的图像更容易符合用户需求,无需反复修改,终端与服务器之间无需多次通信,能够有效减少图像处理方法的成本,提高处理效率。且在生成第二图像时,能够将编辑操作后的图像的分辨率进行更新,生成目标分辨率的图像,这样设备自动生成分辨率符合要求的图像,无需用户下载服务器生成的图像再手动编辑,因而,减少了用户操作,进一步提高了图像处理效率,该图像处理方法的实用性和适用性也更好。This disclosure provides a method for online image editing, capable of displaying selected template images and showing editing results based on user actions, achieving a WYSIWYG (What You See Is What You Get) experience. The generated images more readily meet user needs, eliminating the need for repeated modifications. Multiple communications between the terminal and server are unnecessary, effectively reducing the cost of image processing and improving efficiency. Furthermore, when generating a second image, the resolution of the edited image is updated to the target resolution. This allows the device to automatically generate an image with the required resolution, eliminating the need for users to download and manually edit images generated by the server. This reduces user operations, further improving image processing efficiency and enhancing the practicality and applicability of the image processing method.
图3是本申请实施例提供的一种图像处理方法的流程图,参见图3,该方法包括以下步骤。Figure 3 is a flowchart of an image processing method provided in an embodiment of this application. Referring to Figure 3, the method includes the following steps.
301、电子设备响应于模板选择指令,获取选中的模板图像的图像数据和第一尺寸。301. In response to a template selection instruction, the electronic device acquires the image data and first size of the selected template image.
用户在制作图像时,可以选择一个比较符合本次制作需求的模板图像,在该模板图像的基础上进行编辑操作,来设计得到本次需求的图像。用户还可以输入或选择本次需要的图像的尺寸,在本实施例中,将用户需求的图像称为第二图像,将需求的尺寸称为第一尺寸。When creating an image, users can choose a template image that best suits their needs and then edit it to design the desired image. Users can also input or select the required image size. In this embodiment, the desired image is referred to as the second image, and the required size is referred to as the first size.
在该电子设备中可以存储有至少一个模板图像,在图像生成页面中可以显示候选的至少一个模板图像,由用户进行选择。The electronic device can store at least one template image, and can display at least one candidate template image on the image generation page for the user to select.
在另一种可能实现方式中,该至少一个模板图像可以存储于图像数据库中,在该电子设备需要生成图像时,能够从该图像数据库中提取该至少一个模板图像进行显示,以供用户选择。In another possible implementation, the at least one template image can be stored in an image database, and when the electronic device needs to generate an image, the at least one template image can be retrieved from the image database and displayed for the user to select.
例如,如图4所示,在图像生成页面400中,可以提供有多个模板图像401,不同的模板图像401包括的元素种类,元素的位置或样式可以不同。用户可以选中一个模板图像401作为本次图像生成的基础。For example, as shown in Figure 4, the image generation page 400 can provide multiple template images 401. Different template images 401 may include different types of elements, and the positions or styles of the elements may differ. The user can select a template image 401 as the basis for this image generation.
用户对模板图像进行的操作能够触发模板选择指令,电子设备接收到该模板选择指令,可以响应于该模板选择指令,可以获取选中的模板图像的图像数据以及该第一尺寸。User actions on the template image can trigger a template selection command. When the electronic device receives the template selection command, it can respond to the command by acquiring the image data of the selected template image and its first size.
302、电子设备基于目标分辨率对应的目标转换关系,获取该第一尺寸对应的第二尺寸,该第一尺寸的单位为第一单位,该第二尺寸的单位为第二单位,该目标转换关系为第一单位为第二单位之间的转换关系。302. The electronic device obtains the second size corresponding to the first size based on the target conversion relationship corresponding to the target resolution. The unit of the first size is the first unit, the unit of the second size is the second unit, and the target conversion relationship is the conversion relationship between the first unit and the second unit.
在一种可能实现方式中,第一单位为毫米(mm),第二单位为像素(pixel,px),设计人员制作的模板图像的尺寸通常采用第一单位,而电子设备在显示图像时该图像的尺寸通常采用像素,也即是采用第二单位,因而,电子设备获取到模板图像和第一尺寸后,可以先将模板图像的尺寸单位进行转换,从而将模板图像缩放到一定比例进行显示。当然,该第一单位还可以为其他单位,比如分米、米等,本申请实施例对此不作限定。In one possible implementation, the first unit is millimeters (mm), and the second unit is pixels (px). The template image created by the designer typically uses the first unit, while the electronic device usually displays the image in pixels, i.e., using the second unit. Therefore, after obtaining the template image and the first size, the electronic device can first convert the unit of the template image's size, thereby scaling the template image to a certain proportion for display. Of course, the first unit can also be other units, such as decimeters or meters, and this application does not limit this.
该目标分辨率为每英寸长度内的像素数量。分辨率不同时,该第一尺寸对应的第二尺寸可以不同。可以理解地,同一英寸长度内像素数量不同时,第一尺寸转换得到的像素的尺寸也即不同。因而,由于第二图像的分辨率为目标分辨率,可以基于该目标分辨率来确定目标转换关系,使用该目标转换关系来进行尺寸转换,这样得到的预览图像的显示效果符合该分辨率,用户能够真实获知图像的生成效果。The target resolution is the number of pixels per inch. Different resolutions will result in different second dimensions corresponding to the first size. Understandably, different numbers of pixels per inch will lead to different pixel sizes when the first size is converted. Therefore, since the second image's resolution is the target resolution, a target conversion relationship can be determined based on this target resolution. Using this target conversion relationship for size conversion ensures that the resulting preview image displays at the correct resolution, allowing the user to accurately perceive the generated image.
该目标转换关系可以基于目标分辨率确定,在一个具体示例中,以第一单位为毫米,第二单位为像素为例,该目标转换关系可以如图5中的(a)所示,其中,像素与毫米的转换比率为rate_mm2px,DPI(Dots Per Inch,每英寸点数)为目标分辨率,英寸数*2.54=毫米数。The target conversion relationship can be determined based on the target resolution. In a specific example, taking millimeters as the first unit and pixels as the second unit, the target conversion relationship can be shown in Figure 5(a), where the conversion ratio between pixels and millimeters is rate_mm2px, DPI (Dots Per Inch) is the target resolution, and inches * 2.54 = millimeters.
该目标分辨率能够体现图像的精密度,精密度不同,图像的清晰度不同。在本实施例中,如图5中的(b)所示,DPI(0)可以理解成为起始分辨率,也就是显示器默认分辨率(72dpi)。DPI的值决定了这条曲线的趋势,该曲线的趋势可以理解为图像清晰度提升趋势。其中,n代表了在曲线上取的对应的数字,具体确定的n的数值大小,能够由相关技术人员或用户根据希望生成的图像精密度高低来确定,通过对物料图打印调研,发现图像打印精度要求为300像素/英寸,也即是一英寸长度里面包含300个像素点。因而,该n可以设置为300。也即是目标分辨率为300,这样该目标分辨率对应的目标转换关系为:毫米(mm)与像素(px)的转换比率为rate_mm2px=(1*300)/(2.54*10)。当然,该目标分辨率还可以由相关技术人员或用户根据需求设置为其他数值,本申请实施例对此不作具体限定。The target resolution reflects the precision of the image; different precision results in different image clarity. In this embodiment, as shown in Figure 5(b), DPI(0) can be understood as the starting resolution, which is the default resolution of the display (72 dpi). The value of DPI determines the trend of this curve, which can be understood as the trend of image clarity improvement. Here, n represents the corresponding number on the curve. The specific value of n can be determined by relevant technicians or users based on the desired image precision. Through research on material drawing printing, it was found that the image printing precision requirement is 300 pixels/inch, that is, 300 pixels per inch. Therefore, n can be set to 300. That is, the target resolution is 300. Thus, the target conversion relationship corresponding to this target resolution is: the conversion ratio between millimeters (mm) and pixels (px) is rate_mm2px = (1*300)/(2.54*10). Of course, the target resolution can also be set to other values by relevant technicians or users according to their needs; this embodiment does not specifically limit this.
303、电子设备根据该第二尺寸和预览显示区域的第三尺寸,对该模板图像的图像数据进行缩放处理,得到该预览图像的图像数据,该预览图像的尺寸为该第三尺寸。303. The electronic device scales the image data of the template image according to the second size and the third size of the preview display area to obtain the image data of the preview image, wherein the size of the preview image is the third size.
电子设备在显示该模板图像时,需要考虑到预览显示区域的第三尺寸可能与第二尺寸不同,该模板图像的尺寸可能小于或大于该预览显示区域的尺寸。这样电子设备确定了模板图像的第二尺寸后,可以根据第二尺寸和第三尺寸来对模板图像进行缩放。这样在将模板图像缩放到适合在预览显示区域中显示的尺寸后,再进行显示。When displaying the template image, the electronic device needs to consider that the third dimension of the preview display area may differ from the second dimension, and the size of the template image may be smaller or larger than the size of the preview display area. Therefore, after determining the second dimension of the template image, the electronic device can scale the template image based on both the second and third dimensions. The template image is then scaled to a size suitable for display in the preview display area before being displayed.
在一种可能实现方式中,电子设备在缩放时,能够先确定缩放比例,再按照缩放比例缩放。具体地,该步骤303中,电子设备可以根据第二尺寸和第三尺寸,确定缩放比例,然后按照该缩放比例,对该模板图像的图像数据进行缩放处理,得到该预览图像的图像数据。In one possible implementation, the electronic device can determine the scaling ratio before scaling, and then scale according to the scaling ratio. Specifically, in step 303, the electronic device can determine the scaling ratio based on the second size and the third size, and then scale the image data of the template image according to the scaling ratio to obtain the image data of the preview image.
对于该缩放比例,该缩放比例可以为第三尺寸中高度与第二尺寸中高度之间的第一比例,或者该缩放比例可以为第三尺寸中宽度与第三尺寸中宽度之间的第二比例。或者该缩放比例可以为第一比例或第二比例中的最小值或最大值。本申请实施例对此不作限定。The scaling ratio can be a first ratio between the height in the third dimension and the height in the second dimension, or it can be a second ratio between the widths in the third dimension and the widths in the second dimension. Alternatively, the scaling ratio can be the minimum or maximum value of the first or second ratio. This application does not limit this specific ratio.
在一种可能实现方式中,电子设备可以根据第二尺寸和第三尺寸,对模板图像进行等比例缩放,得到预览图像。也即是,对模板图像的图像数据进行等比例缩放处理,得到预览图像的图像数据。通过等比例缩放方式,能够保证缩放后的预览图像中元素的形状以及元素之间的比例与模板图像相同,与最终生成的第二图像中相同,直观地为用户提供图像中元素的样式,用户能够直接获知生成图像中各元素的形状和彼此之间的比例,能够生成更符合用户需求的图像,这样图像处理方式更准确。In one possible implementation, the electronic device can proportionally scale the template image based on the second and third dimensions to obtain a preview image. That is, the image data of the template image is proportionally scaled to obtain the image data of the preview image. By using proportional scaling, it is ensured that the shapes and proportions of the elements in the scaled preview image are the same as those in the template image and the final generated second image. This intuitively provides the user with the style of the elements in the image, allowing the user to directly understand the shapes and proportions of each element in the generated image. This results in an image that better meets the user's needs, making the image processing method more accurate.
例如,通过在目标分辨率为300时,上述目标转换关系为:1mm≈3.779527559055px,1pt≈1.333333333333px。其中,pt为point的缩写,为点的意思,是一种尺寸的单位。如图6所示,如果第一尺寸包括17.7毫米,转换单位后,能够得到66.8976795276像素(px)。在一个具体的可能实施例中,该目标转换关系可以封装为一个度量单位计算器600,通过该度量单位计算器600,能够将第一尺寸转换为对应的第二尺寸。For example, when the target resolution is 300, the above target conversion relationship is: 1mm ≈ 3.779527559055px, 1pt ≈ 1.333333333333px. Here, pt is an abbreviation for point, a unit of measurement. As shown in Figure 6, if the first dimension includes 17.7 millimeters, after unit conversion, it becomes 66.8976795276 pixels (px). In a specific possible embodiment, this target conversion relationship can be encapsulated as a unit of measurement calculator 600, which can be used to convert the first dimension to the corresponding second dimension.
如图7所示,提供一个具体示例,下面以A4尺寸物料图(宽210mm,高297mm)为例,介绍物料图在浏览器下显示的尺寸换算关系。在图7中,物料图中可以包括四种元素:元素1、元素2、元素3和元素4。左边示意该四种元素的位置以及大小,用户可以对其进行拖拽或缩放操作,右边可以示出该四种元素的信息,例如,宽度、高度、内部间距、字体大小等。Figure 7 provides a specific example. Using an A4-sized material drawing (210mm wide, 297mm high) as an example, the following explains the size conversion relationships for displaying a material drawing in a browser. In Figure 7, the material drawing can include four elements: Element 1, Element 2, Element 3, and Element 4. The left side shows the position and size of these four elements, which users can drag or scale. The right side displays information about these four elements, such as width, height, internal spacing, and font size.
宽度:物料在浏览器下的预览宽度设置为800px(该值可以修改,根据具体情况定)。Width: The preview width of the material in the browser is set to 800px (this value can be modified depending on the specific situation).
高度:将宽210mm换算为793.70px(约等于794px),将高297mm换算为1122.52px(约等于1123px)。则预览宽度为800px时,预览高度为1123x 800/794≈1131px。Height: Converting the width of 210mm to 793.70px (approximately 794px), and the height of 297mm to 1122.52px (approximately 1123px), then when the preview width is 800px, the preview height is approximately 1123 x 800/794 ≈ 1131px.
内部间距:以顶部文字“微信支付暑假狂欢季”居上间距为例,17.7mm换算约为66.90px,在宽794px像素下的17.7mm为66.90px,那在800宽下,则为66.90*800/794≈67px。Internal spacing: Taking the top spacing of the text "WeChat Pay Summer Carnival Season" as an example, 17.7mm is approximately 66.90px. With a width of 794px, 17.7mm is 66.90px. So with a width of 800px, it is 66.90*800/794≈67px.
字体大小:以物料图“最顶上的主题文案”为例,20pt换算约为26.67px,接下来与上同理,在宽794px像素下的20pt约等于26.67px,那在800宽下,则等于26.67*800/794≈27px。Font size: Taking the "topmost theme text" in the material image as an example, 20pt is approximately 26.67px. Similarly, 20pt with a width of 794px is approximately equal to 26.67px. Therefore, with a width of 800px, it is approximately 26.67 * 800 / 794 ≈ 27px.
注:计算过程中采用四舍五入,尽可能多保留小数点后几位,便于得出更加精准的值,例如66.897637*800/794=67.403160≈67px。Note: Rounding is used in the calculation process to retain as many decimal places as possible to obtain a more accurate value. For example, 66.897637*800/794=67.403160≈67px.
步骤302至步骤303为基于该目标分辨率、该第一尺寸和该模板图像的图像数据,获取预览图像的图像数据的过程,上述过程中,电子设备先将模板图像的尺寸的单位进行了转换,然后将其缩放后,再生成了预览图像。电子设备还可以通过其他方式来获取该预览图像,例如电子设备可以获取预览显示区域的第一单位的尺寸,基于该尺寸与第一尺寸来缩放模板图像得到预览图像。本申请实施例对此不作限定。Steps 302 to 303 involve acquiring image data of the preview image based on the target resolution, the first size, and the image data of the template image. In this process, the electronic device first converts the unit of the template image's size, then scales it to regenerate the preview image. The electronic device can also acquire the preview image in other ways; for example, it can acquire the size of the first unit of the preview display area and scale the template image based on this size and the first size to obtain the preview image. This application does not limit this approach.
304、电子设备基于该预览图像的图像数据,在该预览显示区域中显示该预览图像。304. The electronic device displays the preview image in the preview display area based on the image data of the preview image.
电子设备获取到预览图像的图像数据后,即可对预览图像进行渲染显示。该步骤304为基于该预览图像的图像数据,显示该预览图像的过程。Once the electronic device acquires the image data of the preview image, it can render and display the preview image. Step 304 describes the process of displaying the preview image based on its image data.
该步骤301至步骤304为响应于模板选择指令,显示选中的模板图像的过程,上述过程通过缩放操作,将模板图像缩放到了预览显示区域中的预览图像。例如,如图8所示,用户选中了一个模板图像801,并设置了第一尺寸802,电子设备可以显示该选中的模板图像801和第一尺寸802,该第一尺寸802为115毫米(mm)x 160mm。Steps 301 to 304 are processes for displaying the selected template image in response to a template selection command. These processes use a scaling operation to scale the template image to the preview image in the preview display area. For example, as shown in Figure 8, if a user selects a template image 801 and sets a first size 802, the electronic device can display the selected template image 801 and the first size 802, where the first size 802 is 115 mm x 160 mm.
该过程也可以通过其他方式实现,例如,电子设备也可以存储有该模板图像的预览图像,响应于模板选择指令,显示该模板图像的预览图像。本申请实施例对此不作限定。This process can also be implemented in other ways. For example, an electronic device can store a preview image of the template image and display the preview image in response to a template selection instruction. This application does not limit this approach.
305、电子设备响应于对该预览图像的编辑操作,基于第一图像数据,显示第一图像,该第一图像数据基于该编辑操作对该预览图像的图像数据处理得到。305. In response to an editing operation on the preview image, the electronic device displays a first image based on first image data, the first image data being obtained by processing the image data of the preview image based on the editing operation.
电子设备显示预览图像后,用户还可以根据需求对预览图像中的元素进行编辑,以满足使用需求。电子设备在检测到用户的编辑操作时,能够基于编辑操作对预览图像的图像数据进行处理,显示处理后的图像。在编辑操作结束后,得到第一图像。After the electronic device displays a preview image, the user can edit the elements in the preview image as needed to meet their usage requirements. When the electronic device detects the user's editing operation, it can process the image data of the preview image based on the editing operation and display the processed image. After the editing operation is completed, the first image is obtained.
电子设备能够提供在线编辑功能,用户通过终端上的浏览器应用,能够查看该电子设备提供的页面,电子设备也能够根据用户的编辑操作,对页面显示的内容进行更新,以对编辑处理结果进行展示。这样该在线编辑的过程实现了可见即所得,用户能够获知每次编辑后,图像内容的变化,因而能够准确地对图像进行编辑处理。Electronic devices can provide online editing capabilities. Users can view the pages provided by the electronic device through a browser application on their terminal. The electronic device can also update the content displayed on the page based on the user's editing operations to show the editing results. In this way, the online editing process achieves WYSIWYG (What You See Is What You Get), allowing users to see the changes in the image content after each edit, thus enabling them to accurately edit and process the image.
在一种可能实现方式中,该模板图像包括标题、背景、文本、图标、横幅中的至少一项元素,该对该模板图像的编辑操作为对该至少一项元素中任一项元素的拖拽操作、缩放操作、颜色设置操作、更换操作中的任一项。In one possible implementation, the template image includes at least one element selected from title, background, text, icon, and banner, and the editing operation on the template image is any one of dragging, scaling, color setting, or changing any of the at least one element.
在确定满足需求时,用户能够进行图像生成操作,该图像生成操作能够触发图像生成指令,电子设备接收到该图像生成指令,能够响应于该图像生成指令,执行后续步骤来生成第二图像。When the user determines that the requirements are met, the user can perform an image generation operation, which can trigger an image generation instruction. The electronic device receives the image generation instruction and can respond to the image generation instruction by executing subsequent steps to generate a second image.
例如,如图8所示,该模板图像通过预览图像的方式显示,该模板图像或该预览图像中包括标题801、背景802、图标803等,用户可以编辑标题801、更换背景802或者改变背景802的颜色,添加或更换图标803,在编辑过程中,用户可以实时查看到编辑后的图像,在确定满足需求时,能够点击“完成”按钮,该点击“完成”按钮的操作即为图像生成操作。电子设备能够基于当前显示的图像生成第二图像。For example, as shown in Figure 8, the template image is displayed as a preview image. This template image or preview image includes a title 801, a background 802, and an icon 803. Users can edit the title 801, change the background 802 or its color, and add or replace the icon 803. During the editing process, users can view the edited image in real time. When they are satisfied with the result, they can click the "Finish" button. Clicking the "Finish" button is the image generation operation. The electronic device can then generate a second image based on the currently displayed image.
该步骤305为响应于对该模板图像的编辑操作,基于第一图像数据,显示第一图像的过程,该第一图像数据基于该编辑操作对该模板图像的图像数据处理得到。该模板图像在显示时以预览图像的方式显示,且能够对预览图像进行编辑操作,进而得到第一图像数据。Step 305 is a process of displaying a first image based on first image data in response to an editing operation on the template image. The first image data is obtained by processing the image data of the template image based on the editing operation. The template image is displayed as a preview image, and editing operations can be performed on the preview image to obtain the first image data.
306、电子设备响应于图像生成指令,基于该目标转换关系,获取该第三尺寸对应的第四尺寸,该第三尺寸的单位为该第二单位,第四尺寸的单位为该第一单位。306. In response to an image generation instruction, the electronic device obtains a fourth dimension corresponding to the third dimension based on the target conversion relationship, wherein the unit of the third dimension is the second unit and the unit of the fourth dimension is the first unit.
编辑操作后,电子设备需要基于编辑后的第一图像生成第二图像时,可以再将第一图像的尺寸缩放回原始尺寸,也即是第一尺寸。在缩放时,可以先根据目标转换关系,将第二单位转化为第一单位,再进行缩放。After editing, if an electronic device needs to generate a second image based on the edited first image, the size of the first image can be scaled back to its original size, i.e., the first size. During scaling, the second unit can be converted to the first unit according to the target transformation relationship before scaling.
该目标转换关系具体可以参见上述步骤302,电子设备在该步骤306中,能够根据该目标转换关系,将第二单位的第三尺寸转化为第一单位的第四尺寸。The specific target conversion relationship can be found in step 302 above. In step 306, the electronic device can convert the third dimension of the second unit into the fourth dimension of the first unit according to the target conversion relationship.
该步骤306与上述步骤302同理,在此不多做赘述。只是该步骤306中将第二单位转化为第一单位,步骤302中将第一单位转化为第二单位,转化时为逆变换。Step 306 is similar to step 302 above, and will not be elaborated further here. The only difference is that in step 306, the second unit is converted into the first unit, while in step 302, the first unit is converted into the second unit. The conversion is an inverse transformation.
307、电子设备根据该第四尺寸和该第一尺寸,对该第一图像数据进行缩放处理,得到第三图像的第三图像数据,该第三图像的尺寸为该第一尺寸。307. The electronic device performs scaling processing on the first image data based on the fourth size and the first size to obtain third image data of the third image, wherein the size of the third image is the first size.
该步骤307与上述步骤303同理,在此不多做赘述。Step 307 is the same as step 303 above, and will not be elaborated on here.
同理地,该电子设备也可以先基于第四尺寸和第一尺寸,确定缩放比例,再按照缩放比例,对第一图像数据进行缩放处理,得到第三图像的第三图像数据。Similarly, the electronic device can first determine the scaling ratio based on the fourth size and the first size, and then scale the first image data according to the scaling ratio to obtain the third image data of the third image.
同理地,该缩放比例可以为第一尺寸中高度与第四尺寸中高度之间的第一比例,或者该缩放比例可以为第一尺寸中宽度与第四尺寸中宽度之间的第二比例。或者该缩放比例可以为第一比例或第二比例中的最小值或最大值。本申请实施例对此不作限定。Similarly, the scaling ratio can be a first ratio between the height in the first dimension and the height in the fourth dimension, or the scaling ratio can be a second ratio between the width in the first dimension and the width in the fourth dimension. Alternatively, the scaling ratio can be the minimum or maximum value of the first or second ratio. This application does not limit this aspect.
同理地,该缩放处理过程也可以为等比例缩放过程。Similarly, this scaling process can also be a proportional scaling process.
308、电子设备基于该目标分辨率,对该第三图像的第三图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,该第二图像的尺寸为该第一尺寸,该第二图像的分辨率为该目标分辨率。308. Based on the target resolution, the electronic device updates the resolution field data in the third image data of the third image to obtain the second image data of the second image, wherein the size of the second image is the first size and the resolution of the second image is the target resolution.
电子设备在缩放处理后,还可以根据目标分辨率对图像的分辨率进行修改,得到清晰度满足需求的第二图像。该分辨率修改的方式可以通过对图像数据中分辨率字段数据进行更新的方式实现。After scaling, electronic devices can further modify the image resolution based on the target resolution to obtain a second image with satisfactory clarity. This resolution modification can be achieved by updating the resolution field data in the image data.
在一种可能实现方式中,该更新步骤可以通过对分辨率字段数据进行替换的方式实现,具体地,电子设备将该第三图像的第三图像数据中分辨率字段数据替换为该目标分辨率对应的数据,得到第二图像的第二图像数据。将分辨率字段数据替换为目标分辨率对应的数据后,该第二图像数据中分辨率字段数据为目标分辨率对应的数据,该第二图像的分辨率即为该目标分辨率。In one possible implementation, the update step can be achieved by replacing the resolution field data. Specifically, the electronic device replaces the resolution field data in the third image data of the third image with the data corresponding to the target resolution, thus obtaining the second image data of the second image. After replacing the resolution field data with the data corresponding to the target resolution, the resolution field data in the second image data is the data corresponding to the target resolution, and the resolution of the second image is the target resolution.
该第三图像数据为进行缩放后的第一图像数据,该步骤308也即是电子设备将该第一图像数据中分辨率字段数据替换为该目标分辨率对应的数据,得到第二图像的第二图像数据。在上述方式中,电子设备对第一图像进行了缩放,从而基于缩放后的第一图像生成第二图像。在其他实现方式中,电子设备也可以基于The third image data is the scaled-up first image data. Step 308 involves the electronic device replacing the resolution field data in the first image data with the data corresponding to the target resolution, thus obtaining the second image data for the second image. In the above method, the electronic device scales the first image, thereby generating the second image based on the scaled first image. In other implementations, the electronic device can also be based on...
该第一图像数据为基于base64的编码数据,上述分辨率字段数据替换步骤可以为:电子设备将该第一图像的编码数据中分辨率字段数据替换为该目标分辨率对应的十六进制数据,得到第二图像的第二图像数据。The first image data is base64 encoded data. The resolution field data replacement step can be: the electronic device replaces the resolution field data in the encoded data of the first image with hexadecimal data corresponding to the target resolution to obtain the second image data of the second image.
对于该分辨率字段数据,可以通过对不同分辨率的图像的图像数据进行分析确定。例如,如图9所示,图像的dpi信息是保存在图像文件头部的某个位置,因为base64编码是对字节流进行编码,所以可以确定base64编码过后字符串某些地方的base64字符保存了图片的dpi信息,只需要找到这个字符串位置,然后修改成对应300dpi编码后的base64字符即可。The resolution field data can be determined by analyzing image data of images at different resolutions. For example, as shown in Figure 9, the DPI information of an image is stored at a certain position in the header of the image file. Since base64 encoding encodes byte streams, it can be determined that certain base64 characters in the encoded string store the image's DPI information. We only need to find this string position and modify it to the corresponding 300 dpi encoded base64 characters.
具体地,dpi信息的字符串位置确定过程可以通过方式实现。Specifically, the process of determining the string position of dpi information can be implemented in a certain way.
在方式一中,可以选取两张经过图片编辑工具处理过的图片,这两张图片只有dpi不同,然后分别进行base64编码,对比编码后的字符串,尝试找到不同的位置。In Method 1, you can select two images that have been processed by an image editing tool. These two images differ only in dpi. Then, you can encode them separately using base64 and compare the encoded strings to try to find the differences.
在方式二中,可以获取图片的二进制文件,从二进制文件中找到保存dpi信息的字节位置,然后通过base64的编码规则,计算出需要更新的base64字符串的位置。In method two, the binary file of the image can be obtained, the byte position where the dpi information is stored can be found in the binary file, and then the position of the base64 string that needs to be updated can be calculated according to the base64 encoding rules.
在该方式二中,可以获取该图像jpeg文件格式的二进制文件,在二进制文件中找到保存dpi信息的字节位置。在一个具体示例中,该二进制文件中的15-18这四个字节位置保存了图像的dpi信息。保存格式如下:15-16两字节保存了水平dpi,17-18两个字节保存了垂直dpi。水平dpi和垂直dpi是分别使用了两个字节保存的,使用的字节序是大端字节序,即高位字节保存在低内存地址处。In this second method, the binary file of the image in JPEG format can be obtained, and the byte position where the DPI information is stored can be found in the binary file. In a specific example, bytes 15-18 in the binary file store the image's DPI information. The storage format is as follows: bytes 15-16 store the horizontal DPI, and bytes 17-18 store the vertical DPI. The horizontal and vertical DPI are each stored using two bytes, using big-endian byte order, meaning the most significant byte is stored at the lowest memory address.
如图10和图11所示,通过二进制查看工具打开图片文件,发现dpi是96*96的数据正好保存在这四个字节。其中,一个字节用两个十六进制数表示。先取源文件的前20个字节,即前40位(红色数字为保存dpi的16进制字符):FFD8FFE0 00104A46 4946000101010060 00600000。然后可以将dpi字节数据改成300*300对应的16进制字符:FFD8FFE000104A46 49460001 0101012C 012C0000。按每三个字节分一组,字符可以表示为FFD8FFE00010 4A4649 460001 010101 2C012C 0000。这样前18个字节刚好分成6组,保存dpi的数据在第5组和第6组,前四组的数据都是一样的,所以只需要对第五组和第六组进行base64编码。010101 2C012C按照base64编码规则后对应的base64字符串是AQEB LAEs(共8个字符),前四组的12个字节可以编码成16个字符(转换时要去掉空格),再加上base的前导字符串‘data:image/jpeg;base64,’的23个字符,总共是39个字符,从第40字符往后的8个字符保存了dpi信息,所以将经过base64编码后的字符串的40-47个字符替换成’AQEB LAEs’,这8个字符便可达到将图片base64编码字符串的dpi修改成300的效果。As shown in Figures 10 and 11, opening the image file with a binary viewer reveals that the 96*96 dpi data is precisely stored in these four bytes. Each byte is represented by two hexadecimal numbers. First, take the first 20 bytes of the source file, i.e., the first 40 bits (the red numbers are the hexadecimal characters storing the dpi): FFD8FFE0 00104A46 4946000101010060 00600000. Then, the dpi byte data can be changed to the hexadecimal characters corresponding to 300*300: FFD8FFE000104A46 49460001 0101012C 012C0000. Dividing these into groups of three bytes, the characters can be represented as FFD8FFE00010 4A4649 460001 010101 2C012C 0000. The first 18 bytes are divided into 6 groups. The data storing the dpi is in groups 5 and 6. The data in the first four groups is the same, so only groups 5 and 6 need to be base64 encoded. 010101 2C012C, after base64 encoding, corresponds to the base64 string AQEB LAEs (8 characters). The 12 bytes in the first four groups can be encoded into 16 characters (spaces are removed during conversion). Adding the 23 characters of the leading string 'data:image/jpeg;base64,', the total is 39 characters. The 8 characters from the 40th character onwards store the dpi information. Therefore, replacing characters 40-47 of the base64 encoded string with 'AQEB LAEs' will change the dpi of the image's base64 encoded string to 300.
具体地,上述修改过程可以通过下述目标函数实现:Specifically, the above modification process can be achieved through the following objective function:
function formatBase64StrTo300Dpi(base64Str){function formatBase64StrTo300Dpi(base64Str){
return base64Str.substr(0,39)+'AQEBLAEs'+base64Str.substr(47)Return base64Str.substr(0,39)+'AQEBLAEs'+base64Str.substr(47)
}}
对于该目标分辨率对应的数据’AQEB LAEs’,电子设备可以通过Base64编码表查询得到。该Base64编码表可以如表1所示。The electronic device can retrieve the data 'AQEB LAEs' corresponding to the target resolution using a Base64 encoding table. This Base64 encoding table is shown in Table 1.
表1Table 1
需要说明的是,该步骤306至步骤308为响应于图像生成指令,基于目标分辨率,对该第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据的过程,该第二图像的分辨率为该目标分辨率,在一种可能实现方式中,该过程中,电子设备可以将html(Hyper Text Markup Language,超文本标记语言)页面转化为画布(canvas),再将画布转化为图像。It should be noted that steps 306 to 308 are processes of updating the resolution field data in the first image data in response to the image generation instruction, based on the target resolution, to obtain the second image data of the second image. The resolution of the second image is the target resolution. In one possible implementation, during this process, the electronic device can convert the HTML (Hypertext Markup Language) page into a canvas, and then convert the canvas into an image.
具体地,可以通过下述步骤一至步骤三实现。Specifically, this can be achieved through the following steps one through three.
步骤一、电子设备基于该目标分辨率,将该显示的该第一图像绘制到画布上。Step 1: The electronic device draws the first image to be displayed onto the canvas based on the target resolution.
步骤二、电子设备获取该画布的图像数据。Step 2: The electronic device acquires the image data of the canvas.
在步骤二中,电子设备获取该画布的图像数据时,可以基于canvas自带的API实现。具体地,电子设备可以基于浏览器应用的目标应用程序接口,获取该画布的图像数据。In step two, when the electronic device acquires the image data of the canvas, it can do so using the canvas's built-in API. Specifically, the electronic device can acquire the canvas's image data using the target application programming interface (API) of the browser application.
步骤三、电子设备基于该画布的图像数据,执行该分辨率字段数据更新的步骤。Step 3: The electronic device performs the step of updating the resolution field data based on the image data of the canvas.
在一种可能实现方式中,电子设备获取到第二图像的第二图像数据后,可以直接执行打印步骤,也可以将其存储至服务器,以备后续使用。具体地,电子设备可以将该第二图像数据发送至目标服务器进行存储,该目标服务器用于对图像数据进行存储管理。该目标服务器也可以被称为图像服务器,该图像服务器的存储空间以及对图像数据的处理能力优于一般的服务器,因而,将第二图像数据发送至该目标服务器进行存储,例如,该目标服务器可以为云服务器COS。In one possible implementation, after acquiring the second image data of the second image, the electronic device can either directly execute the printing step or store it on a server for later use. Specifically, the electronic device can send the second image data to a target server for storage, where the target server manages the storage of the image data. This target server can also be called an image server, which has superior storage space and image data processing capabilities compared to a typical server. Therefore, sending the second image data to this target server for storage is appropriate; for example, the target server could be a cloud server (COS).
上述步骤301至步骤308为一种可能的实现方式,在上述步骤305之后,电子设备还可以不将第一图像缩放回第一尺寸,而是直接将其生成第二图像,这样生成得到的第二图像尺寸较小,然后存储小尺寸的第二图像以及第一尺寸,后续下载该图像时再重绘得到第一尺寸的图像。具体地,上述步骤305之后,电子设备可以响应于对该预览图像的编辑操作,基于第一图像数据,显示第一图像,该第一图像的尺寸为该第三尺寸。相应地,电子设备可以不执行缩放步骤,直接基于该目标分辨率,对该第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,该第二图像数据中该第二图像的尺寸为第三尺寸。电子设备将该第二图像数据以及第一尺寸发送至服务器进行存储。Steps 301 to 308 described above are one possible implementation. After step 305, the electronic device may not scale the first image back to the first size, but instead directly generate a second image from it. This results in a smaller second image, which is then stored along with the first size. The first-size image is then redrawn when the image is downloaded later. Specifically, after step 305, in response to editing operations on the preview image, the electronic device can display the first image based on the first image data, where the size of the first image is the third size. Correspondingly, the electronic device may skip the scaling step and directly update the resolution field data in the first image data based on the target resolution to obtain second image data for the second image, where the size of the second image is the third size. The electronic device then sends the second image data and the first size to the server for storage.
如果后续再下载该第二图像,电子设备可以响应于对该第二图像的获取指令,从该服务器中获取该第二图像数据和该第一尺寸,基于该第二图像数据和该第一尺寸,绘制该第二图像,得到该第一尺寸的第四图像。这样该第四图像即为重绘得到的大尺寸的第二图像。这样能够向服务器传输数据量小的第二图像,后续使用时重绘得到数据量大的第二图像即可,减少传输数据量的同时,也不影响该第二图像的后续正常使用(比如印刷)。且能够保证在目标接口的数据传输受限的情况下也能够保证图像数据的正常传输。If the second image is downloaded subsequently, the electronic device can respond to the command to acquire the second image, retrieve the second image data and the first size from the server, and draw the second image based on the second image data and the first size to obtain a fourth image of the first size. This fourth image is the redrawn, larger-sized second image. This allows for the transmission of a smaller second image to the server, while a larger second image can be redrawn for subsequent use, reducing the amount of data transmitted without affecting the normal use of the second image (e.g., printing). Furthermore, it ensures normal image data transmission even when data transmission at the target interface is limited.
在另一种可能实现方式中,上述步骤305之后,电子设备还可以进行缩放处理,只是将其缩放至目标尺寸,该目标尺寸小于该第一尺寸,也可以小于该第三尺寸,这样将图像处理为较小尺寸的图像进行存储,能够减少传输数据量的同时,保证图像的后续正常使用。In another possible implementation, after step 305 above, the electronic device can also perform scaling processing, simply scaling it to a target size, which is smaller than the first size or the third size. This process reduces the amount of data transmitted while ensuring the normal use of the image in the future.
在一种可能实现方式中,电子设备可以响应于对目标接口的配置修改指令,将该目标接口的数据传输限制阈值从第一阈值修改为第二阈值,该第二阈值大于该第一阈值,该目标接口用于传输该第二图像数据。该目标接口是传输图像数据至服务器的接口,例如,该目标接口可以为一个php(Hypertext Preprocessor,超文本预处理器)接口。该php接口本身设置有数据传输限制阈值,例如,第一阈值可以为10MB。通过修改该php接口的数据传输上限,从而使得该目标接口能够传输数据量大的第二图像数据,保证第二图像数据的存储步骤能够实现。In one possible implementation, the electronic device can, in response to a configuration modification command for the target interface, change the data transmission limit threshold of the target interface from a first threshold to a second threshold, where the second threshold is greater than the first threshold. The target interface is used to transmit the second image data. This target interface is the interface for transmitting image data to a server; for example, it could be a PHP (Hypertext Preprocessor) interface. The PHP interface itself has a data transmission limit threshold, for example, the first threshold could be 10MB. By modifying the data transmission limit of the PHP interface, the target interface can transmit large amounts of second image data, ensuring that the storage step of the second image data can be achieved.
在一种可能实现方式中,电子设备还可以对该第二图像数据进行压缩处理,得到该第二图像的压缩数据,将该压缩数据发送至服务器进行存储。这样后续下载该第二图像时,可以下载该压缩数据,对压缩数据进行解压缩,得到该第二图像数据。通过压缩处理,减少第二图像数据的数据量,这样能够减少向服务器传输的数据量,减少数据传输负担,也能够减少服务器的存储负担,且在目标接口的数据传输受限的情况下也能够保证图像数据的正常传输。In one possible implementation, the electronic device can further compress the second image data to obtain compressed data of the second image, and then send the compressed data to a server for storage. This way, when downloading the second image later, the compressed data can be downloaded, decompressed, and the second image data obtained. By reducing the amount of data in the second image data through compression, the amount of data transmitted to the server can be reduced, thus reducing the data transmission burden and the server's storage burden. Furthermore, it ensures normal transmission of image data even when data transmission at the target interface is limited.
在一个具体示例中,如图12和图13所示,本申请实施例提供的图像处理方法能够为服务商提供便捷的图像处理服务,该图像处理方法能够应用于物料云平台中,该物料云平台用于为服务商提供物料制作服务。该物料可以为图像的形式。具体地,该图像处理方法可以包括多个阶段:登录阶段、选择模板阶段、设计阶段、合成阶段、下载阶段、存储阶段、打印阶段。在登录阶段,服务器能够登陆该物料云平台。在选择模板阶段,服务商在该物料云平台提供的模板图像中选择一个模板图像。在设计阶段,服务商可以对该模板图像中的各种元素进行个性化编辑,其中,元素可以包括标题(title)、背景(BG)、文本(Text)、图标(Icon)和横幅(Banner)等。具体编辑操作可以包括设置操作、更换操作、拖拽(drag)操作等。在合成阶段,物料云平台能够基于html2canvas的API,将页面元素转化为canvas,并将canvas最终保存(save)为图像(比如jpg格式的图像)。在下载和存储阶段,服务商通过浏览器(Broswer)得到合成后的图像后,可以将其存储(storage)至本地(local)。服务器也可以将合成的图像上传至目标服务器(service)进行存储。这样服务商也可以从目标服务器下载(download)该图像,或者将存储在本地的图像上传(upload)至目标服务器。在打印阶段,服务商可以通过打印机(printer)对图像进行打印。In a specific example, as shown in Figures 12 and 13, the image processing method provided in this embodiment can provide convenient image processing services for service providers. This image processing method can be applied to a material cloud platform, which provides material production services to service providers. The material can be in the form of an image. Specifically, the image processing method can include multiple stages: login stage, template selection stage, design stage, compositing stage, download stage, storage stage, and printing stage. In the login stage, the server can log in to the material cloud platform. In the template selection stage, the service provider selects a template image from the template images provided by the material cloud platform. In the design stage, the service provider can personalize various elements in the template image, including titles, backgrounds, text, icons, and banners. Specific editing operations can include setting operations, changing operations, dragging operations, etc. In the compositing stage, the material cloud platform can convert page elements into canvas based on the html2canvas API and finally save the canvas as an image (such as a JPG image). During the download and storage phase, after obtaining the composite image through a browser, the service provider can store it locally. The server can also upload the composite image to the target server for storage. This allows the service provider to download the image from the target server or upload the locally stored image to the target server. During the printing phase, the service provider can print the image using a printer.
通过本申请提供的方法,能够通过图像编辑和处理过程,生成符合宣传展示和打印尺寸的图像,且无需反复修改,终端与服务器之间无需多次通信,能够有效减少图像处理的成本,提高处理效率。且在生成第二图像时,能够将编辑操作后的图像的分辨率进行更改,生成目标分辨率的新图像,这样终端自动生成符合要求的图像,无需用户从服务器下载。因而,减少了用户操作,进一步提高了图像处理效率,该图像处理方法的实用性和适用性也更加优越。The method provided in this application enables the generation of images that meet the dimensions required for promotional displays and printing through image editing and processing, without the need for repeated modifications or multiple communications between the terminal and the server. This effectively reduces image processing costs and improves processing efficiency. Furthermore, when generating a second image, the resolution of the edited image can be changed to generate a new image at the target resolution. Thus, the terminal automatically generates an image that meets the requirements, eliminating the need for the user to download it from the server. Therefore, user operations are reduced, further improving image processing efficiency, and the practicality and applicability of this image processing method are significantly enhanced.
如图14所示,如图14中的(a)所示,本申请提供的方法90%+的工作由前端完成,相较于图14中的(b)所示的传统方案中约55%的工作由服务端完成,由前端完成能够很好的减少前端与服务端的数据交互次数,实现所见即所得,能够更好的满足用户的个性化需求。As shown in Figure 14, specifically in (a) of Figure 14, over 90% of the work in the method provided by this application is completed by the front end. In contrast, in the traditional solution shown in (b) of Figure 14, approximately 55% of the work is completed by the server. The front end's completion significantly reduces the number of data interactions between the front end and the server, achieving a WYSIWYG (What You See Is What You Get) experience and better meeting the personalized needs of users.
本公开实施例提供了一种在线编辑图像的方法,能够显示选中的模板图像,且能够根据用户的编辑操作对编辑结果进行显示,实现了所见即所得,生成的图像更容易符合用户需求,无需反复修改,终端与服务器之间无需多次通信,能够有效减少图像处理方法的成本,提高处理效率。且在生成第二图像时,能够将编辑操作后的图像的分辨率进行更新,生成目标分辨率的图像,这样设备自动生成分辨率符合要求的图像,无需用户下载服务器生成的图像再手动编辑,因而,减少了用户操作,进一步提高了图像处理效率,该图像处理方法的实用性和适用性也更好。This disclosure provides a method for online image editing, capable of displaying selected template images and showing editing results based on user actions, achieving a WYSIWYG (What You See Is What You Get) experience. The generated images more readily meet user needs, eliminating the need for repeated modifications. Multiple communications between the terminal and server are unnecessary, effectively reducing the cost of image processing and improving efficiency. Furthermore, when generating a second image, the resolution of the edited image is updated to the target resolution. This allows the device to automatically generate an image with the required resolution, eliminating the need for users to download and manually edit images generated by the server. This reduces user operations, further improving image processing efficiency and enhancing the practicality and applicability of the image processing method.
上述所有可选技术方案,能够采用任意结合形成本申请的可选实施例,在此不再一一赘述。All of the above-mentioned optional technical solutions can be combined in any way to form optional embodiments of this application, and will not be described in detail here.
图15是本申请实施例提供的一种图像处理装置的结构示意图,参见图15,该装置包括:Figure 15 is a schematic diagram of an image processing apparatus provided in an embodiment of this application. Referring to Figure 15, the apparatus includes:
显示模块1501,用于响应于模板选择指令,显示选中的模板图像;Display module 1501 is used to display the selected template image in response to a template selection command;
该显示模块1501,还用于响应于对该模板图像的编辑操作,基于第一图像数据,显示第一图像,该第一图像数据基于该编辑操作对该模板图像的图像数据处理得到;The display module 1501 is also configured to, in response to an editing operation on the template image, display a first image based on first image data, the first image data being obtained by processing the image data of the template image based on the editing operation;
更新模块1502,用于响应于图像生成指令,基于目标分辨率,对该第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,该第二图像的分辨率为该目标分辨率。The update module 1502 is used to update the resolution field data in the first image data based on the target resolution in response to the image generation instruction, so as to obtain the second image data of the second image, wherein the resolution of the second image is the target resolution.
在一种可能实现方式中,该更新模块1502用于将该第一图像数据中分辨率字段数据替换为该目标分辨率对应的数据,得到第二图像的第二图像数据。In one possible implementation, the update module 1502 is used to replace the resolution field data in the first image data with the data corresponding to the target resolution to obtain the second image data of the second image.
在一种可能实现方式中,该更新模块1502包括绘制单元、获取单元和更新单元;In one possible implementation, the update module 1502 includes a drawing unit, an acquisition unit, and an update unit;
该绘制单元用于基于该目标分辨率,将该显示的该第一图像绘制到画布上;The drawing unit is used to draw the displayed first image onto the canvas based on the target resolution;
该获取单元用于获取该画布的图像数据;This acquisition unit is used to acquire the image data of the canvas;
该更新单元用于基于该画布的图像数据,执行该分辨率字段数据更新的步骤。This update unit is used to perform the step of updating the resolution field data based on the image data of the canvas.
在一种可能实现方式中,该获取单元用于基于浏览器应用的目标应用程序接口,获取该画布的图像数据。In one possible implementation, the acquisition unit is used to acquire the image data of the canvas based on the target application programming interface of the browser application.
在一种可能实现方式中,该第一图像数据为基于base64的编码数据;In one possible implementation, the first image data is base64-encoded data;
该更新模块1502用于将该第一图像的编码数据中分辨率字段数据替换为该目标分辨率对应的十六进制数据,得到第二图像的第二图像数据。The update module 1502 is used to replace the resolution field data in the encoded data of the first image with hexadecimal data corresponding to the target resolution, so as to obtain the second image data of the second image.
在一种可能实现方式中,该显示模块1501用于:In one possible implementation, the display module 1501 is used for:
响应于模板选择指令,获取选中的模板图像的图像数据和第一尺寸;In response to the template selection command, obtain the image data and first size of the selected template image;
基于该目标分辨率、该第一尺寸和该模板图像的图像数据,获取预览图像的图像数据;Based on the target resolution, the first size, and the image data of the template image, obtain the image data of the preview image;
基于该预览图像的图像数据,显示该预览图像。Based on the image data of the preview image, the preview image is displayed.
在一种可能实现方式中,该显示模块1501用于:In one possible implementation, the display module 1501 is used for:
基于目标分辨率对应的目标转换关系,获取该第一尺寸对应的第二尺寸,该第一尺寸的单位为第一单位,该第二尺寸的单位为第二单位,该目标转换关系为第一单位为第二单位之间的转换关系;Based on the target transformation relationship corresponding to the target resolution, the second size corresponding to the first size is obtained. The unit of the first size is the first unit, the unit of the second size is the second unit, and the target transformation relationship is the transformation relationship between the first unit and the second unit.
根据该第二尺寸和预览显示区域的第三尺寸,对该模板图像的图像数据进行缩放处理,得到该预览图像的图像数据,该预览图像的尺寸为该第三尺寸;Based on the second size and the third size of the preview display area, the image data of the template image is scaled to obtain the image data of the preview image, and the size of the preview image is the third size;
在一种可能实现方式中,该显示模块1501用于基于该预览图像的图像数据,在该预览显示区域中显示该预览图像。In one possible implementation, the display module 1501 is used to display the preview image in the preview display area based on the image data of the preview image.
在一种可能实现方式中,该更新模块1502用于:In one possible implementation, the update module 1502 is used for:
基于该目标转换关系,获取该第三尺寸对应的第四尺寸,该第三尺寸的单位为该第二单位,第四尺寸的单位为该第一单位;Based on this target transformation relationship, the fourth dimension corresponding to the third dimension is obtained, where the unit of the third dimension is the second unit and the unit of the fourth dimension is the first unit;
根据该第四尺寸和该第一尺寸,对该第一图像数据进行缩放处理,得到第三图像的第三图像数据,该第三图像的尺寸为该第一尺寸;Based on the fourth size and the first size, the first image data is scaled to obtain the third image data of the third image, the size of which is the first size;
基于该目标分辨率,对该第三图像的第三图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,该第二图像的尺寸为该第一尺寸。Based on the target resolution, the resolution field data in the third image data of the third image is updated to obtain the second image data of the second image, and the size of the second image is the first size.
在一种可能实现方式中,该装置还包括:In one possible implementation, the device further includes:
第一存储模块,用于将该第二图像数据发送至目标服务器进行存储,该目标服务器用于对图像数据进行存储管理。The first storage module is used to send the second image data to the target server for storage, and the target server is used for storage management of the image data.
在一种可能实现方式中,该显示模块1501用于响应于对该预览图像的编辑操作,基于第一图像数据,显示第一图像,该第一图像的尺寸为该第三尺寸;In one possible implementation, the display module 1501 is configured to display a first image based on first image data in response to an editing operation on the preview image, the first image having the third size;
该更新模块1502用于基于该目标分辨率,对该第一图像数据中分辨率字段数据进行更新,得到第二图像的第二图像数据,该第二图像数据中该第二图像的尺寸为第三尺寸;The update module 1502 is used to update the resolution field data in the first image data based on the target resolution to obtain the second image data of the second image, wherein the size of the second image in the second image data is the third size;
该装置还包括:The device also includes:
第二存储模块,用于将该第二图像数据以及第一尺寸发送至服务器进行存储;The second storage module is used to send the second image data and the first size to the server for storage;
获取模块,用于响应于对该第二图像的获取指令,从该服务器中获取该第二图像数据和该第一尺寸;The acquisition module is configured to, in response to an acquisition instruction for the second image, acquire the second image data and the first size from the server;
绘制模块,用于基于该第二图像数据和该第一尺寸,绘制该第二图像,得到该第一尺寸的第四图像。A drawing module is used to draw the second image based on the second image data and the first size, thereby obtaining a fourth image of the first size.
在一种可能实现方式中,该装置还包括:In one possible implementation, the device further includes:
修改模块,用于响应于对目标接口的配置修改指令,将该目标接口的数据传输限制阈值从第一阈值修改为第二阈值,该第二阈值大于该第一阈值,该目标接口用于传输该第二图像数据。The modification module is used to modify the data transmission limit threshold of the target interface from a first threshold to a second threshold in response to a configuration modification command for the target interface. The second threshold is greater than the first threshold, and the target interface is used to transmit the second image data.
在一种可能实现方式中,该装置还包括:In one possible implementation, the device further includes:
压缩模块,用于对该第二图像数据进行压缩处理,得到该第二图像的压缩数据;A compression module is used to compress the second image data to obtain compressed data of the second image;
第三存储模块,用于将该压缩数据发送至服务器进行存储。The third storage module is used to send the compressed data to the server for storage.
在一种可能实现方式中,该模板图像包括标题、背景、文本、图标、横幅中的至少一项元素,该对该模板图像的编辑操作为对该至少一项元素中任一项元素的拖拽操作、缩放操作、颜色设置操作、更换操作中的任一项。In one possible implementation, the template image includes at least one element selected from title, background, text, icon, and banner, and the editing operation on the template image is any one of dragging, scaling, color setting, or changing any of the at least one element.
本申请实施例提供的装置,能够显示选中的模板图像,且能够根据用户的编辑操作对编辑结果进行显示,实现了所见即所得,生成的图像更容易符合用户需求,无需反复修改,终端与服务器之间无需多次通信,能够有效减少图像处理方法的成本,提高处理效率。且在生成第二图像时,能够将编辑操作后的图像的分辨率进行更新,生成目标分辨率的图像,这样设备自动生成分辨率符合要求的图像,无需用户下载服务器生成的图像再手动编辑,因而,减少了用户操作,进一步提高了图像处理效率,该图像处理装置的实用性和适用性也更好。The device provided in this application embodiment can display the selected template image and the editing results based on the user's editing operations, achieving a WYSIWYG (What You See Is What You Get) effect. The generated image is more likely to meet user needs, eliminating the need for repeated modifications. Multiple communications between the terminal and the server are unnecessary, effectively reducing the cost of image processing methods and improving processing efficiency. Furthermore, when generating the second image, the resolution of the edited image can be updated to generate an image with the target resolution. This allows the device to automatically generate an image with the required resolution, eliminating the need for the user to download and manually edit the image generated by the server. Therefore, user operations are reduced, further improving image processing efficiency, and enhancing the practicality and applicability of this image processing device.
需要说明的是:上述实施例提供的图像处理装置在处理图像时,仅以上述各功能模块的划分进行举例说明,实际应用中,能够根据需要而将上述功能分配由不同的功能模块完成,即将图像处理装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的图像处理装置与图像处理方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that the image processing apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when processing images. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the image processing apparatus can be divided into different functional modules to complete all or part of the functions described above. In addition, the image processing apparatus and the image processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
上述方法实施例中的电子设备能够实现为终端。例如,图16是本申请实施例提供的一种终端的结构框图。该终端1600可以是便携式移动终端,比如:智能手机、平板电脑、MP3(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)播放器、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、笔记本电脑或台式电脑。终端1600还可能被称为用户设备、便携式终端、膝上型终端、台式终端等其他名称。The electronic device in the above method embodiments can be implemented as a terminal. For example, Figure 16 is a structural block diagram of a terminal provided in an embodiment of this application. The terminal 1600 can be a portable mobile terminal, such as a smartphone, tablet computer, MP3 (Moving Picture Experts Group Audio Layer III) player, MP4 (Moving Picture Experts Group Audio Layer IV) player, laptop computer, or desktop computer. The terminal 1600 may also be referred to as a user device, portable terminal, laptop terminal, desktop terminal, or other names.
通常,终端1600包括有:处理器1601和存储器1602。Typically, terminal 1600 includes a processor 1601 and a memory 1602.
处理器1601可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器1601可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器1601也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central ProcessingUnit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器1601可以集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器1601还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。Processor 1601 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1601 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1601 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1601 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, processor 1601 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
存储器1602可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器1602还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器1602中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器1601所执行以实现本申请中方法实施例提供的图像处理方法。The memory 1602 may include one or more computer-readable storage media, which may be non-transitory. The memory 1602 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1602 are used to store at least one instruction, which is executed by the processor 1601 to implement the image processing method provided in the method embodiments of this application.
在一些实施例中,终端1600还可选包括有:外围设备接口1603和至少一个外围设备。处理器1601、存储器1602和外围设备接口1603之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口1603相连。具体地,外围设备包括:射频电路1604、显示屏1605、摄像头组件1606、音频电路1607和电源1609中的至少一种。In some embodiments, the terminal 1600 may also optionally include: a peripheral device interface 1603 and at least one peripheral device. The processor 1601, memory 1602, and peripheral device interface 1603 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 1603 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of: a radio frequency circuit 1604, a display screen 1605, a camera assembly 1606, an audio circuit 1607, and a power supply 1609.
外围设备接口1603可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器1601和存储器1602。在一些实施例中,处理器1601、存储器1602和外围设备接口1603被集成在同一芯片或电路板上;在一些其他实施例中,处理器1601、存储器1602和外围设备接口1603中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。Peripheral interface 1603 can be used to connect at least one I/O (Input/Output) related peripheral device to processor 1601 and memory 1602. In some embodiments, processor 1601, memory 1602 and peripheral interface 1603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 1601, memory 1602 and peripheral interface 1603 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
射频电路1604用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路1604通过电磁信号与通信网络以及其他通信设备进行通信。射频电路1604将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路1604包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路1604可以通过至少一种无线通信协议来与其它终端进行通信。该无线通信协议包括但不限于:万维网、城域网、内联网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路1604还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。The radio frequency (RF) circuit 1604 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1604 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1604 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 1604 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 1604 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1604 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
显示屏1605用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏1605是触摸显示屏时,显示屏1605还具有采集在显示屏1605的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器1601进行处理。此时,显示屏1605还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏1605可以为一个,设置在终端1600的前面板;在另一些实施例中,显示屏1605可以为至少两个,分别设置在终端1600的不同表面或呈折叠设计;在另一些实施例中,显示屏1605可以是柔性显示屏,设置在终端1600的弯曲表面上或折叠面上。甚至,显示屏1605还可以设置成非矩形的不规则图形,也即异形屏。显示屏1605可以采用LCD(Liquid Crystal Display,液晶显示屏)、OLED(Organic Light-EmittingDiode,有机发光二极管)等材质制备。Display screen 1605 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 1605 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 1601 for processing. In this case, display screen 1605 can also be used to provide virtual buttons and/or a virtual keyboard, also known as soft buttons and/or a soft keyboard. In some embodiments, there may be one display screen 1605, disposed on the front panel of terminal 1600; in other embodiments, there may be at least two display screens, disposed on different surfaces of terminal 1600 or in a folded design; in still other embodiments, display screen 1605 may be a flexible display screen, disposed on a curved or folded surface of terminal 1600. Furthermore, display screen 1605 may be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. The display screen 1605 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
摄像头组件1606用于采集图像或视频。可选地,摄像头组件1606包括前置摄像头和后置摄像头。通常,前置摄像头设置在终端的前面板,后置摄像头设置在终端的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件1606还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。The camera assembly 1606 is used to acquire images or videos. Optionally, the camera assembly 1606 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 1606 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
音频电路1607可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器1601进行处理,或者输入至射频电路1604以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在终端1600的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器1601或射频电路1604的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路1607还可以包括耳机插孔。The audio circuit 1607 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting them into electrical signals that are input to the processor 1601 for processing, or to the radio frequency circuit 1604 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each positioned at a different location on the terminal 1600. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from the processor 1601 or the radio frequency circuit 1604 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 1607 may also include a headphone jack.
电源1609用于为终端1600中的各个组件进行供电。电源1609可以是交流电、直流电、一次性电池或可充电电池。当电源1609包括可充电电池时,该可充电电池可以是有线充电电池或无线充电电池。有线充电电池是通过有线线路充电的电池,无线充电电池是通过无线线圈充电的电池。该可充电电池还可以用于支持快充技术。Power supply 1609 is used to power the various components in terminal 1600. Power supply 1609 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 1609 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, and a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
在一些实施例中,终端1600还包括有一个或多个传感器1610。该一个或多个传感器1610包括但不限于:加速度传感器1611、陀螺仪传感器1612、压力传感器1613、光学传感器1615以及接近传感器1616。In some embodiments, the terminal 1600 further includes one or more sensors 1610. The one or more sensors 1610 include, but are not limited to: an accelerometer 1611, a gyroscope 1612, a pressure sensor 1613, an optical sensor 1615, and a proximity sensor 1616.
加速度传感器1611可以检测以终端1600建立的坐标系的三个坐标轴上的加速度大小。比如,加速度传感器1611可以用于检测重力加速度在三个坐标轴上的分量。处理器1601可以根据加速度传感器1611采集的重力加速度信号,控制显示屏1605以横向视图或纵向视图进行用户界面的显示。加速度传感器1611还可以用于游戏或者用户的运动数据的采集。Accelerometer 1611 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by terminal 1600. For example, accelerometer 1611 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 1601 can control display screen 1605 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 1611. Accelerometer 1611 can also be used for games or for acquiring user motion data.
陀螺仪传感器1612可以检测终端1600的机体方向及转动角度,陀螺仪传感器1612可以与加速度传感器1611协同采集用户对终端1600的3D动作。处理器1601根据陀螺仪传感器1612采集的数据,可以实现如下功能:动作感应(比如根据用户的倾斜操作来改变UI)、拍摄时的图像稳定、游戏控制以及惯性导航。The gyroscope sensor 1612 can detect the orientation and rotation angle of the terminal 1600. The gyroscope sensor 1612, in conjunction with the accelerometer sensor 1611, can collect 3D motion data from the user on the terminal 1600. Based on the data collected by the gyroscope sensor 1612, the processor 1601 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
压力传感器1613可以设置在终端1600的侧边框和/或显示屏1605的下层。当压力传感器1613设置在终端1600的侧边框时,可以检测用户对终端1600的握持信号,由处理器1601根据压力传感器1613采集的握持信号进行左右手识别或快捷操作。当压力传感器1613设置在显示屏1605的下层时,由处理器1601根据用户对显示屏1605的压力操作,实现对UI界面上的可操作性控件进行控制。可操作性控件包括按钮控件、滚动条控件、图标控件、菜单控件中的至少一种。The pressure sensor 1613 can be disposed on the side bezel of the terminal 1600 and/or on the lower layer of the display screen 1605. When the pressure sensor 1613 is disposed on the side bezel of the terminal 1600, it can detect the user's grip signal on the terminal 1600, and the processor 1601 can perform left/right hand recognition or quick operation based on the grip signal collected by the pressure sensor 1613. When the pressure sensor 1613 is disposed on the lower layer of the display screen 1605, the processor 1601 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 1605. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
光学传感器1615用于采集环境光强度。在一个实施例中,处理器1601可以根据光学传感器1615采集的环境光强度,控制显示屏1605的显示亮度。具体地,当环境光强度较高时,调高显示屏1605的显示亮度;当环境光强度较低时,调低显示屏1605的显示亮度。在另一个实施例中,处理器1601还可以根据光学传感器1615采集的环境光强度,动态调整摄像头组件1606的拍摄参数。An optical sensor 1615 is used to collect ambient light intensity. In one embodiment, the processor 1601 can control the display brightness of the display screen 1605 based on the ambient light intensity collected by the optical sensor 1615. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1605 is increased; when the ambient light intensity is low, the display brightness of the display screen 1605 is decreased. In another embodiment, the processor 1601 can also dynamically adjust the shooting parameters of the camera assembly 1606 based on the ambient light intensity collected by the optical sensor 1615.
接近传感器1616,也称距离传感器,通常设置在终端1600的前面板。接近传感器1616用于采集用户与终端1600的正面之间的距离。在一个实施例中,当接近传感器1616检测到用户与终端1600的正面之间的距离逐渐变小时,由处理器1601控制显示屏1605从亮屏状态切换为息屏状态;当接近传感器1616检测到用户与终端1600的正面之间的距离逐渐变大时,由处理器1601控制显示屏1605从息屏状态切换为亮屏状态。The proximity sensor 1616, also known as a distance sensor, is typically located on the front panel of the terminal 1600. The proximity sensor 1616 is used to detect the distance between the user and the front of the terminal 1600. In one embodiment, when the proximity sensor 1616 detects that the distance between the user and the front of the terminal 1600 is gradually decreasing, the processor 1601 controls the display screen 1605 to switch from a screen-on state to a screen-off state; when the proximity sensor 1616 detects that the distance between the user and the front of the terminal 1600 is gradually increasing, the processor 1601 controls the display screen 1605 to switch from a screen-off state to a screen-on state.
本领域技术人员可以理解,图16中示出的结构并不构成对终端1600的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。Those skilled in the art will understand that the structure shown in FIG16 does not constitute a limitation on the terminal 1600, and may include more or fewer components than shown, or combine certain components, or employ different component arrangements.
上述方法实施例中的电子设备能够实现为服务器。例如,图17是本申请实施例提供的一种服务器的结构示意图,该服务器1700可因配置或性能不同而产生比较大的差异,能够包括一个或一个以上处理器(Central Processing Units,CPU)1701和一个或一个以上的存储器1702,其中,该存储器1702中存储有至少一条程序代码,该至少一条程序代码由该处理器1701加载并执行以实现上述各个方法实施例提供的图像处理方法。当然,该服务器还能够具有有线或无线网络接口以及输入输出接口等部件,以便进行输入输出,该服务器还能够包括其他用于实现设备功能的部件,在此不做赘述。The electronic device in the above method embodiments can be implemented as a server. For example, Figure 17 is a schematic diagram of a server structure provided in an embodiment of this application. The server 1700 can vary considerably due to different configurations or performance, and can include one or more processors (Central Processing Units, CPUs) 1701 and one or more memories 1702. The memory 1702 stores at least one piece of program code, which is loaded and executed by the processor 1701 to implement the image processing methods provided in the above method embodiments. Of course, the server can also have wired or wireless network interfaces and input/output interfaces for input and output. The server can also include other components for implementing device functions, which will not be elaborated here.
在示例性实施例中,还提供了一种计算机可读存储介质,例如包括至少一条程序代码的存储器,上述至少一条程序代码由可由处理器执行以完成上述实施例中的图像处理方法。例如,计算机可读存储介质能够是只读存储器(Read-Only Memory,简称:ROM)、随机存取存储器(Random Access Memory,简称:RAM)、只读光盘(Compact Disc Read-OnlyMemory,简称:CD-ROM)、磁带、软盘和光数据存储设备等。In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including at least one line of program code, which is executable by a processor to perform the image processing method described above. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, a floppy disk, and an optical data storage device, etc.
在示例性实施例中,还提供一种计算机程序产品,一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或该计算机程序包括一条或多条程序代码,该一条或多条程序代码存储在计算机可读存储介质中。电子设备的一个或多个处理器能够从计算机可读存储介质中读取该一条或多条程序代码,该一个或多个处理器执行该一条或多条程序代码,使得电子设备能够执行上述图像处理方法。In an exemplary embodiment, a computer program product is also provided. In one aspect, a computer program product or computer program is provided, comprising one or more lines of program code stored in a computer-readable storage medium. One or more processors of an electronic device are capable of reading the one or more lines of program code from the computer-readable storage medium, and the one or more processors execute the one or more lines of program code, enabling the electronic device to perform the image processing method described above.
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
应理解,根据A确定B并不意味着仅仅根据A确定B,还能够根据A和/或其它信息确定B。It should be understood that determining B based on A does not mean determining B solely based on A; it also means determining B based on A and/or other information.
本领域普通技术人员能够理解实现上述实施例的全部或部分步骤能够通过硬件来完成,也能够通过程序来指令相关的硬件完成,该程序能够存储于一种计算机可读存储介质中,上述提到的存储介质能够是只读存储器,磁盘或光盘等。Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
以上描述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above description is only an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims (27)
Publications (2)
| Publication Number | Publication Date |
|---|---|
| HK40070017A HK40070017A (en) | 2022-10-21 |
| HK40070017B true HK40070017B (en) | 2025-09-26 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20240231555A1 (en) | Systems, Methods, and Computer-Readable Media for Managing Collaboration on a Virtual Work of Art | |
| CN108415705B (en) | Webpage generation method and device, storage medium and equipment | |
| JP5171968B2 (en) | Accelerate rendering of web-based content | |
| CN107622518B (en) | Picture synthetic method, device, equipment and storage medium | |
| CN110708596A (en) | Method and device for generating video, electronic equipment and readable storage medium | |
| CN112148404B (en) | Avatar generation method, device, equipment and storage medium | |
| US9485290B1 (en) | Method and system for controlling local display and remote virtual desktop from a mobile device | |
| CN108537889A (en) | Adjustment method, device, storage medium and electronic device for augmented reality model | |
| CN112230914B (en) | Method, device, terminal and storage medium for producing small program | |
| JP6090173B2 (en) | Information processing apparatus, information processing method, and program | |
| US10628121B2 (en) | Electronic device and method for controlling the same | |
| CN113837920B (en) | Image rendering method and electronic device | |
| CN111191176B (en) | Website content updating method, device, terminal and storage medium | |
| CN110750734A (en) | Weather display method and device, computer equipment and computer-readable storage medium | |
| CN110889060A (en) | Webpage display method and device, computer equipment and storage medium | |
| CN108734662B (en) | Method and device for displaying icons | |
| CN113747199A (en) | Video editing method, video editing apparatus, electronic device, storage medium, and program product | |
| US10432681B1 (en) | Method and system for controlling local display and remote virtual desktop from a mobile device | |
| WO2024222356A1 (en) | Special-effect generation method and apparatus, and computer device and storage medium | |
| CN112257006A (en) | Page information configuration method, device, equipment and computer readable storage medium | |
| CN111443858A (en) | Application interface display method and device, terminal and storage medium | |
| CN114257755B (en) | Image processing method, device, equipment and storage medium | |
| CN117130516B (en) | Display method and electronic equipment | |
| HK40070017B (en) | Image processing method and apparatus, device, and storage medium | |
| CN116541622A (en) | Webpage rendering method, device, equipment and storage medium |