All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 4m55s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s
FlexiPRINT's Spot OK 1 makes the white from transparency and reads it reliably only from a PNG (Dropstar's third round, item 13): each order item is now DTF-N-item-I.png, 300 DPI, RGBA on a transparent background, with its footer; a film over 15 m leaves as DTF-N-item-I-pK.png parts, each with "Parte K/N" in its footer, cut between pieces of loose art when it can be. app/printpng.py never holds a whole sheet: the film is composed and written in bands. Pillow encodes each band (it picks the PNG filters) and one zlib stream takes them; a long PNG sheet is read band by band by wrapping its compressed rows as small PNGs; a PDF page is drawn band by band at 300 DPI by PDFium (pypdfium2, a self-contained wheel); loose art is turned and scaled once. A 57 x 220 cm sheet peaks at 191 MB, a 15 m film at 279 MB. The parts of an item are dtf_local.print_parts (print_files.upload_id stays the first); the board, the final approval, the folders and the cleanup see every part, and the Kanban approves and downloads them all. A large PNG or PDF is now generated like any other; only other large formats go to hand preparation, and the original no longer stands in as the print file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.6 KiB
Python
32 lines
1.6 KiB
Python
"""Large files: the format check. A large PNG or PDF sheet is read band by band
|
|
(app/printpng.py), so it no longer passes as its own print file."""
|
|
import unittest
|
|
|
|
from app.scanning import check_large, format_matches, real_name
|
|
|
|
|
|
class FormatTest(unittest.TestCase):
|
|
def test_bytes_must_match_the_name(self):
|
|
self.assertTrue(format_matches('A.PNG', b'\x89PNG\r\n\x1a\n'))
|
|
self.assertTrue(format_matches('a.tiff', b'MM\x00*'))
|
|
self.assertFalse(format_matches('a.png', b'%PDF-1.4'))
|
|
self.assertFalse(format_matches('semextensao', b'\x89PNG\r\n\x1a\n'))
|
|
|
|
def test_the_content_names_the_file(self):
|
|
# Dropstar's rule D-13: a ".cdr" that is a PDF is a PDF, a JPG called
|
|
# ".png" is a JPG; a name its content agrees with stays (".ai" is a PDF inside).
|
|
self.assertEqual(real_name('folha.cdr', b'%PDF-1.7'), 'folha.pdf')
|
|
self.assertEqual(real_name('arte.png', b'\xff\xd8\xff\xe0'), 'arte.jpg')
|
|
self.assertEqual(real_name('semextensao', b'%PDF-1.4'), 'semextensao.pdf')
|
|
for name, head in (('folha.cdr', b'RIFF\0\0\0\0CDR9'), ('arte.ai', b'%PDF-1.5'), ('arte.ai', b'%!PS-Adobe'),
|
|
('foto.jpeg', b'\xff\xd8\xff'), ('arte.png', b'GIF89a')):
|
|
self.assertEqual(real_name(name, head), name, (name, head))
|
|
|
|
def test_a_large_file_passes_on_its_content(self):
|
|
self.assertEqual(check_large(b'%PDF-1.7', {'name': 'folha.cdr'})[0], 'clean')
|
|
self.assertEqual(check_large(b'MZ\x90\x00', {'name': 'folha.cdr'})[0], 'rejected')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|