File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,13 +235,9 @@ Exif orientation values to correctly display the letter F:
235235 var ctx = canvas . getContext ( '2d' )
236236 var width = canvas . width
237237 var height = canvas . height
238- var styleWidth = canvas . style . width
239- var styleHeight = canvas . style . height
240238 if ( orientation > 4 ) {
241239 canvas . width = height
242240 canvas . height = width
243- canvas . style . width = styleHeight
244- canvas . style . height = styleWidth
245241 }
246242 switch ( orientation ) {
247243 case 2 :
Original file line number Diff line number Diff line change 220220 }
221221 if ( useCanvas ) {
222222 pixelRatio = options . pixelRatio
223- if ( pixelRatio > 1 ) {
224- if ( parseInt ( img . style . width , 10 ) === width / pixelRatio ) {
225- // Source image is already scaled according to device pixel ratio
226- canvas . style . width = destWidth / pixelRatio + 'px'
227- canvas . style . height = destHeight / pixelRatio + 'px'
228- } else {
229- canvas . style . width = destWidth + 'px'
230- canvas . style . height = destHeight + 'px'
231- destWidth *= pixelRatio
232- destHeight *= pixelRatio
233- canvas . getContext ( '2d' ) . scale ( pixelRatio , pixelRatio )
234- }
223+ if (
224+ pixelRatio > 1 &&
225+ // Check if image has not yet device pixel ratio applied:
226+ parseInt ( img . style . width , 10 ) !== width / pixelRatio
227+ ) {
228+ destWidth *= pixelRatio
229+ destHeight *= pixelRatio
230+ canvas . getContext ( '2d' ) . scale ( pixelRatio , pixelRatio )
235231 }
236232 downsamplingRatio = options . downsamplingRatio
237233 if (
278274 canvas . width = destWidth
279275 canvas . height = destHeight
280276 loadImage . transformCoordinates ( canvas , options , data )
277+ if ( pixelRatio > 1 ) {
278+ canvas . style . width = canvas . width / pixelRatio + 'px'
279+ canvas . style . height = canvas . height / pixelRatio + 'px'
280+ }
281281 return loadImage . renderImageToCanvas (
282282 canvas ,
283283 img ,
You can’t perform that action at this time.
0 commit comments