Fix image uploads being perfectly white when canvas read access is blocked (#11499)
Fixes #11496
This commit is contained in:
		
					parent
					
						
							
								27a0d02d0d
							
						
					
				
			
			
				commit
				
					
						111a0628fc
					
				
			
		
					 1 changed files with 8 additions and 0 deletions
				
			
		|  | @ -67,6 +67,14 @@ const processImage = (img, { width, height, orientation, type = 'image/png' }) = | |||
| 
 | ||||
|   context.drawImage(img, 0, 0, width, height); | ||||
| 
 | ||||
|   // The Tor Browser and maybe other browsers may prevent reading from canvas
 | ||||
|   // and return an all-white image instead. Assume reading failed if the resized
 | ||||
|   // image is perfectly white.
 | ||||
|   const imageData = context.getImageData(0, 0, width, height); | ||||
|   if (imageData.every(value => value === 255)) { | ||||
|     throw 'Failed to read from canvas'; | ||||
|   } | ||||
| 
 | ||||
|   canvas.toBlob(resolve, type); | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue