Coverage for pyguymer3/image/dot2png.py: 11%

9 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-08 18:47 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def dot2png( 

5 dot, 

6 png, 

7 /, 

8 *, 

9 chunksize = 1048576, 

10 debug = __debug__, 

11 dotPath = None, 

12 exiftoolPath = None, 

13 gifsiclePath = None, 

14 jpegtranPath = None, 

15 optipngPath = None, 

16 strip = False, 

17 timeout = 60.0, 

18): 

19 """ 

20 chunksize : int, optional 

21 the size of the chunks of any files which are read in (in bytes) 

22 """ 

23 

24 # Import standard modules ... 

25 import shutil 

26 import subprocess 

27 

28 # Import sub-functions ... 

29 from .optimise_image import optimise_image 

30 

31 # ************************************************************************** 

32 

33 # Try to find the paths if the user did not provide them ... 

34 if dotPath is None: 

35 dotPath = shutil.which("dot") 

36 assert dotPath is not None, "\"dot\" is not installed" 

37 

38 # Create image ... 

39 subprocess.run( 

40 [ 

41 dotPath, 

42 "-Tpng", 

43 dot, 

44 "-o", png, 

45 ], 

46 check = True, 

47 encoding = "utf-8", 

48 stderr = subprocess.DEVNULL, 

49 stdout = subprocess.DEVNULL, 

50 timeout = timeout, 

51 ) 

52 

53 # Optimise PNG ... 

54 optimise_image( 

55 png, 

56 chunksize = chunksize, 

57 debug = debug, 

58 exiftoolPath = exiftoolPath, 

59 gifsiclePath = gifsiclePath, 

60 jpegtranPath = jpegtranPath, 

61 optipngPath = optipngPath, 

62 pool = None, 

63 strip = strip, 

64 timeout = timeout, 

65 )