Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from .._stream_info import StreamInfo

ACCEPTED_MIME_TYPE_PREFIXES = [
"image/gif",
"image/jpeg",
"image/png",
]

ACCEPTED_FILE_EXTENSIONS = [".jpg", ".jpeg", ".png"]
ACCEPTED_FILE_EXTENSIONS = [".gif", ".jpg", ".jpeg", ".png"]


class ImageConverter(DocumentConverter):
Expand Down
Binary file added packages/markitdown/tests/test_files/test.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions packages/markitdown/tests/test_module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,26 @@ def test_markitdown_llm_parameters() -> None:
assert messages[0]["content"][0]["text"] == test_prompt


def test_markitdown_gif_image() -> None:
"""Test that GIF images are accepted by the ImageConverter (issue #1103)."""
mock_client = MagicMock()
mock_response = MagicMock()
mock_response.choices = [MagicMock(message=MagicMock(content="A red pixel."))]
mock_client.chat.completions.create.return_value = mock_response

markitdown = MarkItDown(llm_client=mock_client, llm_model="gpt-4o")

# Must not raise UnsupportedFormatException
result = markitdown.convert(os.path.join(TEST_FILES_DIR, "test.gif"))
assert "A red pixel." in result.text_content

# The image must be sent to the LLM with the correct content type
call_args = mock_client.chat.completions.create.call_args
messages = call_args[1]["messages"]
image_url = messages[0]["content"][1]["image_url"]["url"]
assert image_url.startswith("data:image/gif;base64,")


@pytest.mark.skipif(
skip_llm,
reason="do not run llm tests without a key",
Expand Down