Skip to content

Conversation

@bogdan
Copy link

@bogdan bogdan commented Nov 9, 2025

  • Updated README.md to include instructions for reading metadata from IO objects.
  • Modified lib/exiftool.rb to handle IO objects as input, allowing ExifTool to infer file type from content.
  • Utilized Open3.popen3 for executing shell commands, ensuring proper process management and error handling.
  • Added a test case in test/exiftool_test.rb.

Fixes #52

- Updated `README.md` to include instructions for reading metadata from IO objects.
- Modified `lib/exiftool.rb` to handle IO objects as input, allowing ExifTool to infer file type from content.
- Utilized `Open3.popen3` for executing shell commands, ensuring proper process management and error handling.
- Added a test case in `test/exiftool_test.rb`.
@bogdan
Copy link
Author

bogdan commented Dec 9, 2025

@morozgrafix any chance to merge and release this?

@morozgrafix
Copy link
Member

morozgrafix commented Dec 9, 2025 via email

Copy link
Member

@morozgrafix morozgrafix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting this PR. I'm unsure if 64KB restriction only applies to JPEG files. Have you had a chance to test it with other image/video files?

begin
Open3.popen3(*args) do |stdin, stdout, _stderr, wait_thr|
if io_input
# Reading first 64KB.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 64KB restriction only applies to JPEG format? Any idea on similar restriction in regards to other image and video formats?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a little bit more digging and found some interesting info related to that 64KB limit here. https://exiftool.org/commentary.html#JPEG
I'm wondering if limiting io input to first 64KB would be advisable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is some misconception in the comment. I sends the whole file in 64KB chunks.

LLM suggests a better way of doing it using:

IO.copy_stream(io_input, stdin)

Quote:

What IO.copy_stream does

  • Streams efficiently from one IO to another

  • Uses optimal chunk size internally

  • Stops automatically when either:

    • io_input reaches EOF, or
    • stdin (exiftool) closes early

When exiftool closes stdin early (because it has enough data),
IO.copy_stream simply stops and returns — no broken pipe errors.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exiftool shell command call is inefficient

2 participants