Disclosure of Invention
In view of this, one or more embodiments of the present disclosure are to provide a method and an apparatus for extracting a thumbnail in an android system, and an electronic device, which are capable of adapting to thumb data files of different versions to perform picture restoration and have good universality.
In view of the above, one or more embodiments of the present specification provide a method for extracting a thumbnail in an android system, including:
obtaining a thunmbdataX series file in an android system terminal;
searching the thumbdataX series file, finding the initial position a of a jpg file and obtaining the size b of the jpg file;
extracting a file with the size of b from the starting position a from the thunbbdataX, and storing the file as a jpg file;
and returning to execute the step of searching the jpg file from the thunmbdataX series files until all files are searched.
As an optional implementation manner, the obtaining of the thumbdataX series files in the android system terminal includes searching a/sdcard/DCIM/. thumbfiles directory of the android system terminal, and obtaining the thumbdataX series files under the directory.
As an alternative embodiment, the thumbdataX series file includes a thumbbdata 3 file or a thumbbdata 4 or a thunbdata 5 file.
As an optional implementation manner, the searching the thumbbdata X series file to find the start position a of the jpg file includes
If four consecutive bytes in the thunbbdata X series file are 0xff, 0xd8, 0xff and 0xe0, respectively, and four bytes starting from the seventh byte are the character string "JFIF" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file; or
If the four consecutive bytes in the thumbbdata X series file are 0xff, 0xd8, 0xff and 0xe1, respectively, and the four bytes starting from the seventh byte are the character string "Exif" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file.
As an optional implementation manner, the obtaining the size b of the jpg file includes
And acquiring four bytes before the initial position a of the jpg file, wherein the four bytes correspond to the size of the jpg file.
As a second aspect of the present invention, there is provided an apparatus for extracting a thumbnail in an android system, including:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring the thumbdataX series files in the android system terminal;
the searching module is used for searching the thumbdataX series files, finding the initial position a of the jpg file and obtaining the size b of the jpg file;
the extracting module is used for extracting a file which starts from the starting position a and has the size of b from the thumbdataX and storing the file as a jpg file;
and the circulating module is used for returning to execute the step of searching the jpg file from the thumbdataX series files until all the files are searched.
As an optional implementation manner, the obtaining module is configured to search for an/sdcard/DCIM/. thumbfiles directory of the android system terminal, and obtain the thumbdataX series file in the directory.
As an optional implementation manner, the lookup module is configured to:
if four consecutive bytes in the thunbbdata X series file are 0xff, 0xd8, 0xff and 0xe0, respectively, and four bytes starting from the seventh byte are the character string "JFIF" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file; or
If the four consecutive bytes in the thumbbdata X series file are 0xff, 0xd8, 0xff and 0xe1, respectively, and the four bytes starting from the seventh byte are the character string "Exif" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file.
As an optional implementation manner, the lookup module is further configured to:
and acquiring four bytes before the initial position a of the jpg file, wherein the four bytes correspond to the size of the jpg file.
As a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method as described above when executing the program.
As can be seen from the above, according to the method, the device and the electronic device for extracting thumbnails in an android system provided in one or more embodiments of the present disclosure, first, a thumbfile in a thumbfile system terminal is obtained, then, a search is performed in the thumbfile system, by locating a start position a and a size b of the jpg file, the jpg file can be extracted from the thumbfile system, and the search is continued from the position where the jpg file is extracted until all files in the thumbfile system are completely searched, so that all thumbnails in the thumbfile system can be found.
Detailed Description
For the purpose of promoting a better understanding of the objects, aspects and advantages of the present disclosure, reference is made to the following detailed description taken in conjunction with the accompanying drawings.
In order to achieve the above object, embodiments of the present invention provide a method and an apparatus for extracting a thumbnail in an android system, and an electronic device, where the method and the apparatus may be applied to terminals such as a series of mobile phones and a series of tablet based on the android system, and may also be applied to terminals connected to terminals such as a series of mobile phones and a series of tablet based on the android system, such as a server, a cloud server, a server cluster, and the like, which are not limited specifically. First, a detailed description is given to a thumbnail extraction method in an android system provided by the embodiment of the present invention.
The embodiment of the invention provides a thumbnail extraction method in an android system, which comprises the following steps:
s100, obtaining a thumbdataX series file in the android system terminal;
s200, searching the thumbdataX series file, finding the initial position a of a jpg file and obtaining the size b of the jpg file;
s300, extracting a file which starts from the initial position a and has the size of b from the thumbdataX, and storing the file as a jpg file;
s400, returning to the step of searching the jpg file from the thumbdataX series files until all files are searched.
In the embodiment of the invention, the method comprises the steps of firstly obtaining the thumbdataX series files in the android system terminal, then searching in the thumbdataX series files, extracting the jpg files from the thumbdataX series files by positioning the initial position a and the size b of the jpg files, and continuously searching from the position where the jpg files are extracted until all files in the thumbdataX series files are searched, so that all thumbnails in the thumbdataX series files can be found.
Referring to fig. 1, an embodiment of the present invention provides a method for extracting a thumbnail in an android system, including:
s100, obtaining the thumbdataX series files in the android system terminal.
Optionally, the obtaining of the thumbdataX series files in the android system terminal includes searching for an/sdcard/DCIM/. thumbfiles directory of the android system terminal, and obtaining the thumbdataX series files in the directory.
Optionally, the thumbdataX series file includes a thumbdata3 file, a thumbdata4 file, or a thunbdata 5 file, and it should be noted that the thumbdataX series file may also include other versions of thumbdatafiles, which is not limited specifically.
S200, searching the thumbdataX series file, finding the initial position a of the jpg file and obtaining the size b of the jpg file.
Optionally, the searching is performed on the thumbbdata X series file to find the start position a of the jpg file, including
If four consecutive bytes in the thunbbdata X series file are 0xff, 0xd8, 0xff and 0xe0, respectively, and four bytes starting from the seventh byte are the character string "JFIF" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file; or
If the four consecutive bytes in the thumbbdata X series file are 0xff, 0xd8, 0xff and 0xe1, respectively, and the four bytes starting from the seventh byte are the character string "Exif" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file.
Optionally, the obtaining the size b of the jpg file includes
And acquiring four bytes before the initial position a of the jpg file, wherein the four bytes correspond to the size of the jpg file.
S300, extracting a file which starts from the initial position a and has the size of b from the thumbdataX, and storing the file as a jpg file;
s400, returning to the step of searching the jpg file from the thumbdataX series files until all files are searched.
Corresponding to the method for extracting the thumbnail in the Huawei android system, the embodiment of the invention also discloses a device for extracting the thumbnail in the android system, please refer to fig. 2, which comprises
The obtaining module 10 is configured to obtain a thumbdataX series file in the android system terminal;
the searching module 20 is configured to search the thumbdataX series file, find an initial position a of a jpg file, and obtain a size b of the jpg file;
an extracting module 30, configured to extract a file with a size b starting from a starting position a from the thumbdataX, and store the file as a jpg file;
and the circulation module 40 is configured to return to execute the step of searching for the jpg file from the thumbdataX series files until all files are searched.
In the embodiment of the invention, the method comprises the steps of firstly obtaining the thumbdataX series files in the android system terminal, then searching in the thumbdataX series files, extracting the jpg files from the thumbdataX series files by positioning the initial position a and the size b of the jpg files, and continuously searching from the position where the jpg files are extracted until all files in the thumbdataX series files are searched, so that all thumbnails in the thumbdataX series files can be found.
As an optional implementation manner, the obtaining module is configured to search for an/sdcard/DCIM/. thumbfiles directory of the android system terminal, and obtain the thumbdataX series file in the directory.
As an optional implementation manner, the lookup module is configured to:
if four consecutive bytes in the thunbbdata X series file are 0xff, 0xd8, 0xff and 0xe0, respectively, and four bytes starting from the seventh byte are the character string "JFIF" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file; or
If the four consecutive bytes in the thumbbdata X series file are 0xff, 0xd8, 0xff and 0xe1, respectively, and the four bytes starting from the seventh byte are the character string "Exif" from the first byte of the four bytes, the first byte of the four bytes is the start position a of the jpg file.
As an optional implementation manner, the lookup module is further configured to:
and acquiring four bytes before the initial position a of the jpg file, wherein the four bytes correspond to the size of the jpg file.
For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, the functionality of the modules may be implemented in the same one or more software and/or hardware implementations in implementing one or more embodiments of the present description.
It should be noted that the method of one or more embodiments of the present disclosure may be performed by a single device, such as a computer or server. The method of the embodiment can also be applied to a distributed scene and completed by the mutual cooperation of a plurality of devices. In such a distributed scenario, one of the devices may perform only one or more steps of the method of one or more embodiments of the present disclosure, and the devices may interact with each other to complete the method.
Corresponding to the thumbnail extraction method in the android system, an embodiment of the present invention further provides an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the program to implement the method described above.
Optionally, fig. 3 shows a more specific hardware structure diagram of an electronic device provided in this embodiment, where the device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein the processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 are communicatively coupled to each other within the device via bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. The memory 1020 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 1020 and called to be executed by the processor 1010.
The input/output interface 1030 is used for connecting an input/output module to input and output information. The i/o module may be configured as a component in a device (not shown) or may be external to the device to provide a corresponding function. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
The communication interface 1040 is used for connecting a communication module (not shown in the drawings) to implement communication interaction between the present apparatus and other apparatuses. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, Bluetooth and the like).
Bus 1050 includes a path that transfers information between various components of the device, such as processor 1010, memory 1020, input/output interface 1030, and communication interface 1040.
It should be noted that although the above-mentioned device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only those components necessary to implement the embodiments of the present description, and not necessarily all of the components shown in the figures.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
It is intended that the one or more embodiments of the present specification embrace all such alternatives, modifications and variations as fall within the broad scope of the appended claims. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of one or more embodiments of the present disclosure are intended to be included within the scope of the present disclosure.