Skip to content

Commit

Permalink
Fix loading of SVG as source artwork. Fixes romannurik#139. Fixes rom…
Browse files Browse the repository at this point in the history
  • Loading branch information
romannurik committed Jan 30, 2017
1 parent 8e7f040 commit aba5358
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/scripts/studio/forms/ImageField.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,24 @@ export class ImageField extends Field {
Util.loadImageFromUri(this.imageParams_.uri)
.then(img => {
this.valueOrigImg_ = img;
var size = {
let origSize = {
w: img.naturalWidth,
h: img.naturalHeight
};
let size = Object.assign({}, origSize);
if (this.imageParams_.isSvg && this.params_.maxFinalSize) {
size = Object.assign({}, this.params_.maxFinalSize);
if (size.w / size.h > this.params_.maxFinalSize.w / this.params_.maxFinalSize.h) {
size.w = this.params_.maxFinalSize.w;
size.h = size.w * origSize.h / origSize.w;
} else {
size.h = this.params_.maxFinalSize.h;
size.w = size.h * origSize.w / origSize.h;
}
}
var ctx = imagelib.Drawing.context(size);
ctx.drawImage(img, 0, 0);
let ctx = imagelib.Drawing.context(size);
ctx.drawImage(img,
0, 0, origSize.w, origSize.h,
0, 0, size.w, size.h);
resolve({ctx, size});
});
} else {
Expand Down

0 comments on commit aba5358

Please sign in to comment.