Skip to content

Commit ab90d43

Browse files
Merge pull request #1979 from postscript-dev/fix_exiv2_sample_thumb_stdout
Add exiv2 extract thumb to stdout (#1934)
2 parents 76a9377 + 4798c6b commit ab90d43

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/actions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,13 @@ namespace Action {
950950
std::cerr << path_ << ": " << _("Image does not contain an Exif thumbnail\n");
951951
}
952952
else {
953+
if ( (Params::instance().target_ & Params::ctStdInOut) != 0 ) {
954+
Exiv2::DataBuf buf = exifThumb.copy();
955+
std::cout.write(reinterpret_cast<char*>(buf.data()),
956+
buf.size());
957+
return 0;
958+
}
959+
953960
std::string thumb = newFilePath(path_, "-thumb");
954961
std::string thumbPath = thumb + thumbExt;
955962
if (dontOverwrite(thumbPath)) return 0;
10.6 KB
Loading

test/data/issue_1934_poc1.exv

17.6 KB
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import system_tests
4+
from system_tests import CaseMeta, path, CopyTmpFiles, check_no_ASAN_UBSAN_errors
5+
6+
@CopyTmpFiles("$data_path/issue_1934_poc1.exv")
7+
class TestExiv2ExtractThumbnailToStdout(metaclass=CaseMeta):
8+
"""
9+
Regression test for 'extracting a thumbnail to stdout' bug described in:
10+
https://github.com/Exiv2/exiv2/issues/1934
11+
"""
12+
url = "https://github.com/Exiv2/exiv2/issues/1934"
13+
14+
filename1 = path("$tmp_path/issue_1934_poc1.exv")
15+
filename2 = path("$tmp_path/issue_1934_poc1-thumb.jpg")
16+
filename3 = path("$data_path/issue_1934_poc1-thumb.jpg")
17+
commands = ["$exiv2 --force --extract t- $filename1 > $filename2",
18+
"cmp $filename2 $filename3"
19+
]
20+
stderr = [""]*2
21+
retval = [0]*2
22+
23+
compare_stdout = check_no_ASAN_UBSAN_errors
24+

0 commit comments

Comments
 (0)