Skip to content

Commit

Permalink
add test for generating png file
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellkammer committed Jul 11, 2024
1 parent 3b06951 commit b6ec836
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ jobs:
python test-rec.py -o test-rec--windows-${{ matrix.install-method }}.wav
python test-dependencies.py
python test-notation.py -o 'test-notation-${{ matrix.os }}-${{ matrix.install-method }}-${{ matrix.python-version }}.pdf'
python test-notation.py -o 'test-notation-${{ matrix.os }}-${{ matrix.install-method }}-${{ matrix.python-version }}.png'
cp *.wav ../artifacts
cp *.pdf ../artifacts
cp *.png ../artifacts
# new tests
python test-clip-chords.py
python rosita-centroid.py
Expand Down
15 changes: 8 additions & 7 deletions maelzel/scoring/renderlily.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from maelzel.textstyle import TextStyle
from maelzel._indentedwriter import IndentedWriter
from maelzel import _util
from maelzel import _imgtools
from .common import *
from . import attachment
from . import definitions
Expand Down Expand Up @@ -147,7 +148,7 @@ def lyNote(pitch: pitch_t, baseduration: int, dots: int = 0, tied=False, caution


def markConsecutiveGracenotes(root: Node) -> None:
"""
r"""
Marks consecutive gracenotes by setting their 'graceGroup' attribute inplace
This is needed in lilypond since groups of gracenotes need to
Expand Down Expand Up @@ -191,7 +192,7 @@ def lyArticulation(articulation: attachment.Articulation) -> str:


def lyNotehead(notehead: definitions.Notehead, insideChord=False) -> str:
"""
r"""
Convert a scoring Notehead to its lilypond representation
This uses ``\override`` so it can't be placed inside a chord
Expand Down Expand Up @@ -947,7 +948,7 @@ def makeScore(score: quant.QuantizedScore,
options: RenderOptions,
midi=False
) -> str:
"""
r"""
Convert a list of QuantizedParts to a lilypond score (as str)
Args:
Expand Down Expand Up @@ -1151,14 +1152,14 @@ def write(self, outfile: str, fmt: str = None, removeTemporaryFiles=False) -> No
elif options.cropToContent:
cropfile = f"{tempbase}.cropped.{fmt}"
if os.path.exists(cropfile):
logger.debug(f"Found crop file {cropfile}, using that as output")
logger.debug(f"Found crop file '{cropfile}', using that as output")
tempout = cropfile
else:
logger.debug(f"Asked to generate a crop file, but the file {cropfile} "
f"was not found.")
logger.debug(f"Asked to generate a crop file, but the file '{cropfile}' "
f"was not found. Outfile: {outfile}")
if fmt == 'png':
logger.debug("Trying to generate cropped file via pillow")
_util.imagefileAutocrop(tempout, cropfile, bgcolor="#ffffff")
_imgtools.imagefileAutocrop(tempout, cropfile, bgcolor="#ffffff")
if not os.path.exists(cropfile):
logger.debug("Faild to generate crop file, aborting")

Expand Down

0 comments on commit b6ec836

Please sign in to comment.