define(["ember"],function(a){var b=function(b,c,d){return c=c||320,d=d||180,new a.RSVP.Promise(function(a){var e=document.createElement("canvas"),f=e.getContext("2d"),g=new Image,h=URL.createObjectURL(b);g.onload=function(){var b=g.naturalHeight,i=g.naturalWidth,j=b,k=i;i*d>b*c?i>c&&(k=c,j=k*b/i):b>d&&(j=d,k=j*i/b),e.width=k,e.height=j,f.drawImage(g,0,0,k,j);var l=e.toDataURL("image/jpg");f.clearRect(0,0,e.width,e.height),URL.revokeObjectURL(h),g.src="",a(l)},g.src=h})},c=function(a){var b=a;return/^\d+$/.test(a)&&(b=a+"px"),b};return a.Component.extend({tagName:"img",attributeBindings:["style"],style:function(){var a="";return this.get("width")&&(a+="width:"+c(this.get("width"))+";"),this.get("height")&&(a+="height:"+c(this.get("height"))+";"),a}.property("width","height"),domReady:function(){var a=this,c=a.get("src"),d=a.$()[0],e=c;a.$().error(function(){d.src="../assets/images/pictures.png"}),a.get("nocompress")?c instanceof Blob&&(e=URL.createObjectURL(c),d.onload=function(){URL.revokeObjectURL(e)}):(/^(file:\/\/\/)?[a-zA-Z]:(\\|\/)/.test(c)&&(e=new File(c,"name123")),e instanceof Blob?b(e,this.get("maxWidth"),this.get("maxHeight")).then(function(a){d.src=a}):0==e.indexOf("http")&&this.get("thumbq")&&(e="%@@%@w_%@h_%@q.jpg".fmt(e.replace(/@\d+w_\d+h_\d+q.jpg$/,""),this.get("maxWidth"),this.get("maxHeight"),this.get("thumbq")))),e instanceof Blob||(d.src=e)}.on("didInsertElement"),recycleImg:function(){this.$()[0].src=""}.on("willDestroyElement")})});