Skip to content

Commit e38dee8

Browse files
author
Chris Dowling
committed
Allow image/jpg as well as image/jpeg
Passing a jpg data URI with the wrong data header currently causes an error from getJpegSize. This commit replaces 'jpg' with 'jpeg' in the data URI and removes that error
1 parent 5502399 commit e38dee8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

jspdf.plugin.addimage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ var getJpegSize = function(imgData) {
140140

141141
jsPDFAPI.addImage = function(imageData, format, x, y, w, h) {
142142
'use strict'
143+
if(imageData.substr(11,4).indexOf('jpeg') < 0){
144+
imageData = imageData.substr(0,15).replace('jpg','jpeg')+imageData.substr(15);
145+
}
143146
if (typeof imageData === 'object' && imageData.nodeType === 1) {
144147
var canvas = document.createElement('canvas');
145148
canvas.width = imageData.clientWidth;

0 commit comments

Comments
 (0)