Picture processing method and device

Through SVG technology, images in Internet hospital scenarios are preprocessed and cached images adapted to different sizes are generated, which solves the problems of response extension and high CPU consumption under high concurrency, and achieves efficient query performance and low CPU consumption.

CN119293357APending Publication Date: 2025-01-10BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310839221.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-10
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

In the Internet hospital scenario, real-time processing of images under high concurrent requests leads to an extended response time, and the use of Graphics2D components consumes more CPU resources, reducing the efficiency of request processing.

Method used

The original image is processed according to preset parameters by using SVG technology, multiple images adapted to different sizes are generated and stored in the cache, and pictures that meet the parameters are returned directly from the cache, avoiding real-time processing and reducing CPU resource consumption.

Benefits of technology

Reduces response time, improves query performance, ensures image quality, reduces CPU resource consumption, and improves processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293357A_ABST
    Figure CN119293357A_ABST
Patent Text Reader

Abstract

The invention discloses a picture processing method and device, and relates to the technical field of internet medical treatment. A specific embodiment of the method comprises the steps of obtaining a picture query request comprising a to-be-queried picture identifier and picture parameters; according to the picture identifier and the picture parameter, determining whether a second picture corresponding to the picture query request exists in a plurality of first pictures pre-stored in a cache; wherein the first picture is obtained by processing an original picture according to a preset parameter by utilizing a scalable vector graphics technology; under the condition that the second picture does not exist in the cache, determining a target original picture corresponding to a picture identifier, and processing the target original picture by utilizing a scalable vector graphics technology according to picture parameters to obtain the second picture; and under the condition that the second picture exists in the cache, responding to the picture query request according to the second picture. According to the embodiment, the request response duration is shortened, the query performance is improved, and the picture quality is not reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet medical technology, and in particular to a method and device for processing images. Background Art

[0002] Users can browse and process the same image through different channels. For example, in an Internet hospital scenario, operators, doctors, patients, pharmacists and other users can view the same electronic prescription image through their own terminals of different models.

[0003] The image sizes required by different terminals are not consistent. The current image display method is: according to user requests, the Java drawing tool - Graphics2D (2D image) component is used to process the original image into a size suitable for the requesting terminal in real time, and then the image is displayed.

[0004] However, when high concurrent requests are received, this method of processing the original image in real time for each request takes a long time, reducing the request processing efficiency. In addition, the use of Graphics2D components to draw images consumes more CPU resources. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for processing images, which can use SVG (Scalable Vector Graphics) technology to process the original image according to preset parameters, and obtain multiple first images stored in a cache. After receiving an image query request, a second image corresponding to the requested image parameters and image identifier is determined from the multiple first images in the cache, and the image query request is responded to through the second image. In this way, the second image that meets the image parameters is directly returned when the user queries, and there is no need to process the image in real time, thereby reducing the response time and improving the query performance. In addition, even if the second image does not exist in the cache, the target original image is processed by SVG technology to obtain the second image, and the image quality will not be reduced in the process of adjusting the image parameters. At the same time, it can reduce CPU resource consumption and improve processing efficiency.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for processing an image is provided. A method for processing an image in an embodiment of the present invention comprises: obtaining an image query request, wherein the image query request comprises an image identifier to be queried and image parameters;

[0007] According to the picture identifier and the picture parameters, determining whether there is a second picture corresponding to the picture query request from a plurality of first pictures pre-stored in the cache; wherein the first picture is obtained by processing the original picture according to preset parameters using scalable vector graphics technology;

[0008] If the second picture does not exist in the cache, determining a target original picture corresponding to the picture identifier, and processing the target original picture according to the picture parameters using scalable vector graphics technology to obtain the second picture;

[0009] In a case where the second image exists in the cache, the image query request is responded to according to the second image.

[0010] Optionally, before obtaining the image query request, the method further includes:

[0011] Converting one or more of the original images into scalable vector graphics formats respectively, to obtain extensible markup language strings corresponding to the one or more original images respectively;

[0012] Determine the target characters representing the height and width from the extensible markup language character strings corresponding to the original images;

[0013] The content corresponding to the target character is replaced with a placeholder or a variable to obtain a scalable vector graphics template corresponding to each of the original pictures.

[0014] Optionally, the processing the target original image according to the image parameters by using the scalable vector graphics technology includes: determining a target size parameter corresponding to the target original image according to the image parameters; replacing a placeholder or a variable in a scalable vector graphics template corresponding to the target original image by using the target size parameter to obtain the second image, and storing the second image in the cache;

[0015] Optionally, the placeholders or variables in the scalable vector graphics template are replaced by multiple size parameters included in the preset parameters to obtain multiple first images corresponding to the original image, and the multiple first images are stored in the cache; wherein the multiple first images correspond to different size parameters respectively.

[0016] Optionally, determining a target size parameter corresponding to the target original image according to the image parameter includes:

[0017] Determining whether the image query request includes a stretch parameter;

[0018] In a case where the stretching parameter is not included or the stretching parameter indicates that the picture is not to be stretched: determining a target size parameter corresponding to the target original picture according to the picture parameter and the original parameter of the target original picture;

[0019] In a case where the stretching indicates stretching of the picture, the picture parameter is used as the target size parameter.

[0020] Optionally, the picture parameters include a height parameter and a width parameter, and the original parameters include an original height and an original width; and determining a target size parameter corresponding to the target original picture according to the picture parameters and the original parameters of the target original picture includes:

[0021] respectively calculating a first ratio between the height parameter and the original height, and a second ratio between the width parameter and the original width;

[0022] The target size parameter is determined according to the product of the smaller value of the first ratio and the second ratio, the original height and the original width, respectively.

[0023] Optionally, the method further comprises:

[0024] Record the storage time of the first image and / or the second image in the cache, and if the storage time is greater than a preset time threshold, delete the first image / or the second image whose storage time is greater than the preset time threshold.

[0025] Optionally, when the second picture does not exist in the cache, before the target original picture is processed according to the picture parameters by using the scalable vector graphics technology, the method further includes:

[0026] Determining whether there are preset parameters corresponding to the image parameters;

[0027] If not, determine the cumulative number of times the image parameter is requested, and if the cumulative number is greater than a preset number threshold, configure the image parameter as the preset parameter.

[0028] Optionally, when there are preset parameters corresponding to the picture parameters, the method further includes:

[0029] The target original image is processed according to the size parameters in the preset parameters that are different from the image parameters to obtain second images corresponding to the different size parameters respectively, and the second images are stored in the cache.

[0030] To achieve the above object, according to another aspect of an embodiment of the present invention, a device for processing a picture is provided. The device for processing a picture in an embodiment of the present invention comprises: a request acquisition module, a picture determination module and a processing module; wherein:

[0031] The request acquisition module is used to acquire an image query request, wherein the image query request includes an image identifier to be queried and image parameters;

[0032] The picture determination module is used to determine whether there is a second picture corresponding to the picture query request from multiple first pictures pre-stored in the cache according to the picture identifier and the picture parameters; wherein the first picture is obtained by processing the original picture according to preset parameters using scalable vector graphics technology;

[0033] The processing module is used to determine the target original image corresponding to the image identifier when the second image does not exist in the cache, and use scalable vector graphics technology to process the target original image according to the image parameters to obtain the second image; if the second image exists in the cache, respond to the image query request according to the second image.

[0034] To achieve the above objective, according to another aspect of an embodiment of the present invention, a server for processing pictures is provided.

[0035] A server for processing images according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method for processing images according to an embodiment of the present invention.

[0036] To achieve the above object, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. A computer-readable storage medium according to an embodiment of the present invention stores a computer program, which, when executed by a processor, implements a method for processing a picture according to an embodiment of the present invention.

[0037] An embodiment of the above invention has the following advantages or beneficial effects: the original image is processed according to preset parameters using SVG technology to obtain multiple first images stored in the cache. After receiving the image query request, the second image corresponding to the requested image parameters and image identifier is determined from the multiple first images in the cache, and the image query request is responded to through the second image. In this way, the second image that meets the image parameters is directly returned when the user queries, and there is no need to process the image in real time, thereby reducing the response time and improving the query performance. Moreover, even if the second image does not exist in the cache, the target original image is processed by SVG technology to obtain the second image, and the image quality will not be reduced in the process of adjusting the image parameters. At the same time, it can reduce CPU resource consumption and improve processing efficiency.

[0038] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0040] Figure 1 is a schematic diagram of main steps of a method for processing a picture according to an embodiment of the present invention;

[0041] Figure 2 is a schematic diagram of main steps of generating an SVG template according to an embodiment of the present invention;

[0042] Figure 3 is a schematic diagram of main steps of another method for processing a picture according to an embodiment of the present invention;

[0043] Figure 4 is a schematic diagram of main steps of generating a second image by using SVG technology according to an embodiment of the present invention;

[0044] Figure 5 is a schematic diagram of main modules of a device for processing a picture according to an embodiment of the present invention;

[0045] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0046] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0047] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0048] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0049] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.

[0050] Figure 1FIG. 1 is a schematic diagram of the main steps of a method for processing a picture according to an embodiment of the present invention. Figure 1 As shown, a method for processing a picture according to an embodiment of the present invention mainly includes the following steps:

[0051] Step S101: obtaining an image query request, wherein the image query request includes an image identifier to be queried and image parameters.

[0052] Step S102: According to the image identifier and image parameters, determine whether there is a second image corresponding to the image query request from multiple first images pre-stored in the cache; wherein the first image is obtained by processing the original image according to preset parameters using scalable vector graphics technology; if the second image does not exist in the cache, execute step S103; if the second image exists, execute step S104.

[0053] Step S103: determining a target original picture corresponding to the picture identifier, and processing the target original picture according to the picture parameters using scalable vector graphics technology to obtain the second picture;

[0054] Step S104: respond to the image query request according to the second image.

[0055] According to a method for processing an image according to an embodiment of the present invention, it can be seen that the original image is processed according to preset parameters using SVG technology to obtain multiple first images stored in the cache. After receiving an image query request, a second image corresponding to the requested image parameters and image identifier is determined from the multiple first images in the cache, and the image query request is responded to through the second image. In this way, the second image that meets the image parameters is directly returned when the user queries, and there is no need to process the image in real time, thereby reducing the response time and improving the query performance. Moreover, even if the second image does not exist in the cache, the target original image is processed by SVG technology to obtain the second image, and the image quality will not be reduced in the process of adjusting the image parameters, while the processing efficiency can be improved.

[0056] In the embodiment of the present invention, before obtaining the image query request, the apparatus for processing an image provided by the embodiment of the present invention can process the original image to obtain a first image of multiple sizes adapted to different terminals and pages. Specifically, the apparatus for processing an image provided by the embodiment of the present invention can be implemented as follows: Figure 2 The steps shown are used to process the original images to obtain an SVG template corresponding to each original image, and then first images of different sizes corresponding to the original images can be obtained through the SVG template.

[0057] Step S201: converting one or more original images into SVG format respectively, to obtain XML (Extensible Markup Language) strings corresponding to one or more original images respectively;

[0058] Step S202: determining target characters representing height and width from the XML character strings corresponding to the original images;

[0059] Step S203: replacing the content corresponding to the target character with a placeholder or a variable, and obtaining SVG templates corresponding to the original images.

[0060] Taking the application of the existing distributed file storage system in the Internet hospital scenario as an example, the image content can be an electronic prescription, and the original image is the unprocessed original electronic prescription. After the original electronic prescription is generated, the original electronic prescription is first stored in the database and cache, and an expiration time is set for the data in the cache. After the expiration, the data in the cache is automatically destroyed to save cache space. In order to facilitate different users such as operators, doctors, patients, pharmacists, etc. to view the same electronic prescription through their respective terminals of different models, the original electronic prescription in the cache can be processed to adapt to the display of electronic prescriptions on different terminals. When using SVG technology to process the original electronic prescription, the original electronic prescription is first converted into SVG format. Since images in SVG format can be represented by XML strings, the XML string corresponding to the original electronic prescription can be obtained at this time. For example, the XML string of an original electronic prescription with a width of 1328px and a height of 664px is as follows:

[0061]

[0062] In order to facilitate the subsequent generation of a first image with different image parameters according to the character string of the original electronic prescription, in an embodiment of the present invention, the target characters representing the height and width, namely "width" and "height", are determined from the above XML character string, and then the content corresponding to the target characters is replaced with a placeholder or variable to obtain an SVG template corresponding to the original electronic prescription. For example, the SVG template obtained after the original electronic prescription is replaced by the placeholder is as follows:

[0063]

[0064]

[0065] Then, multiple first images with different image parameters corresponding to the original electronic prescription can be generated through the SVG template. In one embodiment of the present invention, when generating multiple first images corresponding to the original electronic prescription, multiple size parameters included in the preset parameters can be used to replace the placeholders or variables in the scalable vector graphics template to obtain multiple first images corresponding to the original image, and the multiple first images are stored in the cache; wherein the multiple first images correspond to different size parameters respectively.

[0066] Here, the preset parameters include multiple size parameters that can be pre-configured according to the brand and model of the client that views the image, and these pre-configured size parameters can also be dynamically deleted, added or updated. Among them, the size parameters can be configured through the List data structure, and each size parameter object contains two parameters: height (h) and width (w). For example, the preset parameters can include three groups of size parameters {[2,3], [3,3], [6,5]}, where [2,3] indicates that the height of the image is 2 and the width is 3, and other objects are similar. Taking [2,3] as an example, if 2 and 3 are used to replace the placeholders or variables representing the height and width content in the SVG template, then the XML string corresponding to the first image with a height of 2 and a width of 3 can be obtained, and then through the image format conversion, the first image in the format of png format or jpg format that is actually required can be obtained. Similarly, if [3,3] is substituted into the SVG template, the first image with a height of 3 and a width of 3 can be obtained, and if [6,5] is substituted into the SVG template, the first image with a height of 6 and a width of 5 can be obtained. After the first images corresponding to multiple size parameters are stored, these first images are stored in the cache and their storage time is recorded. When the storage time is greater than the preset time threshold (expiration time), that is, after these first images expire, the corresponding first images will be automatically deleted, and the corresponding image storage path in the cache will also be destroyed, thereby saving cache resources. For example, for an electronic prescription, its usage time is usually 3 days, that is, the electronic prescription may be frequently queried within 3 days, but after 3 days, the user may not frequently check the historical electronic prescriptions. Therefore, the time threshold can be set to 3 days, so that the electronic prescription in the cache is automatically deleted after 3 days to save cache resources. Here, the expiration time of the first image can be the same as or different from the expiration time of the corresponding original image in the cache.

[0067] It is understandable that the size parameters in the List data structure need to be unique to avoid repeated generation of the first image of the same size, thereby saving cache resources. When dynamically updating or adding size parameters, if the same size parameters are encountered, the corresponding size parameters can be refused to be updated or added.

[0068] In addition, for these processed first images, the key of the first image can be defined in combination with its image identifier and image parameters. For example, the image identifier (image id) of an original image is 123456789. After processing it according to the preset parameters {[2,3], [3,3], [6,5]}, three first images corresponding to different size parameters are obtained. Then the cache keys of the processed first images are 123456789_2_3, 123456789_3_3, and 123456789_6_5. Thus, the cache key of the first image is set by the uniqueness of the image identifier and the size parameter, ensuring the uniqueness of the cache key, so that it is convenient to quickly find the second image corresponding to the image query request according to the unique cache key after receiving the image query request, thereby further improving the query performance.

[0069] According to the above embodiment, during the storage process of the original image, it is preprocessed according to different size parameters to obtain the first images corresponding to the different size parameters. Even in the case where the amount of original image data is large (the amount of data in the processing process of the original image is also large), since the image is usually written only once, and the number of image queries is large, that is, for scenarios where one writes and multiple reads occur (such as Internet hospital scenarios), this can greatly improve the query efficiency. In particular, for high-concurrency requests, the second image can be queried from a large number of images based on the unique cache key, without the need to resize the original image to adapt it to different request terminals, thereby reducing the response time and improving query performance.

[0070] In one embodiment of the present invention, after obtaining an image query request, it can be determined whether there is a second image corresponding to the image identifier (id) and the image parameters (height h and width w) from the first image pre-stored in the cache, then the image identifier and the image parameters can be spliced ​​to generate a cache key (id_h_w), and then the first image can be queried according to the cache key to query whether there is a corresponding second image in the cache. For example, the image identifier included in the image query request is 123456789, and the image parameters are [6,5]. Then the image identifier and the image parameters can be spliced ​​to generate a cache key 123456789_6_5, and then the cache can be searched from the cache according to the cache key to see whether there is a first image with a cache key of 123456789_6_5. If there is, the first image with a cache key of 123456789_6_5 is used as the second image to respond to the image query request. If the first image with a cache key of 123456789_6_5 does not exist in the cache, it can be queried according to the image id whether there is a corresponding target original image in the cache. If the target original picture exists in the cache, it is processed according to the target original picture in the cache to obtain the second picture. However, since the original picture in the cache may also expire, if the target original picture corresponding to the picture id does not exist in the cache, the target original picture is obtained from the database, and the queried target original picture is stored in the cache, and then the target original picture in the cache is processed to obtain the second picture.

[0071] In one embodiment of the present invention, when processing the target original image, the target size parameter corresponding to the target original image can be determined according to the image parameter of this request, and then the target size parameter is substituted into the SVG template corresponding to the target original image to obtain the second image corresponding to the target original image. Here, if the SVG template corresponding to the target original image already exists in the cache, the target size parameter is directly used to replace the placeholder or variable representing the height and width content in the SVG template to obtain the XML string corresponding to the target size parameter, and then the second image in png or jpg format is obtained by format conversion, and the second image is stored in the cache. If there is no SVG template corresponding to the target original image in the cache, the target original image is first format converted to generate its corresponding SVG template. The process of generating the SVG template is basically the same as the above embodiment, and will not be repeated here. In addition, similar to the first image, after the generated second image is stored in the cache, a corresponding duration threshold (expiration duration) can also be set for it. When the storage duration of the second image in the cache is greater than the duration threshold, the corresponding second image is deleted, thereby saving cache resources.

[0072] In one embodiment of the present invention, if the target original image is directly processed according to the image parameters of this request, the target original image may be deformed. In order to minimize the impact of image deformation on the display of the image on the client, the target size parameter can be determined in combination with another parameter, the stretching parameter stretchPicture, and then the second image is generated according to the target size parameter. Specifically, it can be determined whether the image query request includes the stretching parameter stretchPicture; if the stretching parameter is not included, or the stretching parameter indicates that the image is not stretched: determine the target size parameter corresponding to the target original image based on the image parameters and the original parameters of the target original image; if the stretch indicates that the image is stretched, use the image parameters as the target size parameter.

[0073] The interpretation of the stretching parameters can be shown in Table 1 below:

[0074] Table 1

[0075]

[0076] In this embodiment, if the image query request includes a stretch parameter stretchPicture and stretchPicture is true, it indicates that the image needs to be stretched, which means that the front end determines that the image can be displayed normally by processing according to the image parameters of this request. Therefore, the target original image can be directly processed according to the image parameters of this request, that is, the image parameters of this request can be directly substituted into the SVG template as the target size parameters to obtain the second image corresponding to the target original image. For example, the height of the image parameters in this request is 5 and the width is 4, while the height of the target original image is 6 and the width is 3. Then, the target original image is processed according to the image parameters, that is, the height of 6 and the width of 3 are converted into a second image with a height of 5 and a width of 3. The aspect ratio of the target original image changes from 2:1 to 6:5 of the second image.

[0077] If the image query request does not include the stretch parameter stretchPicture, or includes the stretch parameter stretchPicture and stretchPicture is false, then the target size parameter needs to be determined in combination with the original parameters of the target original image and the image parameters of this request. In one embodiment of the present invention, the image parameters include a height parameter and a width parameter, and the original parameters include an original height and an original width. The first ratio between the height parameter and the original height, and the second ratio between the width parameter and the original width can be calculated respectively; then the target size parameter is determined according to the product between the smaller value of the first ratio and the second ratio and the original height and the original width, so that the target height h' in the target size parameter is ≤ height parameter h, the target width w' in the target size parameter is ≤ width parameter w, and the ratio of the target height to the target width is consistent with the ratio of the original height to the original width, thereby ensuring the normal display of the second image.

[0078] For example, the original height of the target original image is h0=6, and the original width is w0=3. In the image parameters of this request, the height parameter is h=5, and the width parameter is w=4. Then the first ratio between the height parameter and the original height is calculated as h / h0=5 / 6, and the second ratio between the width parameter and the original width is calculated as w / w0=4 / 3. Then, the smaller value of the first ratio and the second ratio (i.e., 5 / 6) is multiplied by the original height and the original width to obtain the target size parameter. In this example, the target height in the target size parameter is h'=5 / 6×6=5, and the target width in the target size parameter is w'=5 / 6×3=5 / 2. Then, the target original image can be processed according to the target size parameter [5,5 / 2] to obtain the second image, so that the second image retains its original aspect ratio (2:1), thereby ensuring the normal display of the second image. Moreover, during the processing, the target size parameter is determined based on the smaller value of the first ratio and the second ratio, so that the generated second image can be adapted to the page, avoiding the problem that the page cannot fully display the second image due to the second image being too large, thereby ensuring the normal display of the second image.

[0079] In addition, when processing the target original image, it can also be determined whether the image parameters requested this time need to be added to the preset parameters. Specifically, in one embodiment of the present invention, before processing the target original image, it is first determined whether there are preset parameters corresponding to the image parameters; if not, the cumulative number of times the image parameters are requested is determined, and when the cumulative number is greater than a preset number threshold, the image parameters are configured as the preset parameters.

[0080] Here, if the image parameter of this request does not exist in the preset parameters, and the cumulative number of times the image parameter is requested is greater than the preset number threshold, it means that the frequency of requesting the image of the size corresponding to the image parameter is high, then the image parameter can be added to the preset parameters to increase the preset parameters. After the image processing thread generates the second image corresponding to the target original image according to the image parameter, it can also perform corresponding size processing on other original images according to the updated newly added preset parameters to obtain the first image corresponding to the other original images and the image parameter (the newly added preset parameter), so as to facilitate the rapid response to subsequent image query requests.

[0081] In addition, if there are preset parameters corresponding to the image parameters (including the two cases where the image parameters are added to the preset parameters and the image parameters are already included in the preset parameters when they are not added), after generating the second image corresponding to this request, the target original image can also be processed according to the size parameters in the preset parameters that are different from the image parameters to obtain second images corresponding to different size parameters, and the second image is stored in the cache. For example, in the image parameters of this request, the height parameter h=5 and the width parameter w=4, and the preset parameters include other size parameters {[2,3], [3,3], [6,5]} in addition to [5,4]. Then, after generating a second image with a height of 5 and a width of 4 according to the target original image and responding to this image query request, second images corresponding to different size parameters can be generated according to the other size parameters {[2,3], [3,3], [6,5]} in the preset parameters, that is, a second image with a height of 2 and a width of 3, a second image with a height of 3 and a width of 3, and a second image with a height of 6 and a width of 5 are generated according to the target original image. The second images corresponding to these different size parameters are stored in the cache, so as to respond to subsequent queries of different users for images of different sizes.

[0082] The following takes the processing of electronic prescription images in an Internet hospital scenario as an example to further illustrate the image processing method provided by the embodiment of the present invention. Among them, electronic prescriptions refer to filling in drug treatment information and issuing prescriptions during diagnosis and treatment activities based on network transmission and information technology programming, and are transmitted to pharmacies through the network. They are reviewed, dispensed, checked, and billed by pharmaceutical professionals and serve as medical electronic documents for pharmacies to dispense and use drugs for medical purposes. Figure 3 As shown, the method may include the following steps:

[0083] Step S301: In response to the generation of the original electronic prescription, the original electronic prescription image is stored in the database and cache.

[0084] In this step, an expiration time can also be set for the original electronic image in the cache, and the original electronic prescription image in the cache will be automatically destroyed after the expiration.

[0085] Step S302: calling the configuration model to obtain multiple preset size parameters.

[0086] Here, the size parameters suitable for different terminals can be configured in advance through the configuration model. After the configuration is released, it can be pushed to the application end in real time, so that the application end can process the original electronic prescription image according to the preset parameters. The configuration model can also monitor the configuration changes (such as the addition, update or deletion of size parameters) to realize the dynamic addition, deletion or update of size parameters.

[0087] Step S303: Convert multiple original electronic prescription images into SVG format respectively to obtain XML strings corresponding to the multiple original electronic prescription images; determine the target characters representing the height and width from each XML string respectively, and replace the content corresponding to the target characters with placeholders to obtain SVG templates corresponding to each original electronic prescription image.

[0088] Step S304: for each SVG template: replace the placeholders therein with multiple size parameters respectively, obtain multiple first images corresponding to the original electronic prescription image corresponding to the SVG template, and store the first images in the cache.

[0089] In this step, multiple size parameters are used to replace the placeholders in the SVG template, so that multiple first images corresponding to each electronic prescription image can be obtained, and each first image corresponds to a different size parameter. For example, for the original electronic prescription image with the image id of 123456789, multiple size parameters {[2,3], [3,3], [6,5]} are used to replace the placeholders in its SVG template respectively, and the three first images corresponding to the original electronic prescription image can be obtained. The size parameters corresponding to these three first images are [2,3], [3,3] and [6,5] respectively. It can be understood that for other original electronic prescription images with different ids, the same processing method can be used to obtain the first images corresponding to the multiple original electronic prescription images. As a result, the cache stores multiple first images corresponding to the original electronic prescription images with multiple ids. The cache key of the first image can be defined in combination with its image identifier and image parameters. For example, the cache keys of the three first images mentioned above are 123456789_2_3, 123456789_3_3, and 123456789_6_5, respectively.

[0090] Step S305: Obtain an image query request, determine whether there is a corresponding second image from the multiple first images in the cache, and execute step S306 if there is a second image, otherwise execute step S307.

[0091] The image query request includes an image identifier (image id) and image parameters (image height h and width w). When querying, the image identifier and image parameters are concatenated to generate a cache key (id_h_w), and then the first image is queried according to the cache key.

[0092] Step S306: respond to the image query request according to the second image, and end the current process.

[0093] Step S307: Determine whether there is a target original electronic prescription image corresponding to the image identifier in the cache. If yes, execute step S308; otherwise, execute step S309.

[0094] Step S308: Use SVG technology to process the target original electronic prescription image in the cache to obtain a second image, and execute step S306.

[0095] Step S309: query the target original electronic prescription image from the database, store the target original electronic prescription image in the cache, and execute step S308.

[0096] The process of processing the target original electronic prescription image in the cache by using the SVG technology in step S308 can be specifically as follows: Figure 4 As shown:

[0097] Step S401: Determine the SVG template corresponding to the target original electronic prescription image.

[0098] This step is basically the same as the process of generating the SVG template corresponding to the original image in the above step S303, and will not be repeated here.

[0099] Step S402: Determine whether the image query request includes a stretch parameter, if yes, execute step S403, otherwise execute step S405.

[0100] Step S403: Determine whether the stretching parameter indicates stretching the image, if so, execute step S404, otherwise execute step S405.

[0101] Step S404: replace the placeholder in the SVG template with the image parameters in the image query request to obtain the replaced SVG template, and execute step S408.

[0102] Step S405: respectively calculating a first ratio between a height parameter in the picture parameters and an original height of the original electronic prescription picture, and a second ratio between a width parameter in the picture parameters and an original width of the original electronic prescription picture.

[0103] For example, the original height of the target original image is h0=6, and the original width is w0=3. In the image parameters of this request, the height parameter is h=5, and the width parameter is w=4. Then the first ratio between the height parameter and the original height is calculated to be h / h0=5 / 6, and the second ratio between the width parameter and the original width is w / w0=4 / 3.

[0104] Step S406: Determine the target size parameter according to the product of the smaller value of the first ratio and the second ratio and the original height and the original width respectively.

[0105] In this example, the target height h′ in the target size parameter is 5 / 6×6=5, and the target width w′ in the target size parameter is 5 / 6×3=5 / 2.

[0106] Step S407: Replace the placeholder in the SVG template with the target size parameter to obtain a replaced SVG template.

[0107] Step S408: convert the format of the replaced SVG template to obtain a second image.

[0108] Here, the replaced SVG template can be converted into a second image in png format or jpg format according to actual needs.

[0109] According to the above embodiment, when the electronic prescription images are generated and stored in the library, the SVG technology is used to pre-process the images and put them into the cache. When the user queries, among the images of various sizes, the images that meet the size are directly searched. If there are any, there is no need to process the images again, thereby improving the query performance. In addition, by dynamically monitoring the changes in the configuration, the size and number of the required images can be dynamically adjusted. In addition, the embodiment of the present invention stores both the original images and the images after size processing into the cache, and adopts a double cache solution to cache the images. When the user queries the images, the query performance is also improved.

[0110] Figure 5 FIG. 1 is a schematic diagram of main modules of a device for processing a picture according to an embodiment of the present invention. Figure 5 As shown, a device 500 for processing a picture according to an embodiment of the present invention includes: a request acquisition module 501, a picture determination module 502 and a processing module 503; wherein,

[0111] The request acquisition module 501 is used to acquire an image query request, wherein the image query request includes an image identifier to be queried and image parameters;

[0112] The picture determination module 502 is used to determine whether there is a second picture corresponding to the picture query request from multiple first pictures pre-stored in the cache according to the picture identifier and the picture parameters; wherein the first picture is obtained by processing the original picture according to preset parameters using scalable vector graphics technology;

[0113] The processing module 503 is used to determine the target original image corresponding to the image identifier when the second image does not exist in the cache, and use scalable vector graphics technology to process the target original image according to the image parameters to obtain the second image; if the second image exists in the cache, respond to the image query request according to the second image.

[0114] In one embodiment of the present invention, the image determination module 502 is also used to convert one or more of the original images into scalable vector graphics format, respectively, to obtain extensible markup language strings corresponding to one or more of the original images; determine target characters representing height and width from the extensible markup language strings corresponding to each of the original images; replace the content corresponding to the target characters with placeholders or variables, to obtain scalable vector graphics templates corresponding to each of the original images.

[0115] In one embodiment of the present invention, the processing module 503 is used to determine the target size parameters corresponding to the target original image according to the image parameters; use the target size parameters to replace the placeholder or variable in the scalable vector graphics template corresponding to the target original image to obtain the second image, and store the second image in the cache.

[0116] In one embodiment of the present invention, the image determination module 502 is used to replace the placeholders or variables in the scalable vector graphics template with the multiple size parameters included in the preset parameters, obtain multiple first images corresponding to the original image, and store the multiple first images in the cache; wherein the multiple first images correspond to different size parameters respectively.

[0117] In one embodiment of the present invention, the processing module 503 is used to determine whether the image query request includes a stretching parameter; if the stretching parameter is not included, or the stretching parameter indicates that the image is not stretched: determine the target size parameter corresponding to the target original image based on the image parameters and the original parameters of the target original image; if the stretching indicates that the image is stretched, use the image parameters as the target size parameter.

[0118] In one embodiment of the present invention, the image parameters include a height parameter and a width parameter, and the original parameters include an original height and an original width; the processing module 503 is used to calculate a first ratio between the height parameter and the original height, and a second ratio between the width parameter and the original width, respectively; and determine the target size parameter according to the product of the smaller value of the first ratio and the second ratio and the original height and the original width, respectively.

[0119] In one embodiment of the present invention, the processing module 503 is also used to record the storage time of the first image and / or the second image in the cache, and when the storage time is greater than a preset time threshold, delete the first image / or the second image whose storage time is greater than the preset time threshold.

[0120] In one embodiment of the present invention, the processing module 503 is also used to determine whether there are preset parameters corresponding to the image parameters when the second image does not exist in the cache; if not, determine the cumulative number of times the image parameters are requested, and when the cumulative number is greater than a preset number threshold, configure the image parameters as the preset parameters.

[0121] In one embodiment of the present invention, the processing module 503 is also used to process the target original image according to size parameters in the preset parameters that are different from the image parameters, in the presence of preset parameters corresponding to the image parameters, to obtain second images corresponding to different size parameters, and store the second images in the cache.

[0122] It can be seen from a device for processing images according to an embodiment of the present invention that the original image is processed according to preset parameters using SVG technology to obtain multiple first images stored in a cache. After receiving an image query request, a second image corresponding to the requested image parameters and image identifier is determined from the multiple first images in the cache, and the image query request is responded to through the second image. In this way, the second image that meets the image parameters is directly returned when the user queries, and there is no need to process the image in real time, thereby reducing the response time and improving the query performance. Moreover, even if the second image does not exist in the cache, the target original image is processed by SVG technology to obtain the second image, and the image quality will not be reduced in the process of adjusting the image parameters, while the processing efficiency can be improved.

[0123] Figure 6 An exemplary system architecture 600 of a method for processing a picture or an apparatus for processing a picture according to an embodiment of the present invention is shown.

[0124] like Figure 6As shown, system architecture 600 may include terminal devices 601, 602, 606, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 606 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0125] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0126] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0127] The server 605 may be a server that provides various services, such as a background management server that provides support for the image query pages browsed by the user using the terminal devices 601, 602, and 603. The background management server may analyze and process the received query request and other data, and feed back the processing result (such as the second image found in the query) to the terminal device.

[0128] It should be noted that the method for processing pictures provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device for the method for processing pictures is generally arranged in the server 605 .

[0129] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0130] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0131] like Figure 7As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0132] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0133] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0134] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0135] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0136] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a request acquisition module, an image determination module, and a processing module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the request acquisition module may also be described as a "module for obtaining image query requests."

[0137] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining an image query request, the image query request includes an image identifier to be queried and image parameters; according to the image identifier and image parameters, determining whether there is a second image corresponding to the image query request from multiple first images pre-stored in the cache; wherein the first image is obtained by processing the original image according to preset parameters using scalable vector graphics technology; if the second image does not exist in the cache, determining the target original image corresponding to the image identifier, and processing the target original image according to the image parameters using scalable vector graphics technology to obtain the second image; if the second image exists in the cache, responding to the image query request according to the second image.

[0138] According to the technical solution of the embodiment of the present invention, the original image is processed according to preset parameters using SVG technology to obtain multiple first images stored in the cache. After receiving the image query request, the second image corresponding to the requested image parameters and image identifier is determined from the multiple first images in the cache, and the image query request is responded to through the second image. In this way, the second image that meets the image parameters is directly returned when the user queries, and there is no need to process the image in real time, thereby reducing the response time and improving the query performance. Moreover, even if the second image does not exist in the cache, the target original image is processed by SVG technology to obtain the second image, and the image quality will not be reduced in the process of adjusting the image parameters, while the processing efficiency can be improved.

[0139] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for processing a picture, characterized in that: include: Obtaining an image query request, wherein the image query request includes an image identifier to be queried and image parameters; According to the picture identifier and the picture parameters, determining whether there is a second picture corresponding to the picture query request from a plurality of first pictures pre-stored in the cache; wherein the first picture is obtained by processing the original picture according to preset parameters using scalable vector graphics technology; If the second picture does not exist in the cache, determining a target original picture corresponding to the picture identifier, and processing the target original picture according to the picture parameters using scalable vector graphics technology to obtain the second picture; In a case where the second image exists in the cache, the image query request is responded to according to the second image.

2. The method according to claim 1, characterized in that Before obtaining the image query request, the method further includes: Converting one or more of the original images into scalable vector graphics formats respectively, to obtain extensible markup language strings corresponding to the one or more original images respectively; Determine the target characters representing the height and width from the extensible markup language character strings corresponding to the original images; The content corresponding to the target character is replaced with a placeholder or a variable to obtain a scalable vector graphics template corresponding to each of the original pictures.

3. The method according to claim 2, characterized in that Include at least one of the following: The processing of the target original image according to the image parameters by using the scalable vector graphics technology includes: determining a target size parameter corresponding to the target original image according to the image parameters; replacing a placeholder or a variable in a scalable vector graphics template corresponding to the target original image by using the target size parameter to obtain the second image, and storing the second image in the cache; The placeholders or variables in the scalable vector graphics template are replaced by using the multiple size parameters included in the preset parameters to obtain multiple first images corresponding to the original image, and the multiple first images are stored in the cache; wherein the multiple first images correspond to different size parameters respectively.

4. The method according to claim 3, characterized in that The determining, according to the picture parameters, a target size parameter corresponding to the target original picture includes: Determining whether the image query request includes a stretch parameter; In a case where the stretching parameter is not included or the stretching parameter indicates that the picture is not to be stretched: determining a target size parameter corresponding to the target original picture according to the picture parameter and the original parameter of the target original picture; In a case where the stretching indicates stretching of the picture, the picture parameter is used as the target size parameter.

5. The method according to claim 4, characterized in that The picture parameters include a height parameter and a width parameter, and the original parameters include an original height and an original width; and determining a target size parameter corresponding to the target original picture according to the picture parameters and the original parameters of the target original picture includes: respectively calculating a first ratio between the height parameter and the original height, and a second ratio between the width parameter and the original width; The target size parameter is determined according to the product of the smaller value of the first ratio and the second ratio, the original height and the original width, respectively.

6. The method according to claim 3, characterized in that Also includes: Record the storage time of the first image and / or the second image in the cache, and if the storage time is greater than a preset time threshold, delete the first image / or the second image whose storage time is greater than the preset time threshold.

7. The method according to claim 1, characterized in that In the case that the second picture does not exist in the cache, before the target original picture is processed according to the picture parameters by using the scalable vector graphics technology, the method further includes: Determining whether there are preset parameters corresponding to the image parameters; If not, determine the cumulative number of times the image parameter is requested, and if the cumulative number is greater than a preset number threshold, configure the image parameter as the preset parameter.

8. The method according to claim 7, characterized in that In the case where there are preset parameters corresponding to the picture parameters, the method further includes: The target original picture is processed according to the size parameters in the preset parameters that are different from the picture parameters to obtain second pictures corresponding to the different size parameters respectively, and the second pictures are stored in the cache.

9. A device for processing a picture, characterized in that: include: Request acquisition module, image determination module and processing module; wherein, The request acquisition module is used to acquire an image query request, wherein the image query request includes an image identifier to be queried and image parameters; The picture determination module is used to determine whether there is a second picture corresponding to the picture query request from multiple first pictures pre-stored in the cache according to the picture identifier and the picture parameters; wherein the first picture is obtained by processing the original picture according to preset parameters using scalable vector graphics technology; The processing module is used to determine the target original image corresponding to the image identifier when the second image does not exist in the cache, and use scalable vector graphics technology to process the target original image according to the image parameters to obtain the second image; if the second image exists in the cache, respond to the image query request according to the second image.

10. A server for processing pictures, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.