kean/DFImageManager

Image decompression and scaling in a single step

Closed this issue · 4 comments

kean commented

Move image decompression to the processing stage which allows to decompress and scale images in a single step

  • Implement image decompression in DFImageProcessor
  • Add shouldDecompressImages property to DFImageProcessor
kean commented

Benchmark (decompression and scaling in a single step is x2-4 times faster, also reduces memory usage)


Decoding JPEG with image size (204, 152), compression quality: (0.30)
Decompression and scaling (x0.5) in separate steps: benchmark [1485871 ns, 1.49 ms, 0.0015 s]
Decompression and scaling (x0.5) in single step: benchmark [503621 ns, 0.50 ms, 0.0005 s]
Decompression and scaling (x0.33) in separate steps: benchmark [1433704 ns, 1.43 ms, 0.0014 s]
Decompression and scaling (x0.33) in single step: benchmark [891871 ns, 0.89 ms, 0.0009 s]


Decoding JPEG with image size (204, 152), compression quality: (0.50)
Decompression and scaling (x0.5) in separate steps: benchmark [1595912 ns, 1.60 ms, 0.0016 s]
Decompression and scaling (x0.5) in single step: benchmark [552787 ns, 0.55 ms, 0.0006 s]
Decompression and scaling (x0.33) in separate steps: benchmark [1320829 ns, 1.32 ms, 0.0013 s]
Decompression and scaling (x0.33) in single step: benchmark [809329 ns, 0.81 ms, 0.0008 s]


Decoding JPEG with image size (204, 152), compression quality: (0.70)
Decompression and scaling (x0.5) in separate steps: benchmark [1363621 ns, 1.36 ms, 0.0014 s]
Decompression and scaling (x0.5) in single step: benchmark [578329 ns, 0.58 ms, 0.0006 s]
Decompression and scaling (x0.33) in separate steps: benchmark [1399162 ns, 1.40 ms, 0.0014 s]
Decompression and scaling (x0.33) in single step: benchmark [880079 ns, 0.88 ms, 0.0009 s]


Decoding JPEG with image size (204, 152), compression quality: (0.90)
Decompression and scaling (x0.5) in separate steps: benchmark [1450787 ns, 1.45 ms, 0.0015 s]
Decompression and scaling (x0.5) in single step: benchmark [736954 ns, 0.74 ms, 0.0007 s]
Decompression and scaling (x0.33) in separate steps: benchmark [1456162 ns, 1.46 ms, 0.0015 s]
Decompression and scaling (x0.33) in single step: benchmark [925704 ns, 0.93 ms, 0.0009 s]


Decoding JPEG with image size (512, 384), compression quality: (0.30)
Decompression and scaling (x0.5) in separate steps: benchmark [7971162 ns, 7.97 ms, 0.0080 s]
Decompression and scaling (x0.5) in single step: benchmark [2417787 ns, 2.42 ms, 0.0024 s]
Decompression and scaling (x0.33) in separate steps: benchmark [7139371 ns, 7.14 ms, 0.0071 s]
Decompression and scaling (x0.33) in single step: benchmark [3815537 ns, 3.82 ms, 0.0038 s]


Decoding JPEG with image size (512, 384), compression quality: (0.50)
Decompression and scaling (x0.5) in separate steps: benchmark [7488704 ns, 7.49 ms, 0.0075 s]
Decompression and scaling (x0.5) in single step: benchmark [2498204 ns, 2.50 ms, 0.0025 s]
Decompression and scaling (x0.33) in separate steps: benchmark [7043912 ns, 7.04 ms, 0.0070 s]
Decompression and scaling (x0.33) in single step: benchmark [3839912 ns, 3.84 ms, 0.0038 s]


Decoding JPEG with image size (512, 384), compression quality: (0.70)
Decompression and scaling (x0.5) in separate steps: benchmark [7537162 ns, 7.54 ms, 0.0075 s]
Decompression and scaling (x0.5) in single step: benchmark [2502204 ns, 2.50 ms, 0.0025 s]
Decompression and scaling (x0.33) in separate steps: benchmark [7329621 ns, 7.33 ms, 0.0073 s]
Decompression and scaling (x0.33) in single step: benchmark [3937121 ns, 3.94 ms, 0.0039 s]


Decoding JPEG with image size (512, 384), compression quality: (0.90)
Decompression and scaling (x0.5) in separate steps: benchmark [7187954 ns, 7.19 ms, 0.0072 s]
Decompression and scaling (x0.5) in single step: benchmark [2909496 ns, 2.91 ms, 0.0029 s]
Decompression and scaling (x0.33) in separate steps: benchmark [7271704 ns, 7.27 ms, 0.0073 s]
Decompression and scaling (x0.33) in single step: benchmark [4046037 ns, 4.05 ms, 0.0040 s]


Decoding JPEG with image size (1024, 768), compression quality: (0.30)
Decompression and scaling (x0.5) in separate steps: benchmark [24884996 ns, 24.88 ms, 0.0249 s]
Decompression and scaling (x0.5) in single step: benchmark [5283704 ns, 5.28 ms, 0.0053 s]
Decompression and scaling (x0.33) in separate steps: benchmark [25489829 ns, 25.49 ms, 0.0255 s]
Decompression and scaling (x0.33) in single step: benchmark [10882996 ns, 10.88 ms, 0.0109 s]


Decoding JPEG with image size (1024, 768), compression quality: (0.50)
Decompression and scaling (x0.5) in separate steps: benchmark [24778121 ns, 24.78 ms, 0.0248 s]
Decompression and scaling (x0.5) in single step: benchmark [5259287 ns, 5.26 ms, 0.0053 s]
Decompression and scaling (x0.33) in separate steps: benchmark [24489454 ns, 24.49 ms, 0.0245 s]
Decompression and scaling (x0.33) in single step: benchmark [11284537 ns, 11.28 ms, 0.0113 s]


Decoding JPEG with image size (1024, 768), compression quality: (0.70)
Decompression and scaling (x0.5) in separate steps: benchmark [23987912 ns, 23.99 ms, 0.0240 s]
Decompression and scaling (x0.5) in single step: benchmark [5286537 ns, 5.29 ms, 0.0053 s]
Decompression and scaling (x0.33) in separate steps: benchmark [23690746 ns, 23.69 ms, 0.0237 s]
Decompression and scaling (x0.33) in single step: benchmark [10921329 ns, 10.92 ms, 0.0109 s]


Decoding JPEG with image size (1024, 768), compression quality: (0.90)
Decompression and scaling (x0.5) in separate steps: benchmark [24384621 ns, 24.38 ms, 0.0244 s]
Decompression and scaling (x0.5) in single step: benchmark [5255579 ns, 5.26 ms, 0.0053 s]
Decompression and scaling (x0.33) in separate steps: benchmark [24718996 ns, 24.72 ms, 0.0247 s]
Decompression and scaling (x0.33) in single step: benchmark [11069746 ns, 11.07 ms, 0.0111 s]


Decoding JPEG with image size (2048, 1536), compression quality: (0.30)
Decompression and scaling (x0.5) in separate steps: benchmark [91214121 ns, 91.21 ms, 0.0912 s]
Decompression and scaling (x0.5) in single step: benchmark [16776121 ns, 16.78 ms, 0.0168 s]
Decompression and scaling (x0.33) in separate steps: benchmark [94461454 ns, 94.46 ms, 0.0945 s]
Decompression and scaling (x0.33) in single step: benchmark [40004704 ns, 40.00 ms, 0.0400 s]


Decoding JPEG with image size (2048, 1536), compression quality: (0.50)
Decompression and scaling (x0.5) in separate steps: benchmark [90625662 ns, 90.63 ms, 0.0906 s]
Decompression and scaling (x0.5) in single step: benchmark [16638412 ns, 16.64 ms, 0.0166 s]
Decompression and scaling (x0.33) in separate steps: benchmark [93974454 ns, 93.97 ms, 0.0940 s]
Decompression and scaling (x0.33) in single step: benchmark [39846662 ns, 39.85 ms, 0.0398 s]


Decoding JPEG with image size (2048, 1536), compression quality: (0.70)
Decompression and scaling (x0.5) in separate steps: benchmark [91874246 ns, 91.87 ms, 0.0919 s]
Decompression and scaling (x0.5) in single step: benchmark [17422912 ns, 17.42 ms, 0.0174 s]
Decompression and scaling (x0.33) in separate steps: benchmark [95948537 ns, 95.95 ms, 0.0959 s]
Decompression and scaling (x0.33) in single step: benchmark [44032662 ns, 44.03 ms, 0.0440 s]


Decoding JPEG with image size (2048, 1536), compression quality: (0.90)
Decompression and scaling (x0.5) in separate steps: benchmark [91005912 ns, 91.01 ms, 0.0910 s]
Decompression and scaling (x0.5) in single step: benchmark [17017871 ns, 17.02 ms, 0.0170 s]
Decompression and scaling (x0.33) in separate steps: benchmark [92661079 ns, 92.66 ms, 0.0927 s]
Decompression and scaling (x0.33) in single step: benchmark [39704329 ns, 39.70 ms, 0.0397 s]


Decoding JPEG with image size (2560, 1920), compression quality: (0.30)
Decompression and scaling (x0.5) in separate steps: benchmark [140827746 ns, 140.83 ms, 0.1408 s]
Decompression and scaling (x0.5) in single step: benchmark [25092912 ns, 25.09 ms, 0.0251 s]
Decompression and scaling (x0.33) in separate steps: benchmark [144833287 ns, 144.83 ms, 0.1448 s]
Decompression and scaling (x0.33) in single step: benchmark [62724871 ns, 62.72 ms, 0.0627 s]


Decoding JPEG with image size (2560, 1920), compression quality: (0.50)
Decompression and scaling (x0.5) in separate steps: benchmark [140110912 ns, 140.11 ms, 0.1401 s]
Decompression and scaling (x0.5) in single step: benchmark [25110412 ns, 25.11 ms, 0.0251 s]
Decompression and scaling (x0.33) in separate steps: benchmark [143194704 ns, 143.19 ms, 0.1432 s]
Decompression and scaling (x0.33) in single step: benchmark [63018037 ns, 63.02 ms, 0.0630 s]


Decoding JPEG with image size (2560, 1920), compression quality: (0.70)
Decompression and scaling (x0.5) in separate steps: benchmark [139273662 ns, 139.27 ms, 0.1393 s]
Decompression and scaling (x0.5) in single step: benchmark [25201162 ns, 25.20 ms, 0.0252 s]
Decompression and scaling (x0.33) in separate steps: benchmark [145002121 ns, 145.00 ms, 0.1450 s]
Decompression and scaling (x0.33) in single step: benchmark [63134787 ns, 63.13 ms, 0.0631 s]


Decoding JPEG with image size (2560, 1920), compression quality: (0.90)
Decompression and scaling (x0.5) in separate steps: benchmark [140843787 ns, 140.84 ms, 0.1408 s]
Decompression and scaling (x0.5) in single step: benchmark [26034746 ns, 26.03 ms, 0.0260 s]
Decompression and scaling (x0.33) in separate steps: benchmark [144372496 ns, 144.37 ms, 0.1444 s]
Decompression and scaling (x0.33) in single step: benchmark [63767412 ns, 63.77 ms, 0.0638 s]

kean commented

Done

simply amazing work @kean

kean commented

thanks :)