fixed image copy bug... need to test if this is linux-specific...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-02-16 16:47:13 +03:00
parent 4dad475e8c
commit 7046e88ad8

View File

@ -63,8 +63,15 @@ function({url, orientation, flipped}, callback){
var img = new Image var img = new Image
img.onload = function(){ img.onload = function(){
var width = this.naturalWidth // XXX .naturalWidth/.naturalHeight seem to ignore .imageOrientation
var height = this.naturalHeight // setting and orient the image via exif while .width/.height
// seem to respect it but only when atached to DOM...
// XXX for some reason noticed this on Linux, need to test under
// Windows if this is a platform-specific thing...
//var width = this.naturalWidth
//var height = this.naturalHeight
var width = this.width
var height = this.height
var c = document.createElement('canvas') var c = document.createElement('canvas')
c.style.imageOrientation = 'none' c.style.imageOrientation = 'none'
@ -76,12 +83,12 @@ function({url, orientation, flipped}, callback){
// prepare for rotate... // prepare for rotate...
// 90 / 270 // 90 / 270
if(orientation == 90 || orientation == 270){ if(orientation == 90 || orientation == 270){
var w = c.width = this.naturalHeight var w = c.width = height
var h = c.height = this.naturalWidth var h = c.height = width
// 0 / 180 // 0 / 180
} else { } else {
var w = c.width = this.naturalWidth var w = c.width = width
var h = c.height = this.naturalHeight } var h = c.height = height }
// prepare for flip... // prepare for flip...
var x = flipped && flipped.includes('horizontal') ? var x = flipped && flipped.includes('horizontal') ?
-1 -1