CN118229495A - Image file processing method, device, equipment and medium - Google Patents

Image file processing method, device, equipment and medium Download PDF

Info

Publication number
CN118229495A
CN118229495A CN202410228113.0A CN202410228113A CN118229495A CN 118229495 A CN118229495 A CN 118229495A CN 202410228113 A CN202410228113 A CN 202410228113A CN 118229495 A CN118229495 A CN 118229495A
Authority
CN
China
Prior art keywords
compressed
image file
pixel point
information
identifier
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410228113.0A
Other languages
Chinese (zh)
Inventor
肖鹏博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202410228113.0A priority Critical patent/CN118229495A/en
Publication of CN118229495A publication Critical patent/CN118229495A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses an image file processing method, an image file processing device, image file processing equipment and an image file processing medium, which are applied to the technical field of image processing, wherein an executable file generation instruction aiming at a front-end project is obtained, and an image file to be compressed, which is included in the front-end project, is determined; acquiring pixel point information of the image file to be compressed; if the pixel point information does not include the compressed identification, writing the compressed identification into the pixel point information of the image file to be compressed to generate the pixel point information of the image file to be compressed, compressing the image file to be compressed to generate the compressed image file, and generating an executable file by using the compressed image file. And if the pixel point information is determined to comprise the compressed identification, generating an executable file by using the image file to be compressed. Therefore, repeated compression of the image file can be avoided, equipment resources required for compressing the image are reduced, and the time required for compressing the image is further shortened.

Description

Image file processing method, device, equipment and medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method, an apparatus, a device, and a medium for processing an image file.
Background
During the use of an Application (APP) by a user, the APP needs to display content, such as text, images, etc., within an Application page presented to the user. The content that needs to be displayed at the front end is pre-stored in the executable file of the front end item. When the content needs to be displayed, a file comprising the content is obtained from the executable file and analyzed to display the content.
In order to improve user experience of using APP, images to be displayed at the front end of APP are rich, and the number of image files included in the front end project is large, so that the volume of executable files of the front end project is large, the speed of analyzing the executable files by the APP is slow, the speed of displaying content by the APP is slow, and the use of the APP is affected.
Disclosure of Invention
In view of the above, the present application provides an image file processing method, apparatus, device, and medium, which can reduce the resource consumption of compressed image files based on the compressed image files.
In order to solve the problems, the technical scheme provided by the application is as follows:
in a first aspect, the present application provides an image file processing method, the method comprising:
determining an image file to be compressed included in the front-end project in response to acquiring an executable file generation instruction for the front-end project;
Acquiring pixel point information of the image file to be compressed;
If the pixel point information does not comprise the compressed identifier, writing the compressed identifier into the pixel point information of the image file to be compressed to generate the pixel point information of the image file to be compressed, compressing the image file to be compressed to generate the compressed image file, and generating an executable file by using the compressed image file, wherein the compressed identifier is used for identifying that the image file is compressed;
and if the pixel point information is determined to comprise the compressed identifier, generating an executable file by using the image file to be compressed.
In one possible implementation manner, the pixel information is RGBA red, blue, green, and transparency information, and the writing the compressed identifier into the pixel information of the image file to be compressed includes:
And writing the compressed identification into transparency information included in pixel point information of the image file to be compressed.
In a possible implementation manner, the writing the compressed identifier into the transparency information included in the pixel point information of the image file to be compressed includes:
sequentially obtaining transparency values of pixel points with a preset number of bits in the image file to be compressed, wherein the preset number of bits is determined based on the number of bits of the compressed identification;
if the transparency value is not represented by a preset system, converting the transparency value into the preset system, wherein the preset system is determined based on the system of the compressed identifier;
acquiring a compressed identifier represented by a number of digits of a preset number of digits;
And from the first pixel point, replacing the last bit of the transparency values of the pixel points with the number of preset bits with the compressed marked values with the corresponding bits in sequence, and generating the transparency values of the replaced pixel points.
In one possible implementation, the determining that the pixel point information does not include the compressed identifier includes:
sequentially obtaining transparency values of pixel points with a preset number of bits in the image file to be compressed, wherein the preset number of bits is determined based on the number of bits of the compressed identification;
if the transparency value is not represented by a preset system, converting the transparency value into a value of the preset system, wherein the preset system is determined based on the system of the compressed identifier;
Sequentially obtaining the last bit of the transparency values of the pixel points with the preset number of bits from the first pixel point to obtain the mark to be determined;
and determining that the identification to be determined is different from the compressed identification.
In one possible implementation manner, the determining the image file to be compressed included in the front-end item includes:
Acquiring size information of an image file included in the front-end item;
and taking the image file with the size information meeting the compression size condition as an image file to be compressed.
In one possible implementation manner, the compressing the image file to be compressed includes:
And compressing the image file to be compressed according to a preset compression ratio.
In a second aspect, the present application provides an image file processing apparatus, the apparatus comprising:
A determining unit, configured to determine an image file to be compressed included in the front-end item in response to acquiring an executable file generation instruction for the front-end item;
The information acquisition unit is used for acquiring pixel point information of the image file to be compressed;
The compressing unit is used for writing a compressed identifier into the pixel information of the image file to be compressed if the pixel information does not comprise the compressed identifier, generating the pixel information of the compressed image file, compressing the image file to be compressed, generating the compressed image file, and generating an executable file by utilizing the compressed image file, wherein the compressed identifier is used for identifying that the image file is compressed;
and the processing unit is used for generating an executable file by utilizing the image file to be compressed if the pixel point information comprises the compressed identifier.
In a possible implementation manner, the determining unit is configured to determine an image file to be compressed included in the front-end item, and includes:
The determining unit is used for acquiring the size information of the image file included in the front-end item; and taking the image file with the size information meeting the compression size condition as an image file to be compressed.
In one possible implementation manner, the pixel information is RGBA red, blue, green and transparency information, and the compression unit is configured to write a compressed identifier into the pixel information of the image file to be compressed, and includes:
The compressing unit is used for writing the compressed identification into transparency information included in pixel point information of the image file to be compressed.
In a possible implementation manner, the compressing unit is configured to write the compressed identifier into transparency information included in pixel point information of the image file to be compressed, and includes:
the compressing unit is used for sequentially obtaining transparency values of pixel points with a preset number of bits in the image file to be compressed, and the preset number of bits is determined based on the number of bits of the compressed identification; if the transparency value is not represented by a preset system, converting the transparency value into the preset system, wherein the preset system is determined based on the system of the compressed identifier; acquiring a compressed identifier represented by a number of digits of a preset number of digits; sequentially replacing the last bit of the transparency values of the continuous preset number of bits of pixel points with the value of the compressed identifier of the corresponding bit from the first bit of pixel point; and generating a transparency value of the replaced pixel point.
In a possible implementation manner, the compressing unit is configured to determine that the pixel point information does not include the compressed identifier, and includes:
The compressing unit is used for sequentially obtaining transparency values of pixel points with a preset number of bits in the image file to be compressed, and the preset number of bits is determined based on the number of bits of the compressed identification; if the transparency value is not represented by a preset system, converting the transparency value into a value of the preset system, wherein the preset system is determined based on the system of the compressed identifier; sequentially obtaining the last bit of the transparency values of the continuous preset number of bits of pixel points from the first bit of pixel points to obtain the mark to be determined; and determining that the identification to be determined is different from the compressed identification.
In a possible implementation manner, the compression unit is configured to compress the image file to be compressed, and includes:
the compression unit is used for compressing the image file to be compressed according to a preset compression ratio.
In a third aspect, the present application provides an image file processing apparatus comprising: a processor, memory, system bus;
The processor and the memory are connected through the system bus;
The memory is configured to store one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform the method of any of the embodiments of the first aspect described above.
In a fourth aspect, the present application provides a computer readable storage medium having instructions stored therein, which when run on a terminal device, cause the terminal device to perform the method according to any of the embodiments of the first aspect.
From this, the application has the following beneficial effects:
The application provides an image file processing method, device, equipment and medium, which are used for responding to an executable file generation instruction for a front-end project and determining an image file to be compressed included in the front-end project; acquiring pixel point information of the image file to be compressed; if the pixel point information does not include the compressed identifier, writing the compressed identifier into the pixel point information of the image file to be compressed to generate the pixel point information of the image file to be compressed, compressing the image file to be compressed to generate the compressed image file, and generating an executable file by using the compressed image file, wherein the compressed identifier is used for identifying that the image file is compressed. And if the pixel point information is determined to comprise the compressed identification, generating an executable file by using the image file to be compressed. Therefore, compressed identification can be carried in pixel point information of the compressed image file, the compressed image file is identified when the executable file is generated, the compressed image file is not compressed, and repeated compression of the image file is avoided. On the basis of reducing the cost of manually compressing the image file and improving the image compression efficiency, the equipment resources required by the compressed image are reduced, and the time required by the compressed image is further shortened.
Drawings
Fig. 1 is a flow chart of an image file processing method according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating another image file processing method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an image file processing device according to an embodiment of the present application.
Detailed Description
In order to facilitate understanding and explanation of the technical solution provided by the embodiments of the present application, the background art of the present application will be described.
The technical terms related to the present application will be explained first:
Front end engineering: the front-end project aggregate developed by the front-end framework generally comprises page codes displayed to users, data interaction codes with the back-end and static resource files.
Static resources: including image resources, font resources, style files, etc. used in the page.
Front end packaging: and packaging the front-end codes and the static resources into an image file capable of being deployed and operated, namely an executable file through a packaging tool.
The volume of the bag is as follows: the front end packages the size of the generated image file.
Page loading: when a user opens a page, the user requests the layout and image resources in the page, and finally the layout and the image resources are arranged into page display.
With the popularization and development of the Internet and various devices, various types and functions of APP enter the life of people. Taking a bank APP as an example, the bank APP provides users with various financial functions, such as smart medical functions, smart campus functions, and the like.
Taking the intelligent medical function as an example, the complete intelligent medical function comprises a large number of guide images for guiding the user to finish operations such as appointment registration and the intelligent diagnosis guiding function. Various hospital profile images, doctor photos, examination report images, human organ profiles and the like are displayed in the APP and are used for guiding a user to reserve registration and helping the user to know diagnosis results. The images displayed at the front end are all stored in the static resource file of the front end project. When a user opens an application page, the APP analyzes a static resource file of a front-end item, and acquires resources such as images, texts and the like which need to be displayed in the page. On the one hand, under the condition that the data volume of the image file included in the executable file of the front-end project is larger, the data volume of the executable file is larger, and resources are wasted; on the other hand, the executable file is analyzed, and the time for acquiring the image to be displayed is longer, namely the starting time of the APP page is longer. The user is required to wait for a long time to completely display the page, and the user experience is affected. Currently, there are two modes of manual compression and automatic compression, and compression of image files is realized to reduce the data volume of executable files. But manual compression by developers is less efficient. For automatic compression, compression of all image files can be achieved by means of an automatic compression tool, but compression of part of image files which do not need to be compressed wastes resources, and excessive occupation of equipment performance results in longer compression time.
Based on the above, the embodiment of the application provides an image file processing method, which is used for determining an image file to be compressed included in a front-end project in response to acquiring an executable file generation instruction for the front-end project; acquiring pixel point information of the image file to be compressed; if the pixel point information does not include the compressed identifier, writing the compressed identifier into the pixel point information of the image file to be compressed to generate the pixel point information of the image file to be compressed, compressing the image file to be compressed to generate the compressed image file, and generating an executable file by using the compressed image file, wherein the compressed identifier is used for identifying that the image file is compressed. And if the pixel point information is determined to comprise the compressed identification, generating an executable file by using the image file to be compressed. Therefore, compressed identification can be carried in pixel point information of the compressed image file, the compressed image file is identified when the executable file is generated, the compressed image file is not compressed, and repeated compression of the image file is avoided. On the basis of reducing the cost of manually compressing the image file and improving the image compression efficiency, the equipment resources required by the compressed image are reduced, and the time required by the compressed image is further shortened.
In order to facilitate understanding of the technical solution provided by the embodiments of the present application, the image file processing provided by the embodiments of the present application is described below with reference to the accompanying drawings.
Referring to fig. 1, the flow chart of an image file processing method according to an embodiment of the present application is shown. As shown in fig. 1, an image file processing method provided in an embodiment of the present application includes S101 to S104.
S101: and determining the image file to be compressed included in the front-end item in response to acquiring the executable file generation instruction for the front-end item.
The front-end item is an item related to the device front-end display. The executable file of the front-end project is generated by packaging front-end page codes of the front-end project, data interaction codes with the back-end, static resource files and the like. Running the executable file achieves the front-end display.
The executable file generation instruction for the front-end project is used for triggering the code and the resource file packaging of the front-end project, and generating the executable file of the front-end project.
And when the executable file generation instruction aiming at the front-end project is acquired, determining the image file to be compressed, which is included in the front-end project and needs to be compressed. Therefore, the compression processing of the image file can be triggered when the front-end project is packed, the compressed image file is convenient to package, and the data quantity of the generated executable file is reduced.
As an example, referring to fig. 2, fig. 2 is a schematic flow chart of another image file processing method according to an embodiment of the present application. And traversing the image file included in the static resource file of the front-end project in response to acquiring the executable file generation instruction for the front-end project.
The front-end item may include a greater number of image files, but not all image files need to be compressed. And determining the image file needing to be compressed from the image files included in the front-end item as a file to be compressed. In one possible implementation, the compression conditions are preset. The compression conditions are used to determine the file to be compressed. As an example, the compression condition generates, for example, an image file having a time later than a preset time. As another example, the compression condition is that, for example, the image file size satisfies the compression size condition. The compression size condition is, for example, that the size of the image file is greater than or equal to an image compression start threshold (minSize). An image having a size smaller than the image compression start threshold does not need to be compressed. The specific value of the image compression starting threshold can be set based on service requirements, various service requirements can be met, and the practicability is high.
Taking the above compression condition as an example that the size of the image file satisfies the compression size condition, in determining the image file to be compressed, it is necessary to acquire the size information of the image file. As an example, referring to fig. 2, the base64 encoding of the image file is obtained by reading the image file through the FileReader, and the length of the base64 encoding can represent the image size. And comparing the length of the base64 code with an image compression starting threshold, wherein the image files smaller than the image compression starting threshold do not need to be compressed, waiting for the subsequent processing of generating the executable files, and the image files larger than or equal to the image compression starting threshold need to be compressed. In some possible implementations, an image object corresponding to the file to be compressed is created as a compressed image file that replaces the file to be compressed after compression.
The image files with larger sizes can be determined by utilizing the compression size condition for screening, so that the image files with larger sizes are convenient to compress, the data quantity of the generated executable files is reduced, the analysis of the executable files is convenient to accelerate, and the starting time of pages is reduced.
S102: and acquiring pixel point information of the image file to be compressed.
And acquiring pixel point information of the image file to be compressed between the image files to be compressed.
As one example, the pixel point information is RGBA (Red, blue, green, alpha, red, blue, green, transparency) information. Pixel point information of the image file to be compressed is acquired through GETIMAGEDATA () of canvas, and IMAGEDATA is obtained. The data type in IMAGEDATA is Uint8CLAMPEDARRAY. IMAGEDATA, each four elements represents RGBA information for one pixel.
For example, IMAGEDATA of one image file is [20,32,56,255,20,32,56,255,20,32,56,255,20,32,56,255,20,32,56,255,21,33,57,255,20,32,56,255,18,30,53,255,15,27,49,255,15,27,49,255,16,28,50,255,18,30,52,255,19,30,52,255,19,30,52,255,18,30,52,255,19,31,53,255,19,31,54,255,17,30,54,255,18,31,55,255,16,31,54,255,18,32,57,255,16,30,56,255,17,31,57,255,17,30,55,255,17,30,54,255,...]. in which four consecutive bits are a group for RGBA information representing one pixel point. For example, the first group is [20,32,56,255], the second group is [20,32,56,255], and so on.
The pixel information of the image file to be compressed may include a compressed flag (flag). The compressed flag is used to indicate that the image file is an image file that has undergone compression processing. The compressed identifier can be a preset identifier represented by a number, letter, text, etc., which is not limited in the embodiment of the present application.
And judging whether pixel point information of the image file to be compressed comprises a compressed identifier or not. If the pixel point information of the image file to be compressed includes the compressed identifier, it is indicated that the image file to be compressed is already a compressed image file, and S104 is performed without compressing again. If the pixel point information of the image file to be compressed does not include the compressed identifier, it indicates that the image file to be compressed has not yet been compressed, and compression is required in the process of processing the image file this time, and S103 is executed.
In one possible implementation, the pixel point information is RGBA information. The compressed identification is preset and written into transparency information included in pixel point information of the image file.
As one example, the last bit of transparency value included in pixel point information identified as an image file has been compressed. The embodiment of the application provides an implementation mode for judging whether pixel point information comprises compressed marks, which comprises the following steps:
A1: and sequentially acquiring transparency values of the pixels with the number of the preset bits in the image file to be compressed.
The preset number of bits is the number of bits of the compressed identification. The preset number of bits can be set based on the number of bits of the compressed identification. The number of bits of the compressed flag is the number of bits when the compressed flag is written into the transparency information. Taking the compressed label "a" as an example, when transparency information is written, "a" uses a 16-bit binary representation of 0000000001100001.
The transparency value is used to represent transparency information. As an example, the transparency value is used to measure the degree of transparency of a pixel.
Taking IMAGEDATA of the above image file as an example, four data are taken as a group. The compressed identity is represented by a binary system with 16 bits, and the number of preset bits is 16. And acquiring transparency values of the first 16 pixel points. The 16 transparency values obtained were 255.
A2: if the transparency value is not represented by a preset system, converting the transparency value into a value of the preset system, wherein the preset system is a system of the compressed identification.
Taking the compressed identified bin as binary, the transparency value is 255, instead of using a binary representation, the transparency value 255 is converted into a binary value, 11111111.
A3: and sequentially obtaining the last bit of transparency values of the continuous preset number of bits of pixel points from the first bit of pixel points to obtain the mark to be determined.
Taking the preset number of digits as 16 as an example, the 16 transparency values are 11111111, and the obtained to-be-determined mark is 1111111111111111.
A4: and judging whether the identification to be determined is the same as the compressed identification.
And comparing the identification to be determined with the compressed identification. It should be noted that if the compressed identifier is different from the number of digits or the number of digits of the identifier to be determined, the compressed identifier or the identifier to be determined needs to be processed, and the compressed identifier and the identifier to be determined are unified into the preset number of digits or the number of digits.
Taking compressed identification "a" as an example, the 16-bit binary of "a" is 0000000001100001. Where "a" is converted to a binary number 1100001, less than 16 bits, and 0 is appended to the front to obtain a 0000000001100001 of 16 bits.
Taking the compressed identification of "me" as an example, the 16-bit binary of "me" is 0110001000010001. Where "I" translates to a binary 110001000010001, less than 16 bits, supplemented with 0 in front to get 0110001000010001 of 16 bits.
A5: and if the to-be-determined identification is different from the compressed identification, determining that the pixel point information does not comprise the compressed identification.
Taking the compressed identifier "a" as an example, comparing the identifier 1111111111111111 to be determined with the compressed identifier 0000000001100001 can determine that the identifier to be determined is different from the compressed identifier, and determine that the pixel point information of the image file does not include the compressed identifier.
A6: and if the to-be-determined identifier is the same as the compressed identifier, determining that the pixel point information comprises the compressed identifier.
As an example of the use of a further embodiment, IMAGEDATA of the image file are [20,32,56,254,20,32,56,254,20,32,56,254,20,32,56,254,20,32,56,254,21,33,57,254,20,32,56,254,18,30,53,254,15,27,49,254,15,27,49,255,16,28,50,255,18,30,52,254,19,30,52,254,19,30,52,254,18,30,52,254,19,31,53,255,19,31,54,255,17,30,54,255,18,31,55,255,16,31,54,255,18,32,57,255,16,30,56,255,17,31,57,255,17,30,55,255,17,30,54,255,...].16 transparency values of 254, 254 respectively 254, 255 255, 254, 255. 254, the 8-bit binary value after conversion is 11111110. And sequentially obtaining the last bit of transparency values of the 16 continuous pixel points from the first pixel point to obtain a mark to be determined as 0000000001100001.
Taking the compressed identifier "a" as an example, comparing the identifier 0000000001100001 to be determined with the compressed identifier 0000000001100001 can determine that the identifier to be determined is the same as the compressed identifier, and determine that the pixel point information of the image file includes the compressed identifier.
It should be noted that the above example is only an example, and the number of bits of the compressed identifier can be adjusted based on the need, for example, an 8-bit binary representation is adopted. In addition, in the case where the compressed identification includes a plurality of letters, the number of transparency values of the acquired pixel points can also be adjusted. For example, in the case that the compressed identifier is "ab", the last bit of the transparency value of the 32 pixel points is obtained, and the identifier to be determined is obtained.
S103: if the pixel point information does not include the compressed identification, writing the compressed identification into the pixel point information of the image file to be compressed, generating the pixel point information of the compressed image file, compressing the image file to be compressed, generating the compressed image file, generating an executable file by using the compressed image file, and using the compressed identification to identify that the image file is compressed.
If the pixel point information of the image file to be compressed does not comprise the compressed identification, the image file to be compressed is not compressed, and the image file to be compressed is compressed in the process of the current processing. Writing the compressed identification into pixel point information of the image file to be compressed, and generating the pixel point information of the compressed image file. Therefore, whether the image file is compressed or not can be judged based on the pixel point information of the generated compressed image file conveniently, repeated compression of the compressed image file is reduced, and equipment performance resources used by compression are saved.
In the case where the pixel point information is RGBA information, the compressed flag can be written in the transparency information to reduce the influence on the image file.
In one possible implementation manner, the embodiment of the present application provides a method for writing compressed identification into pixel point information of an image file to be compressed, including the following steps:
b1: and sequentially acquiring transparency values of the pixels with the number of the preset bits in the image file to be compressed.
B2: if the transparency value is not represented by the preset system, converting the transparency value into the value of the preset system.
The content of B1-B2 is similar to that of A1-A2, and for specific description of B1-B2, please refer to the specific description of A1-A2, which is not repeated here.
B3: a compressed identifier represented by a number of digits of a preset number of digits is obtained.
Taking the example that the number of bits of the preset number of bits is 16 bits, if the compressed identifier is not in 16-bit binary representation, the compressed identifier is converted. If the converted binary compressed flag does not satisfy 16 bits, the number of bits is padded by supplementing 0 in front.
B4: and from the first pixel point, sequentially replacing the last bit of the transparency values of the continuous pixel points with the number of the preset bits with the number of the compressed marks corresponding to the number of the bits, and generating the transparency values of the replaced pixel points.
Replacing the last digit of the transparency value can reduce the impact on the image file. It is difficult for the human eye to recognize a minute change in transparency. Therefore, on the basis of minimizing the influence on the image file, compressed marks are carried in pixel point information of the image file, so that the compressed image file can be identified, and repeated compression is reduced.
Taking the compressed identifier a of IMAGEDATA as [20,32,56,255,20,32,56,255,20,32,56,255,20,32,56,255,20,32,56,255,21,33,57,255,20,32,56,255,18,30,53,255,15,27,49,255,15,27,49,255,16,28,50,255,18,30,52,255,19,30,52,255,19,30,52,255,18,30,52,255,19,31,53,255,19,31,54,255,17,30,54,255,18,31,55,255,16,31,54,255,18,32,57,255,16,30,56,255,17,31,57,255,17,30,55,255,17,30,54,255,...], of the image file as an example, the replacement procedure is shown in table 1:
TABLE 1
The image data of the obtained compressed image file is [20,32,56,254,20,32,56,254,20,32,56,254,20,32,56,254,20,32,56,254,21,33,57,254,20,32,56,254,18,30,53,254,15,27,49,254,15,27,49,255,16,28,50,255,18,30,52,254,19,30,52,254,19,30,52,254,18,30,52,254,19,31,53,255,19,31,54,255,17,30,54,255,18,31,55,255,16,31,54,255,18,32,57,255,16,30,56,255,17,31,57,255,17,30,55,255,17,30,54,255,...].
And compressing the image file to be compressed to generate a compressed image file. Specifically, the Canvas is drawn, the address of the uniform resource location system (uniform resource locator, URL) of the image file is returned, and the image file to be compressed is compressed. The embodiment of the application is not limited to the mode of compressing the image file to be compressed. As an example, a preset compression ratio is preset. The preset compression ratio is indicated for example by encoderOtp. encoderOtp is the second entry for the toDataUrl method on canvas tags. encoderOtp is used to specify the compression ratio of the image volume, the range of values is 0-1. For example, the preset compression ratio is 0.5, which means that the volume of the compressed image is 50% of the volume of the image before compression. The numerical value of the preset compression ratio can be set based on service requirements, various service requirements can be met, and the practicability is high.
The generated compressed image file replaces the image file to be compressed. An executable file is generated using the compressed image file.
S104: and if the pixel point information comprises the compressed identification, generating an executable file by using the image file to be compressed.
And if the pixel point information comprises the compressed identification, indicating that the image file to be compressed is the image file obtained after compression. In order to save resources, the image file to be compressed is not compressed in the process of processing the image file. And generating an executable file by using the image file to be compressed.
Based on the above-mentioned content related to S101-S104, it is known that the compressed identifier is carried in the pixel point information of the compressed image file, so that the compressed image file can be identified when the executable file is generated by packing, and repeated compression of the image file is avoided. On the basis of reducing the cost of manually compressing the image file and improving the image compression efficiency, the equipment resources required by the compressed image are reduced, and the time required by the compressed image is further shortened.
Based on the image file processing method provided by the embodiment of the method, the embodiment of the application also provides an image file processing device, and the image file processing device will be described with reference to the accompanying drawings.
Referring to fig. 3, the structure of an image file processing device according to an embodiment of the present application is shown. As shown in fig. 3, the image file processing apparatus includes:
a determining unit 301, configured to determine, in response to acquiring an executable file generation instruction for the front-end item, an image file to be compressed included in the front-end item;
An information obtaining unit 302, configured to obtain pixel point information of the image file to be compressed;
a compression unit 303, configured to, if it is determined that the pixel information does not include a compressed identifier, write the compressed identifier into pixel information of the image file to be compressed, generate pixel information of the compressed image file, compress the image file to be compressed, generate the compressed image file, and generate an executable file using the compressed image file, where the compressed identifier is used to identify that the image file is compressed;
And the processing unit 304 is configured to generate an executable file by using the image file to be compressed if it is determined that the pixel point information includes the compressed identifier.
In a possible implementation manner, the determining unit 301 is configured to determine an image file to be compressed included in the front-end item, and includes:
the determining unit 301 is configured to obtain size information of an image file included in the front-end item; and taking the image file with the size information meeting the compression size condition as an image file to be compressed.
In one possible implementation manner, the pixel information is RGBA red, blue, green, and transparency information, and the compressing unit 303 is configured to write a compressed identifier into the pixel information of the image file to be compressed, and includes:
The compressing unit 303 is configured to write the compressed identifier into transparency information included in pixel point information of the image file to be compressed.
In a possible implementation manner, the compressing unit 303 is configured to write the compressed identifier into transparency information included in pixel point information of the image file to be compressed, and includes:
The compressing unit 303 is configured to sequentially obtain transparency values of a number of pixels in a previous preset number of bits in the image file to be compressed, where the preset number of bits is determined based on the number of bits of the compressed identifier; if the transparency value is not represented by a preset system, converting the transparency value into the preset system, wherein the preset system is determined based on the system of the compressed identifier; acquiring a compressed identifier represented by a number of digits of a preset number of digits; sequentially replacing the last bit of the transparency values of the continuous preset number of bits of pixel points with the value of the compressed identifier of the corresponding bit from the first bit of pixel point; and generating a transparency value of the replaced pixel point.
In a possible implementation manner, the compressing unit 303 is configured to determine that the pixel point information does not include the compressed identifier, and includes:
The compressing unit 303 is configured to sequentially obtain transparency values of a number of pixels in a previous preset number of bits in the image file to be compressed, where the preset number of bits is determined based on the number of bits of the compressed identifier; if the transparency value is not represented by a preset system, converting the transparency value into a value of the preset system, wherein the preset system is determined based on the system of the compressed identifier; sequentially obtaining the last bit of the transparency values of the continuous preset number of bits of pixel points from the first bit of pixel points to obtain the mark to be determined; and determining that the identification to be determined is different from the compressed identification.
In a possible implementation manner, the compressing unit 303 is configured to compress the image file to be compressed, and includes:
The compressing unit 303 is configured to compress the image file to be compressed according to a preset compression ratio.
Based on the image file processing method provided by the embodiment of the method, the application provides image file processing equipment, which comprises the following steps: a processor, memory, system bus;
The processor and the memory are connected through the system bus;
The memory is configured to store one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform the image file processing method of any of the embodiments described above.
Based on the image file processing method provided by the above method embodiment, the present application provides a computer readable storage medium, where an instruction is stored in the computer readable storage medium, and when the instruction is executed on a terminal device, the terminal device is caused to execute the image file processing method described in any one of the above embodiments.
It should be noted that, in the present description, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different manner from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the system or device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant points refer to the description of the method section.
It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
It is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. An image file processing method, the method comprising:
determining an image file to be compressed included in the front-end project in response to acquiring an executable file generation instruction for the front-end project;
Acquiring pixel point information of the image file to be compressed;
If the pixel point information does not comprise the compressed identifier, writing the compressed identifier into the pixel point information of the image file to be compressed to generate the pixel point information of the image file to be compressed, compressing the image file to be compressed to generate the compressed image file, and generating an executable file by using the compressed image file, wherein the compressed identifier is used for identifying that the image file is compressed;
and if the pixel point information is determined to comprise the compressed identifier, generating an executable file by using the image file to be compressed.
2. The method of claim 1, wherein the pixel information is RGBA red, blue, green, transparency information, and the writing the compressed identification to the pixel information of the image file to be compressed comprises:
And writing the compressed identification into transparency information included in pixel point information of the image file to be compressed.
3. The method according to claim 2, wherein the writing of the compressed identification to the pixel point information of the image file to be compressed includes transparency information, comprising:
sequentially obtaining transparency values of pixel points with a preset number of bits in the image file to be compressed, wherein the preset number of bits is determined based on the number of bits of the compressed identification;
if the transparency value is not represented by a preset system, converting the transparency value into the preset system, wherein the preset system is determined based on the system of the compressed identifier;
acquiring a compressed identifier represented by a number of digits of a preset number of digits;
And from the first pixel point, replacing the last bit of the transparency values of the pixel points with the number of preset bits with the compressed marked values with the corresponding bits in sequence, and generating the transparency values of the replaced pixel points.
4. The method of claim 2, wherein the determining that pixel point information does not include a compressed identification comprises:
sequentially obtaining transparency values of pixel points with a preset number of bits in the image file to be compressed, wherein the preset number of bits is determined based on the number of bits of the compressed identification;
if the transparency value is not represented by a preset system, converting the transparency value into a value of the preset system, wherein the preset system is determined based on the system of the compressed identifier;
Sequentially obtaining the last bit of the transparency values of the pixel points with the preset number of bits from the first pixel point to obtain the mark to be determined;
and determining that the identification to be determined is different from the compressed identification.
5. The method of any of claims 1-4, wherein the determining the image file to be compressed that the front-end item includes comprises:
Acquiring size information of an image file included in the front-end item;
and taking the image file with the size information meeting the compression size condition as an image file to be compressed.
6. The method according to any one of claims 1-4, wherein compressing the image file to be compressed comprises:
And compressing the image file to be compressed according to a preset compression ratio.
7. An image file processing apparatus, characterized in that the apparatus comprises:
A determining unit, configured to determine an image file to be compressed included in the front-end item in response to acquiring an executable file generation instruction for the front-end item;
The information acquisition unit is used for acquiring pixel point information of the image file to be compressed;
The compressing unit is used for writing a compressed identifier into the pixel information of the image file to be compressed if the pixel information does not comprise the compressed identifier, generating the pixel information of the compressed image file, compressing the image file to be compressed, generating the compressed image file, and generating an executable file by utilizing the compressed image file, wherein the compressed identifier is used for identifying that the image file is compressed;
and the processing unit is used for generating an executable file by utilizing the image file to be compressed if the pixel point information comprises the compressed identifier.
8. The apparatus according to claim 7, wherein the determining unit configured to determine the image file to be compressed included in the front-end item includes:
The determining unit is used for acquiring the size information of the image file included in the front-end item; and taking the image file with the size information meeting the compression size condition as an image file to be compressed.
9. An image file processing apparatus, characterized by comprising: a processor, memory, system bus;
The processor and the memory are connected through the system bus;
the memory is for storing one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform the method of any of claims 1-6.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein instructions, which when run on a terminal device, cause the terminal device to perform the method of any of claims 1-6.
CN202410228113.0A 2024-02-29 2024-02-29 Image file processing method, device, equipment and medium Pending CN118229495A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410228113.0A CN118229495A (en) 2024-02-29 2024-02-29 Image file processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410228113.0A CN118229495A (en) 2024-02-29 2024-02-29 Image file processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN118229495A true CN118229495A (en) 2024-06-21

Family

ID=91504048

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410228113.0A Pending CN118229495A (en) 2024-02-29 2024-02-29 Image file processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN118229495A (en)

Similar Documents

Publication Publication Date Title
TW565803B (en) System and method for accurately recognizing text font in a document processing system
CN101364216B (en) Method and device for displaying electronic book documentary on mobile terminal
CN110781925B (en) Software page classification method and device, electronic equipment and storage medium
CN112800372B (en) Page loading method and device and electronic equipment
US20120005564A1 (en) Content distribution system and method
CN113779168A (en) Vector space data analysis method based on WebAssembly
CN112308802A (en) Image analysis method and system based on big data
CN113297425A (en) Document conversion method, device, server and storage medium
US20040091162A1 (en) Run length compression format for storing raster data in a cache
CN118229495A (en) Image file processing method, device, equipment and medium
CN116542221A (en) PDF file analysis preview method, device, equipment and storage medium
CN102467490B (en) Font data processing method and device
CN115409041B (en) Unstructured data extraction method, device, equipment and storage medium
US11776290B2 (en) Document classification using signal processing
CN113705686B (en) Image classification method, device, electronic equipment and readable storage medium
CN112233194B (en) Medical picture optimization method, device, equipment and computer readable storage medium
CN112069549B (en) Method and system for downloading picture when Bootstrap-table plug-in exports table
CN115034177A (en) Presentation file conversion method, device, equipment and storage medium
CN114706552A (en) Voice control method, device and equipment based on interactive page and storage medium
CN114676097A (en) OFD file processing method, device, equipment and medium
CN116366790B (en) Network video storage method and system
CN116090422B (en) Method and device for inputting electric power industry expansion form
CN109816896A (en) A kind of multithreading Method of printing and POS machine based on POS machine
US20050154981A1 (en) Document processing method
CN114297142A (en) Vector diagram conversion method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination