Summary of the invention
The technical problem to be solved in the present invention is, at prior art easy defective that produces disk fragments behind deleted image, provides a kind of image file management method and system.
The technical solution adopted for the present invention to solve the technical problems is:
A kind of image file management method comprises:
Storing step comprises:
Receive image storage request, extract the attributes of images information of request storage, wherein this attribute information comprises sign and resolution;
Resolution according to the image of described request storage is searched the available storage location in this resolution corresponding storage in the continuous storage space that sets in advance in management document, and corresponding compress mode;
To ask the size of the compression of images of storage according to described compress mode to this compress mode correspondence, image after will compressing then stores this available storage location into, and generate stored record, and it is added in the management document corresponding to the image of this request storage according to described attribute information, described compress mode and described available storage location.
In method provided by the invention, also comprise:
Read step comprises:
Receive image and read request, the sign of the image that the request of extraction is read;
Search corresponding stored record in the management document according to being identified at of image that described request reads;
The compress mode of the image that the described stored record search request of foundation reads and the memory location in the described continuous storage space that sets in advance;
Determine described size of images according to described compress mode, read the image that described request reads in this memory location, and after decompression, return according to described compress mode according to this size.
In method provided by the invention, also comprise:
The deletion step comprises:
Receive the image-erasing request, extract the sign of the image of request deletion;
Being identified at of image according to the described request deletion searched corresponding stored record in the management document;
The memory location of image in the described continuous storage space that sets in advance according to described stored record search request deletion;
The image of request deletion is deleted from described memory location, and deleted described stored record.
The present invention also provides a kind of image file management system, comprising:
The storage operation module is used for:
Receive image storage request, extract the attributes of images information of request storage, wherein this attribute information comprises sign and resolution;
Resolution according to the image of described request storage is searched the available storage location in this resolution corresponding storage in the continuous storage space that sets in advance in management document, and corresponding compress mode;
To ask the size of the compression of images of storage according to described compress mode to this compress mode correspondence, image after will compressing then stores this available storage location into, and generate stored record, and it is added in the management document corresponding to the image of this request storage according to described attribute information, described compress mode and described available storage location.
In system provided by the invention, also comprise:
Read module is used for:
Receive image and read request, the sign of the image that the request of extraction is read;
Search corresponding stored record in the management document according to being identified at of image that described request reads;
The compress mode of the image that the described stored record search request of foundation reads and the memory location in the described continuous storage space that sets in advance;
Determine described size of images according to described compress mode, read the image that described request reads in this memory location, and after decompression, return according to described compress mode according to this size.
In system provided by the invention, also comprise:
Removing module is used for:
Receive the image-erasing request, extract the sign of the image of request deletion;
Being identified at of image according to the described request deletion searched corresponding stored record in the management document;
The memory location of image in the described continuous storage space that sets in advance according to described stored record search request deletion;
The image of request deletion is deleted from described memory location, and deleted described stored record.
Implement technical scheme of the present invention, have following beneficial effect: the present invention sorts out view data according to resolution, is stored in then in the continuous storage space.Just can reduce the disk fragments that deletion action produces thus.In addition, the present invention comes the various attribute informations of recording image data by the image management file, to strengthen the management to view data.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
The invention provides a kind of image file management method and system, can sort out view data, be stored in then in the continuous storage space according to resolution.Just can reduce the disk fragments that deletion action produces thus.In addition, technical scheme provided by the invention is come the various attribute informations of recording image data by the image management file, to strengthen the management to view data.Below just describe technical scheme provided by the invention in detail with specific embodiment in conjunction with the accompanying drawings.
Image management method provided by the invention comprises storing step, read step and deletion step, below just in conjunction with the accompanying drawings each step is described in detail.
Fig. 1 is the process flow diagram according to the storing step 100 of a preferred embodiment of the present invention.As shown in Figure 1, storing step 100 starts from step 102.
Subsequently, at next step 104, receive image storage request, extract the attributes of images information of request storage, wherein this attribute information comprises sign and resolution.
Subsequently,, in management document, search the available storage location in this resolution corresponding storage in the continuous storage space that sets in advance according to the resolution of the image of described request storage at next step 106, and corresponding compress mode.
Subsequently, at next step 108, will ask the size of the compression of images of storage to this compress mode correspondence according to described compress mode, the image after will compressing then stores this available storage location into;
Subsequently, at next step 110, generate the stored record of asking the image of storage corresponding to this, and it is added in the management document according to described attribute information, described compress mode and described available storage location.
At last, storing step 100 ends at step 112.
Fig. 2 is the process flow diagram according to the read step 200 of a preferred embodiment of the present invention.As shown in Figure 2, read step 200 starts from step 202.
Subsequently, at next step 204, receive image and read request, the sign of the image that the request of extraction is read;
Subsequently, at next step 206, search corresponding stored record in the management document according to being identified at of image that described request reads;
Subsequently, at next step 208, the compress mode of the image that the described stored record search request of foundation reads and the memory location in the described continuous storage space that sets in advance;
Subsequently,, determine described size of images, read the image that described request reads according to this size in this memory location, and after decompression, return according to described compress mode according to described compress mode at next step 210.
At last, read step 200 ends at step 212.
Fig. 3 is the process flow diagram according to the deletion step 300 of a preferred embodiment of the present invention.As shown in Figure 3, deletion step 300 starts from step 302.
Subsequently,, receive the image-erasing request, extract the sign of the image of request deletion at next step 304;
Subsequently, at next step 306, search corresponding stored record in the management document according to being identified at of image of described request deletion;
Subsequently, at next step 308, according to the memory location of image in the described continuous storage space that sets in advance of described stored record search request deletion;
Subsequently, at next step 310, the image of request deletion is deleted from described memory location, and deleted described stored record.
At last, deletion step 300 ends at step 312.
The present invention also provides a kind of image file management system, and it comprises storage operation module, read module and removing module.
The storage operation module is used for:
Receive image storage request, extract the attributes of images information of request storage, wherein this attribute information comprises sign and resolution;
Resolution according to the image of described request storage is searched the company that sets in advance in management document
Renew the available storage location in this resolution corresponding storage in the storage space, and corresponding compress mode;
To ask the size of the compression of images of storage according to described compress mode to this compress mode correspondence, image after will compressing then stores this available storage location into, and generate stored record, and it is added in the management document corresponding to the image of this request storage according to described attribute information, described compress mode and described available storage location.
Read module is used for:
Receive image and read request, the sign of the image that the request of extraction is read;
Search corresponding stored record in the management document according to being identified at of image that described request reads;
The compress mode of the image that the described stored record search request of foundation reads and the memory location in the described continuous storage space that sets in advance;
Determine described size of images according to described compress mode, read the image that described request reads in this memory location, and after decompression, return according to described compress mode according to this size.
Removing module is used for:
Receive the image-erasing request, extract the sign of the image of request deletion;
Being identified at of image according to the described request deletion searched corresponding stored record in the management document;
The memory location of image in the described continuous storage space that sets in advance according to described stored record search request deletion;
The image of request deletion is deleted from described memory location, and deleted described stored record.
In the specific implementation process, also can comprise other management information in the management document.Below just these information are described in detail.
Management document is divided by funtion part can be divided into four parts (structure such as Fig. 2): one, file header part; Two, data management matrix section; Three, data qualification admin table part; Four, file type admin table part.
The top of file branch comprises that part begins sign, the length of this partial record file header (being used to write down the size of this part), the total length of file (is used for the record management file size, and be used for when resolution data, avoiding the skew phenomenon of makeing mistakes), the authorization information of relevant device is (because the technical program can be applicable on the equipment such as smart mobile phone and electron album, can conveniently manage different data layout on the distinct device according to device authentication information), other most of sums (being used to manage the subdivision of back), the beginning side-play amount of each part (can find relevant part start address rapidly).
The data management matrix section comprises following content:
1, beginning identification data section comprises that " data segment " begins sign, the length of " data segment ", " data management table " total length and " data type sign ", composition data segment data;
2, tabulation section comprises " tabulation section " sign, " tabulation section " length, and what images of items numbers " tabulation section " comprises;
3, images of items section, comprise " images of items section " sign, the length of " project segment ", the image numbering in tabulation, images of items section comprise the number (data directory tabulation section number is to obtain according to back file type administration module) of data directory tabulation section;
4, data directory tabulation section comprises " data directory tabulation section " sign, " data directory section " list length, " image name section " number, the deviation post of image in image file, the size of image (image it is calculated that by sexadecimal number, shared figure place), horizontal supplementary data width, vertical data is replenished height, the height of image, the width of image, (form commonly used has the compressed format of image, UYVY, RGB24, RGB565, JPEG, PNG, TIF-FAX4, TGA).
5, image file management section, " image file management section " sign, " image file management section " length, character string type (English ASCII character, UTF-8, UTF-16 etc.), string length, " data directory section " total length.
The data qualification admin table partly comprises following information:
1, data management section comprises " data management section " and begins sign, " data management section " length, " data management section " total length, " data management section " type.
2, data management tabulation section comprises " data management tabulation section " and begins sign, " data management tabulation section " length, " image special edition section " number.
3, image special edition section, " comprise image special edition section " and begin sign, " image special edition section " length, " image special edition section " total length (comprising " image special edition section " length and all " special edition item section " total length sums), " special edition item section " number (the total number that in this special edition, comprises image).
4, special edition item section is divided into " album name section " and " special edition image management section " again.
5, album name section, " album name section " begins sign, " album name section " length, " album name section " total length (comprising album name segment data self length and string length summation), character string type (English ASCII character, UTF-8, UTF-16 etc.), string length, character string itself.
6, special edition image management section, " special edition image management section " sign, " special edition image management section " length, " special edition image management section " total length, picture number (using " numbering of image in tabulation " among Fig. 2).
The file type admin table partly is used to manage the physical file of different resolution image, and this document is to carry out the difference numbering according to the rate of distinguishing, an a kind of resolution of numbering representative generally has three to four different resolution physical files in a kind of hardware.According to different compression algorithms, every image is added to each physical file afterbody sequentially.
1, file type admin table section, comprise file type admin table segment identification, file type admin table segment length, file type admin table section total length (file type admin table segment length+file type managing listings segment length+file type management item segment length), file type admin table type.
2, file type managing listings section comprises file type managing listings segment identification, file type managing listings segment length, file type management item section number.
3, file type item section comprises file type item segment identification, file type item segment length, file name numbering, single image physical data size.
In technical scheme provided by the invention, each image is the image physical data file of creating according to the different file types in the file type admin table part, the all corresponding a kind of image resolution ratio form of each physical file, and require all images to be to use unified compression algorithm to add to come in, picture size can not be greater than restricted portion, need adopt identical algorithms this Flame Image Process to be become the image of prescribed level size if exceeded the image of scope, write the corresponding file afterbody again, continuous like this adding up, thus the problem that file disperses solved.
Because all images is stored in the continuous storage space, when doing deletion,, can falls data deletion easily, and not produce too much fragment, thereby protect disk by the image physical file is handled.
Because the image physical file is to store respectively by different resolution, and by the data management table partial record in the data management table corresponding resolution file name, data-bias position, supplementary data, size of data.Data management is got up easily like this, and image manages according to the image special edition in the data qualification admin table part, and the picture number information that can obtain being correlated with by special edition obtains the position of image correspondence according to numbering, searches very fast.
When showing, choosing the different resolution image according to different display modes draws on distinct device, the velocity ratio of obtaining data like this is very fast, not needing to carry out too much picture decoding handles, CPU and memory consumption have been reduced, thereby improved display efficiency, and image displaying quality is improved also, experience also promotes greatly.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.