-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1968 from Exiv2/mergify/bp/0.27-maintenance/pr-1958
Canon cr3 previews (backport #1958)
- Loading branch information
Showing
4 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import system_tests | ||
import unittest | ||
from tempfile import TemporaryDirectory | ||
import shutil | ||
import hashlib | ||
import os | ||
|
||
# test needs system_tests.BT.vv['enable_bmff']=1 | ||
bSkip=system_tests.BT.verbose_version().get('enable_bmff')!='1' | ||
|
||
if bSkip: | ||
raise unittest.SkipTest('*** requires enable_bmff=1 ***') | ||
|
||
file_basename = 'Canon-R6-pruned.CR3' | ||
previews_expected = ( | ||
('Canon-R6-pruned-preview1.jpg', 'a182ef12ac883309b4dfc66b87eac1891286d3ae'), | ||
('Canon-R6-pruned-preview2.jpg', '524a07f1797854e349ae140e2682ba37147fa6b2') | ||
) | ||
|
||
class issue_1893_cr3_preview(metaclass=system_tests.CaseMeta): | ||
""" | ||
Check that THMB and PRVW images are extracted from Canon CR3 files | ||
""" | ||
url = "https://github.com/Exiv2/exiv2/issues/1893" | ||
filename = "$data_path/" + file_basename | ||
commands=[] # see setUp() | ||
|
||
if bSkip: | ||
retval=[] | ||
stdin=[] | ||
stderr=[] | ||
stdout=[] | ||
print("*** test skipped. requires enable_bmff=1***") | ||
else: | ||
retval = [ 0, 0] | ||
stderr = [ "",""] | ||
stdin = [ "", ""] | ||
stdout = ["""Preview 1: image/jpeg, 160x120 pixels, 16005 bytes | ||
Preview 2: image/jpeg, 1620x1080 pixels, 389450 bytes | ||
""", ""] | ||
|
||
def post_tests_hook(self): | ||
if self.commands: | ||
for j, sha1 in previews_expected: | ||
p = os.path.join(self.preview_image_tmp_dir.name, j) | ||
self.assertTrue(os.path.isfile(p)) | ||
h = hashlib.sha1(open(p, 'rb').read()).hexdigest() | ||
self.assertEqual(h, sha1) | ||
|
||
def setUp(self): | ||
if bSkip: | ||
return | ||
# Avoid polluting the test data directory with extracted previews | ||
self.preview_image_tmp_dir = TemporaryDirectory() | ||
shutil.copy(self.expand_variables(self.filename), | ||
self.preview_image_tmp_dir.name) | ||
p = os.path.join( | ||
self.preview_image_tmp_dir.name, | ||
file_basename) | ||
self.commands = [ | ||
self.expand_variables("$exiv2 -pp ") + p, | ||
self.expand_variables("$exiv2 -ep ") + p | ||
] |