Image resource processing methods, apparatus, equipment, storage media and products

By intercepting image resources during the application build process and using visual attributes and a multimodal large language model for automated translation and adaptation, the problem of low efficiency in multilingual localization of mobile application image resources is solved, enabling efficient multilingual application development.

CN122411933APending Publication Date: 2026-07-17BEIJING QIHOOD TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING QIHOOD TECHNOLOGY CO LTD
Filing Date
2026-04-24
Publication Date
2026-07-17

Smart Images

  • Figure CN122411933A_ABST
    Figure CN122411933A_ABST
Patent Text Reader

Abstract

This application discloses an image resource processing method, apparatus, device, storage medium, and product, relating to the field of image processing technology. The method includes: intercepting image resources to be processed during the resource merging stage of a target application's build process; processing the image resources to be processed based on image attributes to obtain the target image resource and its visual attribute information; translating the target image resource to obtain text content in the target language; rendering the target image resource based on the visual attribute information and the text content in the target language to obtain a local file of the target image; and merging resources based on the local file of the target image to generate an application package supporting the target language. This method can automatically complete the processing and adaptation of image resources in the target language during the application build process, eliminating the need for manual creation of image resources in different language versions, reducing the manpower and time costs of multilingual application development, and improving the development efficiency of multilingual applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to image resource processing methods, apparatus, devices, storage media, and products. Background Technology

[0002] With the globalization of the mobile internet, the overseas expansion of enterprise mobile applications has become a core engine for business growth. In the process of international adaptation, in addition to translating text resources, the numerous image resources embedded with text within the application also require multilingual localization.

[0003] Currently, the multilingual localization of image resources in mobile applications mainly relies on manual processing and semi-automatic processing by third-party image translation platforms. When there are many image resources, the processing efficiency is low and the operation process is complicated. Summary of the Invention

[0004] The main purpose of this application is to provide a method, apparatus, device, storage medium and product for image resource processing, which aims to solve the technical problem of low efficiency in multilingual localization processing of image resources in current mobile application development.

[0005] To achieve the above objectives, the first aspect of this application provides an image resource processing method, the method comprising: acquiring an original image resource to be processed; identifying text content embedded in the original image resource and corresponding area information; and addressing the technical problem of identification.

[0006] To achieve the above objectives, this application proposes an image resource processing method, which includes: During the resource merging phase of the target application's build process, intercept the image resources to be processed; The image resource to be processed is processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource. The target image resource is translated to obtain text content in the target language; The target image resource is rendered based on the visual attribute information and the text content in the target language to obtain a local file of the target image; Resources are merged based on the target image's local files to generate an application package that supports the target language.

[0007] In one embodiment, the step of translating the target image resource to obtain text content in the target language includes: Determine the visual fingerprint of the target image resource; Based on the visual fingerprint, query the preset cache database to see if there is a cached visual fingerprint that matches the visual fingerprint; When a cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the translation result of the target translation language corresponding to the cached visual fingerprint is used as the text content of the target language.

[0008] In one embodiment, the step of determining the visual fingerprint of the target image resource includes: Retrieve a pre-configured list of target translation languages; Obtain the resource path of the target image resource in the project and the text area information of the target image resource; Read the binary content of the target image resource, and calculate the hash value of the pixel content of the target image resource based on the binary content; A visual fingerprint is generated based on the target translation language list, the resource path, the text region information, and the hash value.

[0009] In one embodiment, after the step of querying the preset cache database based on the visual fingerprint to see if a cached visual fingerprint matching the visual fingerprint exists, the method further includes: If no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, obtain the context association information of the target image resource in the current application project; Based on the contextual information and the target image resource, a multimodal large language model is input for translation to obtain the text content in the target language.

[0010] In one embodiment, the step of obtaining the context association information of the target image resource in the current application project when no cached visual fingerprint matching the visual fingerprint exists in the preset cache database includes: When no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, code association analysis, layout association analysis, and visual semantic classification are performed on the target image resource to obtain code association information, layout context information, and visual semantic classification results. The code association information, the layout context information, and the visual semantic classification results are integrated into the context association information of the target image resource in the application project.

[0011] In one embodiment, the steps of performing code association analysis, layout association analysis, and visual semantic classification on the target image resource to obtain code association information, layout context information, and visual semantic classification results include: Obtain the resource identifier of the target image resource; Scan the source code directory and resource directory of the application project to determine the resource directory of the target image resource; Based on the resource catalog, code association analysis and layout association analysis are performed on the target image resources to obtain code association information and layout context information. The visual semantic categories of the target image resources are analyzed to obtain visual semantic classification results.

[0012] In one embodiment, the step of rendering the target image resource based on the visual attribute information and the text content of the target language to obtain a local file of the target image includes: Based on the visual attribute information, the target image resource is restored to obtain a background image. The text content in the target language is rendered onto the background image to generate a local file of the target image.

[0013] In one embodiment, the step of performing background restoration on the target image resource based on the visual attribute information to obtain a background base image includes: The bounding box of the text region in the target image resource is obtained based on the visual attribute information; Obtain a blank mask image with the same size as the target image resource; The bounding box of the text region is filled into the blank mask image to obtain the mask image; The target image resource is then repaired based on the mask image to obtain a background base image.

[0014] In one embodiment, the step of rendering the text content of the target language onto the background image to generate a local file of the target image includes: Based on the visual attribute information, the text region area, the font size value corresponding to the text region, the text alignment method, the text color, and the text style parameters in the target image resource are obtained; Calculate the area of ​​the translated text based on the text content in the target language and the font size value; Based on the area of ​​the translated text, the text alignment and font size are adjusted to obtain the target text alignment and target font size. The target text content in the target language is filled into the background image using the target text alignment method and the target font size value; The text content in the target language after filling is rendered using the text color and the text style parameters to generate a local target image file.

[0015] In one embodiment, the step of adjusting the text alignment and font size based on the translated text area to obtain the target text alignment and target font size includes: When the area of ​​the translated text is less than or equal to the area of ​​the text region, the text alignment method is used as the target text alignment method, and the font size value is used as the target font size value; When the area of ​​the translated text is greater than the area of ​​the text region and less than or equal to a preset ratio of the area of ​​the text region, the font size value obtained by annotating the text and reducing the font size value by the preset ratio is used as the target font size value. A line break strategy is set in the text alignment method, and the text alignment method after setting the line break strategy is used as the target text alignment method. When the area of ​​the translated text is greater than a preset ratio of the area of ​​the text region, the minimum allowed font size of the font size value is taken as the target font size value, a line spacing reduction strategy is set in the text alignment method, and the text alignment method after setting the line spacing reduction strategy is taken as the target text alignment method.

[0016] In one embodiment, the step of processing the image resource to be processed based on image attributes to obtain the target image resource and the visual attribute information of the target image resource includes: The preset image size threshold and preset file size value are obtained based on image attributes; Images whose size is smaller than the preset image size threshold or whose file size in bytes is smaller than the preset file size value are removed from the image resources to be processed to obtain candidate image resources; Text detection is performed on the candidate image resources to obtain the bounding boxes of the text regions and the confidence values ​​of each candidate image; Candidate images with confidence values ​​greater than a preset confidence threshold are used as target image resources, and visual attributes are extracted from the text regions of the target image resources to obtain the text attributes and background texture features of the text regions in the target image resources. The visual attribute information of the target image resource is obtained based on the text region bounding box, the text attributes, and the background texture features.

[0017] In one embodiment, the step of merging resources based on the local file of the target image to generate an application package supporting the target language includes: Obtain the directory structure of virtual image resources in various languages ​​constructed in memory; The image files of each language in the target image local file are mapped to the corresponding resource qualifier directories in the virtual image resource directory structure to generate virtual resource data; The virtual resource data is merged to generate an application package that supports the target language.

[0018] In one embodiment, the step of intercepting the image resources to be processed during the resource merging phase of the target application's build process includes: During the resource merging phase of the target application's build process, the preset static configuration data is parsed to obtain the pre-configured list of target translation languages ​​and the range of image resource directories to be translated. Based on the target translation language list and the range of image resource directories to be translated, the intercepted application project directory structure is parsed to obtain the image resources to be processed in the range of image resource directories to be translated.

[0019] Furthermore, to achieve the above objectives, this application also proposes an image resource processing apparatus, which includes: The interception module is used to intercept image resources to be processed during the resource merging phase of the target application's build process. The processing module is used to process the image resource to be processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource; The translation module is used to translate the target image resource to obtain text content in the target language; The rendering module is used to render the target image resource based on the visual attribute information and the text content in the target language to obtain a local file of the target image; The resource merging module is used to merge resources based on the local files of the target image to generate an application package that supports the target language.

[0020] In one embodiment, the translation module is further configured to determine the visual fingerprint of the target image resource; Based on the visual fingerprint, query the preset cache database to see if there is a cached visual fingerprint that matches the visual fingerprint; When a cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the translation result of the target translation language corresponding to the cached visual fingerprint is used as the text content of the target language.

[0021] In one embodiment, the translation module is further configured to obtain a pre-configured list of target translation languages; Obtain the resource path of the target image resource in the project and the text area information of the target image resource; Read the binary content of the target image resource, and calculate the hash value of the pixel content of the target image resource based on the binary content; A visual fingerprint is generated based on the target translation language list, the resource path, the text region information, and the hash value.

[0022] In one embodiment, the device further includes an acquisition module, which is used to acquire the context association information of the target image resource in the current application project when there is no cached visual fingerprint matching the visual fingerprint in the preset cache database; Based on the contextual information and the target image resource, a multimodal large language model is input for translation to obtain the text content in the target language.

[0023] In addition, to achieve the above objectives, this application also proposes an image resource processing device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the image resource processing method described above.

[0024] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the image resource processing method described above.

[0025] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the image resource processing method described above.

[0026] The present application proposes one or more technical solutions that, during the resource merging stage of the target application's build process, intercept image resources to be processed; process the image resources to be processed based on image attributes to obtain the target image resources and their visual attribute information; translate the target image resources to obtain text content in the target language; render the target image resources based on the visual attribute information and the text content in the target language to obtain a local file of the target image; and merge resources based on the local file of the target image to generate an application package that supports the target language. This approach automatically completes the processing and adaptation of image resources in the target language during the application build process, eliminating the need for manual creation of image resources in different language versions. This reduces the manpower and time costs of developing multilingual applications while ensuring consistency in the display of image and text in different languages, thus improving the development efficiency of multilingual applications. Attached Figure Description

[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0028] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is a flowchart illustrating an embodiment of the image resource processing method of this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the image resource processing method of this application; Figure 3 This is a flowchart illustrating Embodiment 3 of the image resource processing method of this application; Figure 4 This is a flowchart illustrating Embodiment 4 of the image resource processing method of this application; Figure 5 A simplified flowchart is provided for one embodiment of the image resource processing method of this application; Figure 6 This is a schematic diagram of the module structure of the image resource processing device according to an embodiment of this application; Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the image resource processing method in the embodiments of this application.

[0030] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0031] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0032] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0033] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone; or an electronic device or image resource processing device capable of performing the above functions, such as a plugin in the target application building process. The following description uses a plugin in the target application building process as an example to illustrate this embodiment and the subsequent embodiments. All actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection regulations of the country where the application is located and with authorization from the owner of the corresponding device.

[0034] Based on this, embodiments of this application provide an image resource processing method, referring to... Figure 1, Figure 1 This is a flowchart illustrating the first embodiment of the image resource processing method of this application.

[0035] In this embodiment, the image resource processing method includes steps S10 to S50: Step S10: During the resource merging phase of the target application's build process, intercept the image resources to be processed.

[0036] It should be noted that the target application can be any mobile application or desktop application that supports multiple languages, such as Android applications or iOS applications. This embodiment does not limit this; this embodiment uses Android applications as an example for illustration.

[0037] The image resources to be processed are the embedded text image resources in the target application project that need to be translated and adapted into multiple languages.

[0038] This embodiment allows for the customization of a plugin module, which can be integrated into the Android Gradle build lifecycle. This module is responsible for static configuration parsing, build task interception, image resource scanning and filtering, OCR scheduling, translation result collection, inpainting repair coordination, adaptive typesetting and redrawing, and dynamic injection of compiled artifacts.

[0039] In the original build process of the target application, the resource merging stage organizes and packages various resources within the project. By integrating interception logic at this stage through a plugin, the image resources to be processed can be filtered without changing the original development process. This eliminates the need for developers to make additional adjustments to the existing project build configuration, thus lowering the barrier to entry for the method.

[0040] In one feasible implementation, step S10 may include steps A11-A12: Step A11: In the resource merging stage of the target application's build process, parse the preset static configuration data to obtain the pre-configured list of target translation languages ​​and the range of image resource directories to be translated; It should be noted that the preset static configuration data includes multiple translation languages, which are configured by the developer in advance in the build.gradle script of the Android project, and the target translation language list is generated by the build process.

[0041] For example, the target translation language list is represented as: targetLangs = ['en', 'ja', 'ko', 'de'].

[0042] In specific implementation, the scope of the image resource directory to be translated is the directory path of the image resources that need to be translated and adapted, as specified by the developer. For example, it can be specified that only promotional images under the drawable-xhdpi directory will be processed, or multiple resource directories containing images to be translated can be specified. This embodiment does not impose any restrictions on this.

[0043] Step A12: Based on the target translation language list and the range of the image resource directory to be translated, parse the intercepted application project directory structure to obtain the image resources to be processed in the range of the image resource directory to be translated.

[0044] In practice, a customized Gradle plugin intervenes during the project evaluation phase to parse preset static configuration data, register build lifecycle listeners, and proactively locate the resource processing task chain of AAPT2 (Android resource packaging tool 2nd generation) for deep interception. Specifically, during the Gradle build graph execution phase, the plugin hooks the native mergeResources task, during which the plugin automatically scans all image resource files.

[0045] The plugin parses the application project's res or directory structure to build a complete image resource index, thereby identifying all image files in the drawable and mipmap directories. The drawable and mipmap directories are two directories used to store image resources and support PNG, WebP, and SVG formats. Finally, it obtains the image resources to be processed within the range of the image resource directories to be translated.

[0046] Step S20: Process the image resource to be processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource.

[0047] In practice, image attributes can include information such as image size, image dimensions, image resolution, text region location, text size, font style, and color. The image resources to be processed can be filtered first by the image attributes, and then the text regions in the filtered image resources can be identified by OCR technology to extract the target image resources containing text. At the same time, the visual attribute information of the corresponding text can be extracted to provide parameter support for subsequent rendering.

[0048] The target image resource is the image resource that needs to be translated. The visual attribute information of the target image resource is the text area information in the target image resource. For example, it may include the text attributes and background texture features within the text area. The text attributes may include information such as text color, text size, text direction, alignment, and line spacing.

[0049] Step S30: Translate the target image resource to obtain text content in the target language.

[0050] It should be noted that when translating the target image resource, a multimodal large language model can be used for translation processing. It is also possible to query whether there is translation data identical to the target image resource in the cached data in the local or intranet shared cache server, and finally obtain the translated text content in multiple languages.

[0051] Step S40: Render the target image resource based on the visual attribute information and the text content of the target language to obtain a local file of the target image.

[0052] In practice, the background of the original text area can be repaired first based on the visual attribute information, the original text can be erased, and then the text content of the target language can be adaptively laid out to the original text area according to the parameters in the visual attribute information, the complete target image of the corresponding language can be rendered and saved as a local target image file.

[0053] Step S50: Merge resources based on the local files of the target image to generate an application package that supports the target language.

[0054] It should be noted that the processed local files of target images in each target language can be merged, the text can be packaged together, and then injected into the specific project file to finally generate an application package containing image resources in the corresponding language.

[0055] In one feasible implementation, step S50 may include steps A21 to A23: Step A21: Obtain the directory structure of virtual image resources for each language constructed in memory; It should be noted that before AAPT2 compiles the resource files into the final output, it needs to dynamically inject the generated localized images for each language into the corresponding target. Therefore, it is possible to first obtain the virtual image resource directory structure for each language that the plugin has pre-built in memory, i.e., the virtual drawable resource directory structure, such as drawable-en, drawable-ja, drawable-ko, etc.

[0056] Step A22: Map the image files of each language in the target image local file to the corresponding resource qualifier directories in the virtual image resource directory structure to generate virtual resource data; Understandably, image files in different languages ​​within the target image's local file can be mapped to their respective resource qualifier directories, thereby generating virtual resource data.

[0057] Step A23: Merge the virtual resource data to generate an application package that supports the target language.

[0058] In practice, these virtual resource data can be merged and then sent to AAPT2. Upon receiving the merged virtual resource data, AAPT2 compiles and packages it into the final APK or AAB artifact. After injection, the plugin is allowed to run the build pipeline until the final artifact is generated. The entire process is completely transparent to developers, requiring no multilingual image files to be placed in the source code, achieving seamless image translation and injection.

[0059] This embodiment provides an image resource processing method. During the resource merging stage of the target application's build process, it intercepts image resources to be processed; processes the image resources based on their attributes to obtain the target image resource and its visual attribute information; translates the target image resource to obtain text content in the target language; renders the target image resource based on the visual attribute information and the text content in the target language to obtain a local file of the target image; and merges resources based on the local file of the target image to generate an application package supporting the target language. This method can automatically complete the processing and adaptation of image resources in the target language during the application build process, eliminating the need for manual creation of image resources in different language versions. This reduces the manpower and time costs of multilingual application development while ensuring the consistency of image and text display effects across different languages, thus improving the development efficiency of multilingual applications.

[0060] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 Step S30 includes steps S301 to S303: Step S301: Determine the visual fingerprint of the target image resource.

[0061] It should be noted that, in order to avoid repeatedly launching time-consuming AI inferences for the same image during frequent compilation, an incremental image translation mechanism can be introduced. Therefore, the visual fingerprint of the target image resource can be determined first. The visual fingerprint is the feature code generated by hash calculation of the target image resource. Each image with different content corresponds to a unique visual fingerprint, which can accurately distinguish whether the image content has changed.

[0062] In one feasible implementation, step S301 may include steps B11 to B14: Step B11: Obtain the pre-configured list of target translation languages; It is understandable that the pre-configured list of target translation languages, i.e. the list of multiple translation languages ​​described in Example 1, can be obtained by parsing the preset static configuration data.

[0063] Step B12: Obtain the resource path of the target image resource in the project and the text region information of the target image resource; In practical implementation, the resource path of the target image resource in the application project and the text area information of the target image resource can be obtained. The text area information can be obtained by performing OCR recognition on the target image resource as described above. The resource path is the storage location information of the target image resource in the project directory, which is used to uniquely identify the location of the image in the project.

[0064] Step B13: Read the binary content of the target image resource and calculate the hash value of the pixel content of the target image resource based on the binary content; Understandably, the binary content of the target image resource, i.e., the pixel content, can be read, and the hash value of the pixel content of the target image resource, such as the MD5 hash value, can be calculated based on the pixel content.

[0065] Step B14: Generate a visual fingerprint based on the target translation language list, the resource path, the text region information, and the hash value.

[0066] In practice, a unique visual fingerprint can be generated by comprehensively calculating the resource path, hash value, text region information detected by OCR, and the list of target translation languages ​​for each image. For example, the above information can be concatenated into a complete string according to a preset order and format. This string is the "visual fingerprint" of the target image resource in the current project state.

[0067] The visual fingerprint generated in this way perfectly associates image content, layout information, project structure, and building goals, providing a solid foundation for subsequent incremental caching mechanisms.

[0068] Step S302: Based on the visual fingerprint, query the preset cache database to see if there is a cached visual fingerprint that matches the visual fingerprint.

[0069] It should be noted that before initiating a translation request, the plugin can first query the preset cache database in the local or intranet shared cache server using visual fingerprints to determine whether the currently generated visual fingerprint already exists in the preset cache database. The preset cache database is used to store the visual fingerprints and translation results corresponding to already translated image resources.

[0070] It is understandable that if the currently generated visual fingerprint does not exist in the preset cache database, then the target image resource may need to be sent to the multimodal large language model for translation. Therefore, in one feasible implementation, after step S302, steps B21 to B23 are also included: Step B21: When no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, obtain the context association information of the target image resource in the current application project; It should be noted that if the cached visual fingerprint for visual fingerprint matching does not exist in the preset cache database, a large language model is required to translate the target image resource. In order to solve the translation ambiguity caused by the text in the image being out of the application context, the plugin can perform multi-dimensional context association analysis on each image that needs to be translated, thereby obtaining the context association information of the target image resource in the current application project.

[0071] Contextual information may include code association information of the target image resource, layout context information, and visual semantic classification results, such as the resource file name where the target image resource is located, the path of the functional module where the image is located, the code comments and layout XML text descriptions that reference the image, the overall application package name, and the application name, etc., which can help determine the translation context.

[0072] In one feasible implementation, step B21 may include: When no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, code association analysis, layout association analysis, and visual semantic classification are performed on the target image resource to obtain code association information, layout context information, and visual semantic classification results; the code association information, layout context information, and visual semantic classification results are then integrated into the context association information of the target image resource in the application project.

[0073] It should be noted that if a corresponding visual fingerprint does not exist, code association analysis, layout association analysis, and visual semantic classification can be performed on the target image resource.

[0074] In practice, code association analysis of the target image resources includes: Scan the source code directory and resource directory of the application project to determine the resource identifier of the target image resource; locate the code position referenced by the resource identifier; extract the page class name and the functional module tag of the page to which the code position belongs, and obtain the code association information based on the page class name and the functional module tag.

[0075] Understandably, lightweight static parsing can be used to scan all layout XML files and Java / Kotlin source code in the project to find the location where the image resource ID is referenced. The Activity / Fragment class name and the functional module tag of the page containing it can then be extracted, allowing the code association information of the target image resource to be obtained based on the page class name and functional module tag.

[0076] In one feasible implementation, layout association analysis of the target image resource includes: The resource directory referencing the target image resource is parsed, and the layout element text, control type, and position of the target image resource in the page layout hierarchy are extracted from the preset position of the control of the target image resource. The layout context information is obtained based on the layout element text, the control type, and the position of the target image resource in the page layout hierarchy.

[0077] It should be noted that the resource directory referencing the target image resource can be parsed, i.e., the Layout XML file referencing the target image resource. The default position is before and after the target image resource control. From this, we can obtain the text of other UI layout elements before and after the image control, the control type, and the image's position in the page layout hierarchy. The control type can be ImageView, ViewPager, etc.

[0078] In practice, the layout element text, control type, and position can be used as the layout context information of the target image resource.

[0079] In one feasible implementation, the visual semantic category of the target image resource can be analyzed using a lightweight image classification model, such as an image classification model based on the MobileNet architecture, to infer the visual semantic category of the image and obtain visual semantic classification results, such as "new user guide page", "functional description image", "activity banner", "empty status prompt image", "button background", etc., thereby providing scene dimension information for translation.

[0080] Step B22: Based on the contextual information and the target image resource, input the multimodal large language model for translation to obtain the text content in the target language.

[0081] In practice, contextual information can be integrated into multimodal contextual prompts, or MultimodalPrompts. These multimodal contextual prompts, along with the text content to be translated from the target image resource and the image itself, are then sent to a multimodal translation service to obtain the text content in the target language.

[0082] It should be noted that this embodiment can be based on a private multimodal large language model, which is deployed in a secure and controllable environment within the enterprise intranet. This model receives translation requests with application context, generates intelligent translations of appropriate length based on the context, and performs accurate disambiguation translation.

[0083] This embodiment extracts a three-dimensional context of "code + layout + visual semantics" through static analysis during compilation, and uses this to construct a mechanism for multimodal cue words to guide large-scale model reasoning. This enables the private multimodal LLM to understand the actual usage scenarios of images in applications, just like developers and designers, accurately eliminating semantic ambiguity in isolated image translation. The translation accuracy and localization fit far exceed traditional context-agnostic translation methods.

[0084] In practice, after generating the text content in the target language, the newly generated translation results and their corresponding visual fingerprints can be written into a cache database for reuse in subsequent constructions.

[0085] Step S303: When a cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the translation result of the target translation language corresponding to the cached visual fingerprint is taken as the text content of the target language.

[0086] Understandably, if a cached visual fingerprint exists in the preset cache database that matches the visual fingerprint, then the translated content stored in the cached visual fingerprint can be directly used as the text content of the target language.

[0087] This embodiment determines the visual fingerprint of the target image resource; queries a preset cache database to see if a matching cached visual fingerprint exists; and when a matching cached visual fingerprint exists in the preset cache database, the translation result of the target language corresponding to the cached visual fingerprint is used as the text content in the target language. By introducing an incremental caching mechanism based on visual fingerprints, time-consuming text detection, translation, image repair, and rendering are only triggered when the image resource changes. In everyday incremental compilation scenarios, most unchanged images can directly hit the cache, improving translation efficiency and effectiveness.

[0088] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Step S40 includes steps S401 to S402: Step S401: Perform background restoration on the target image resource based on the visual attribute information to obtain a background image.

[0089] It should be noted that visual reconstruction of the target image resource can be performed based on the visual attribute information in the target image resource. For example, a mask can be generated based on the bounding box of the text region in the visual attribute information, and then image inpainting can be performed based on the generated mask image.

[0090] In one feasible implementation, step S401 may include steps C11 to C14: Step C11: Obtain the bounding box of the text region in the target image resource based on the visual attribute information; It should be noted that, based on visual attribute information, the location bounding box corresponding to each text block obtained by OCR can be extracted, and the bounding boxes of all text regions together constitute the location identifier of the area to be repaired.

[0091] Step C12: Obtain a blank mask image with the same size as the target image resource; In practice, a blank mask image with the same size as the target image resource can be obtained, that is, a completely black image with the same length and width pixels as the original image and all pixels having an initial value of 0 can be created.

[0092] Step C13: Fill the text region bounding box into the blank mask image to obtain the mask image; It should be noted that by setting the pixel value of the corresponding position of the bounding box of all text regions to 255, after filling, all areas where text needs to be removed will be marked in white, while the remaining areas will remain in black, thus obtaining a mask image containing the complete text region markings.

[0093] Understandably, the white areas of the mask are marked as text areas that need to be erased, while the black areas are the original image areas that need to be preserved. To avoid jagged edges on the text, the edges of the mask are moderately dilated.

[0094] Step C14: Perform background restoration on the target image resource based on the mask image to obtain a background base image.

[0095] It should be noted that the mask image and the target image resource can be sent together to the private Inpainting service. The Inpainting service is an image restoration service based on the Diffusion Model, responsible for erasing the original text area and reconstructing the background texture. Specifically, AI Inpainting mainly uses artificial intelligence generative model technology to erase specific text areas (bounding boxes) in the image while adaptively filling in and reconstructing a coherent background texture based on surrounding pixels, generating a "clean" base image.

[0096] The Inpainting engine, based on a diffusion model, analyzes the color gradient, texture pattern, and geometric structure of the area surrounding the mask, and gradually completes the background pattern obscured by text through an iterative denoising process. The restoration result naturally continues the original visual elements such as gradient colors, geometric shapes, and illustration style, ensuring that the erased background image is visually free of afterimages and has no sense of incongruity.

[0097] In practice, automated quality checks can be performed on the restored image, including edge smoothness detection, color consistency verification, and ghosting detection. If the quality does not meet the standards, a second restoration iteration is triggered.

[0098] Step S402: Render the text content of the target language onto the background image to generate a local file of the target image.

[0099] It should be noted that after obtaining the cleaned background map, the text in the target language can be rendered onto the cleaned background map, ultimately generating the target image local file.

[0100] During rendering, the text redrawing stage is entered, which requires considering the text area and text layout. Then, the text is rendered, and finally, the target image local file is generated.

[0101] In one feasible implementation, step S402 may include steps C21-C23: Step C21: Obtain the text area, font size, text alignment, text color, and text style parameters of the target image resource based on the visual attribute information; It should be noted that the visual attribute information includes the text region location of the target image resource, the original text content recognition result, and the font size, color, alignment method, and font style parameters corresponding to each text block. These parameters are obtained through OCR text detection and visual analysis, which can accurately restore the text layout features of the original image.

[0102] Step C22: Calculate the area of ​​the translated text based on the text content in the target language and the font size value; In practice, the pixel area of ​​the translated text at the original font size can be calculated based on the font size value corresponding to the text area, i.e., the area of ​​the translated text, and the total width and height required for the translated text can be calculated.

[0103] Step C23: Adjust the text alignment and font size value based on the area of ​​the translated text to obtain the target text alignment and target font size value; Understandably, adaptive layout can be implemented based on the area of ​​the translated text. Different layout methods are required for different areas of the translated text. The layout can be adjusted through text alignment and font size. Therefore, text alignment and font size can be dynamically adjusted based on the area of ​​the translated text.

[0104] In one feasible implementation, the step of adjusting the text alignment and font size value based on the translated text area to obtain the target text alignment and target font size value includes: When the area of ​​the translated text is less than or equal to the area of ​​the text region, the text alignment method is used as the target text alignment method, and the font size value is used as the target font size value; When the area of ​​the translated text is greater than the area of ​​the text region and less than or equal to a preset ratio of the area of ​​the text region, the font size value obtained by annotating the text and reducing the font size value by the preset ratio is used as the target font size value. A line break strategy is set in the text alignment method, and the text alignment method after setting the line break strategy is used as the target text alignment method. When the area of ​​the translated text is greater than a preset ratio of the area of ​​the text region, the minimum allowed font size of the font size value is taken as the target font size value, a line spacing reduction strategy is set in the text alignment method, and the text alignment method after setting the line spacing reduction strategy is taken as the target text alignment method.

[0105] It should be noted that if the area of ​​the translated text is less than or equal to the area of ​​the mosquito region, the original font size and the original layout will remain unchanged. That is, the target text alignment will be the original text alignment, and the target font size will be the original Chinese font size.

[0106] In practice, the preset ratio is set to 150%. If the area of ​​the translated text is larger than the original text area but does not exceed 150% of the original text area, the target font size can be the font size reduced according to the preset ratio and the font size of the text annotation. The preset ratio can be set according to needs, but should not be less than 70% of the original font size. The text annotation can be in bold form to maintain visual weight. The line wrapping strategy can be an automatic line wrapping strategy, such as reducing the font size to 80% of the original font size and making it bold, while simultaneously activating an automatic caching strategy during typesetting.

[0107] In practice, if the area of ​​the translated text is greater than 150% of the original text area, the minimum allowed font size can be used as the target font size, and a line spacing strategy can be set. If necessary, an abbreviation strategy can be enabled. For example, a short translation version that is semantically equivalent to that provided by a multimodal LLM can be obtained and then abbreviated for translation.

[0108] Step C24: Fill the background image with the text content of the target language using the target text alignment method and the target font size value; In practice, the target text alignment method and target font size value can be used to fill the target language text content into the background image.

[0109] Step C25: Render the text content in the target language after filling using the text color and the text style parameters to generate a local target image file.

[0110] In practice, text can be rendered according to the original font's text color and text style parameters to render the target semantic text. The rendering engine supports anti-aliasing and subpixel rendering to ensure that the text is clear and sharp.

[0111] In practice, based on the rendered standard resolution image, five sets of image files with different densities—mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi—can be automatically scaled to obtain the target image local file, ensuring the best display effect on various Android devices.

[0112] This embodiment performs background restoration on the target image resource based on the visual attribute information to obtain a background base image; the text content of the target language is then rendered onto the background base image to generate a local target image file. Through these steps, a fully automated process is achieved, from erasing the original text from the original image, reconstructing the background, and then adapting and rendering the new text. This eliminates the need for manual modification of each image, significantly reducing the labor costs of image localization, while ensuring that the translated text layout is adapted to the original image's layout space and maintains visual style consistency with the original image. Based on the first embodiment of this application, in the fourth embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 Step S20 includes steps S201 to S205: Step S201: Obtain the preset image size threshold and preset file size value based on image attributes.

[0113] It should be noted that the image attributes include the size information and file size information for filtering images. The preset image size threshold refers to the size boundary set when filtering images, and the preset file size value is the minimum file size allowed when filtering images. Only image resources that meet the size and file size requirements will be marked as target image resources that need to be processed.

[0114] Step S202: Remove images from the image resources to be processed whose image size is smaller than the preset image size threshold or whose file size in bytes is smaller than the preset file size value, to obtain candidate image resources.

[0115] In practice, preset image size thresholds and file size values ​​can be used to filter out pure icons and decorative images that do not contain text, thereby obtaining candidate image resources.

[0116] Step S203: Perform text detection on the candidate image resources to obtain the text region bounding box and confidence value of each candidate image.

[0117] Understandably, candidate image resources can be sent to an OCR inference service for text detection. The OCR inference service is based on a lightweight OCR model (such as PaddleOCR Lite), which is responsible for image text region detection and visual attribute extraction. The OCR model is used to quickly scan the image resources of the entire project during construction and filter out background images or placeholder images containing pixel-level text.

[0118] In practice, the OCR model performs text region localization on each candidate image and can output information such as the geometric bounding box coordinates of each text region, the recognized text content, and the confidence value.

[0119] Step S204: Select candidate images with confidence values ​​greater than a preset confidence threshold as target image resources, and extract visual attributes from the text regions of the target image resources to obtain the text attributes and background texture features of the text regions in the target image resources.

[0120] It should be noted that the pre-set confidence threshold can be set in advance as needed, for example, to 0.85. Only when a candidate image resource contains a text region with a confidence value greater than the pre-set confidence threshold will that candidate image be marked as a resource requiring translation, i.e., the target image resource. This pre-screening mechanism effectively avoids the waste of computing resources caused by sending a large number of purely decorative icons into the AI ​​processing pipeline.

[0121] For image resources marked as requiring translation, the plugin further invokes the advanced analysis capabilities of the OCR inference service to extract refined visual attribute information for each text region, specifically including text attributes and background texture features.

[0122] It should be noted that the text attributes of the text area include font color, font size, text direction, and text alignment.

[0123] In practice, font color extraction can be achieved by sampling and analyzing pixels within the text area, identifying the main text color using the K-Means clustering algorithm (supporting RGB and alpha channels), and accurately matching the color value of the original text.

[0124] Font size estimation can be performed by combining the height of the bounding box in pixels and the number of characters in the text content with DPI information to estimate the original font size. Text orientation includes whether the text is arranged horizontally or vertically, and text alignment includes left alignment, center alignment, and right alignment.

[0125] Understandably, background texture features can be obtained by extracting the color distribution and texture features of non-text pixel areas around the text area, providing contextual reference for subsequent image restoration.

[0126] Step S205: Obtain the visual attribute information of the target image resource based on the text region bounding box, the text attributes, and the background texture features.

[0127] In practice, the text region bounding box, text attribute information, and background texture features of the target image resource can be integrated into a structured style description document (Style Descriptor) as the visual attribute information of the target image resource, which facilitates the parameter input for subsequent layout and redrawing.

[0128] This embodiment obtains a preset image size threshold and a preset file size value based on image attributes; images whose size is smaller than the preset image size threshold or whose file size is smaller than the preset file size value are removed from the image resources to be processed, resulting in candidate image resources; text detection is performed on the candidate image resources to obtain the text region bounding boxes and confidence values ​​of each candidate image; candidate images with confidence values ​​greater than a preset confidence threshold are selected as target image resources, and visual attributes are extracted from the text regions of the target image resources to obtain the text attributes and background texture features of the text regions in the target image resources; visual attribute information of the target image resources is obtained based on the text region bounding boxes, the text attributes, and the background texture features. Through the above steps, valid candidates are pre-screened based on image size and file size, and then the target image is locked through OCR detection and confidence filtering. Finally, structured visual attribute information is extracted, providing an accurate parameter basis for subsequent background repair and text rendering. While ensuring that no target images containing text are missed, invalid calculations are significantly reduced, and the overall efficiency of the image processing workflow is improved.

[0129] For example, to help understand the implementation flow of the image resource processing method obtained by combining this embodiment with the above embodiment one, please refer to... Figure 5 , Figure 5 A simplified flowchart of an image resource processing method is provided, specifically including: S1: Build lifecycle monitoring and target language and image resource target parsing; S2: AAPT2 mergeResources task interception and text-containing image resource filtering; S3: Fine extraction of visual attributes of text regions and generation of style descriptions; S4: Image context construction based on engineering correlation analysis; S5: Incremental caching judgment based on visual fingerprint and multimodal LLM intelligent translation; S6: Text region erasure and background texture reconstruction based on AI Inpainting; S7: Cross-language adaptive text version and intelligent redraw engine; S8: Seamless injection of AAPT2 compilation artifacts and subsequent build chain release.

[0130] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the image resource processing method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0131] This application also provides an image resource processing device, please refer to... Figure 6 The image resource processing device includes: Interception module 10 is used to intercept image resources to be processed during the resource merging stage of the target application's build process.

[0132] The processing module 20 is used to process the image resource to be processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource.

[0133] The translation module 30 is used to translate the target image resource to obtain text content in the target language.

[0134] The rendering module 40 is used to render the target image resource based on the visual attribute information and the text content of the target language to obtain a local file of the target image.

[0135] The resource merging module 50 is used to merge resources based on the local files of the target image to generate an application package that supports the target language.

[0136] The image resource processing apparatus provided in this application, employing the image resource processing method described in the above embodiments, can solve the technical problem of low efficiency in multilingual localization processing of image resources in current mobile application development. Compared with the prior art, the beneficial effects of the image resource processing apparatus provided in this application are the same as those of the image resource processing method provided in the above embodiments, and other technical features in the image resource processing apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0137] In one embodiment, the translation module 30 is further configured to determine the visual fingerprint of the target image resource; query a preset cache database based on the visual fingerprint to see if there is a cached visual fingerprint that matches the visual fingerprint; and when there is a cached visual fingerprint in the preset cache database that matches the visual fingerprint, use the translation result of the target translation language corresponding to the cached visual fingerprint as the text content of the target language.

[0138] In one embodiment, the translation module 30 is further configured to obtain a pre-configured list of target translation languages; obtain the resource path of the target image resource in the project and the text region information of the target image resource; read the binary content of the target image resource and calculate the hash value of the pixel content of the target image resource based on the binary content; and generate a visual fingerprint based on the list of target translation languages, the resource path, the text region information and the hash value.

[0139] In one embodiment, the device further includes an acquisition module, which is configured to acquire contextual association information of the target image resource in the current application project when no cached visual fingerprint matching the visual fingerprint exists in the preset cache database; and to translate the target image resource into a multimodal large language model based on the contextual association information and the target image resource to obtain text content in the target language.

[0140] In one embodiment, the acquisition module is further configured to perform code association analysis, layout association analysis, and visual semantic classification on the target image resource when no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, to obtain code association information, layout context information, and visual semantic classification results; and integrate the code association information, the layout context information, and the visual semantic classification results into context association information of the target image resource in the application project.

[0141] In one embodiment, the acquisition module is further configured to acquire the resource identifier of the target image resource; scan the source code directory and resource directory of the application project to determine the resource directory of the target image resource; perform code association analysis and layout association analysis on the target image resource based on the resource directory to obtain code association information and layout context information; and analyze the visual semantic category of the target image resource to obtain visual semantic classification results.

[0142] In one embodiment, the rendering module 40 is further configured to perform background repair on the target image resource based on the visual attribute information to obtain a background base map; and render the text content of the target language onto the background base map to generate a local file of the target image.

[0143] In one embodiment, the rendering module 40 is further configured to: obtain the bounding box of the text region in the target image resource based on the visual attribute information; obtain a blank mask image with the same size as the target image resource; fill the text region bounding box into the blank mask image to obtain a mask image; and perform background restoration on the target image resource based on the mask image to obtain a background image.

[0144] In one embodiment, the rendering module 40 is further configured to obtain the area of ​​the text region, the font size value corresponding to the text region, the text alignment method, the text color, and the text style parameters in the target image resource based on the visual attribute information; calculate the area of ​​the translated text based on the text content of the target language and the font size value; adjust the text alignment method and the font size value based on the translated text area to obtain the target text alignment method and the target font size value; fill the text content of the target language into the background image using the target text alignment method and the target font size value; and render the filled text content of the target language using the text color and the text style parameters to generate a local file of the target image.

[0145] In one embodiment, the rendering module 40 is further configured to: when the area of ​​the translated text is less than or equal to the area of ​​the text region, use the text alignment method as the target text alignment method and the font size value as the target font size value; when the area of ​​the translated text is greater than the area of ​​the text region and less than or equal to a preset ratio of the area of ​​the text region, use the font size value obtained by annotating the text and reducing the font size value by a preset ratio as the target font size value, set a line break strategy in the text alignment method, and use the text alignment method after setting the line break strategy as the target text alignment method; when the area of ​​the translated text is greater than a preset ratio of the area of ​​the text region, use the minimum allowed font size of the font size value as the target font size value, set a line spacing reduction strategy in the text alignment method, and use the text alignment method after setting the line spacing reduction strategy as the target text alignment method.

[0146] In one embodiment, the processing module 20 is further configured to: obtain a preset image size threshold and a preset file size value based on image attributes; remove images from the image resources to be processed whose image size is smaller than the preset image size threshold or whose file size in the image resources to be processed is smaller than the preset file size value, thereby obtaining candidate image resources; perform text detection on the candidate image resources to obtain the text region bounding boxes and confidence values ​​of each candidate image; use candidate images whose confidence values ​​are greater than a preset confidence threshold as target image resources, and extract visual attributes from the text regions of the target image resources to obtain the text attributes and background texture features of the text regions in the target image resources; and obtain the visual attribute information of the target image resources based on the text region bounding boxes, the text attributes, and the background texture features.

[0147] In one embodiment, the resource merging module 50 is further configured to obtain the virtual image resource directory structure for each language constructed in memory; map the image files for each language in the target image local file to the corresponding resource qualifier directories in the virtual image resource directory structure to generate virtual resource data; and merge the virtual resource data to generate an application package that supports the target language.

[0148] In one embodiment, the interception module 10 is further configured to, during the resource merging stage of the target application's construction process, parse preset static configuration data to obtain a pre-configured list of target translation languages ​​and a range of image resource directories to be translated; and based on the list of target translation languages ​​and the range of image resource directories to be translated, parse the directory structure of the intercepted application project to obtain the image resources to be processed in the range of image resource directories to be translated.

[0149] This application provides an image resource processing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image resource processing method in Embodiment 1 above.

[0150] The following is for reference. Figure 7This document illustrates a structural schematic diagram of an image resource processing device suitable for implementing embodiments of this application. The image resource processing device in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 7 The image resource processing device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0151] like Figure 7 As shown, the image resource processing device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the image resource processing device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touch screens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. The communication device 1009 allows the image resource processing device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show image resource processing devices with various systems, it should be understood that implementing or having all of the systems shown is not required. More or fewer systems may be implemented alternatively.

[0152] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0153] The image resource processing device provided in this application, employing the image resource processing method described in the above embodiments, can solve the technical problem of low efficiency in multilingual localization processing of image resources in current mobile application development. Compared with the prior art, the beneficial effects of the image resource processing device provided in this application are the same as those of the image resource processing method provided in the above embodiments, and other technical features of this image resource processing device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0154] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0155] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0156] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the image resource processing method in the above embodiments.

[0157] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0158] The aforementioned computer-readable storage medium may be included in the image resource processing device; or it may exist independently and not be assembled into the image resource processing device.

[0159] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by the image resource processing device, the image resource processing device: intercepts image resources to be processed during the resource merging stage of the target application's construction process; processes the image resources to be processed based on image attributes to obtain target image resources and their visual attribute information; translates the target image resources to obtain text content in the target language; renders the target image resources based on the visual attribute information and the text content in the target language to obtain a local target image file; and merges resources based on the local target image file to generate an application package that supports the target language.

[0160] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0161] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0162] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0163] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described image resource processing method, which can solve the technical problem of low efficiency in multilingual localization processing of image resources in current mobile application development. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the image resource processing method provided in the above embodiments, and will not be repeated here.

[0164] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the image resource processing method described above.

[0165] The computer program product provided in this application can solve the technical problem of low efficiency in multilingual localization processing of image resources in current mobile application development. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the image resource processing method provided in the above embodiments, and will not be repeated here.

[0166] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

[0167] This application discloses A1. A method for processing image resources, the method comprising: During the resource merging phase of the target application's build process, intercept the image resources to be processed; The image resource to be processed is processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource. The target image resource is translated to obtain text content in the target language; The target image resource is rendered based on the visual attribute information and the text content in the target language to obtain a local file of the target image; Resources are merged based on the target image's local files to generate an application package that supports the target language.

[0168] A2. As described in A1, the step of translating the target image resource to obtain text content in the target language includes: Determine the visual fingerprint of the target image resource; Based on the visual fingerprint, query the preset cache database to see if there is a cached visual fingerprint that matches the visual fingerprint; When a cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the translation result of the target translation language corresponding to the cached visual fingerprint is used as the text content of the target language.

[0169] A3. As described in A2, the step of determining the visual fingerprint of the target image resource includes: Retrieve a pre-configured list of target translation languages; Obtain the resource path of the target image resource in the project and the text area information of the target image resource; Read the binary content of the target image resource, and calculate the hash value of the pixel content of the target image resource based on the binary content; A visual fingerprint is generated based on the target translation language list, the resource path, the text region information, and the hash value.

[0170] A4. As described in A2, after the step of querying the preset cache database based on the visual fingerprint to see if a cached visual fingerprint matching the visual fingerprint exists, the method further includes: If no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, obtain the context association information of the target image resource in the current application project; Based on the contextual information and the target image resource, a multimodal large language model is input for translation to obtain the text content in the target language.

[0171] A5. As described in A4, the step of obtaining the context association information of the target image resource in the current application project when there is no cached visual fingerprint matching the visual fingerprint in the preset cache database includes: When no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, code association analysis, layout association analysis, and visual semantic classification are performed on the target image resource to obtain code association information, layout context information, and visual semantic classification results. The code association information, the layout context information, and the visual semantic classification results are integrated into the context association information of the target image resource in the application project.

[0172] A6. As described in A5, the steps of performing code association analysis, layout association analysis, and visual semantic classification on the target image resource to obtain code association information, layout context information, and visual semantic classification results include: Obtain the resource identifier of the target image resource; Scan the source code directory and resource directory of the application project to determine the resource directory of the target image resource; Based on the resource catalog, code association analysis and layout association analysis are performed on the target image resources to obtain code association information and layout context information. The visual semantic categories of the target image resources are analyzed to obtain visual semantic classification results.

[0173] A7. The method as described in any one of A1 to A6, wherein the step of rendering the target image resource based on the visual attribute information and the text content of the target language to obtain a local file of the target image includes: Based on the visual attribute information, the target image resource is restored to obtain a background image. The text content in the target language is rendered onto the background image to generate a local file of the target image.

[0174] A8. As described in A7, the step of performing background restoration on the target image resource based on the visual attribute information to obtain a background image includes: The bounding box of the text region in the target image resource is obtained based on the visual attribute information; Obtain a blank mask image with the same size as the target image resource; The bounding box of the text region is filled into the blank mask image to obtain the mask image; The target image resource is then repaired based on the mask image to obtain a background base image.

[0175] A9. As described in A7, the step of rendering the text content of the target language onto the background image to generate a local target image file includes: Based on the visual attribute information, the text region area, the font size value corresponding to the text region, the text alignment method, the text color, and the text style parameters in the target image resource are obtained; Calculate the area of ​​the translated text based on the text content in the target language and the font size value; Based on the area of ​​the translated text, the text alignment and font size are adjusted to obtain the target text alignment and target font size. The target text content in the target language is filled into the background image using the target text alignment method and the target font size value; The text content in the target language after filling is rendered using the text color and the text style parameters to generate a local target image file.

[0176] A10. As described in A9, the step of adjusting the text alignment and the font size value based on the translated text area to obtain the target text alignment and the target font size value includes: When the area of ​​the translated text is less than or equal to the area of ​​the text region, the text alignment method is used as the target text alignment method, and the font size value is used as the target font size value; When the area of ​​the translated text is greater than the area of ​​the text region and less than or equal to a preset ratio of the area of ​​the text region, the font size value obtained by annotating the text and reducing the font size value by the preset ratio is used as the target font size value. A line break strategy is set in the text alignment method, and the text alignment method after setting the line break strategy is used as the target text alignment method. When the area of ​​the translated text is greater than a preset ratio of the area of ​​the text region, the minimum allowed font size of the font size value is taken as the target font size value, a line spacing reduction strategy is set in the text alignment method, and the text alignment method after setting the line spacing reduction strategy is taken as the target text alignment method.

[0177] A11. The method as described in any one of A1 to A6, wherein the step of processing the image resource to be processed based on image attributes to obtain the target image resource and the visual attribute information of the target image resource includes: The preset image size threshold and preset file size value are obtained based on image attributes; Images whose size is smaller than the preset image size threshold or whose file size in bytes is smaller than the preset file size value are removed from the image resources to be processed to obtain candidate image resources; Text detection is performed on the candidate image resources to obtain the bounding boxes of the text regions and the confidence values ​​of each candidate image; Candidate images with confidence values ​​greater than a preset confidence threshold are used as target image resources, and visual attributes are extracted from the text regions of the target image resources to obtain the text attributes and background texture features of the text regions in the target image resources. The visual attribute information of the target image resource is obtained based on the text region bounding box, the text attributes, and the background texture features.

[0178] A12. The method as described in any one of A1 to A6, wherein the step of merging resources based on the local file of the target image to generate an application package supporting the target language includes: Obtain the directory structure of virtual image resources in various languages ​​constructed in memory; The image files of each language in the target image local file are mapped to the corresponding resource qualifier directories in the virtual image resource directory structure to generate virtual resource data; The virtual resource data is merged to generate an application package that supports the target language.

[0179] A13. The method as described in any one of A1 to A6, wherein the step of intercepting the image resource to be processed during the resource merging phase of the target application's build process includes: During the resource merging phase of the target application's build process, the preset static configuration data is parsed to obtain the pre-configured list of target translation languages ​​and the range of image resource directories to be translated. Based on the target translation language list and the range of image resource directories to be translated, the intercepted application project directory structure is parsed to obtain the image resources to be processed in the range of image resource directories to be translated.

[0180] This application also discloses B14. An image resource processing apparatus, the apparatus comprising: The interception module is used to intercept image resources to be processed during the resource merging phase of the target application's build process. The processing module is used to process the image resource to be processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource; The translation module is used to translate the target image resource to obtain text content in the target language; The rendering module is used to render the target image resource based on the visual attribute information and the text content in the target language to obtain a local file of the target image; The resource merging module is used to merge resources based on the local files of the target image to generate an application package that supports the target language.

[0181] B15. The apparatus as described in B14, wherein the translation module is further configured to determine a visual fingerprint of the target image resource; Based on the visual fingerprint, query the preset cache database to see if there is a cached visual fingerprint that matches the visual fingerprint; When a cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the translation result of the target translation language corresponding to the cached visual fingerprint is used as the text content of the target language.

[0182] B16. The apparatus as described in B15, wherein the translation module is further configured to obtain a pre-configured list of target translation languages; Obtain the resource path of the target image resource in the project and the text area information of the target image resource; Read the binary content of the target image resource, and calculate the hash value of the pixel content of the target image resource based on the binary content; A visual fingerprint is generated based on the target translation language list, the resource path, the text region information, and the hash value.

[0183] B17. The apparatus as described in B15, the apparatus further comprising an acquisition module, the acquisition module being configured to acquire contextual association information of the target image resource in the current application project when no cached visual fingerprint matching the visual fingerprint exists in the preset cache database; Based on the contextual information and the target image resource, a multimodal large language model is input for translation to obtain the text content in the target language.

[0184] This application also discloses C18. An image resource processing apparatus, the apparatus comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the image resource processing method as described above.

[0185] This application also discloses D19. A storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the image resource processing method described above.

[0186] This application also discloses E20. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the image resource processing method described above.

Claims

1. A method for processing image resources, characterized in that, The image resource processing method includes: During the resource merging phase of the target application's build process, intercept the image resources to be processed; The image resource to be processed is processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource. The target image resource is translated to obtain text content in the target language; The target image resource is rendered based on the visual attribute information and the text content in the target language to obtain a local file of the target image; Resources are merged based on the target image's local files to generate an application package that supports the target language.

2. The method as described in claim 1, characterized in that, The step of translating the target image resource to obtain text content in the target language includes: Determine the visual fingerprint of the target image resource; Based on the visual fingerprint, query the preset cache database to see if there is a cached visual fingerprint that matches the visual fingerprint; When a cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the translation result of the target translation language corresponding to the cached visual fingerprint is used as the text content of the target language.

3. The method as described in claim 2, characterized in that, The step of determining the visual fingerprint of the target image resource includes: Retrieve a pre-configured list of target translation languages; Obtain the resource path of the target image resource in the project and the text area information of the target image resource; Read the binary content of the target image resource, and calculate the hash value of the pixel content of the target image resource based on the binary content; A visual fingerprint is generated based on the target translation language list, the resource path, the text region information, and the hash value.

4. The method as described in claim 2, characterized in that, After the step of querying the preset cache database based on the visual fingerprint to see if a cached visual fingerprint matching the visual fingerprint exists, the method further includes: If no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, obtain the context association information of the target image resource in the current application project; Based on the contextual information and the target image resource, a multimodal large language model is input for translation to obtain the text content in the target language.

5. The method as described in claim 4, characterized in that, When no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, the step of obtaining the context association information of the target image resource in the current application project includes: When no cached visual fingerprint matching the visual fingerprint exists in the preset cache database, code association analysis, layout association analysis, and visual semantic classification are performed on the target image resource to obtain code association information, layout context information, and visual semantic classification results. The code association information, the layout context information, and the visual semantic classification results are integrated into the context association information of the target image resource in the application project.

6. The method as described in claim 5, characterized in that, The steps for performing code association analysis, layout association analysis, and visual semantic classification on the target image resource to obtain code association information, layout context information, and visual semantic classification results include: Obtain the resource identifier of the target image resource; Scan the source code directory and resource directory of the application project to determine the resource directory of the target image resource; Based on the resource catalog, code association analysis and layout association analysis are performed on the target image resources to obtain code association information and layout context information. The visual semantic categories of the target image resources are analyzed to obtain visual semantic classification results.

7. An image resource processing device, characterized in that, The device includes: The interception module is used to intercept image resources to be processed during the resource merging phase of the target application's build process. The processing module is used to process the image resource to be processed based on the image attributes to obtain the target image resource and the visual attribute information of the target image resource; The translation module is used to translate the target image resource to obtain text content in the target language; The rendering module is used to render the target image resource based on the visual attribute information and the text content in the target language to obtain a local file of the target image; The resource merging module is used to merge resources based on the local files of the target image to generate an application package that supports the target language.

8. An image resource processing device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the image resource processing method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the image resource processing method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the image resource processing method as described in any one of claims 1 to 6.