@@ -64,6 +64,8 @@ export default async function compress (file, options) {
64
64
65
65
const origExceedMaxSize = tempFile . size > maxSizeByte
66
66
const sizeBecomeLarger = tempFile . size > file . size
67
+ // console.log('original file size', file.size)
68
+ // console.log('current file size', tempFile.size)
67
69
68
70
// check if we need to compress or resize
69
71
if ( ! origExceedMaxSize && ! sizeBecomeLarger ) {
@@ -81,6 +83,8 @@ export default async function compress (file, options) {
81
83
while ( remainingTrials -- && ( currentSize > maxSizeByte || currentSize > sourceSize ) ) {
82
84
const newWidth = origExceedMaxSize ? canvas . width * 0.95 : canvas . width
83
85
const newHeight = origExceedMaxSize ? canvas . height * 0.95 : canvas . height ;
86
+ // console.log('current width', newWidth);
87
+ // console.log('current height', newHeight);
84
88
[ newCanvas , ctx ] = getNewCanvasAndCtx ( newWidth , newHeight )
85
89
86
90
ctx . drawImage ( canvas , 0 , 0 , newWidth , newHeight )
@@ -98,8 +102,6 @@ export default async function compress (file, options) {
98
102
setProgress ( Math . min ( 99 , Math . floor ( ( renderedSize - currentSize ) / ( renderedSize - maxSizeByte ) * 100 ) ) )
99
103
}
100
104
101
- // garbage clean canvas for safari
102
- // ref: https://bugs.webkit.org/show_bug.cgi?id=195325
103
105
cleanupCanvasMemory ( canvas )
104
106
cleanupCanvasMemory ( newCanvas )
105
107
cleanupCanvasMemory ( maxWidthOrHeightFixedCanvas )
0 commit comments