View Issue Details

IDProjectCategoryView StatusLast Update
0000515fileGeneralpublic2024-04-08 19:29
Reportermarcoribeiro Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version5.45 
Summary0000515: Magic inserts linebreaks inside TIFF descriptions, making it not possible to correcly split lines
DescriptionWhen I use the flag 'MAGIC_CONTINUE', I expect each detection to be on a separate line, but on some cases it also adds a linebreak followed by "- " inside a detection from a TIFF buffer

Here is an example, using the flags MAGIC_CONTINUE | MAGIC_RAW (also happens with MAGIC_RAW is not set, but with "\n" replaced with "\012"):
'TIFF image data, little-endian, direntries=18, height=434, bps=14534, compression=none, PhotometricInterpretation=RGB, name=/home/marta/Desktop/www/file ex/files/grafa/tiff/file_example_TIFF_1MB.tiff, orientation=upper-left\n- , width=650\n- data'

Note that the "width=650" should be on the previous line (or at least, it should not have the "- " before it)

This (attached) TIFF image was downloaded from https://file-examples.com/index.php/sample-images-download/sample-tiff-download/ (the 1MB version)
Steps To ReproduceUsing the file-magic package for Python:

-------------------------------------------------
import magic
from pathlib import Path

magic_desc = magic.open(magic.MAGIC_CONTINUE | magic.MAGIC_RAW)
assert magic_desc.load() == 0

data = Path("file_example_TIFF_1MB").read_bytes()
print(magic_desc.buffer(data))
-------------------------------------------------

Using the python-magic package:

-------------------------------------------------
import magic
from pathlib import Path

magic_desc = magic.Magic(keep_going=True, raw=True)
data = Path("file_example_TIFF_1MB").read_bytes()
print(magic_desc.from_buffer(data))
-------------------------------------------------

Both cases should output:
TIFF image data, little-endian, direntries=18, height=434, bps=14534, compression=none, PhotometricInterpretation=RGB, name=/home/marta/Desktop/www/file ex/files/grafa/tiff/file_example_TIFF_1MB.tiff, orientation=upper-left
- , width=650
- data
TagsNo tags attached.

Activities

marcoribeiro

2024-04-08 19:13

reporter  

file_example_TIFF_1MB.tiff (1,131,930 bytes)

Issue History

Date Modified Username Field Change
2024-04-08 19:13 marcoribeiro New Issue
2024-04-08 19:13 marcoribeiro File Added: file_example_TIFF_1MB.tiff