A method, device and storage medium for in-situ streaming replacement compression and recovery of GeoTIFF image tiles in fixed slots
By determining the fixed slot information of GeoTIFF image blocks, compressing and saving pixel block data, the problem of low processing efficiency caused by the need to rearrange the directory in the existing technology is solved, and efficient GeoTIFF file compression and conversion is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN JIETENG TECHNOLOGY CO LTD
- Filing Date
- 2026-05-06
- Publication Date
- 2026-06-05
AI Technical Summary
Existing GeoTIFF compression or conversion schemes require overall layout, making it difficult to maintain the physical offset relationship of the original image blocks, resulting in low processing efficiency. Furthermore, when the length of a local block increases after recoding, the entire block must be abandoned or the positions of subsequent blocks rearranged, leading to poor engineering robustness.
Based on the file header and image file directory of the tag image file, determine the fixed slot information corresponding to each image block, compress the pixel block data and save the compressed bitstream, keep the original physical offset relationship unchanged, and avoid rearranging the image file directory.
It improves the efficiency of GeoTIFF file compression and conversion, maintains the original file structure compatibility and engineering robustness, and solves the problem of low processing efficiency in existing technologies.
Smart Images

Figure CN122156332A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image file processing technology, and in particular to an in-situ streaming replacement compression and recovery method, device and storage medium for GeoTIFF image block fixed slots. Background Technology
[0002] GeoTIFF (Geographic Tagged Image File Format) or TIFF (Tagged Image File Format) files record the physical offset position and byte length of each image patch within the file through the image file directory. Current GIS (Geographic Information System) software, archiving systems, and data distribution chains strictly rely on this offset relationship for data reading and positioning.
[0003] Specifically, existing GeoTIFF compression or conversion schemes use whole file transcoding, format repackaging, or structural rearrangement. Such operations generate new file layouts, causing changes in the physical offset relationships of the original image blocks. The increased length of local blocks after recoding also triggers a chain reaction of adjustments to the positions of subsequent blocks.
[0004] When the software opens a file, it doesn't read the image; it first reads the directory. This means the software must retrieve the data exactly as recorded in the physical offset. If the file content has been reformatted, but the physical offset hasn't changed, the software won't be able to retrieve the original data. Therefore, related technologies require rearranging the image file directory after compression or conversion, resulting in low processing efficiency. Summary of the Invention
[0005] The main objective of this application is to provide an in-situ streaming replacement compression and recovery method, device, and storage medium within a fixed slot of a GeoTIFF image block, aiming to solve the technical problem of low processing efficiency caused by the need to rearrange the image file directory after compression or conversion of tagged image files.
[0006] To achieve the above objectives, this application provides an in-situ streaming replacement compression and recovery method within a fixed slot of a GeoTIFF image block. The in-situ streaming replacement compression and recovery method within a fixed slot of a GeoTIFF image block includes: Based on the file header and image file directory of the label image file, determine the fixed slot information corresponding to each image block in the label image file; Based on the fixed slot information of the image block corresponding to the currently received byte stream, the pixel block data corresponding to the image block is compressed to obtain the target compressed bitstream; The target compressed bitstream is saved based on the original physical offset of the image block corresponding to the image file in the image file directory and the fixed slot information.
[0007] In one embodiment, determining the fixed slot information corresponding to each image block in the label image file based on the file header and image file directory of the label image file includes: The file header of the tag image file is parsed to identify the file byte order, the magic number of the tag image file format, and the physical offset address of the first image file directory; Based on the file byte order and the physical offset address of the first image file directory, all image file directories within the tag image file are traversed to extract the block positioning parameters and image attribute parameters corresponding to each image block. The block positioning parameters include the original physical offset address and original byte length of each image block, and the image attribute parameters include the total width and height of the image, the number of strip lines, the width and height of the tile, the pixel bit depth, the number of samples, and the original compression format. Based on the block positioning parameters and image attribute parameters corresponding to each image block, the physical offset order of each image block in the file is determined, and then the fixed slot information of each image block is determined. The fixed slot information includes at least the starting physical offset of the slot and the total length of the slot. The starting physical offset of the slot is consistent with the original physical offset address of the corresponding image block, and the total length of the slot is consistent with the original byte length of the corresponding image block.
[0008] In one embodiment, determining the physical offset order of each image block in the file based on the block positioning parameters and image attribute parameters corresponding to each image block, and then determining the fixed slot information of each image block, includes: If the original byte length of the target image block is determined to be zero, an abnormal value, or out of bounds based on the block positioning parameters and image attribute parameters, the adjacent image blocks of the target image block are determined according to the order of the physical offsets. Based on the offset address of the adjacent image block, the end position of the same-level image file directory, and the physical boundary of the file, the total length of the slot corresponding to the target image block is derived. The fixed slot information is determined based on the total length of the slot and the starting physical offset of the slot in the target image block.
[0009] In one embodiment, compressing the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream includes: Based on the fixed slot information corresponding to each image block and the current stream position of the byte stream, when it is determined that the current stream position enters the slot range corresponding to the image block, it is verified whether the byte length of the current input buffer covers the complete slot corresponding to the image block; If the current input buffer length is insufficient to cover the entire slot, output a waiting state indicating that more input is needed; If the current input buffer length is sufficient to cover the entire slot, read the original data within the image block slot; Based on the original compression format corresponding to the image block, the original data is parsed to obtain the pixel block data corresponding to the image block; The pixel block data is subjected to a preset re-encoding process to generate a target compressed bitstream.
[0010] In one embodiment, the step of parsing the original data to obtain the pixel block data corresponding to the image block according to the original compression format corresponding to the image block includes: When the original compression format of the image block is Deflate or Adobe Deflate, the original data is decompressed to obtain the initial pixel data; When the image block is in an uncompressed format, the read raw data will be used as the initial pixel data; If the image block is determined to be an edge tile or an incomplete strip block based on the image attribute parameters corresponding to the image block, the effective pixel area of the image block is determined based on the total width and height of the image, the number of strip rows, and the width and height of the tile. The pixel block data is obtained by removing invalid padding data from the initial pixel data based on the effective pixel region.
[0011] In one embodiment, saving the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information includes: The actual byte length of the target compressed bitstream is compared with the total length of the slots in the fixed slot information of the image block; If the actual byte length of the target compressed bitstream is less than or equal to the total length of the slot, the target compressed bitstream is written into the corresponding slot, starting from the original physical offset address corresponding to the image block in the image file directory. Zero padding is performed on the remaining tail bytes in the slot that are not occupied by the target compressed bitstream; If the actual byte length of the target compressed bitstream is greater than the total length of the slot, or if an abnormality occurs during the generation of the target compressed bitstream, the write-back operation of the image block is terminated, and the original byte content of the image block at the corresponding original physical offset address remains unchanged and is transparently transmitted out.
[0012] In one embodiment, before compressing the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream, the following steps are included: If the original physical offset address corresponding to the initial image block is earlier than the end position of the metadata area, switch to rectified pass-through; If the original physical offset address corresponding to the initial image block is not earlier than the end position of the metadata region, determine whether the current stream position of the byte stream is a non-image block region; If so, pass through the current byte stream; If not, perform the step of compressing the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream.
[0013] In one embodiment, after saving the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information, the process includes: Receives compressed tag image files as files to be recovered; The file header and image file directory of the file to be recovered are parsed to determine the fixed slot information corresponding to each image block in the file to be recovered. Based on the fixed slot information corresponding to each image block and the current stream position of the byte stream, for each image block in sequence, detect whether the original physical offset position corresponding to the image block contains the preset target compressed bit stream identifier; If the target image block is detected to contain the preset target compressed bitstream identifier, the end marker of the target compressed bitstream is located within the fixed slot range corresponding to the target image block, and the target compressed bitstream located before the end marker is decoded to obtain the recovered pixel block data; The recovered pixel block data is subjected to a preset re-encoding process to generate a TIFF-compatible image block, and the byte length of the TIFF-compatible image block is compared with the total length of the slots in the fixed slot information corresponding to the target image block. If the byte length of the TIFF-compatible image block is less than or equal to the total length of the slot, then starting from the original physical offset address corresponding to the target image block, the TIFF-compatible image block is written into the corresponding slot range, and zero padding is performed on the remaining tail bytes in the slot range that are not occupied by the TIFF-compatible image block. If the preset target compressed bitstream identifier is not detected, the end marker is not located, decoding fails, re-encoding fails, or the byte length of the TIFF compatible image block is greater than the total length of the slot, then the existing byte content of the corresponding image block remains unchanged and is transmitted out transparently.
[0014] Furthermore, to achieve the above objectives, this application also provides an in-situ streaming replacement compression and restoration device within a fixed slot of a GeoTIFF image block. The in-situ streaming replacement compression and restoration device within a fixed slot of a GeoTIFF image block includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. The computer program is configured to implement the steps of the in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described above.
[0015] Furthermore, to achieve the above objectives, this application also provides a storage medium, which is a computer-readable storage medium, storing a program for implementing an in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block. The program for implementing the in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block is executed by a processor to implement the steps of the in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described above.
[0016] This application provides an in-situ streaming replacement compression and recovery method within fixed slots of GeoTIFF image blocks. First, based on the file header and image file directory of the tag image file, the fixed slot information corresponding to each image block in the tag image file is determined. Slot positioning is directly completed based on the original file structure, without disassembling or reconstructing the image file directory. Then, based on the fixed slot information of the image block corresponding to the currently received byte stream, the pixel block data corresponding to the image block is compressed to obtain the target compressed bitstream. Block-level compression processing is completed based on the fixed slots, without adjusting the physical arrangement of the image blocks. Finally, the target compressed bitstream is saved based on the original physical offset of the image block in the image file directory and the fixed slot information. The compressed bitstream is stored directly in the original physical location, without rearranging the image file directory.
[0017] In summary, this application solves the technical problem of low processing efficiency caused by the need to rearrange the image file directory after compressing or converting label image files through the core steps of determining fixed slot information, in-situ block-level compression, and saving the bitstream based on the original physical offset and fixed slot. The entire process does not require rearranging the image file directory of the label image files. This simplifies the file compression and conversion process and effectively improves the processing efficiency of label image file compression and conversion. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating an embodiment of the in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block in this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the in-situ streaming replacement compression and restoration method for GeoTIFF image blocks in this application. Figure 3 This is a flowchart illustrating Embodiment 3 of the in-situ streaming replacement compression and restoration method for GeoTIFF image blocks in this application. Figure 4 This is a simplified flowchart illustrating the in-situ streaming replacement compression and recovery method within a fixed slot of a GeoTIFF image block provided in Embodiment 3 of this application. Figure 5 This is a schematic diagram illustrating the control principle of the in-situ streaming replacement compression and recovery method within the fixed slot of a GeoTIFF image block provided in Embodiment 3 of this application. Figure 6 This is a schematic diagram of the module structure of the in-situ streaming replacement compression and recovery device within the fixed slot of the GeoTIFF image block in an embodiment of this application.
[0021] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0022] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of this application and are not intended to limit this application.
[0023] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0024] Currently, TIFF or GeoTIFF files typically record the physical offset positions and byte lengths of stripe blocks or tile blocks through an image file directory. Many existing GIS software programs, browsers, archiving systems, and data distribution chains rely on this directory structure and block offset relationships to function. For GeoTIFF files already in use, the physical location relationships of image blocks within the file not only reflect the data storage method but also directly affect the compatibility of existing reading chains.
[0025] Existing GeoTIFF compression or conversion solutions typically employ whole-file transcoding, format conversion, repackaging, or layout optimization. For example, converting the entire GeoTIFF file to JPEG2000, JP2, JPH, or other compression formats, or improving range reading performance by reorganizing the TIFF's internal structure. While these methods can improve file size or access efficiency, they usually require generating a new file layout or adjusting the physical offset relationships of the original image blocks.
[0026] The above solution has at least the following problems: It is difficult to maintain the original physical offset relationship of image blocks, and the cost of compatibility with existing reading links is high; When the length of a local image block increases after recoding, it is often necessary to discard the entire conversion result or rearrange the positions of subsequent blocks. The processing granularity is usually at the whole file level, making it difficult to isolate local block failures; In scenarios involving massive amounts of heterogeneous GeoTIFF files, the overall success or failure handling methods have poor engineering robustness.
[0027] The main solution of this application is as follows: Based on the file header and image file directory of the tag image file, determine the fixed slot information corresponding to each image block in the tag image file; based on the fixed slot information of the image block corresponding to the currently received byte stream, compress the pixel block data corresponding to the image block to obtain the target compressed bitstream; save the target compressed bitstream based on the original physical offset of the image block corresponding to the image block in the image file directory and the fixed slot information.
[0028] This application addresses the technical problems of existing GeoTIFF compression or conversion schemes, which typically require overall relayout, are difficult to maintain the physical offset relationship of the original image blocks, and are difficult to isolate and roll back when local image blocks fail.
[0029] It should be noted that the execution subject in this embodiment can be an in-situ streaming replacement compression and restoration system within a fixed slot of a GeoTIFF image block, or a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an in-situ streaming replacement compression and restoration device within a fixed slot of a GeoTIFF image block capable of performing the above functions. This embodiment does not specifically limit this. The following description uses an in-situ streaming replacement compression and restoration system within a fixed slot of a GeoTIFF image block as the execution subject to illustrate this embodiment and the subsequent embodiments.
[0030] Based on this, Embodiment 1 of this application proposes an in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block. Please refer to... Figure 1The in-situ streaming replacement compression and restoration method within the fixed slot of the GeoTIFF image block includes steps S10~S30: Step S10: Determine the fixed slot information corresponding to each image block in the label image file based on the file header and image file directory of the label image file.
[0031] In this embodiment, the file header is used to identify the format attributes and directory addressing basic information of the tag image file. The image file directory is used to record the physical storage location and image attribute parameters of all image blocks. Fixed slot information is used to define the immutable physical storage area and length boundary of each image block in the file.
[0032] As an optional implementation, based on the received tag image file, the file header data and the full image file directory data of the tag image file are first parsed. Then, the file byte order and the offset address of the first image file directory are obtained based on the file header. Next, all image file directories are traversed to extract the original physical offset, original byte length, and image attribute parameters of the image blocks. Basic slot information is constructed according to the physical offset order of the image blocks. For image blocks with abnormal byte lengths, the effective slot length is deduced by combining the offset of adjacent blocks and the file boundary. Finally, complete fixed slot information is formed, which includes the starting physical offset of the slot and the total length of the slot.
[0033] As an optional implementation, based on the segmented data of the streamed tagged image file, the header streaming data and hierarchical image file directory data are first parsed, and the image block positioning parameters are read using a segmented addressing method to directly generate basic fixed slot information. The security verification of the slot boundary and the file metadata area is completed simultaneously. Image blocks that do not meet the processing conditions are directly marked as transparent, and finally, valid image block fixed slot information that has passed the security verification is formed.
[0034] Step S20: Based on the fixed slot information of the image block corresponding to the currently received byte stream, compress the pixel block data corresponding to the image block to obtain the target compressed bitstream.
[0035] In this embodiment, the byte stream is continuous data transmitted in physical storage order from the tag image file. The pixel block data is the valid raw pixel information obtained after parsing the image blocks. The target compressed bitstream is compliant compressed data generated by re-encoding the pixel block data.
[0036] As an optional implementation, based on the real-time received byte stream data and the pre-generated fixed slot information, the file region where the byte stream is currently located is first determined. For non-image block regions, pass-through processing is directly performed. After entering the target image block region, it is checked whether the input buffer covers the complete slot. For image blocks that meet the buffer conditions, pixel block data is parsed and extracted according to the original compression format. Then, the pixel block data is re-encoded, and finally the target compressed bitstream corresponding to the target image block is generated.
[0037] As an optional implementation, based on the preloaded byte stream fragments, fixed slot information and image attribute parameters, the data range of the target image block is first located in advance based on the fixed slot information. The effective pixel area is first delineated for edge tiles and incomplete strip blocks. Then, the original data is decoded and extracted. A high-throughput coding algorithm is used to perform parallel compression processing on the effective pixel block data, and finally, an optimized target compressed bitstream adapted to the slot length constraint is generated.
[0038] Step S30: Save the target compressed bitstream based on the original physical offset of the image block corresponding to the image in the image file directory and the fixed slot information.
[0039] In this embodiment, the original physical offset is the starting storage address of the image block recorded in the image file directory. The save operation is a write operation that completes the writing of the compressed bitstream within a fixed slot range without changing the overall file structure.
[0040] As an optional implementation, based on the generated target compressed bitstream, the original physical offset of the image block, and the fixed slot information, the length of the target compressed bitstream is first compared with the total length of the slot. If the length is compliant, the compressed bitstream is written starting from the original physical offset address. Zero padding is performed on the remaining tail bytes in the slot. If the length exceeds the limit or the processing is abnormal, the original data of the image block remains unchanged and is transmitted out transparently. The physical offset and directory content of subsequent image blocks are not modified throughout the process, and finally a tag image file with in-situ compression and unchanged structure is obtained.
[0041] As an optional implementation, based on the target compressed bitstream, the original physical offset, fixed slot information and bitstream verification identifier, the target compressed bitstream is first subjected to integrity verification. After the verification is passed, precise writing is performed according to the original physical offset and slot boundary. After writing, the block processing status is recorded synchronously, allowing compressed blocks and uncompressed blocks to be mixed and stored in the same file, and finally a tag image file that supports subsequent reversible recovery is obtained.
[0042] For example, when processing geotagged image files, the entire file data is first read and the header information and all image file directories are parsed to obtain the file byte order and the original physical offset and byte length parameters of each image block. For image blocks with abnormal parameters, the effective slot length is deduced by combining the positions of adjacent blocks and the file boundaries, generating fixed slot information for all image blocks. The file byte stream data is received segment by segment, and file regions are distinguished according to the fixed slot information. Non-image block regions are directly transmitted out. After entering the image block region, the buffer is waited to cover the complete slots, and then the original data of the image blocks is parsed to extract the effective pixel block data and complete the re-encoding to generate the target compressed bitstream. The length of the target compressed bitstream is compared with the total length of the slots. The compliant bitstream is written to the file from the original physical offset address, and the remaining tail bytes are filled with zero values. Image blocks that exceed the limit or have processing abnormalities retain their original data unchanged, and finally, a compressed file is obtained without changing the original directory structure and block offset relationship.
[0043] This embodiment determines fixed slots based on the original directory structure of the tag image file, and completes streaming compression and in-situ saving of image blocks with the slots as boundaries. The entire process does not require rearranging the image file directory and the physical location of the image blocks, which solves the problem of low processing efficiency caused by the need to rearrange the directory after the tag image file is compressed or converted. At the same time, it preserves the compatibility of the original file structure and improves the processing efficiency and engineering robustness of file compression and conversion.
[0044] Based on any of the above embodiments, in Embodiment 2 of this application, determining the fixed slot information corresponding to each image block in the label image file according to the file header and image file directory of the label image file includes: Step S11: Parse the file header of the tag image file to identify the file byte order, the magic number of the tag image file format, and the physical offset address of the first image file directory.
[0045] In this embodiment, file byte order is used to determine the reading and arrangement rules of file data. The format magic number is used to verify the format validity of the tag image file. The physical offset address is used to locate the starting storage location of the first image file directory within the file.
[0046] As an optional implementation, based on the received tag image file, the file header data at the beginning of the file is directly read, the file header data is parsed field by field to identify the file byte order, the legality of the magic number of the tag image file format is verified, and the physical offset address of the first image file directory is extracted.
[0047] As an optional implementation, based on the header fragment of the streamed tag image file, the header data is first cached and spliced, and then the spliced header data is parsed to identify the file byte order, format magic number and the physical offset address of the first image file directory.
[0048] Step S12: Based on the file byte order and the physical offset address of the first image file directory, traverse all image file directories within the tag image file to extract the block positioning parameters and image attribute parameters corresponding to each image block.
[0049] In this embodiment, block location parameters are used to determine the physical storage location and length of image blocks within the file. Image attribute parameters are used to describe the basic features and encoding format of the image. The block location parameters include the original physical offset address and original byte length of each image block, while the image attribute parameters include the total width and height of the image, the number of stripe lines, the tile width and height, the pixel bit depth, the number of samples, and the original compression format.
[0050] As an optional implementation, based on the parsed file byte order and the physical offset address of the first image file directory, the system traverses from the starting position of the first image file directory, sequentially reads the field data of all image file directories in the file, and extracts block positioning parameters such as the original physical offset address and original byte length corresponding to each image block. At the same time, it extracts image attribute parameters such as the total width and height of the image, the number of strip lines, the width and height of the tile, the pixel bit depth, the number of samples, and the original compression format.
[0051] As an optional implementation, the reading rules for directory data are determined based on the file byte order. A hierarchical traversal is performed in combination with the physical offset address of the first image file directory. The data of each level of image file directory is read segment by segment. The block positioning parameters and image attribute parameters corresponding to valid image blocks are filtered and extracted, and invalid directory field data is removed.
[0052] Step S13: Based on the block positioning parameters and image attribute parameters corresponding to each image block, determine the physical offset order of each image block in the file, and then determine the fixed slot information of each image block.
[0053] In this embodiment, the physical offset order is the order in which image blocks are arranged in the file from smallest to largest starting address. The starting physical offset of the slot and the total length of the slot constitute the core boundary parameters of the fixed slot.
[0054] Optionally, the fixed slot information includes at least the slot starting physical offset and the total slot length. The slot starting physical offset is consistent with the original physical offset address of the corresponding image block, and the total slot length is consistent with the original byte length of the corresponding image block.
[0055] As an optional implementation, based on the extracted original physical offset addresses of each image block, the physical offset order of the image blocks in the file is obtained. The original physical offset address of each image block is directly used as the starting physical offset of the slot, and the original byte length is directly used as the total length of the slot, generating fixed slot information containing the starting physical offset of the slot and the total length of the slot.
[0056] As an optional implementation, by combining the block positioning parameters and image attribute parameters of each image block, the physical offset order is first determined by sorting according to the original physical offset address, and then the parameters are checked for consistency. After the check passes, the original physical offset address and the original byte length are mapped to fixed slot information to ensure that the slot boundary is completely consistent with the original storage area of the image block.
[0057] Optionally, after traversing all image file directories of the tag image file based on the file byte order and the physical offset address of the first image file directory, the block positioning parameters and image attribute parameters corresponding to each image block are extracted. The block positioning parameters explicitly include the original physical offset address and original byte length of each image block, and the image attribute parameters explicitly include the total image width and height, number of stripe lines, tile width and height, pixel bit depth, number of samples, and original compression format. Subsequently, based on the original physical offset address in the block positioning parameters, all image blocks are sorted to determine the physical offset order of each image block in the file, and the original physical offset address of each image block is directly mapped to the starting physical offset of the corresponding image block's slot. The process involves mapping the original byte length directly to the total slot length of the corresponding image block, while simultaneously performing a full verification of the block positioning parameters based on image attribute parameters. This is achieved by calculating the theoretical byte length of each image block using the total width and height of the image, pixel bit depth, and number of samples, verifying the consistency between the original byte length and the theoretical length. For image blocks with original byte lengths of zero, outliers, or out-of-bounds values, the total slot length is corrected by combining the offset addresses of adjacent image blocks determined by the physical offset order, the end position of the same-level image file directory, and the physical boundaries of the file. Finally, fixed slot information for each image block, including the starting physical offset of the slot and the total slot length, is generated, thus fully realizing the determination of fixed slot information based on block positioning parameters and image attribute parameters.
[0058] For example, when processing geotagged image files, the file header at the beginning of the file is first read and parsed to obtain the file byte order, format magic number, and physical offset address of the first image file directory. All image file directories are traversed according to the file byte order and physical offset address, extracting block positioning parameters such as the original physical offset address and original byte length for each image block, as well as image attribute parameters such as total image width and height, pixel bit depth, and original compression format. The physical offset order of image blocks is determined based on the original physical offset address. The original physical offset address is used as the starting physical offset of the slot, and the original byte length is used as the total slot length to generate fixed slot information for all image blocks. The file byte stream is received segment by segment. File regions are distinguished according to the fixed slot information. Non-image block regions are directly transmitted out. Upon entering an image block region, the buffer is waited to cover the entire slot before parsing the original image block data, extracting valid pixel block data, and re-encoding to generate the target compressed bitstream. The target compressed bitstream length is compared with the total length of the slots. Valid bitstreams are written to the file from the original physical offset address, and the remaining tail bytes are filled with zero values. Image blocks that exceed the limit or are processed abnormally retain their original data. Finally, a compressed file is obtained without changing the original directory structure and block offset relationship.
[0059] This embodiment determines fixed slots based on the original directory structure of the tag image file, and completes streaming compression and in-situ saving of image blocks with the slots as boundaries. The entire process does not require rearranging the image file directory and the physical location of the image blocks, which solves the problem of low processing efficiency caused by the need to rearrange the directory after the tag image file is compressed or converted. At the same time, it preserves the compatibility of the original file structure and improves the processing efficiency and engineering robustness of file compression and conversion.
[0060] Based on any of the above embodiments, in Embodiment 3 of this application, the physical offset order of each image block in the file is determined according to the block positioning parameters and image attribute parameters corresponding to each image block, thereby determining the fixed slot information of each image block, including: Step S131: If the original byte length of the target image block is determined to be zero, an abnormal value, or an out-of-bounds value based on the block positioning parameters and image attribute parameters, the adjacent image blocks of the target image block are determined according to the order of the physical offsets.
[0061] In this embodiment, the target image block refers to an image block whose original byte length in the block positioning parameters is invalid and cannot be directly used to construct a fixed slot. Abnormal original byte lengths include zero values, values that do not match the image attribute parameters, and out-of-bounds values exceeding the file's physical range. The physical offset order is the result of sorting all image blocks according to their original physical offset addresses from smallest to largest. Adjacent image blocks refer to valid forward or backward image blocks that are directly adjacent to the target image block in the physical offset order.
[0062] As an optional implementation, the block location parameters and image attribute parameters of all image blocks are traversed, and image blocks with original byte lengths of zero, abnormal, or out-of-bounds values are marked as target image blocks. According to the determined physical offset order, the preceding and following image blocks of the target image block are extracted as adjacent image blocks of the target image block.
[0063] As an optional implementation, the theoretical byte length of the image block is calculated based on image attribute parameters such as total width and height, pixel bit depth, and number of samples. The image block corresponding to the original byte length that does not match the theoretical length is determined as the target image block. Then, the effective adjacent image blocks corresponding to the target image block are located and determined according to the sorting result of the physical offset order.
[0064] Step S132: Based on the offset address of the adjacent image block, the end position of the same-level image file directory, and the physical boundary of the file, the total length of the slot corresponding to the target image block is derived.
[0065] In this embodiment, the adjacent image block offset address is the original physical offset address corresponding to the adjacent image block. The end position of the sibling image file directory is the terminating storage address of the same image file directory to which the target image block belongs. The file physical boundary is the overall data end address of the tag image file. The total slot length is the fixed storage range length that the target image block can use after valid derivation.
[0066] As an optional implementation, the offset address of adjacent image blocks is preferentially used for derivation. The initial slot length is obtained by subtracting the starting physical offset of the target image block from the original physical offset address of the next adjacent image block. If the initial slot length exceeds the end position of the same-level image file directory, the total slot length is corrected with the end position of the same-level image file directory as the upper limit.
[0067] As an optional implementation, when there are no effective adjacent image blocks, the candidate length is obtained by subtracting the starting physical offset of the slot of the target image block from the ending position of the same-level image file directory. If the candidate length exceeds the physical boundary of the file, the total slot length corresponding to the target image block is derived by taking the physical boundary of the file as the final reference.
[0068] Step S133: Determine the fixed slot information based on the total length of the slot and the starting physical offset of the slot of the target image block.
[0069] In this embodiment, the initial physical offset of the slot is the original physical offset address of the target image block, which remains unchanged throughout. The fixed slot information consists of the initial physical offset of the slot and the derived total length of the slot, and is a set of parameters used to define the in-situ storage boundary of the target image block.
[0070] As an optional implementation, the original physical offset of the slot in the target image block is kept unchanged, and the total length of the derived legal slot is combined with the physical offset of the slot to directly generate the fixed slot information corresponding to the target image block.
[0071] As an optional implementation, the starting physical offset of the slot and the derived total length of the slot are checked in intervals. After confirming that the storage interval does not overlap with other image blocks and does not exceed the physical boundary of the file, the starting physical offset of the slot and the total length of the slot that have passed the check are determined as the final fixed slot information of the target image block.
[0072] Optionally, if the original byte length of the target image block is determined to be non-zero, abnormal, or out of bounds based on the block positioning parameters and image attribute parameters, the physical offset order of each image block in the file is determined based on the block positioning parameters and image attribute parameters corresponding to each image block, thereby determining the fixed slot information of each image block.
[0073] For example, when processing geotagged image files, the file header at the beginning of the file is first read and parsed to obtain the file byte order, format magic number, and physical offset address of the first image file directory. All image file directories are traversed according to the file byte order and physical offset address, extracting block location parameters such as the original physical offset address and original byte length for each image block, as well as image attribute parameters such as total image width and height, pixel bit depth, and original compression format. During parameter verification, some image blocks are identified as having abnormal original byte lengths of zero or exceeding limits; these image blocks are marked as target image blocks. Adjacent image blocks to the target image block are located according to their physical offset order. The initial slot length is first derived from the offset addresses of adjacent image blocks, and then length correction is performed by combining the end position of the same-level image file directory and the file physical boundary to obtain the valid total slot length. Keeping the original slot starting physical offset of the target image block unchanged, the corrected total slot length is combined with the slot starting physical offset to generate the fixed slot information of the target image block, ultimately completing the complete construction of the fixed slot information for all image blocks.
[0074] This embodiment solves the technical problem of being unable to construct slots for abnormal image blocks by locating adjacent blocks, deriving multi-level boundaries, and correcting slot information for target image blocks with abnormal original byte lengths. This is achieved without changing the original physical offset address of the target image block. At the same time, it ensures that the slot boundaries of all image blocks are generated based on the original file structure, without needing to rearrange the image file directory and the physical location of the image blocks, further improving the compatibility and engineering robustness of tag image file processing.
[0075] Based on any of the above embodiments, in Embodiment 4 of this application, the pixel block data corresponding to the image block is compressed according to the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream, including: Step S21: Based on the fixed slot information corresponding to each image block and the current stream position of the byte stream, when it is determined that the current stream position enters the slot range corresponding to the image block, it is verified whether the byte length of the current input buffer covers the complete slot corresponding to the image block.
[0076] In this embodiment, the current stream position is the real-time read position of the byte stream in the physical storage order of the tag image file. The target image block is the image block to be processed matched by the current stream position. The input buffer is a storage area used to temporarily store byte stream data, and the complete slot is the entire storage area of the target image block defined by fixed slot information.
[0077] As an optional implementation, the current stream position updated in real time is matched with the fixed slot information of each image block one by one. After determining that the current stream position falls within the slot start and end range of the target image block, the length of the stored bytes in the current input buffer is read, and the length of the buffer bytes is directly compared with the total length of the slots of the target image block to complete the check of buffer coverage integrity.
[0078] As an optional implementation, a stream position matching mapping table is pre-generated based on fixed slot information. The target image block corresponding to the current stream position is quickly located through the mapping table. The cumulative number of received bytes in the input buffer is counted simultaneously. The difference between the cumulative number of received bytes and the total length of the slot of the target image block is calculated. Based on the calculation result, it is determined whether the buffer covers the entire slot.
[0079] Step S22: If the current input buffer length is sufficient to cover the entire slot, read the original data in the image block slot; Step S23: Based on the original compression format corresponding to the image block, parse the original data to obtain the pixel block data corresponding to the image block.
[0080] In this embodiment, the raw data is the unprocessed raw byte data of the target image block stored in a fixed slot. The raw compression format is the original encoding format of the target image block recorded in the image file directory, and the pixel block data is the set of valid pixel information obtained after parsing the raw data.
[0081] As an optional implementation, after the cache covers the entire slot, starting from the physical offset of the slot in the target image block, all the original data in the slot is read completely. According to the original compression format in the image attribute parameters, the corresponding decoding operation is performed on the original data to directly extract the pixel block data corresponding to the target image block.
[0082] As an optional implementation, after reading the original data in the target image block slot, the original data is first checked for integrity. After the check passes, the original data is parsed hierarchically according to the parsing rules of Deflate format, Adobe Deflate format or uncompressed format. After removing invalid padding data, standard pixel block data is obtained.
[0083] Step S24: Perform a preset re-encoding process on the pixel block data to generate the target compressed bitstream.
[0084] In this embodiment, the recoding process is an encoding operation that converts pixel block data into a high-throughput compressed format. The target compressed bitstream is generated after recoding and can be used for in-situ write-back of standardized compressed data.
[0085] As an optional implementation, encoding parameters are configured according to the total width and height of the image, pixel bit depth, and number of samples in the image attribute parameters. A preset high-throughput encoding algorithm is used to re-encode the pixel block data to directly generate a target compressed bitstream that meets the slot length constraint.
[0086] As an optional implementation, after performing a second determination of the effective pixel region on the pixel block data, an optimized encoding strategy is used to perform compression encoding on the effective pixel data. After the encoding is completed, the bitstream length is counted to generate a target compressed bitstream that adapts to the fixed slot constraint.
[0087] For example, when processing geotagged image files, the file byte stream is received segment by segment and the current stream position is updated in real time. The current stream position is matched with the generated fixed slot information to quickly locate the target image block to be processed. The byte length of the input buffer is counted in real time, and it is verified whether the buffer completely covers the complete slot of the target image block. Once the buffer meets the condition, all raw data is read from the physical offset of the starting slot of the target image block. The raw data is parsed according to the original compression format recorded in the image file directory to obtain clean pixel block data. Then, the pixel block data is re-encoded according to the preset encoding rules to finally generate the target compressed bitstream that can be written back in situ. The entire process maintains a byte stream streaming processing rhythm without interrupting the file transmission and processing flow.
[0088] Optionally, if the current input buffer length is insufficient to cover the entire slot, output a waiting state indicating that more input is needed.
[0089] In this embodiment, the waiting state that requires more input refers to the paused processing state in which the data receiver requests the continued transmission of the byte stream until the buffer covers the entire slot.
[0090] As an optional implementation, if the input buffer byte length is insufficient, a waiting state indicating that more input is needed is directly output, the current block processing flow is paused, and the byte stream is continuously received; if the buffer byte length is sufficient, all the original data in the slot is completely read from the physical offset starting from the slot of the target image block.
[0091] As an optional implementation, branch processing is performed based on the cache coverage status. When the cache is insufficient, a byte stream replenishment request is sent out and a waiting state is maintained. When the cache is sufficient, all the original data in the corresponding slot of the target image block is read directly without modifying the data content.
[0092] This embodiment uses streaming processing logic, including stream position matching, cache integrity verification, hierarchical parsing of raw data, and pixel block recoding, to complete image block compression without loading the entire file. This solves the inefficiency problem caused by the need to load the entire file in traditional file processing. At the same time, it relies on fixed slot information to achieve precise block-level processing, further improving the smoothness and stability of label image file compression processing.
[0093] Based on any of the above embodiments, in Embodiment 5 of this application, parsing the original data according to the original compression format corresponding to the image block to obtain the pixel block data corresponding to the image block includes: Step S231: When the original compression format of the image block is Deflate or Adobe Deflate, decompress the original data to obtain the initial pixel data.
[0094] In this embodiment, Deflate is a lossless data compression format widely used for pixel data storage in label image files. Adobe Deflate is a derivative of Deflate, adapted to the label image file storage specifications of Adobe software. The initial pixel data is the unfiltered set of raw pixels obtained after decompressing the original data.
[0095] As an optional implementation, when the original compression format of the image block is identified as Deflate or Adobe Deflate, a preset decompression algorithm is called to perform decompression operation on the read original data. After decompression, the initial pixel data is directly output, retaining all the information of the original pixels.
[0096] As an optional implementation, the original data is first format-checked to confirm that it conforms to the encoding specifications of Deflate or Adobe Deflate format. Then, an optimized decompression strategy is used to decompress the original data, removing invalid and redundant data generated during the decompression process to obtain standard initial pixel data.
[0097] Step S232: When the image block is in an uncompressed format, the read raw data is used as the initial pixel data.
[0098] In this embodiment, uncompressed format means that the raw data of the image block has not undergone any compression or encoding processing and is stored directly as raw pixel data. In this scenario, the initial pixel data is completely consistent with the pixel information of the original data, requiring no additional parsing processing.
[0099] As an optional implementation, after determining that the image block is in an uncompressed format, no decompression or parsing operation is performed. Instead, the original data in the read image block slot is directly assigned as the initial pixel data, preserving the storage format and pixel information of the original data.
[0100] As an optional implementation, pixel integrity verification is performed on the uncompressed raw data. After confirming that the raw data is free of missing or disordered data, it is used as the initial pixel data, and the data verification results are recorded for subsequent traceability.
[0101] Step S233: If the image block is determined to be an edge tile or an incomplete strip block according to the image attribute parameters corresponding to the image block, the effective pixel area of the image block is determined based on the total width and height of the image, the number of strip rows, and the width and height of the tile.
[0102] In this embodiment, edge tiles refer to tile-like image blocks located at the edge of the label image that are not fully filled with pixels. Incomplete strip blocks refer to strip-like image blocks that do not reach the preset number of strip rows. Valid pixel areas refer to the areas of an image block that contain actual valid pixels and do not contain invalid fill portions.
[0103] As an optional implementation, the total width and height of the image, the number of strip rows, and the width and height of the tile are extracted from the image attribute parameters and compared with the actual size of the current image block. After determining whether it is an edge tile or an incomplete strip block, the start and end boundaries of the effective pixel area are determined by coordinate calculation, thus clarifying the range of effective pixels.
[0104] As an optional implementation, an effective region determination model is constructed based on image attribute parameters. The position and size information of the current image block are input into the model to quickly determine whether it is an edge tile or an incomplete strip block. Then, combined with the total width and height of the image, the number of strip rows, and the width and height of the tile, the effective pixel region is accurately determined.
[0105] Optionally, after parsing the initial pixel data according to the original compressed format of the image block, edge detection and effective region determination are performed based on the extracted image attribute parameters: First, based on the total width and height of the image, the number of strip rows, and the width and height of the tile, it is determined whether the current image block is an edge tile or a non-intact strip. For images stored in tile format, if the actual coverage area of the current tile exceeds the boundary of the total width and height of the image, or the actual pixel size is smaller than the preset tile width and height, it is determined to be an edge tile. For images stored in strip format, if the actual number of rows of the current strip is less than the preset number of strip rows, it is determined to be a non-intact strip. For images determined to be edge tiles... For edge tiles or non-continuous strips of image blocks, the pixel boundaries of the entire image are determined based on the total width and height of the image. The start and end coordinates of the current image block in the overall image are determined by combining the number of strip rows and the width and height of the tiles. Then, the effective pixel byte range of the current image block is calculated by combining the pixel bit depth and the number of samples, thereby accurately determining the effective pixel area of the image block. Subsequently, based on the determined effective pixel area, invalid padding data outside the effective area in the initial pixel data is removed to obtain pure pixel block data containing only effective pixel information. This fully realizes the determination of the effective pixel area of edge tiles and non-continuous strips based on image attribute parameters.
[0106] Step S234: Remove invalid padding data from the initial pixel data based on the effective pixel region to obtain the pixel block data.
[0107] In this embodiment, invalid padding data refers to blank padding data outside the valid pixel area in edge tiles or incomplete strip blocks, which does not contain any valid image information. Pixel block data is a standardized data set containing only valid pixel information after removing invalid padding data.
[0108] As an optional implementation, the initial pixel data is filtered pixel by pixel based on the determined effective pixel region boundary, invalid padding data outside the boundary is removed, and all pixel information within the effective pixel region is retained to obtain clean pixel block data.
[0109] As an optional implementation, the initial pixel data is first partitioned and marked to clearly distinguish between valid pixel areas and invalid padding areas. Then, the pixel data corresponding to the invalid padding areas are removed in batches to generate pixel block data that meets the requirements of subsequent recoding.
[0110] For example, when processing geotagged image files, after sufficient caching, the raw data within the target image patch slots is read, first identifying the raw compression format of the image patch. If the raw compression format is Deflate, a decompression algorithm is called to decompress the raw data, obtaining the initial pixel data; if the image patch is uncompressed, the raw data is directly used as the initial pixel data. The total image width and height, number of strip rows, and tile width and height are extracted from the image attribute parameters. After determining that the current image patch is an edge tile, the start and end range of the effective pixel area is determined through coordinate calculation. Invalid padding data in the initial pixel data is then removed based on this range, ultimately obtaining clean pixel patch data, providing a high-quality data foundation for subsequent recoding processing.
[0111] Optionally, if the original data decompression fails, the effective pixel area determination is abnormal, or the initial pixel data extraction fails, the compression processing of the current image block is terminated, and the complete original data of the image block is processed by full pass-through.
[0112] In this embodiment, "raw data decompression failure" refers to the situation where, when performing decompression on raw data in Deflate or Adobe Deflate format, valid initial pixel data cannot be obtained due to data corruption, format abnormalities, or other reasons. "Valid pixel region determination abnormality" refers to the situation where the valid pixel region of edge tiles or incomplete strip blocks cannot be determined based on the image attribute parameters such as the total width and height of the image, the number of strip rows, and the tile width and height. "Initial pixel data extraction failure" refers to the situation where valid initial pixel data cannot be obtained regardless of whether it is decompressed or directly read. "Full pass-through processing" means that no compression or parsing operations are performed on the raw data of the image block; the raw data is output as is, maintaining its original state.
[0113] As an optional implementation, if an anomaly is detected at any stage of the original data decompression, effective pixel area determination, or initial pixel data extraction, all compression processing of the current image block is immediately terminated, and no further parsing or re-encoding operations are performed. The complete original data in the slot of the image block is directly read and transmitted out as is, without changing any content of the original data.
[0114] As an optional implementation, the entire process of raw data parsing is monitored in real time. When decompression failure, abnormal determination of effective pixel area, or failure to extract initial pixel data is detected, the abnormality type and abnormality location are recorded first, and then the compression processing of the current image block is terminated. The complete raw data of the image block is then fully transmitted, and the abnormality record is simultaneously stored for subsequent traceability.
[0115] For example, when processing geotagged image files, after sufficient caching, the raw data in the target image block slot is read. If the raw compression format is Adobe Deflate, and the decompression algorithm fails to decompress the raw data due to data corruption, the compression process for that image block is immediately terminated. Subsequent valid pixel region determination, initial pixel data extraction, and re-encoding operations are not performed. The complete raw data in the image block slot is directly read and transmitted out intact, ensuring uninterrupted file processing and preventing file structure corruption due to abnormal processing. If another image block fails to determine its valid pixel region due to missing image attribute parameters, the compression process for that block is also terminated, and its raw data is fully transmitted.
[0116] This embodiment employs a differentiated parsing strategy for different original compression formats to accurately extract initial pixel data. At the same time, it selectively removes invalid padding data from edge tiles and incomplete strip blocks, solving the technical problems of inaccurate original data parsing and invalid data interfering with subsequent compression processing. This ensures the integrity and purity of pixel block data, providing reliable support for subsequent recoding to generate compliant target compressed bitstreams, and further improving the accuracy and quality of label image file compression processing.
[0117] Based on any of the above embodiments, in Embodiment Six of this application, saving the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information includes: Step S31: Compare the actual byte length of the target compressed bitstream with the total length of the slots in the fixed slot information of the image block.
[0118] In this embodiment, the actual byte length of the target compressed bitstream refers to the actual byte size occupied by the compressed data generated after the pixel block data has undergone recoding. The total slot length is the total byte length of the original storage area of the image block defined in the fixed slot information, and this length is consistent with the original byte length of the image block.
[0119] As an optional implementation, the actual byte length of the generated target compressed bitstream is counted, the total length of the slots in the fixed slot information of the corresponding image block is retrieved, the two sets of values are directly compared, the comparison results are recorded, and subsequent branch processing is performed.
[0120] As an optional implementation, the actual byte length is synchronously counted during the generation of the target compressed bitstream. After generation, the difference is immediately compared with the total length of the pre-stored slots. Based on the comparison result, it is determined whether the target compressed bitstream meets the slot storage requirements.
[0121] Step S32: If the actual byte length of the target compressed bitstream is less than or equal to the total length of the slot, the target compressed bitstream is written into the corresponding slot, starting from the original physical offset address corresponding to the image block in the image file directory.
[0122] In this embodiment, the original physical offset address is the starting storage address of the image block recorded in the image file directory in the tag image file, and the write operation is a storage operation that stores the target compressed bitstream in the slot range starting from the original physical offset address corresponding to the image block.
[0123] As an optional implementation, after confirming that the actual byte length of the target compressed bitstream is less than or equal to the total length of the slot based on the comparison results, the original physical offset address corresponding to the image block in the image file directory is located, and the complete target compressed bitstream is written byte by byte into the corresponding slot range starting from the starting position of this address.
[0124] As an optional implementation, after verifying the integrity of the target compressed bitstream, the write start position is determined based on the original physical offset address, and the target compressed bitstream is written into the fixed slot corresponding to the image block according to the storage specifications of the tag image file, without changing the write start address and slot boundary.
[0125] Step S33: Perform zero-padding on the remaining tail bytes in the slot that are not occupied by the target compressed bitstream.
[0126] In this embodiment, the remaining tail bytes refer to the unoccupied blank byte area within the slot interval after subtracting the actual byte length of the target compressed bitstream from the total slot length. Zero padding is a process of filling this blank byte area with zero-value bytes.
[0127] As an optional implementation, the blank byte range at the end of the target compressed bitstream is determined after the data is written, and all remaining bytes in the range are filled with zero values bit by bit to keep the total byte range occupied by the image block consistent with that before the replacement.
[0128] As an optional implementation, the number and position of the remaining tail bytes in the slot are calculated, and zero-value filling is performed on the bytes in batches to ensure that the total length of the slot remains unchanged after filling, and does not affect the storage position of subsequent image blocks.
[0129] Step S34: If the actual byte length of the target compressed bitstream is greater than the total length of the slot, or if an abnormality occurs during the generation of the target compressed bitstream, then the write-back operation of the image block is terminated, and the original byte content of the image block at the corresponding original physical offset address remains unchanged and is transparently transmitted out.
[0130] In this embodiment, abnormalities in the generation of the target compressed bitstream include recoding failure, bitstream data corruption, and incorrect bitstream length calculation. Write-back operation termination means stopping the writing and zero-padding process of the target compressed bitstream, while full pass-through means outputting the original data of the image blocks as is, without any modification.
[0131] As an optional implementation, if the actual byte length of the target compressed bitstream is found to be greater than the total length of the slot, or if an abnormal bitstream generation is detected, the write-back operation of the image block is immediately terminated, no data modification is performed, the original byte content of the image block at the original physical offset address is maintained, and the original data is transmitted out as is.
[0132] As an optional implementation, the code stream length comparison results and generation status are monitored in real time. When an over-limit or abnormal situation occurs, the abnormal information is recorded and the write-back process is terminated. The original complete original data of the image block is directly read and transmitted without changing the original structure and data content of the file.
[0133] For example, when processing geotagged image files, after recoding the pixel block data of the target image block, the actual byte length of the target compressed bitstream is calculated and compared with the total length of slots in the fixed slot information of the image block. If the compressed bitstream length meets the slot length requirement, the compressed bitstream is written starting from the original physical offset address corresponding to the image block, and the remaining tail bytes in the slot are padded with zeros to ensure that the total slot length remains unchanged. If the compressed bitstream length exceeds the total slot length, or if a bitstream generation anomaly occurs during the recoding process, the write-back operation of the image block is immediately terminated, the original data of the image block remains unchanged, and it is transmitted out unchanged without modifying the image file directory content or the physical offset address of subsequent image blocks.
[0134] Optionally, refer to Figure 2 For an image block with an initial slot offset of Offset_i and a length of SlotLen_i, the target compressed bitstream is first generated. Then, it is determined whether the bitstream length is less than or equal to SlotLen_i. If the bitstream length does not meet the requirement of ≤SlotLen_i, no replacement is performed, and the original byte content remains unchanged, while the offset of subsequent image blocks remains unchanged. If the bitstream length meets the requirement of ≤SlotLen_i, the target compressed bitstream is written at Offset_i. Then, the remaining tail length Tail = SlotLen_i - CodeLen_i is calculated, and zeros are padded in the Tail range to keep the total occupied area of the current image block unchanged, while the offset of subsequent image blocks remains unchanged. Finally, the closed write-back is completed, achieving the processing effect that the write-back range is limited to the current original slot, does not expand the occupied area of the current image block, and does not move subsequent image blocks.
[0135] Optionally, after writing is complete, the original physical offset address and image file directory content corresponding to other image blocks are not modified.
[0136] In this embodiment, subsequent image blocks refer to all remaining image blocks located after the currently processed image block, in order of their physical offsets. The original physical offset address is the starting storage address of the original record of the subsequent image block in the image file directory. The image file directory content is a set of core metadata used to record the block positioning parameters and image attribute parameters of each image block.
[0137] As an optional implementation, after the target compressed bitstream of the current image block is written and zero-padding is completed, the original physical offset address corresponding to other subsequent image blocks is kept unchanged, and all original record contents in the image file directory are retained without adding, deleting or modifying any directory fields.
[0138] As an optional implementation, after the write-back operation of the current image block is completed, the original physical offset address of the subsequent image blocks and the contents of the image file directory are locked and protected. No directory recompilation or address offset adjustment operation is triggered throughout the process, and the original metadata structure of the file remains intact.
[0139] For example, when processing geotagged image files, after writing the compressed bitstream and padding the tail of the current target image block, the original physical offset address of any other image block after that image block is not adjusted, nor are the block positioning parameters and image attribute parameters recorded in the image file directory modified. The overall metadata structure and physical layout of the file are kept completely in their original state, and only the data in the slot of the current image block is updated in situ.
[0140] This embodiment employs a hierarchical processing logic that includes compressed bitstream length comparison, compliant in-situ writing, tail zero padding, and abnormal over-limit pass-through. It strictly relies on fixed slots and original physical offset addresses to complete the saving operation of the target compressed bitstream. Throughout the process, the image file directory is not rearranged and the physical storage location of image blocks is not adjusted. This solves the problem of low processing efficiency caused by modifying the file structure after the label image file is compressed. At the same time, the pass-through mechanism for abnormal and over-limit scenarios ensures the integrity of file data and the stability of the processing flow, further improving the compatibility and engineering reliability of label image file compression processing.
[0141] Based on any of the above embodiments, in Embodiment 7 of this application, before compressing the pixel block data corresponding to the image block according to the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream, the process includes: Step S141: Determine whether the original physical offset address corresponding to the initial image block is earlier than the end position of the metadata region.
[0142] In this embodiment, the initial image block is the first image block arranged in physical offset order, and it is the first image block in the file to enter the processing flow. The end position of the metadata area is the final storage address of the metadata area, which is composed of the file header and the entire image file directory. Rectified pass-through refers to a complete pass-through mode that abandons all image block compression processing logic and performs full-process unedited output on the tag image file.
[0143] As an optional implementation, the original physical offset address of the initial image block and the end position of the metadata region are retrieved, the two sets of address values are compared, and the initial image block is determined to have intruded into the metadata region based on the comparison result.
[0144] As an optional implementation, the physical offset order of all image blocks is traversed to locate the initial image block and extract its original physical offset address. Combined with the boundary calculation results of the metadata region, it is determined whether the offset address is within the range of the metadata region.
[0145] Step S142: If the original physical offset address corresponding to the initial image block is earlier than the end position of the metadata area, switch to rectified pass-through.
[0146] As an optional implementation, once it is determined that the original physical offset address of the initial image block is earlier than the end position of the metadata area, the image block compression processing module is immediately shut down, and the system is switched to the rectification pass-through mode to output the file byte stream as is without performing any parsing, compression, or modification operations.
[0147] As an optional implementation, after detecting that the initial image block intrudes into the metadata area, a security protection mechanism is triggered, and the system directly switches to the rectification and pass-through state, preserving the original file data and structure throughout the process and preventing the metadata from being overwritten or damaged.
[0148] Step S143: If the original physical offset address corresponding to the initial image block is not earlier than the end position of the metadata region, determine whether the current stream position of the byte stream is a non-image block region.
[0149] In this embodiment, the current stream position is the real-time read point of the byte stream in the physical storage order of the file. The non-image block region is the remaining metadata and blank padding area in the file after excluding all fixed slot intervals of image blocks.
[0150] As an optional implementation, after the initial image block verification is compliant, the current stream position is matched with the fixed slot information of each image block to determine whether the current stream position falls within the slot range of any image block, thereby distinguishing the image block area from the non-image block area.
[0151] As an optional implementation, a region partitioning mapping table is constructed based on fixed slot information. The mapping table is used to quickly query the region to which the current flow position belongs and determine whether it is a non-image block region.
[0152] Step S144: If yes, pass through the current byte stream; if no, execute the step of compressing the image block pixel block data according to the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bit stream.
[0153] As an optional implementation, when the current stream position is determined to be a non-image block region, the current byte stream data is directly transmitted without any processing; when it is determined to be an image block region, the image block compression processing flow is started, and subsequent pixel block data compression and target compressed bitstream generation steps are performed.
[0154] As an optional implementation, streaming splitting is performed based on the region determination result. Data from non-image block regions is directly transmitted out, while data from image block regions enters the compression processing link, ensuring the continuity and specificity of streaming processing.
[0155] For example, when processing geotagged image files, after constructing the fixed slot information for all image blocks, the initial image block is located and its original physical offset address is extracted. This address is then compared with the end position of the metadata region. If the initial image block offset address does not intrude into the metadata region, the current stream position of the byte stream is monitored in real time. Byte streams flowing through non-image block regions are directly passed through. When the stream position enters the image block region, the image block compression process is initiated, parsing and re-encoding the pixel block data. If the initial image block offset address is earlier than the end position of the metadata region, the process is directly switched to the rectification pass-through mode, outputting the file data as is without performing any compression operations.
[0156] This embodiment avoids the risk of file metadata being accidentally modified or damaged by pre-checking the initial image blocks and metadata areas. At the same time, through streaming region splitting processing, compression is only performed on the image block areas, while non-image block areas are directly passed through, reducing the overhead of invalid data processing and further improving the efficiency and security of streaming processing of tag image files, thus ensuring the integrity of the original file structure.
[0157] Based on any of the above embodiments, in Embodiment 8 of this application, after saving the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information, the following steps are included: Step A10: Receive the compressed tag image file as the file to be recovered.
[0158] In this embodiment, the file to be recovered refers to the tag image file that has undergone the aforementioned in-situ compression processing, contains the target compressed bitstream, and retains the original physical structure and image file directory information. Its file format, metadata area, and physical offset of image blocks have not been changed.
[0159] As an optional implementation, a compressed tag image file transmitted from an external source is received through a streaming interface. The file is first checked for format magic number verification. After confirming that the file is a valid tag image format, it is marked as a file to be recovered and loaded into the byte stream processing link. At the same time, the stream position pointer is initialized to the beginning of the file.
[0160] As an optional implementation, the local storage reading module reads the saved compressed label image file, completes the file integrity verification (verifies that the file header and image file directory are not damaged), determines it as a file to be recovered, starts the recovery process, and synchronously loads the basic storage parameters of the file.
[0161] Step A11: Parse the file header and image file directory of the file to be recovered to determine the fixed slot information corresponding to each image block in the file to be recovered.
[0162] In this embodiment, the fixed slot information is completely consistent with the original parameters during compression processing. The core includes the starting physical offset of the slot and the total length of the slot. The starting physical offset of the slot is equal to the original physical offset address of the corresponding image block, and the total length of the slot is equal to the original byte length of the corresponding image block. This is used to limit the in-situ processing boundary of the image block during the restoration process.
[0163] As an optional implementation, in accordance with the tag image file parsing specification, the file header data of the file to be recovered is first read, and the file byte order and the physical offset address of the first image file directory are parsed. Then, based on the offset address, all image file directories are traversed to extract the original physical offset address, original byte length and other block positioning parameters of each image block. The fixed slot information corresponding to each image block is directly mapped and generated, and a slot information mapping table is constructed simultaneously for subsequent fast query.
[0164] As an optional implementation, a streaming segmented parsing mode is adopted to read the header data and hierarchical image file directory of the file to be recovered segment by segment. Combined with the file byte order correction parsing rules, the block positioning parameters of valid image blocks are selected, invalid directory fields are removed, and fixed slot information of all image blocks is generated. At the same time, the validity of the slot boundaries is verified to ensure that the slot intervals do not overlap or cross the boundary.
[0165] Step A12: Based on the fixed slot information corresponding to each image block and the current stream position of the byte stream, sequentially detect whether the original physical offset position corresponding to the image block contains the preset target compressed bitstream identifier for each image block.
[0166] In this embodiment, the current stream position is the real-time reading point of the byte stream of the file to be recovered, which is updated synchronously with the progress of byte stream reception; the target compressed bitstream identifier is a special marker (pre-set as a fixed 4-byte identifier) that is written at the beginning of the original physical offset address of the image block, and is used to uniquely distinguish whether the image block has been compressed and whether it contains the target compressed bitstream; sequential detection means that the identifier is detected one by one according to the physical offset order of each image block, without skipping any image blocks.
[0167] As an optional implementation, the current stream position is first matched with the fixed slot information mapping table to locate the target image block to be detected. The stream position pointer is moved to the original physical offset address of the image block. Starting from the address, 4 bytes of data are read byte by byte and compared with the preset target compressed bitstream identifier. If the 4 bytes of data match completely, it is determined that the identifier has been detected; otherwise, it is determined that the identifier has not been detected. After the detection is completed, the stream position pointer is moved to the original physical offset address of the next image block, and the detection is repeated in a loop.
[0168] As an optional implementation, an image block detection order list is pre-generated based on fixed slot information. The original physical offset address of each image block is retrieved one by one according to the list order. The 4 bytes of data starting from the address are read in batches and compared with the preset identifier in batches. The detection results are recorded at the same time. For image blocks that are not identified, they are directly marked as uncompressed blocks. No subsequent recovery steps are required. Only pass-through processing is performed.
[0169] Step A13: If the target image block is detected to contain the preset target compressed bitstream identifier, the end marker of the target compressed bitstream is located within the fixed slot range corresponding to the target image block, and decoding processing is performed on the target compressed bitstream located before the end marker to obtain the recovered pixel block data.
[0170] In this embodiment, the end marker is a termination boundary marker (preset as a fixed 2-byte marker) written synchronously with the target compressed bitstream during compression processing. It is located at the end of the target compressed bitstream and before the zero-padding data at the end of the slot, and is used to clarify the effective range of the target compressed bitstream. The recovered pixel block data is the effective pixel information obtained after decoding the target compressed bitstream, which is completely consistent with the original pixel block data before compression. The decoding process is the inverse operation of compression encoding, and adopts the decoding algorithm corresponding to that during compression to ensure that the data after decoding is distortion-free.
[0171] As an optional implementation, after detecting the target compressed bitstream identifier, the stream position pointer is kept within the fixed slot range of the current image block. Starting from the end position of the identifier, the system searches byte by byte until a preset end marker is found. The physical offset address of the end marker is recorded, and all data from the end position of the identifier to the end marker is extracted as the complete target compressed bitstream. The same decompression algorithm as during compression is called to perform decoding processing on the target compressed bitstream. After decoding, the initial recovered pixel data is obtained. The integrity of the initial recovered pixel data is then checked (the number of pixels, pixel bit depth and image attribute parameters are checked to be consistent). After the check passes, it is determined to be the recovered pixel block data.
[0172] As an optional implementation, after locating the target compressed bitstream identifier, the total length of the fixed slots of the image block is first read to determine the maximum possible range of the target compressed bitstream (from the end of the identifier to the end of the slot). Within this range, a segmented search mode is used to quickly locate the end marker, avoiding the inefficiency of byte-by-byte search. After finding the end marker, the target compressed bitstream is subjected to CRC verification. After confirming that the bitstream is not damaged, decoding is performed. During the decoding process, invalid and redundant data is removed, and the recovered pixel block data that meets the requirements of the image attribute parameters is directly output.
[0173] Step A14: Perform a preset recoding process on the recovered pixel block data to generate a TIFF-compatible image block, and compare the byte length of the TIFF-compatible image block with the total length of the slots in the fixed slot information corresponding to the target image block.
[0174] In this embodiment, the TIFF-compatible image block is an original format image block that conforms to the TIFF 6.0 standard format specification and can be directly recognized by general image reading software. Its encoding format is consistent with the encoding format of the original image block before compression. The re-encoding process is an encoding operation that converts the recovered pixel block data into the standard TIFF format. The encoding parameters are strictly matched with the image attribute parameters (pixel bit depth, number of samples, total image width and height, etc.). The length comparison is used to determine whether the TIFF-compatible image block can be written to the fixed slot in situ to avoid exceeding the slot boundary.
[0175] As an optional implementation, the image attribute parameters corresponding to the image block in the file to be recovered are retrieved, and TIFF standard encoding parameters are configured according to the parameters (such as the number of bits corresponding to the pixel bit depth and the number of samples corresponding to the channel encoding method). The TIFF standard encoding algorithm is used to perform re-encoding processing on the recovered pixel block data to generate a TIFF compatible image block. The actual byte length of the image block is counted, the total length of the slot in the corresponding fixed slot information is retrieved, the two are compared numerically, the length difference is calculated, and the comparison result (less than or equal to or greater than the total length of the slot) is recorded.
[0176] As an optional implementation, the recovered pixel block data is first validated to ensure that the pixel data is free of missing or disordered areas. Then, an optimized TIFF encoding strategy is adopted to compress and encode redundant data to generate TIFF-compatible image blocks while ensuring lossless image quality. The actual byte length is simultaneously counted and compared with the total length of the slots. If the length exceeds the total length of the slots, it is immediately marked as an encoding anomaly, and subsequent writing operations are terminated. If the length is within the rules, the next step of processing is initiated.
[0177] Step A15: If the byte length of the TIFF compatible image block is less than or equal to the total length of the slot, then starting from the original physical offset address corresponding to the target image block, the TIFF compatible image block is written into the corresponding slot range, and zero-padding is performed on the remaining tail bytes in the slot range that are not occupied by the TIFF compatible image block.
[0178] As an optional implementation, after confirming that the length of the TIFF-compatible image block is compliant, the stream position pointer is moved to the original physical offset address of the target image block. Starting from the address, the TIFF-compatible image block is written byte by byte into the corresponding fixed slot range. After writing is completed, the difference between the total slot length and the actual byte length of the TIFF-compatible image block is calculated to determine the number and starting position of the remaining tail bytes. The tail bytes are filled with zero values bit by bit to ensure that the total slot length after filling is completely consistent with the original state and does not change the physical offset address of the slot boundary and subsequent image blocks.
[0179] As an optional implementation, a batch write mode is adopted, in which TIFF compatible image blocks are written to the starting position of the original physical offset address of the target slot in one go. After the writing is completed, batch zero-padding is performed on the unoccupied tail blank area in the slot. After the zero-padding is completed, it is verified whether the total length of the slot is consistent with the original byte length to ensure that the writing and zero-padding operations are without deviation and do not affect the overall file structure.
[0180] Step A16: If the preset target compressed bitstream identifier is not detected, the end marker is not located, decoding fails, re-encoding fails, or the byte length of the TIFF compatible image block is greater than the total length of the slot, then the existing byte content of the corresponding image block remains unchanged and is transmitted out transparently.
[0181] In this embodiment, if the target compressed bitstream identifier is not detected, the image block has not been compressed; if the end marker is not located, the target compressed bitstream is damaged or incomplete; if decoding fails, the target compressed bitstream cannot be parsed into valid pixel data; if re-encoding fails, the recovered pixel block data cannot be converted into a standard TIFF compatible image block; and if transparent transmission is performed, no modification, parsing, or encoding operation is performed on the existing byte content of the image block, and it is output as is, keeping the original data and storage state unchanged.
[0182] As an optional implementation, if in any step A12 to A15, if the target compressed bitstream identifier is not detected, the end marker is not located, decoding fails, re-encoding fails, or the TIFF compatible image block length exceeds the limit, all recovery processing procedures for the current image block are immediately terminated, no subsequent write or zero-padding operations are performed, all existing byte content in the fixed slot corresponding to the image block is directly read and transmitted out as is, and the anomaly type and the physical offset address of the abnormal image block are recorded for subsequent tracing.
[0183] As an optional implementation, the entire recovery process is monitored in real time. When any abnormal condition is triggered, an abnormal protection mechanism is activated to lock the existing data of the image block, disallowing any modification operations, and directly transmitting the byte stream of the image block out in its original order. For image blocks that are not identified, all recovery steps are skipped and the data is transmitted out directly, ensuring that the processing flow is not interrupted and the integrity of the file data is guaranteed.
[0184] For example, when processing geotagged files to be recovered, the compressed tag image files are first received via streaming. After verifying the format magic number and file integrity, the files are marked as files to be recovered and loaded into the processing chain. The file header and full image file directory of the files to be recovered are parsed to extract the original physical offset address and original byte length of each image block, generate fixed slot information for all image blocks, and construct a mapping table. Each image block is detected one by one in the order of physical offset. The stream position pointer is moved to the original physical offset address of the image block, and 4 bytes of data are read byte by byte and compared with the preset target compressed bitstream identifier. For the detected target image block, the end marker is searched in segments within the fixed slot range. The target compressed bitstream between the identifier and the end marker is extracted, and the corresponding decoding algorithm is executed to obtain the recovered pixel block data. Then, according to the image attribute parameters, the TIFF encoding parameters are configured to re-encode the recovered pixel block data into a TIFF-compatible image block. Its byte length is counted and compared with the total slot length. If the length is correct, it is written from the original physical offset address. The remaining bytes at the end are padded with zeros in batches. If a certain image block is not identified, or if there is an abnormality such as decoding failure or exceeding the length limit of a TIFF compatible image block, the existing data of the image block is kept unchanged and transmitted out. The recovery process of all image blocks is completed in sequence, and finally a lossless recovery tag image file with a structure consistent with the original file is obtained and can be recognized by general software.
[0185] Optionally, refer to Figure 3In this embodiment, the process starts by receiving the TIFF or GeoTIFF file to be recovered, parsing the file header and image file directory, establishing a fixed slot table for image blocks, and performing recovery judgments according to the image block order. Then, it checks whether a preset target compressed bitstream identifier is detected in the current image block. If no preset target compressed bitstream identifier is detected, the existing byte content of the current image block remains unchanged and is passed through, and then it checks whether there are any subsequent image blocks. If a preset target compressed bitstream identifier is detected, the bitstream end marker is located within the original slot range, and then it checks whether the location is successful. If the location fails, the existing byte content of the current image block remains unchanged and is passed through, and then it checks whether there are any subsequent image blocks. If the location is successful, the target compressed bitstream is decoded, and then it checks whether the decoding is successful. Success; if decoding fails, keep the existing byte content of the current image block unchanged and pass it through, then determine if there are any subsequent image blocks; if decoding is successful, obtain the recovered pixel block data, recompress it into a TIFF-compatible image block, and then determine if the length of the recompressed block does not exceed the original slot length; if the length of the recompressed block exceeds the original slot length, keep the existing byte content of the current image block unchanged and pass it through, then determine if there are any subsequent image blocks; if the length of the recompressed block does not exceed the original slot length, write back the original physical offset position, keep the existing layout of the remaining image blocks unchanged, then determine if there are any subsequent image blocks; if there are any subsequent image blocks, return to the step of performing the recovery judgment according to the image block order, and repeat the above process; if there are no subsequent image blocks, the process ends.
[0186] This embodiment employs a full-process recovery mechanism encompassing in-situ analysis, precise identifier detection, reversible decoding, and standard TIFF re-encoding. It strictly relies on fixed slot information to achieve lossless recovery of tag image files, without modifying the image file directory content or adjusting the original physical offset addresses of any image blocks, thus completely avoiding file structure disorder during recovery. For various abnormal scenarios in the recovery process, explicit abnormal termination and pass-through protection mechanisms are established. This ensures that the compressed file can be reversibly restored to the universal TIFF format, solving the technical problem of poor compatibility of compressed files, while also guaranteeing the integrity of file data and the stability of the processing flow during recovery. Furthermore, detailed operational steps improve the accuracy and feasibility of the recovery process, further perfecting the complete technical loop from tag image file compression to recovery, and enhancing the engineering practicality and reliability of the solution.
[0187] Based on any of the above embodiments, in Embodiment Nine of this application, referring to Figure 4 and Figure 5 The explanation will be based on the overall process.
[0188] In this embodiment, refer to Figure 4In this embodiment, the process is divided into two main stages: metadata parsing and streaming scheduling. In the metadata parsing stage, the beginning of the input byte stream is first entered, the TIFF file header is parsed, one or more image file directories are traversed, and the number of bytes related to strip or tile offset and length, the number of bytes of strip or tile, the height and width of the image, and the parameters related to the segmentation of the line data are extracted. Based on the extracted parameters, an image block fixed slot table is established. After completing the metadata parsing, the process enters the streaming scheduling stage. In the streaming scheduling stage, based on the established image block fixed slot table, it is first determined whether to enter an image block slot. If not, the non-image block area is directly passed through. If it enters an image block slot, it is further determined whether the cache covers the entire slot. If the cache does not cover the entire slot, it waits for more input. If the cache covers the entire slot, the current block processing is advanced. At the same time, the slot interval is checked during the entire streaming scheduling process, and finally the entire process of building the image block fixed slot table and streaming scheduling is completed.
[0189] Reference Figure 5 In this embodiment, the system first receives a TIFF or GeoTIFF input byte stream, parses the file header and image file directory, establishes a fixed slot table for image blocks, and then determines whether the offset of the first image block is earlier than the end position of the metadata region. If the offset of the first image block is earlier than the end position of the metadata region, the system switches to the rectification pass-through mode, outputs the original file byte stream, and ends the process. If the offset of the first image block is not earlier than the end position of the metadata region, the system performs streaming scheduling according to the current stream position, and then determines whether the current region is a non-image block region. If the current region is a non-image block region, the current byte is directly passed through, and then it is determined whether there are any subsequent image blocks. If the current region is an image block region, it is determined whether the buffer is sufficient to cover the complete slot of the current image block. If the buffer is insufficient to cover the complete slot of the current image block, the output is... If more input states are needed, return to the loop of executing streaming scheduling according to the current stream position; if the buffer is sufficient to cover the complete slot of the current image block, read the current target image block, decode or directly read it as pixel block data, re-encode the pixel block to obtain the target compressed bitstream, and then determine whether the bitstream length does not exceed the original slot length; if the bitstream length exceeds the original slot length, keep the original image block content unchanged and pass it through, and then determine whether there are any subsequent image blocks; if the bitstream length does not exceed the original slot length, write the target compressed bitstream according to the original physical offset, pad the remaining tail bytes with zeros, keep the physical offset of subsequent image blocks unchanged, and then determine whether there are any subsequent image blocks; if there are any subsequent image blocks, return to the loop of executing streaming scheduling according to the current stream position; if there are no subsequent image blocks, the process ends.
[0190] Optionally, the header information and image file directory of the TIFF or GeoTIFF file are parsed first to establish a fixed slot table for image blocks; each image block is mapped to a pre-existing byte slot with fixed boundaries in the file; during streaming processing, non-image block regions are directly passed through; when the stream position enters the original physical offset position corresponding to the target image block and the buffer is sufficient to cover the complete slot, block-level replacement processing is performed on the image block; in-situ write-back is only allowed at the original physical offset position if the length of the target compressed bitstream does not exceed the length of the original slot; after write-back, the remaining tail bytes are padded with zeros to keep the total byte range occupied by the image block unchanged; when the target compressed bitstream exceeds the limit or the processing is abnormal, the original byte content is kept unchanged and passed through; the physical offset position of subsequent image blocks is not modified after replacement; replaced image blocks and unreplaced image blocks are allowed to coexist in the same file; during the recovery phase, the image blocks are still detected, decoded, recompressed, and subjected to the same length constraint judgment within the original slot range.
[0191] Optionally, the header information and image file directory of the TIFF or GeoTIFF file to be processed are parsed to determine the original physical offset positions and original slot lengths corresponding to multiple image blocks, and an image block fixed slot table is established. During the streaming reception of file byte streams, based on the current stream position and the image block fixed slot table, non-image block regions are transparently transmitted out. When the current stream position enters the original physical offset position corresponding to the target image block and the buffered data is sufficient to cover the corresponding byte slot of the target image block, block-level replacement processing is performed on the target image block. Decoding or direct reading processing is performed on the target image block to obtain the corresponding pixel block data, and re-encoding processing is performed on the pixel block data to obtain the target compressed bitstream. The bitstream length of the target compressed bitstream is compared with the original slot length corresponding to the target image block. Only when the bitstream length of the target compressed bitstream is less than or equal to the original slot length is the target compressed bitstream written to the original physical offset position corresponding to the target image block. After the write operation is completed, zero-padding is performed on the remaining tail bytes in the byte slot corresponding to the target image block that are not occupied by the target compressed bitstream, so that the total byte range occupied by the target image block remains consistent with that before the replacement. If the bitstream length of the target compressed bitstream is greater than the original slot length, or if an anomaly occurs in the target image block during decoding, re-encoding, verification, or write-back, the original byte content of the target image block at the corresponding original physical offset position remains unchanged and is transparently transmitted out.
[0192] When establishing the image block fixed slot table, the following can be included: identifying the file byte order, TIFF magic number, and the directory offset of the first image file; traversing one or more image file directories; extracting strip offset, strip byte count, tile offset, tile byte count, as well as image width and height, strip row count, tile width and height, bit depth, and sample count information; and establishing the image block fixed slot table according to the actual physical offset order of each image block in the file.
[0193] For cases where the byte number field of an image block is zero, an abnormal value, or out of bounds, the original slot length of the corresponding image block can be deduced based on the offset of adjacent image blocks, the end position of the same-level image file directory, or the file boundary.
[0194] For the last image block in the same-level image file directory, if its stripe byte count or tile byte number segment is abnormal, the starting offset of the image block can be recorded, and its original slot length can be deduced by combining the offset of adjacent image blocks, the end position of the same-level image file directory, and the boundary or file boundary corresponding to the offset of the next image file directory in the same level. If a valid original slot length still cannot be obtained, the image block will not be replaced and its original byte content will be passed out.
[0195] In the block-level transformation stage: when the target image block is compressed using Deflate or Adobe Deflate, the target image block is decompressed to obtain pixel block data; when the target image block is uncompressed, the target image block data is directly used as pixel block data; for edge tiles or non-whole stripes, the effective pixel area can be determined based on the total width and height of the image, the number of strip rows, the width and height of the tile, the bit depth, and the number of samples; in the re-encoding stage, a high-throughput JPEG2000 bitstream or JPH bitstream can be preferentially generated.
[0196] If the target compressed bitstream exceeds the original slot length, or if an anomaly occurs during decoding, re-encoding, verification, or write-back, the image block will not be rewritten with an expanded capacity. Instead, the original byte content of the image block will remain unchanged and will be transparently transmitted out.
[0197] To ensure the safety boundaries of streaming processing, further restrictions can be imposed: block-level replacement processing is only performed on image block regions after a complete fixed slot table for image blocks has been established; when the input buffer is insufficient to cover the complete byte slots of the target image block corresponding to the current stream position, the output requires more input states, and block-level replacement processing continues after subsequent bytes arrive; if the earliest image block offset is detected to be earlier than the end position of the metadata region required to complete the parsing of the image file directory, the stream is switched to rectification pass-through mode, and no replacement processing is performed on any image block.
[0198] The recovery method includes at least the following steps: parsing the header information and image file directory of the TIFF or GeoTIFF file to be recovered, determining the original physical offset positions and original slot lengths corresponding to multiple image blocks, and establishing a fixed slot table for image blocks; during streaming processing, detecting whether the image block data located at the corresponding original physical offset position contains a preset target compressed bitstream identifier for each image block; when the target image block is detected to contain the preset target compressed bitstream identifier, locating the end marker of the target compressed bitstream within the original slot range corresponding to the target image block, and decoding the target compressed bitstream located before the end marker. The data is processed to obtain recovered pixel block data; the recovered pixel block data is recompressed into TIFF-compatible image blocks, and the length of the recompressed data is compared with the original slot length corresponding to the target image block. Only when the length of the recompressed data is less than or equal to the original slot length, the recompressed data is written back to the original physical offset position corresponding to the target image block; if the preset target compressed bitstream identifier is not detected, the end marker is not located, decoding fails, recompression fails, or the length of the recompressed data is greater than the original slot length, the existing byte content of the corresponding image block remains unchanged and is transparently transmitted out.
[0199] Preferably, the TIFF-compatible image block can be a Deflate compressed block; the preset target compressed bitstream identifier can include a JPH identifier at the start position of the image block, and the end marker can include a JPEG2000 bitstream end marker.
[0200] Optionally, compared with existing GeoTIFF whole-file transcoding, relayout optimization, or general block compression schemes, the main differences in this embodiment are: instead of generating a new file layout, it performs a decisional replacement within the existing physical slots of the image blocks; it uses "the target compressed bitstream length does not exceed the original slot length" as a precondition for in-situ write-back; after write-back, it pads the remaining tail bytes with zeros to keep the total byte range occupied by the image blocks unchanged; in cases of exceeding limits or abnormal situations, it does not expand or rearrange subsequent offsets, but maintains the original byte content for transparent transmission; it allows replaced and unreplaced image blocks to coexist in the same file; and in the recovery phase, it continues to process the blocks block by block using the original slot boundary and length constraint rules.
[0201] Based on this, by restricting image block replacement behavior to the original fixed slots, the entire file layout and subsequent block offset rearrangement are avoided; by padding the remaining tail bytes with zeros, the total byte range of the replaced image block remains unchanged, which is beneficial to maintaining the existing physical layout relationship; by keeping the original byte content unchanged and passing it through in case of exceeding limits or abnormal situations, the isolation between local block failure and the whole file processing result is achieved; by allowing replaced blocks and unreplaced blocks to coexist, the engineering usability of progressive migration and local processing is improved; by judging and writing back block by block according to the same slot constraint rules in the recovery phase, block-by-block recovery in mixed states is supported.
[0202] This application provides an in-situ streaming replacement compression and restoration device for a fixed slot in a GeoTIFF image block. The in-situ streaming replacement compression and restoration device for a fixed slot in a GeoTIFF image block includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the in-situ streaming replacement compression and restoration method for a fixed slot in a GeoTIFF image block as described in Embodiment 1 above.
[0203] The following is for reference. Figure 6 This document illustrates a structural schematic diagram of an in-situ streaming replacement compression and restoration device suitable for implementing embodiments of the present application within a GeoTIFF image block fixed slot. The in-situ streaming replacement compression and restoration device within a GeoTIFF image block fixed slot in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablets, and in-vehicle terminals, as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The in-situ streaming replacement compression and recovery device shown in the GeoTIFF image block fixed slot is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0204] like Figure 6As shown, the in-situ streaming replacement compression and recovery device within the GeoTIFF image block fixed slot may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for the operation of the in-situ streaming replacement compression and recovery device within the GeoTIFF image block fixed slot. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the in-situ streaming replacement compression and recovery device within the GeoTIFF image block mounting slot to wirelessly or wiredly communicate with other devices to exchange data. Although the figure shows in-situ streaming replacement compression and recovery devices within the GeoTIFF image block mounting slot with various systems, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0205] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0206] The in-situ streaming replacement compression and restoration device within the fixed slot of a GeoTIFF image block provided in this application employs the in-situ streaming replacement compression and restoration method within the fixed slot of a GeoTIFF image block in the above embodiments. This solves the technical problem of low processing efficiency caused by the need to rearrange the image file directory after compression or conversion of tagged image files. Compared with the prior art, the beneficial effects of the in-situ streaming replacement compression and restoration device within the fixed slot of a GeoTIFF image block provided in this application are the same as those of the in-situ streaming replacement compression and restoration device within the fixed slot of a GeoTIFF image block provided in the above embodiments. Furthermore, other technical features of this in-situ streaming replacement compression and restoration device within the fixed slot of a GeoTIFF image block are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0207] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0208] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0209] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the in-situ streaming replacement compression and recovery method within the fixed slot of the GeoTIFF image block in the above embodiments.
[0210] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), or any suitable combination thereof.
[0211] The aforementioned computer-readable storage medium may be included in an in-situ streaming replacement compression and recovery device within a GeoTIFF image block fixed slot; or it may exist independently and not assembled into an in-situ streaming replacement compression and recovery device within a GeoTIFF image block fixed slot.
[0212] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by the in-situ streaming replacement compression and restoration device within the fixed slot of the GeoTIFF image block, the in-situ streaming replacement compression and restoration device within the fixed slot of the GeoTIFF image block performs the following: determines the fixed slot information corresponding to each image block in the tag image file based on the file header and image file directory of the tag image file; compresses the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream, to obtain a target compressed bitstream; and saves the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information.
[0213] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0214] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation that may be implemented in systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0215] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0216] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the in-situ streaming replacement compression and recovery method within the fixed slot of the GeoTIFF image block described above. This solves the technical problem of low processing efficiency caused by the need to rearrange the image file directory after compression or conversion of tag image files. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the in-situ streaming replacement compression and recovery method within the fixed slot of the GeoTIFF image block provided in the above embodiments, and will not be repeated here.
[0217] This application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the in-situ streaming replacement compression and restoration method within the fixed slot of a GeoTIFF image block as described above.
[0218] The computer program product provided in this application can solve the technical problem of low processing efficiency caused by the need to rearrange the image file directory after compression or conversion of tag image files. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the in-situ streaming replacement compression and recovery method in the fixed slot of GeoTIFF image block provided in the above embodiments, and will not be repeated here.
[0219] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.
Claims
1. A method for in-situ streaming replacement compression and restoration within a fixed slot of a GeoTIFF image block, characterized in that, The in-situ streaming replacement compression and restoration method within the fixed slot of the GeoTIFF image block includes: Based on the file header and image file directory of the label image file, determine the fixed slot information corresponding to each image block in the label image file; Based on the fixed slot information of the image block corresponding to the currently received byte stream, the pixel block data corresponding to the image block is compressed to obtain the target compressed bitstream; The target compressed bitstream is saved based on the original physical offset of the image block corresponding to the image file in the image file directory and the fixed slot information.
2. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 1, characterized in that, The step of determining the fixed slot information corresponding to each image block in the label image file based on the file header and image file directory of the label image file includes: The file header of the tag image file is parsed to identify the file byte order, the magic number of the tag image file format, and the physical offset address of the first image file directory; Based on the file byte order and the physical offset address of the first image file directory, all image file directories within the tag image file are traversed to extract the block positioning parameters and image attribute parameters corresponding to each image block. The block positioning parameters include the original physical offset address and original byte length of each image block, and the image attribute parameters include the total width and height of the image, the number of strip lines, the width and height of the tile, the pixel bit depth, the number of samples, and the original compression format. Based on the block positioning parameters and image attribute parameters corresponding to each image block, the physical offset order of each image block in the file is determined, and then the fixed slot information of each image block is determined. The fixed slot information includes at least the starting physical offset of the slot and the total length of the slot. The starting physical offset of the slot is consistent with the original physical offset address of the corresponding image block, and the total length of the slot is consistent with the original byte length of the corresponding image block.
3. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 2, characterized in that... The step of determining the physical offset order of each image block in the file based on the block positioning parameters and image attribute parameters corresponding to each image block, and then determining the fixed slot information of each image block, includes: If the original byte length of the target image block is determined to be zero, an abnormal value, or out of bounds based on the block positioning parameters and image attribute parameters, the adjacent image blocks of the target image block are determined according to the order of the physical offsets. Based on the offset address of the adjacent image block, the end position of the same-level image file directory, and the physical boundary of the file, the total length of the slot corresponding to the target image block is derived. The fixed slot information is determined based on the total length of the slot and the starting physical offset of the slot in the target image block.
4. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 1, characterized in that, The step of compressing the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream includes: Based on the fixed slot information corresponding to each image block and the current stream position of the byte stream, when it is determined that the current stream position enters the slot range corresponding to the image block, it is verified whether the byte length of the current input buffer covers the complete slot corresponding to the image block; If the current input buffer length is insufficient to cover the entire slot, output a waiting state indicating that more input is needed; If the current input buffer length is sufficient to cover the entire slot, read the original data within the image block slot; Based on the original compression format corresponding to the image block, the original data is parsed to obtain the pixel block data corresponding to the image block; The pixel block data is subjected to a preset re-encoding process to generate a target compressed bitstream.
5. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 4, characterized in that, The step of parsing the original data according to the original compression format corresponding to the image block to obtain the pixel block data corresponding to the image block includes: When the original compression format of the image block is Deflate or Adobe Deflate, the original data is decompressed to obtain the initial pixel data; When the image block is in an uncompressed format, the read raw data will be used as the initial pixel data; If the image block is determined to be an edge tile or an incomplete strip block based on the image attribute parameters corresponding to the image block, the effective pixel area of the image block is determined based on the total width and height of the image, the number of strip rows, and the width and height of the tile. The pixel block data is obtained by removing invalid padding data from the initial pixel data based on the effective pixel region.
6. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 1, characterized in that, Saving the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information includes: The actual byte length of the target compressed bitstream is compared with the total length of the slots in the fixed slot information of the image block; If the actual byte length of the target compressed bitstream is less than or equal to the total length of the slot, the target compressed bitstream is written into the corresponding slot, starting from the original physical offset address corresponding to the image block in the image file directory. Zero padding is performed on the remaining tail bytes in the slot that are not occupied by the target compressed bitstream; If the actual byte length of the target compressed bitstream is greater than the total length of the slot, or if an abnormality occurs during the generation of the target compressed bitstream, the write-back operation of the image block is terminated, and the original byte content of the image block at the corresponding original physical offset address remains unchanged and is transparently transmitted out.
7. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 1, characterized in that, Before compressing the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream, the following steps are included: If the original physical offset address corresponding to the initial image block is earlier than the end position of the metadata area, switch to rectified pass-through; If the original physical offset address corresponding to the initial image block is not earlier than the end position of the metadata region, determine whether the current stream position of the byte stream is a non-image block region; If so, pass through the current byte stream; If not, perform the step of compressing the pixel block data corresponding to the image block based on the fixed slot information of the image block corresponding to the currently received byte stream to obtain the target compressed bitstream.
8. The in-situ streaming replacement compression and restoration method within a fixed slot of a GeoTIFF image block as described in claim 1, characterized in that, After saving the target compressed bitstream based on the original physical offset corresponding to the image block in the image file directory and the fixed slot information, the process includes: Receives compressed tag image files as files to be recovered; The file header and image file directory of the file to be recovered are parsed to determine the fixed slot information corresponding to each image block in the file to be recovered. Based on the fixed slot information corresponding to each image block and the current stream position of the byte stream, for each image block in sequence, detect whether the original physical offset position corresponding to the image block contains the preset target compressed bit stream identifier; If the target image block is detected to contain the preset target compressed bitstream identifier, the end marker of the target compressed bitstream is located within the fixed slot range corresponding to the target image block, and the target compressed bitstream located before the end marker is decoded to obtain the recovered pixel block data; The recovered pixel block data is subjected to a preset re-encoding process to generate a TIFF-compatible image block, and the byte length of the TIFF-compatible image block is compared with the total length of the slots in the fixed slot information corresponding to the target image block. If the byte length of the TIFF-compatible image block is less than or equal to the total length of the slot, then starting from the original physical offset address corresponding to the target image block, the TIFF-compatible image block is written into the corresponding slot range, and zero padding is performed on the remaining tail bytes in the slot range that are not occupied by the TIFF-compatible image block. If the preset target compressed bitstream identifier is not detected, the end marker is not located, decoding fails, re-encoding fails, or the byte length of the TIFF compatible image block is greater than the total length of the slot, then the existing byte content of the corresponding image block remains unchanged and is transmitted out transparently.
9. An in-situ streaming replacement compression and restoration device within a fixed slot of a GeoTIFF image block, characterized in that, The in-situ streaming replacement compression and recovery device within the fixed slot of the GeoTIFF image block includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the in-situ streaming replacement compression and recovery method within the fixed slot of the GeoTIFF image block as described in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, it implements the steps of the in-situ streaming replacement compression and recovery method in the fixed slot of the GeoTIFF image block as described in any one of claims 1 to 8.