Browser image loop decodes, draws, encodes and saves photos one at a time, with per-step timings
A developer reviewed a teammate's in-browser loop that converts a folder of product photos to JPEGs for an upload form, measuring each step with timers. The loop processes one photo at a time and releases the decoded bitmap after drawing it to a canvas, keeping memory low compared with decoding everything first, which had reached about 5,192 MB by photo 100. Tests on six valid photos plus two invalid files showed that corrupt images are caught at the decode step by a try/catch, so processing continues rather than stopping early. Measurements across two runs put decoding at roughly 24–29 ms per photo and encoding at 46–52 ms, with drawing and saving much faster. The author notes that the progress display should show each file's label, since files arrive in input order rather than sorted order.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in