CN117667481A - Nef file repairing method, device, equipment and storage medium - Google Patents

Nef file repairing method, device, equipment and storage medium Download PDF

Info

Publication number
CN117667481A
CN117667481A CN202311632300.7A CN202311632300A CN117667481A CN 117667481 A CN117667481 A CN 117667481A CN 202311632300 A CN202311632300 A CN 202311632300A CN 117667481 A CN117667481 A CN 117667481A
Authority
CN
China
Prior art keywords
file
nef
offset position
data
image file
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
CN202311632300.7A
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.)
Shenzhen Ruan Niu Technology Group Co ltd
Original Assignee
Shenzhen Ruan Niu Technology Group 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 Shenzhen Ruan Niu Technology Group Co ltd filed Critical Shenzhen Ruan Niu Technology Group Co ltd
Priority to CN202311632300.7A priority Critical patent/CN117667481A/en
Publication of CN117667481A publication Critical patent/CN117667481A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of computers and discloses a method, a device, equipment and a storage medium for repairing a Nef file. The method comprises the following steps: obtaining the offset position of the image file directory according to the file header position of the normal Nef file; obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to all the sub-image file directories; extracting RGB data of an RGB data offset position, and storing the RGB data into JPG data through an OpenCV library; according to the initial offset position of the Raw data, the Raw data of the damaged Nef file is obtained; and respectively filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in the normal Nef file to obtain the repaired Nef file. In the embodiment of the invention, the complete Nef file can be recovered, and the accuracy of the Nef file repair is improved.

Description

Nef file repairing method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computers, and in particular, to a method, an apparatus, a device, and a storage medium for repairing a Nef file.
Background
The Nef file is a Nikon digital camera RAW image file, and is mainly applied to the fields of networks, digital media and the like at present, and is mainly stored in a computer storage medium as an application mode of website graphic elements, daily life souvenirs and the like. However, in daily life work, the file is damaged irreversibly due to the damage of the storage medium, the file in Nef format cannot be opened at all, or the picture after opening presents the disorder of pixel blocks, so that normal images cannot be formed,
the existing technical scheme does not have a repair scheme for directly repairing the Nef format, so that the repair accuracy of the Nef file is low.
Disclosure of Invention
The invention mainly aims to solve the technical problem of low accuracy of Nef file repair.
The first aspect of the invention provides a Nef file repair method, which comprises the following steps:
acquiring a normal Nef file and a damaged Nef file, and acquiring an offset position of an image file directory according to the file header position of the normal Nef file;
obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to all the sub-image file directories;
searching the damaged Nef file to obtain an RGB data offset position in the damaged Nef file, extracting RGB data of the RGB data offset position, and storing the RGB data into JPG data through an OpenCV library;
searching the damaged Nef file to obtain a Raw data initial offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data initial offset position;
and filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in the normal Nef file respectively to obtain a repaired Nef file.
Optionally, in a first implementation manner of the first aspect of the present invention, the obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to the all sub-image file directories includes:
searching an offset position of a preset first catalog item type according to the offset position of the image file catalog and a preset reading rule;
obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type;
and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to the all sub-image file catalogues.
Optionally, in a second implementation manner of the first aspect of the present invention, the obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type includes:
obtaining the number of directory entries according to the offset position of the preset first directory entry type;
obtaining the number of sub-image file directories according to the number of directory entries;
and acquiring the offset position of the first sub-image file directory, and acquiring all sub-image file directories according to the offset position of the first sub-image file directory and the number of the sub-image file directories.
Optionally, in a third implementation manner of the first aspect of the present invention, the obtaining, according to the all sub-image file directories, the JPG data offset location and the Raw data offset location in the normal Nef file includes:
obtaining a first sub-image file directory according to all the sub-image file directories;
obtaining a JPG data offset position in the normal Nef file according to the first sub-image file directory and the preset reading rule;
and acquiring a next sub-image file directory, and acquiring the Raw data offset position in the normal Nef file according to the next sub-image file directory and the preset reading rule.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the searching the damaged Nef file to obtain a Raw data start offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data start offset position includes:
searching the damaged Nef file, and searching an offset position of a preset second catalog item type according to the RGB data offset position;
obtaining byte data of a preset byte position according to the offset position of the preset second directory entry type;
and if the byte data of the preset byte position is equal to a preset threshold value, acquiring a Raw data initial offset position in the damaged Nef file, and acquiring Raw data of the damaged Nef file according to the Raw data initial offset position.
Optionally, in a fifth implementation manner of the first aspect of the present invention, before the searching the damaged Nef file, the method further includes:
acquiring the byte order of the normal Nef file;
and setting a reading mode of the damaged Nef file according to the byte order.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in the normal Nef file, to obtain the repaired Nef file includes:
obtaining RGB data offset positions in the normal Nef file according to the all sub-image file catalogues;
and filling the RGB data, the JPG data and the Raw data into an RGB data offset position, a JPG data offset position and a Raw data offset position in the normal Nef file respectively to obtain a repaired Nef file.
The second aspect of the present invention provides a Nef file repair device, including: a memory and at least one processor, the memory having instructions stored therein, the memory and the at least one processor being interconnected by a line; the at least one processor invokes the instructions in the memory to cause the Nef file repair device to perform the Nef file repair method described above.
A third aspect of the invention provides a computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the Nef file repair method described above.
In the embodiment of the invention, a normal Nef file and a damaged Nef file are obtained, and the offset position of an image file directory is obtained according to the file header position of the normal Nef file; obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to all the sub-image file directories; searching the damaged Nef file to obtain an RGB data offset position in the damaged Nef file, extracting RGB data of the RGB data offset position, and storing the RGB data into JPG data through an OpenCV library; searching the damaged Nef file to obtain a Raw data initial offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data initial offset position; and filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in the normal Nef file respectively to obtain a repaired Nef file. According to the invention, the offset position and the sub-image file directory of the normal Nef file are read to obtain the JPG data offset position and the Raw data offset position in the normal Nef file, the damaged Nef file is searched to obtain the Raw data and the RGB data of the damaged Nef file, the RGB data is saved as the JPG data through an OpenCV library, and the JPG data and the Raw data are respectively filled into the JPG data offset position and the Raw data offset position in the normal Nef file, so that the damaged Nef file can be directly repaired, the complete Nef file is recovered, and the accuracy of Nef file repair is improved.
Drawings
FIG. 1 is a schematic diagram of an embodiment of a Nef file repair method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an embodiment of a Nef file repair device according to an embodiment of the invention;
fig. 3 is a schematic diagram of an embodiment of a Nef file repair device according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a Nef file repairing method, a device, equipment and a storage medium.
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the present disclosure has been illustrated in the drawings in some form, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and examples of the present disclosure are for illustrative purposes only and are not intended to limit the scope of the present disclosure.
In describing embodiments of the present disclosure, the term "comprising" and its like should be taken to be open-ended, i.e., including, but not limited to. The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first," "second," and the like, may refer to different or the same object. Other explicit and implicit definitions are also possible below.
For easy understanding, the following describes a specific flow of an embodiment of the present invention, referring to fig. 1, and one embodiment of a Nef file repair method in an embodiment of the present invention includes:
s100, acquiring a normal Nef file and a damaged Nef file, and obtaining the offset position of the image file directory according to the file header position of the normal Nef file.
In this embodiment, a user may select a damaged Nef file to be repaired through a target frame on a terminal interface, send a file repair command, generate a file repair request, send the file repair request to a server, receive the file repair request, and obtain the damaged Nef file and a normal Nef file from a storage space; according to the Tiff specification, reading data in a normal Nef file, firstly acquiring the file header position of the normal Nef file, then reading data offset from the file header by 5-8 bytes, and storing the data as offset positions of an Image File Directory (IFD), wherein the IFD contains image data and metadata associated with an image, the IFD provides a series of pointers pointing to the initial positions of various data fields in the file, and giving the data type and length of each field.
S200, obtaining all sub-image file directories corresponding to the image file directories according to the offset positions of the image file directories and preset reading rules, and obtaining the JPG data offset positions and the Raw data offset positions in the normal Nef file according to all the sub-image file directories.
In this embodiment, each IFD may contain one or more sub-image file directories (sub-fids), which may also contain image data and metadata, which are typically reduced resolution versions (thumbnails) of the image data in the IFD containing sub-fids. To read the sub-images in the IFD, the positions of the sub-images must be acquired from the sub-fid marks. The sub fid tag contains an array of byte offsets pointing to the sub-image. After the offset position of the image file directory is obtained, searching all sub-image file directories corresponding to the image file directory backwards through a preset reading rule, and searching to obtain the JPG data offset position and the Raw data offset position in the normal Nef file according to the offset position of all the sub-image file directories, wherein the preset reading rule refers to a reading rule of a size end, namely, the low level of data is stored in a high address of a memory, the high level of data is stored in the low address of the memory, the low level of data is stored in the low address of the memory, and the high level of data is stored in the high address of the memory, and the data is read according to the storing rule.
And S300, searching the damaged Nef file, obtaining an RGB data offset position in the damaged Nef file, extracting RGB data of the RGB data offset position, and storing the RGB data as JPG data through an OpenCV library.
In this embodiment, the Nef file directly represents the image data including RGB data, JPG data, and Raw data, and first, according to a size end reading rule, searching for the number of bytes 0x0111 or 0x1101 from the damaged Nef file, and when 0x0117 or 0x1701 appears after 8 bytes are separated, the offset position and size of the thumbnail in RGB format are saved, the RGB data at the position is extracted and saved as a three-dimensional array of GBR arrangement, and saved as JPG data by means of an OpenCV three-party library, so as to recover the damaged JPG data in the damaged file by using the normal RGB data in the damaged Nef file.
S400, searching the damaged Nef file to obtain the initial offset position of the Raw data in the damaged Nef file, and obtaining the Raw data of the damaged Nef file according to the initial offset position of the Raw data.
In this embodiment, after searching for the RGB data offset position, searching for the Raw data start offset position, and obtaining Raw data of the damaged Nef file according to the length of the RGB data and the Raw data start offset position.
S500, filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in a normal Nef file respectively to obtain a repaired Nef file.
In an optional implementation manner of the first aspect of the present invention, obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to all the sub-image file directories includes:
searching an offset position of a preset first catalog item type according to the offset position of the image file catalog and a preset reading rule; obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type; and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to the file catalogues of all the sub-images.
In this embodiment, according to the size end reading rule, searching for the byte number 0x0111 or 0x1101 after obtaining the IFD offset position, obtaining the offset position of the first thumbnail, searching for 0x0117 or 0x1701 backwards to obtain the size of the first thumbnail, and temporarily storing the offset position; searching for an offset position of a preset first directory entry type after a first IFD offset position according to a size end reading rule, wherein the offset position of the preset first directory entry type refers to an offset position of byte number 0x014A or 0x4A01, the offset position indicates the type of a Directory Entry (DE) item, continuing searching backwards to obtain all sub FIDs corresponding to the IFD, and obtaining a JPG data offset position and a Raw data offset position in a normal Nef file according to the offset position of all the sub FIDs.
In an optional implementation manner of the first aspect of the present invention, obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type includes:
obtaining the number of directory entries according to the offset position of the preset first directory entry type; obtaining the number of sub-image file directories according to the number of directory entries; and acquiring the offset position of the first sub-image file directory, and acquiring all the sub-image file directories according to the offset position of the first sub-image file directory and the number of the sub-image file directories.
In this embodiment, after obtaining 4 bytes of offset positions of a preset first directory entry type, reading 4 bytes of data, and obtaining Count of DE entries of an image file directory, that is, number of DE entries, where the number of DE entries is not only number of SubFID, where the DE entries include attribute information of an image, continuously reading 4 bytes of data backwards, obtaining a first SubFID offset position, sequentially reading all SubFID according to the obtained Count and the first SubFID offset position, and temporarily storing.
In an optional implementation manner of the first aspect of the present invention, obtaining the JPG data offset location and the Raw data offset location in the normal Nef file according to all the sub-image file directories includes:
obtaining a first sub-image file directory according to all the sub-image file directories; obtaining a JPG data offset position in a normal Nef file through presetting a reading rule according to a first sub-image file directory; and acquiring a next sub-image file directory, and acquiring the Raw data offset position in the normal Nef file according to the next sub-image file directory by presetting a reading rule.
In this embodiment, after the sub fid#0, searching for an offset position of 0x0201 or 0x0102 according to a size end reading rule, reading 4 bytes of data from the last 8 bytes of the offset position, and temporarily storing the offset position of the JPG data; after the sub fid#1, an offset position of 0x0111 or 0x1101 is searched according to a size end reading rule, and 4 bytes are read from the last 8 bytes of the offset position, and the offset position is temporarily stored as a Raw data offset position.
In an optional implementation manner of the first aspect of the present invention, searching for a damaged Nef file to obtain a Raw data start offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data start offset position includes:
searching a damaged Nef file, and searching an offset position of a preset second catalog item type according to the RGB data offset position; obtaining byte data of a preset byte position according to the offset position of the preset second directory entry type; if the byte data of the preset byte position is equal to the preset threshold value, acquiring the initial offset position of the Raw data in the damaged Nef file, and acquiring the Raw data of the damaged Nef file according to the initial offset position of the Raw data.
In this embodiment, searching for a damaged Nef file to obtain an offset position of a preset second directory entry type, where the offset position of the preset second directory entry type is an offset position where the offset position of RGB data searches for the number of bytes 0x00FE or 0xFE00, and starting from the offset position to the last 8 bytes, reading 4 bytes of data, that is, the byte data of the preset byte position, and determining whether the byte data of the preset byte position is equal to a preset threshold, if so, searching for the initial offset position of Raw data in the damaged Nef file to obtain Raw data; if not, continuing to search the offset position of 0x00FE or 0xFE00 in a backward circulation way beyond the preset byte position until judging the offset position to be the preset threshold value, wherein the preset threshold value is 0.
In an optional implementation manner of the first aspect of the present invention, before searching for the damaged Nef file, the method further includes:
acquiring the byte order of a normal Nef file; and setting a reading mode of the damaged Nef file according to the byte order.
In this embodiment, the data of the beginning 2 bytes of the normal file is read, if the data is 0x4D, the data is the big-end byte order, if the data is 0x4949, the data is the small-end byte order, and the reading sequence of the damaged Nef file is set according to the small-end byte order or the big-end byte order.
In an optional implementation manner of the first aspect of the present invention, filling JPG data and Raw data into a JPG data offset position and a Raw data offset position in a normal Nef file, respectively, to obtain a repaired Nef file includes:
obtaining RGB data offset positions in a normal Nef file according to all sub-image file catalogues; and filling the RGB data, the JPG data and the Raw data into the RGB data offset position, the JPG data offset position and the Raw data offset position in the normal Nef file respectively to obtain the repaired Nef file.
In this embodiment, according to the offset positions of all the sub-image file directories, the RGB data offset positions in the normal Nef file are searched, and the RGB data, JPG data, and Raw data are respectively filled into the RGB data offset positions, JPG data offset positions, and Raw data offset positions in the normal Nef file, so as to assemble the repaired complete Nef file.
Referring to fig. 2, a second aspect of the present invention provides a Nef file repair apparatus, including:
the first position obtaining module 10 is configured to obtain a normal Nef file and a damaged Nef file, and obtain an offset position of an image file directory according to a header position of the normal Nef file;
the second position obtaining module 20 is configured to obtain all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtain a JPG data offset position and a Raw data offset position in the normal Nef file according to all the sub-image file directories;
the first data obtaining module 30 is configured to search the damaged Nef file, obtain an RGB data offset position in the damaged Nef file, extract RGB data of the RGB data offset position, and store the RGB data as JPG data through an OpenCV library;
the second data obtaining module 40 is configured to search for the damaged Nef file, obtain a Raw data initial offset position in the damaged Nef file, and obtain Raw data of the damaged Nef file according to the Raw data initial offset position;
and the repair file obtaining module 50 is configured to fill the JPG data and the Raw data into the JPG data offset position and the Raw data offset position in the normal Nef file, respectively, to obtain a repaired Nef file.
In an alternative embodiment of the second aspect of the present invention, the second location obtaining module 20 is further configured to search for an offset location of the preset first directory entry type according to the offset location of the image file directory and the preset reading rule; obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type; and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to the file catalogues of all the sub-images.
In an alternative embodiment of the second aspect of the present invention, the second location obtaining module 20 is further configured to obtain the number of directory entries according to an offset location of the preset first directory entry type; obtaining the number of sub-image file directories according to the number of directory entries; and acquiring the offset position of the first sub-image file directory, and acquiring all the sub-image file directories according to the offset position of the first sub-image file directory and the number of the sub-image file directories.
In an alternative embodiment of the second aspect of the present invention, the second location obtaining module 20 is further configured to obtain a first sub-image file directory according to all sub-image file directories; obtaining a JPG data offset position in a normal Nef file through presetting a reading rule according to a first sub-image file directory; and acquiring a next sub-image file directory, and acquiring the Raw data offset position in the normal Nef file according to the next sub-image file directory by presetting a reading rule.
In an alternative embodiment of the second aspect of the present invention, the second data obtaining module 40 is further configured to search for a damaged Nef file, and search for an offset location of a preset second directory entry type according to the RGB data offset location; obtaining byte data of a preset byte position according to the offset position of the preset second directory entry type; if the byte data of the preset byte position is equal to the preset threshold value, acquiring the initial offset position of the Raw data in the damaged Nef file, and acquiring the Raw data of the damaged Nef file according to the initial offset position of the Raw data.
In an optional embodiment of the second aspect of the present invention, the Nef file repair device further includes:
the setting module is used for acquiring the byte order of the normal Nef file; and setting a reading mode of the damaged Nef file according to the byte order.
In an alternative embodiment of the second aspect of the present invention, the repair file obtaining module 50 is further configured to obtain, according to the file directories of all the sub-images, an RGB data offset position in the normal Nef file; and filling the RGB data, the JPG data and the Raw data into the RGB data offset position, the JPG data offset position and the Raw data offset position in the normal Nef file respectively to obtain the repaired Nef file.
Fig. 3 is a schematic structural diagram of a Nef file repair device according to an embodiment of the present invention, where the Nef file repair device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (e.g., one or more processors) and a memory 520, and one or more storage media 530 (e.g., one or more mass storage devices) storing application programs 533 or data 532. Wherein memory 520 and storage medium 530 may be transitory or persistent storage. The program stored in the storage medium 530 may include one or more modules (not shown), each of which may include a series of instruction operations on the Nef file repair device 500. Still further, the processor 510 may be configured to communicate with the storage medium 530 and execute a series of instruction operations in the storage medium 530 on the Nef file repair device 500.
The Nef-based file repair device 500 may also include one or more power sources 540, one or more wired or wireless network interfaces 550, one or more input/output interfaces 560, and/or one or more operating systems 531, such as Windows service, mac OS X, unix, linux, free BSD, and the like. It will be appreciated by those skilled in the art that the Nef file repair device structure illustrated in FIG. 3 is not limiting and that the Nef file repair device may include more or fewer components than shown, or may be combined with certain components, or may have a different arrangement of components.
The present invention also provides a computer readable storage medium, which may be a non-volatile computer readable storage medium, and may also be a volatile computer readable storage medium, where instructions are stored in the computer readable storage medium, when the instructions are executed on a computer, cause the computer to perform the steps of the Nef file repair method.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Moreover, although operations are depicted in a particular order, this should be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation can also be implemented in multiple implementations separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (10)

1. The Nef file repairing method is characterized by comprising the following steps of:
acquiring a normal Nef file and a damaged Nef file, and acquiring an offset position of an image file directory according to the file header position of the normal Nef file;
obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to all the sub-image file directories;
searching the damaged Nef file to obtain an RGB data offset position in the damaged Nef file, extracting RGB data of the RGB data offset position, and storing the RGB data into JPG data through an OpenCV library;
searching the damaged Nef file to obtain a Raw data initial offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data initial offset position;
and filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in the normal Nef file respectively to obtain a repaired Nef file.
2. The method of repairing a Nef file according to claim 1, wherein obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the image file directory and a preset reading rule, and obtaining JPG data offset positions and Raw data offset positions in the normal Nef file according to the all sub-image file directories includes:
searching an offset position of a preset first catalog item type according to the offset position of the image file catalog and a preset reading rule;
obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type;
and obtaining the JPG data offset position and the Raw data offset position in the normal Nef file according to the all sub-image file catalogues.
3. The method of repairing a Nef file according to claim 2, wherein obtaining all sub-image file directories corresponding to the image file directory according to the offset position of the preset first directory entry type includes:
obtaining the number of directory entries according to the offset position of the preset first directory entry type;
obtaining the number of sub-image file directories according to the number of directory entries;
and acquiring the offset position of the first sub-image file directory, and acquiring all sub-image file directories according to the offset position of the first sub-image file directory and the number of the sub-image file directories.
4. The method of repairing a Nef file according to claim 2, wherein obtaining the JPG data offset location and the Raw data offset location in the normal Nef file according to the all sub-image file directories includes:
obtaining a first sub-image file directory according to all the sub-image file directories;
obtaining a JPG data offset position in the normal Nef file according to the first sub-image file directory and the preset reading rule;
and acquiring a next sub-image file directory, and acquiring the Raw data offset position in the normal Nef file according to the next sub-image file directory and the preset reading rule.
5. The method of repairing a Nef file according to claim 1, wherein the searching for the damaged Nef file to obtain a Raw data start offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data start offset position includes:
searching the damaged Nef file, and searching an offset position of a preset second catalog item type according to the RGB data offset position;
obtaining byte data of a preset byte position according to the offset position of the preset second directory entry type;
and if the byte data of the preset byte position is equal to a preset threshold value, acquiring a Raw data initial offset position in the damaged Nef file, and acquiring Raw data of the damaged Nef file according to the Raw data initial offset position.
6. The method of claim 1, further comprising, prior to searching for the corrupted Nef file:
acquiring the byte order of the normal Nef file;
and setting a reading mode of the damaged Nef file according to the byte order.
7. The method of repairing a Nef file according to claim 1, wherein the filling the JPG data and the Raw data into the JPG data offset position and the Raw data offset position in the normal Nef file respectively, to obtain the repaired Nef file includes:
obtaining RGB data offset positions in the normal Nef file according to the all sub-image file catalogues;
and filling the RGB data, the JPG data and the Raw data into an RGB data offset position, a JPG data offset position and a Raw data offset position in the normal Nef file respectively to obtain a repaired Nef file.
8. A Nef file repair device, the Nef file repair device comprising:
the first position acquisition module is used for acquiring a normal Nef file and a damaged Nef file, and acquiring an offset position of an image file directory according to the file header position of the normal Nef file;
the second position acquisition module is used for obtaining all sub-image file directories corresponding to the image file directories according to the offset positions of the image file directories and preset reading rules, and obtaining JPG data offset positions and Raw data offset positions in the normal Nef file according to all the sub-image file directories;
the first data acquisition module is used for searching the damaged Nef file to obtain an RGB data offset position in the damaged Nef file, extracting RGB data of the RGB data offset position, and storing the RGB data into JPG data through an OpenCV library;
the second data acquisition module is used for searching the damaged Nef file to obtain a Raw data initial offset position in the damaged Nef file, and obtaining Raw data of the damaged Nef file according to the Raw data initial offset position;
and the repair file acquisition module is used for respectively filling the JPG data and the Raw data into a JPG data offset position and a Raw data offset position in the normal Nef file to obtain a repaired Nef file.
9. A Nef file repair device, the Nef file repair device comprising: a memory and at least one processor, the memory having instructions stored therein, the memory and the at least one processor being interconnected by a line;
the at least one processor invokes the instructions in the memory to cause the Nef file repair device to perform the Nef file repair method according to any one of claims 1-7.
10. A computer readable storage medium having a computer program stored thereon, wherein the computer program when executed by a processor implements the Nef file repair method according to any of claims 1-7.
CN202311632300.7A 2023-11-30 2023-11-30 Nef file repairing method, device, equipment and storage medium Pending CN117667481A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311632300.7A CN117667481A (en) 2023-11-30 2023-11-30 Nef file repairing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311632300.7A CN117667481A (en) 2023-11-30 2023-11-30 Nef file repairing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117667481A true CN117667481A (en) 2024-03-08

Family

ID=90085786

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311632300.7A Pending CN117667481A (en) 2023-11-30 2023-11-30 Nef file repairing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117667481A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117950903A (en) * 2024-03-21 2024-04-30 深圳软牛科技集团股份有限公司 Repair method and device for damaged WebP file and related components
CN117950903B (en) * 2024-03-21 2024-06-04 深圳软牛科技集团股份有限公司 Repair method and device for damaged WebP file and related components

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117950903A (en) * 2024-03-21 2024-04-30 深圳软牛科技集团股份有限公司 Repair method and device for damaged WebP file and related components
CN117950903B (en) * 2024-03-21 2024-06-04 深圳软牛科技集团股份有限公司 Repair method and device for damaged WebP file and related components

Similar Documents

Publication Publication Date Title
US7386576B2 (en) Data file storage device with automatic filename creation function, data file storage program and data file storage method
US8249398B2 (en) Image retrieval system and method
US20100281070A1 (en) Data file having more than one mode of operation
CN106326292B (en) Data structure and file aggregation and reading method and device
US8843504B2 (en) Method and system for updating images in an image database
EP2611158A1 (en) Method and system for optimized delta encoding
JP7303625B2 (en) Image file generation device, image file generation method, and program
JPH0779403A (en) Electronic still camera
CN113448946B (en) Data migration method and device and electronic equipment
CN107590233B (en) File management method and device
CN117667481A (en) Nef file repairing method, device, equipment and storage medium
KR20150089598A (en) Apparatus and method for creating summary information, and computer readable medium having computer program recorded therefor
US8156133B2 (en) Modifying an electronic graphics file to be searchable according to annotation information
WO2019085591A1 (en) Intelligent hardware device, intelligent disk data processing method, and storage medium
CN112835858A (en) Method, device and equipment for recovering non-continuously stored files and storage medium
CN114218411A (en) System for generating picture through video
CN112905546A (en) Deleted file recovery method, device, equipment and storage medium
CN114168079B (en) Method, device and related component for identifying tiff type data deleted from disk
CN117785809A (en) CR3 file repairing method, device, equipment and storage medium
CN110765290A (en) Picture storage method, reading method, device and access system
CN104380288A (en) Image search system and image search method
CN110399346B (en) Storage path setting method and device using file counter and computer equipment
CN117708062A (en) Heic file repairing method, device and storage medium
CN117076474B (en) Method, device, equipment and medium for updating offline multi-mode literature data
CN117762662A (en) png file repairing method, device, equipment and 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