CN116991802A - File repair method, device, terminal equipment and readable storage medium - Google Patents

File repair method, device, terminal equipment and readable storage medium Download PDF

Info

Publication number
CN116991802A
CN116991802A CN202310807966.5A CN202310807966A CN116991802A CN 116991802 A CN116991802 A CN 116991802A CN 202310807966 A CN202310807966 A CN 202310807966A CN 116991802 A CN116991802 A CN 116991802A
Authority
CN
China
Prior art keywords
file
repaired
image data
ifd
extracting
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
CN202310807966.5A
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.)
Afirstsoft Co Ltd
Original Assignee
Afirstsoft Co Ltd
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 Afirstsoft Co Ltd filed Critical Afirstsoft Co Ltd
Priority to CN202310807966.5A priority Critical patent/CN116991802A/en
Publication of CN116991802A publication Critical patent/CN116991802A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application is suitable for the technical field of restoration, and provides a method and a device for restoring files, terminal equipment and a readable storage medium. The file repairing method comprises the following steps: obtaining a file to be repaired, wherein the file to be repaired is a damaged DNG file; acquiring a reference file, wherein the reference file is a DNG file and is acquired by the same shooting equipment as a file to be repaired, and the reference file and the file to be repaired are different files; extracting IFH, IFD and DE in the reference file; extracting image data in a file to be repaired; and obtaining a repair file based on IFH, IFD, DE in the reference file and the image data in the file to be repaired, wherein the repair file is a repaired DNG file. According to the embodiment of the application, the non-image data in the reference file and the image data in the file to be repaired are combined to obtain the repair file, so that the damaged DNG file can be repaired, and the DNG file can be normally opened.

Description

File repair method, device, terminal equipment and readable storage medium
Technical Field
The application belongs to the technical field of repair, and particularly relates to a file repair method, a file repair device, terminal equipment and a readable storage medium.
Background
The DNG (Digital Negative) format is a public archiving format for raw data files generated by a digital camera, which can better save the files and can also better improve the working efficiency. The DNG file includes IFH (image file header), IFD (image file directory), DE (directory entry), and image data. When the DNG file is damaged, it is common that other data than the image data is damaged, resulting in damage to the DNG file. In the related art, the DNG file cannot be repaired so that it can be normally opened.
Disclosure of Invention
The embodiment of the application provides a file repairing method, a device, terminal equipment and a readable storage medium, which can solve the problem that DNG files cannot be repaired in the related technology.
In a first aspect, an embodiment of the present application provides a method for repairing a file, including:
obtaining a file to be repaired, wherein the file to be repaired is a damaged DNG file;
acquiring a reference file, wherein the reference file is a DNG file and is acquired by the same shooting equipment as a file to be repaired, and the reference file and the file to be repaired are different files;
extracting IFH, IFD and DE in the reference file;
extracting image data in a file to be repaired;
and obtaining a repair file based on IFH, IFD, DE in the reference file and the image data in the file to be repaired, wherein the repair file is a repaired DNG file.
In a second aspect, an embodiment of the present application provides a device for repairing a file, including:
the first acquisition module is used for acquiring a file to be repaired, wherein the file to be repaired is a damaged DNG file;
the second acquisition module is used for acquiring a reference file, wherein the reference file is a DNG file and is acquired by the same shooting equipment as a file to be repaired, and the reference file and the file to be repaired are different files;
the first extraction module is used for extracting IFH, IFD and DE in the reference file;
the second extraction module is used for extracting the image data in the file to be repaired;
and the repair module is used for obtaining a repair file based on IFH, IFD, DE in the reference file and the image data in the file to be repaired, wherein the repair file is a repaired DNG file.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements steps of a method for repairing a file as described above when the processor executes the computer program.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the above-described method of repairing a file.
In a fifth aspect, an embodiment of the present application provides a computer program product, which when run on a terminal device, causes the terminal device to perform a method for repairing a file as described above.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the file to be repaired and the reference file are firstly obtained, IFH, IFD, DE in the reference file and the image data in the file to be repaired are extracted, and the repair file is obtained based on IFH, IFD, DE in the reference file and the image data in the file to be repaired. Because the reference file and the file to be repaired are acquired by the same equipment, the non-image data in the reference file is basically consistent with the corresponding non-image data in the file to be repaired. According to the embodiment of the application, the non-image data in the reference file and the image data in the file to be repaired are combined to obtain the repair file, so that the damaged DNG file can be repaired, and the DNG file can be normally opened.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic implementation flow chart of a method for repairing a file according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an implementation flow of IFD in an extracted reference file according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an implementation flow of determining image data in a reference file according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an implementation flow of obtaining a repair file according to an embodiment of the present application;
fig. 5 is a schematic diagram of an implementation flow for extracting image data in a file to be repaired according to an embodiment of the present application;
FIG. 6 is a schematic structural diagram of a file repairing device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by a person skilled in the art without any inventive effort, are intended to be protected by the present application based on the embodiments of the present application.
It is noted that the terms "comprising," "including," and "having," and any variations thereof, in the description and claims of the application and in the foregoing figures, are intended to cover non-exclusive inclusions. For example, a process, method, terminal, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. In the claims, specification, and drawings of the present application, relational terms such as "first" and "second", and the like are used solely to distinguish one entity/operation/object from another entity/operation/object without necessarily requiring or implying any such real-time relationship or order between such entities/operations/objects.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The DNG (Digital Negative) format is a public archiving format for raw data files generated by a digital camera, which can better save the files and can also better improve the working efficiency. The DNG file includes IFH (image file header), IFD (image file directory), DE (directory entry), and image data. When the DNG file is damaged, it is common that other data than the image data is damaged, resulting in damage to the DNG file. In the related art, the DNG file cannot be repaired so that it can be normally opened.
Therefore, according to the embodiment of the application, the non-image data in the reference file and the image data in the file to be repaired are combined to obtain the repair file, so that the damaged DNG file can be repaired, and the DNG file can be normally opened.
In order to illustrate the technical scheme of the application, the following description is made by specific examples.
Fig. 1 shows a schematic implementation flow chart of a method for repairing a file according to an embodiment of the present application, where the method may be applied to a terminal device. The terminal device may be a mobile phone, tablet computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, etc.
Specifically, the repair method of the file may include the following steps S101 to S105.
Step S101, obtaining a file to be repaired.
The files to be repaired are damaged DNG files, wherein the DNG files comprise IFH (image file header), IFD (image file directory), DE (directory entry) and image data. DNG file corruption is typically caused by corruption of data other than image data.
In the embodiment of the application, the terminal equipment can directly acquire the files to be repaired input by the user, and can also directly retrieve the files to be repaired stored in the memory.
Step S102, a reference file is acquired.
The reference file is a DNG file, the reference file and the file to be repaired are acquired by the same shooting equipment, and the reference file and the file to be repaired are different files. Because the reference file and the file to be repaired are acquired by the same equipment, the non-image data in the reference file is basically consistent with the corresponding non-image data in the file to be repaired.
In the embodiment of the application, the terminal equipment can directly acquire the reference file input by the user, and can also directly retrieve the reference file stored in the memory.
Step S103, IFH, IFD and DE in the reference file are extracted.
In the embodiment of the application, the terminal device can directly copy a reference file and remove other data (i.e. image data) except the IFH, the IFD and the DE, so as to extract the IFH, the IFD and the DE in the reference file. Furthermore, the terminal device may also extract IFH, IFD and DE sequentially from the reference file. The embodiments of the present application are not limited in this regard.
Step S104, extracting the image data in the file to be repaired.
In the embodiment of the application, the image data in the file to be repaired is mainly stored in the Tiles in the file to be repaired. The terminal equipment can extract the image data in the file to be repaired by determining the offset position and the occupied byte number of the Tiles in the file to be repaired.
Step S105, obtaining the repair file based on IFH, IFD, DE in the reference file and the image data in the file to be repaired.
The repair file is a repaired DNG file.
In the embodiment of the application, after extracting IFH, IFD, DE in the reference file and the image data in the file to be repaired, the terminal equipment can synthesize the data into one file, and then the repair file can be obtained. That is, the IFH, IFD, and DE in the repair file are from the reference file, and the image data are from the file to be repaired.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the file to be repaired and the reference file are firstly obtained, IFH, IFD, DE in the reference file and the image data in the file to be repaired are extracted, and the repair file is obtained based on IFH, IFD, DE in the reference file and the image data in the file to be repaired. Because the reference file and the file to be repaired are acquired by the same equipment, the non-image data in the reference file is basically consistent with the corresponding non-image data in the file to be repaired. According to the embodiment of the application, the non-image data in the reference file and the image data in the file to be repaired are combined to obtain the repair file, so that the damaged DNG file can be repaired, and the DNG file can be normally opened.
In some embodiments of the present application, the IFH in the above extraction reference file may specifically include:
and reading a preset number of bytes of a second preset offset position in the reference file, and extracting the IFH in the reference file.
It should be appreciated that IFH includes data that stores the end-of-size representation, the flag bit of TIFF, and the offset of the first IFD.
In an embodiment of the present application, the second preset offset position may be set to 0x00 to 0x01. The preset number may be set to 8, where the first two bytes may be used to determine a storage size end representation, specifically, if the value of the first two bytes is 0x4D, the reference file is in a large end storage mode, and if the value of the first two bytes is 0x1919, the reference file is in a small end storage mode. The third and fourth two bytes may represent the flag bit of TIFF. The last 4 bytes may be used to determine the offset of the first IFD.
In some embodiments of the present application, the DE in the above extraction reference may specifically include:
searching the DE of which all tags meet the preset value from the reference file, and extracting the DE.
It should be understood that DE includes Tag (DE Type), type (data Type), number (Number of data), offset (storing corresponding data or Offset position of corresponding data), and the like.
In the embodiment of the application, the specific TAG value corresponds to the specific DE type, so that the terminal device can search the reference file for the specific TAG value and determine the DE type according to the TAG value, thereby extracting the corresponding DE.
As shown in fig. 2, in some embodiments of the present application, the IFD in the extraction reference file may specifically include step S202 and step S203.
In step S201, 4 bytes of the first preset offset position in the reference file are read, and the offset of the IFD is obtained.
In an embodiment of the present application, the first preset offset position may be set to 0x04 to 0x07. These 4 bytes belong to the last 4 bytes in the IFH, and the terminal device can obtain the offset of the IFD according to the information corresponding to these 4 bytes.
Step S202, jumping the offset of the IFD from the beginning position of the reference file, and extracting the IFD.
In the embodiment of the application, after obtaining the offset of the IFD, the terminal device may skip the offset of the IFD from the beginning position of the reference file to reach the position of the IFD, thereby extracting the IFD.
In some embodiments, when there are multiple IFDs in the reference file, the terminal device may derive the offset of the first IFD from the last 4 bytes in the IFH, then jump to the location of the first IFD and extract the first IFD. And then jumping to the position of the next IFD and extracting the next IFD according to the offset of the next IFD recorded in the first IFD, and the like until all the IFDs are extracted.
In some embodiments of the application, as shown in fig. 3, it is also necessary to determine the image data in the reference file after the IFD is extracted, so as to replace the image data in the reference file with the image data in the file to be repaired. Specifically, the method for repairing a file further includes steps S301 to S307.
Step S301, searching for a first DE whose Tag satisfies a first preset value from the IFD.
The IFD may store a DE therein, which may include a Tag therein, which may be used to indicate the type of DE.
In an embodiment of the present application, different first preset values may be set for different storage modes. Specifically, when the reference file is in a large-end storage mode, the first preset value may be set to 0x014A, and the terminal device may find a first DE with Tag of 0x014A from the IFD; when the reference file is in a small-end storage mode, the first preset value can be set to 0x4a01, and the terminal equipment can search the first DE with Tag of 0x4a01 from the IFD.
In step S302, the offset of the subIFDs is determined based on the first DE.
Among them, the SubIFDs may include a plurality of SubIFDs. The SubIFDs may be formed of a group of SubIFDs, which are also an IFD, and information such as the length, width, color channel, and image source data of the image are stored in the IFDs and the SubIFDs; the offset of the SubIFD is described in the DE corresponding to a certain preset Tag value of the IFD.
In an embodiment of the present application, count in the first DE records the number of SubIFDs, offset in the first DE records the offsets of a plurality of SubIFDs (i.e., subIFDs), and the terminal device may read the Offset to obtain the Offset of the SubIFDs.
Step S303, jumping the offset of the subIFDs from the beginning position of the reference file to obtain the subIFDs.
In the embodiment of the present application, after obtaining the offsets of the SubIFDs, the terminal device may jump to each SubIFD in turn from the beginning position of the reference file, to obtain multiple SubIFDs (i.e., subIFDs).
Step S304, searching a second DE with Tag meeting a second preset value from the subIFDs.
In an embodiment of the present application, the second preset value may be set to 0x00FE or 0xFE0. The Tag of the second DE satisfies the second preset value, and at this time, the image data of the reference file is stored in the subIFD corresponding to the second DE.
In step S305, a third DE whose Tag satisfies a third preset value and a fourth DE whose Tag satisfies a fourth preset value are searched from the subifds corresponding to the second DE.
In an embodiment of the present application, the third preset value may be set to 0x0144 or 0x4401 and the fourth preset value may be set to 0x0145 or 0x4501. The Tag of the third DE satisfies the third predetermined value, at which time the offset location of the Tiles is stored in the third DE. The Tag of the fourth DE satisfies the fourth predetermined value, and the number of bytes occupied by the tones is stored in the fourth DE.
In step S306, the offset position of the Tiles is obtained based on the third DE, and the number of bytes occupied by the Tiles is obtained based on the fourth DE.
Wherein, the Tiles store image data.
In the embodiment of the application, since the offset position of the Tiles is stored in the third DE, the terminal device can obtain the offset position of the Tiles by reading the related information in the third DE. And because the fourth DE stores the occupied byte number of the Tiles, the terminal equipment can acquire the occupied byte number of the Tiles by reading the related information in the fourth DE.
In step S307, the image data of the reference file is obtained based on the offset position of the Tiles and the number of bytes occupied by the Tiles.
In the embodiment of the application, after obtaining the offset position of the Tiles and the number of bytes occupied by the Tiles, the terminal device can jump to the offset position of the Tiles and read the number of bytes occupied by the Tiles backwards, thereby obtaining the image data of the reference file.
In some embodiments of the present application, the reference file further includes a thumbnail corresponding to the image data in the reference file. When non-image data (including thumbnail) of the reference file and image data of the file to be repaired are assembled to obtain the repair file, if the thumbnail in the reference file is not removed, the repair file is affected. It may be caused that the image data of the repair file does not correspond to the thumbnail, i.e., the image data of the repair file is the image data in the file to be repaired, and the thumbnail of the repair file is the thumbnail of the image data in the reference file. It is also possible that two different thumbnails exist in the repair file, namely one that is a thumbnail of the image data in the reference file and one that is a thumbnail of the image data in the file to be repaired.
In view of this, the thumbnail of the reference file may be removed before the non-image data of the reference file and the image data of the file to be repaired are assembled.
Specifically, after skipping the offset of the SubIFDs from the beginning position of the reference file to obtain the SubIFDs, the file repairing method further includes:
searching a seventh DE of which the Tag meets a seventh preset value from the subIFDs; obtaining an offset position of the thumbnail based on the seventh DE; jumping to the position of the thumbnail based on the offset position of the thumbnail; the thumbnail is removed.
In an embodiment of the present application, the seventh preset value may be set to 0x0111 or 0x1101. The Tag of the seventh DE meets the seventh preset value, and at this time, the offset position of the thumbnail is stored in the seventh DE, so that the terminal device can read the related information in the seventh DE to obtain the offset position of the thumbnail, jump to the position of the thumbnail, empty the head and tail of the thumbnail, thereby removing the thumbnail in the reference file and avoiding affecting the repair file.
As shown in fig. 4, in some embodiments of the present application, the obtaining the repair file based on IFH, IFD, DE in the reference file and the image data in the file to be repaired may specifically include step S401 and step S402.
In step S401, the image data in the reference file is replaced with the image data in the file to be repaired, so as to obtain the replaced image data.
In the embodiment of the application, in the process of assembling the repair file, the terminal equipment can copy one reference file and replace the image data in the copied reference file with the image data in the file to be repaired, so that the replaced image data is obtained.
In step S402, a repair file is obtained based on IFH, IFD, DE in the reference file and the replaced image data.
In the embodiment of the application, after the replaced image data is obtained, the repair file can be obtained by combining IFH, IFD, DE in the reference file and the replaced image data.
As shown in fig. 5, in some embodiments of the present application, the extracting the image data in the file to be repaired may specifically include steps S501 to S504.
In step S501, a fifth DE whose Tag satisfies a fifth preset value and a sixth DE whose Tag satisfies a sixth preset value are searched for from the file to be repaired.
Step S502, obtaining the offset position of the Tiles in the file to be repaired based on the fifth DE.
Wherein, the Tiles store image data;
in step S503, the number of bytes occupied by the Tiles in the file to be repaired is obtained based on the sixth DE.
In step S504, image data is extracted from the file to be repaired based on the offset position of the Tiles and the number of bytes occupied by the Tiles.
In an embodiment of the present application, the fifth preset value may be set to 0x0144 or 0x4401, and the sixth preset value may be set to 0x0145 or 0x4501. The specific steps of extracting the image data in the file to be repaired can refer to the steps S305 to S307, and the principle thereof is similar, and will not be repeated here.
In some embodiments of the present application, before performing the step S501, the method may further include:
searching an eighth DE of which Tag meets an eighth preset value from the file to be repaired; judging whether the value of the eighth DE meets a preset value; if so, the above step S501 is performed.
In an embodiment of the present application, the eighth preset value may be set to 0x00FE or 0xFE00, and the preset value may be set to full_image.
Fig. 6 shows a schematic structural diagram of a file repairing apparatus according to an embodiment of the present application, where the file repairing apparatus 6 may be configured on a terminal device, and specifically, the file repairing apparatus 6 may include:
the first obtaining module 601 is configured to obtain a file to be repaired, where the file to be repaired is a damaged DNG file;
the second obtaining module 602 is configured to obtain a reference file, where the reference file is a DNG file, the reference file and the file to be repaired are acquired by the same shooting device, and the reference file and the file to be repaired are different files;
a first extracting module 603, configured to extract IFH, IFD, and DE in the reference file;
a second extracting module 604, configured to extract image data in a file to be repaired;
the repair module 605 is configured to obtain a repair file based on IFH, IFD, DE in the reference file and the image data in the file to be repaired, where the repair file is a repaired DNG file.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the file to be repaired and the reference file are firstly obtained, IFH, IFD, DE in the reference file and the image data in the file to be repaired are extracted, and the repair file is obtained based on IFH, IFD, DE in the reference file and the image data in the file to be repaired. Because the reference file and the file to be repaired are acquired by the same equipment, the non-image data in the reference file is basically consistent with the corresponding non-image data in the file to be repaired. According to the embodiment of the application, the non-image data in the reference file and the image data in the file to be repaired are combined to obtain the repair file, so that the damaged DNG file can be repaired, and the DNG file can be normally opened.
In some embodiments of the present application, the first extraction module 603 is further configured to: reading 4 bytes of a first preset offset position in a reference file, and obtaining the offset of the IFD; the IFD is extracted by jumping the offset of the IFD from the beginning position of the reference file.
In some embodiments of the present application, the repairing device 6 of the above document may further include: a third extraction module for: searching a first DE with the Tag meeting a first preset value from the IFD, wherein the DE comprises the Tag which is used for representing the type of the DE; determining an offset of SubIFDs based on the first DE, the SubIFDs including a plurality of SubIFDs; jumping the offset of the subIFDs from the beginning position of the reference file to obtain the subIFDs; searching a second DE of which the Tag meets a second preset value from the subIFDs; searching a third DE of which the Tag meets a third preset value and a fourth DE of which the Tag meets a fourth preset value from subIFDs corresponding to the second DE; obtaining the offset position of the Tiles based on the third DE, obtaining the number of bytes occupied by the Tiles based on the fourth DE, and storing the image data by the Tiles; image data of the reference file is obtained based on the offset position of the Tiles and the number of bytes occupied by the Tiles.
In some embodiments of the present application, the repair module 605 is further configured to: replacing the image data in the reference file with the image data in the file to be repaired to obtain replaced image data; a repair file is derived based on IFH, IFD, DE in the reference file and the replaced image data.
In some embodiments of the present application, the second extraction module 604 is further configured to: searching a fifth DE of which the Tag meets a fifth preset value from the file to be repaired and a sixth DE of which the Tag meets a sixth preset value; obtaining offset positions of Tiles in the file to be repaired based on the fifth DE, wherein the Tiles store image data; obtaining the occupied byte number of the Tiles in the file to be repaired based on the sixth DE; image data is extracted from the file to be repaired based on the offset position of the Tiles and the number of bytes occupied by the Tiles.
In some embodiments of the present application, the first extraction module 603 is further configured to: and reading a preset number of bytes of a second preset offset position in the reference file, and extracting the IFH in the reference file.
In some embodiments of the present application, the first extraction module 603 is further configured to: searching the DE of which all tags meet the preset value from the reference file, and extracting the DE.
Fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present application. The terminal device 7 may include: a processor 701, a memory 702, and a computer program 703, such as a file repair program, stored in the memory 702 and executable on the processor 701. The processor 701 implements the steps in the above-described embodiments of the repair method of each file when executing the computer program 703, for example, steps S101 to S105 shown in fig. 1. Alternatively, the processor 701 executes the computer program 703 to implement the functions of the modules/units in the above-described apparatus embodiments, for example, the first acquisition module 601, the second acquisition module 602, the first extraction module 603, the second extraction module 604, and the repair module 605 shown in fig. 6.
The computer program may be divided into one or more modules/units, which are stored in the memory 702 and executed by the processor 701 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions, which instruction segments are used for describing the execution of the computer program in the terminal device.
The terminal device may include, but is not limited to, a processor 701, a memory 702. It will be appreciated by those skilled in the art that fig. 7 is merely an example of a terminal device and is not limiting of the terminal device, and may include more or fewer components than shown, or may combine some components, or different components, e.g., the terminal device may also include input and output devices, network access devices, buses, etc.
The processor 701 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 702 may be an internal storage unit of the terminal device, such as a hard disk or a memory of the terminal device. The memory 702 may also be an external storage device of the terminal device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like. Further, the memory 702 may also include both internal storage units and external storage devices of the terminal device. The memory 702 is used for storing the computer program and other programs and data required by the terminal device. The memory 702 may also be used to temporarily store data that has been output or is to be output.
It should be noted that, for convenience and brevity of description, the structure of the above terminal device may also refer to a specific description of the structure in the method embodiment, which is not repeated herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program can realize the steps in the file repairing method when being executed by a processor.
The embodiment of the application provides a computer program product which can realize the steps in the file repairing method when being executed by a mobile terminal when the computer program product runs on the mobile terminal.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. A method for repairing a document, comprising:
obtaining a file to be repaired, wherein the file to be repaired is a damaged DNG file;
acquiring a reference file, wherein the reference file is a DNG file, the DNG file and the file to be repaired are acquired by the same shooting equipment, and the reference file and the file to be repaired are different files;
extracting IFH, IFD and DE in the reference;
extracting image data in the file to be repaired;
and obtaining a repair file based on the IFH, the IFD, the DE and the image data in the file to be repaired in the reference file, wherein the repair file is a repaired DNG file.
2. The method for repairing a file according to claim 1, wherein said extracting the IFD in the reference file comprises:
reading 4 bytes of a first preset offset position in the reference file, and obtaining the offset of the IFD;
and jumping the offset of the IFD from the beginning position of the reference file to extract the IFD.
3. The method of repairing a file according to claim 2, wherein after extracting the IFD, the method further comprises:
searching a first DE with a Tag meeting a first preset value from the IFD, wherein the DE comprises the Tag which is used for representing the type of the DE;
determining an offset of SubIFDs based on the first DE, the SubIFDs including a plurality of SubIFDs;
jumping the offset of the SubIFDs from the beginning position of the reference file to obtain the SubIFDs;
searching a second DE of which the Tag meets a second preset value from the subIFDs;
searching a third DE of which the Tag meets a third preset value and a fourth DE of which the Tag meets a fourth preset value from the subIFDs corresponding to the second DE;
obtaining offset positions of the Tiles based on the third DE, and obtaining the occupied byte numbers of the Tiles based on the fourth DE, wherein the Tiles store image data;
and obtaining the image data of the reference file based on the offset position of the Tiles and the occupied byte number of the Tiles.
4. A method of repairing a document according to claim 3, wherein said obtaining a repair document based on image data in said IFH, said IFD, said DE and said document to be repaired in said reference document comprises:
replacing the image data in the reference file with the image data in the file to be repaired to obtain replaced image data;
and obtaining the repair file based on the IFH, the IFD, the DE and the replaced image data in the reference file.
5. The method for repairing a file according to claim 1, wherein the extracting the image data in the file to be repaired comprises:
searching a fifth DE of which the Tag meets a fifth preset value from the file to be repaired and a sixth DE of which the Tag meets a sixth preset value;
obtaining offset positions of Tiles in the file to be repaired based on the fifth DE, wherein the Tiles store image data;
obtaining the occupied byte number of the Tiles in the file to be repaired based on the sixth DE;
and extracting the image data from the file to be repaired based on the offset position of the Tiles and the occupied byte number of the Tiles.
6. A method of repairing a document according to any one of claims 1 to 5, wherein said extracting the IFH in the reference document comprises:
and reading a preset number of bytes of a second preset offset position in the reference file, and extracting the IFH in the reference file.
7. The method for repairing a file according to any one of claims 1 to 5, wherein said extracting DE in said reference file comprises:
and searching DE (DE) of which all tags meet preset values from the reference file, and extracting the DE.
8. A document repair device, comprising:
the first acquisition module is used for acquiring a file to be repaired, wherein the file to be repaired is a damaged DNG file;
the second acquisition module is used for acquiring a reference file, wherein the reference file is a DNG file, the DNG file and the file to be repaired are acquired by the same shooting equipment, and the reference file and the file to be repaired are different files;
the first extraction module is used for extracting IFH, IFD and DE in the reference file;
the second extraction module is used for extracting the image data in the file to be repaired;
and the repair module is used for obtaining a repair file based on the IFH, the IFD, the DE and the image data in the file to be repaired in the reference file, wherein the repair file is a repaired DNG file.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method of repairing a file according to any one of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method for repairing a file according to any one of claims 1 to 7.
CN202310807966.5A 2023-07-03 2023-07-03 File repair method, device, terminal equipment and readable storage medium Pending CN116991802A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310807966.5A CN116991802A (en) 2023-07-03 2023-07-03 File repair method, device, terminal equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310807966.5A CN116991802A (en) 2023-07-03 2023-07-03 File repair method, device, terminal equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN116991802A true CN116991802A (en) 2023-11-03

Family

ID=88533024

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310807966.5A Pending CN116991802A (en) 2023-07-03 2023-07-03 File repair method, device, terminal equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN116991802A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556187A (en) * 2023-11-10 2024-02-13 纬创软件(武汉)有限公司 Cloud data restoration method and system based on deep learning and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556187A (en) * 2023-11-10 2024-02-13 纬创软件(武汉)有限公司 Cloud data restoration method and system based on deep learning and readable storage medium
CN117556187B (en) * 2023-11-10 2024-05-10 纬创软件(武汉)有限公司 Cloud data restoration method and system based on deep learning and readable storage medium

Similar Documents

Publication Publication Date Title
US8836817B2 (en) Data processing apparatus, imaging apparatus, and medium storing data processing program
US8271544B2 (en) Data file having more than one mode of operation
CN116991802A (en) File repair method, device, terminal equipment and readable storage medium
CN113010116B (en) Data processing method, device, terminal equipment and readable storage medium
CN109496292B (en) Disk management method, disk management device and electronic equipment
CN111125034A (en) Aggregation object data processing method, system and related equipment
CN113495903A (en) Electric power time sequence database caching method, system, equipment and readable storage medium
WO2006049413A1 (en) Mobile terminal and operating method thereof
CN106128460A (en) A kind of record labels method and device
CN117667481A (en) Nef file repairing method, device, equipment and storage medium
CN107832021B (en) Electronic evidence fixing method, terminal equipment and storage medium
CN109359878B (en) Archive data processing method, computer device and computer readable storage medium
CN117472648A (en) File repair method, device, terminal equipment and readable storage medium
CN108108467B (en) Data deleting method and device
CN111162792A (en) Compression method and device for power load data
CN116909997A (en) File repair method, device, terminal equipment and readable storage medium
JP2016015669A (en) Moving image restoration device, moving image restoration method, and program for moving image restoration device
CN109413355A (en) A kind of method and terminal device for quickly transferring monitoring video
CN111221803B (en) Feature library management method and coprocessor
KR100613076B1 (en) Method For Image File Management In The Mobile Communication Terminal
CN108153604B (en) Method for recovering deleted files in F2FS file system
CN117194100A (en) File repair method, device, terminal equipment and readable storage medium
CN103312792A (en) Method and system for reading file from external storage equipment
CN117271448A (en) File repair method, device, terminal equipment and readable storage medium
CN116778978A (en) File repair method, device, terminal equipment and readable storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: 1301-1310, Building 2, Jinlitong Financial Center Building, No. 1100 Xingye Road, Haiwang Community, Xin'an Street, Bao'an District, Shenzhen City, Guangdong Province

Applicant after: Shenzhen Ruan Niu Technology Group Co.,Ltd.

Address before: No. 15-3 Haitian Road, Building C, Excellence Times Square, N23 Haiwang Community, Xin'an Street, Bao'an District, Shenzhen City, Guangdong Province, China 2903

Applicant before: AFIRSTSOFT CO.,LTD.

Country or region before: China