Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dear-image

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dear-image - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

index.js

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).DearImage=n()}(this,function(){"use strict";var t=function(t){this.context=t},n={canvas:{configurable:!0},sizeX:{configurable:!0},sizeY:{configurable:!0},size:{configurable:!0},minSize:{configurable:!0},maxSize:{configurable:!0}};function e(){return document.createElement("canvas")}function r(){return new OffscreenCanvas}function i(){try{return e()}catch(t){}try{return r()}catch(t){}try{return new(0,require("canvas").Canvas)}catch(t){}throw new Error}function a(t){return Number.isFinite(t)}function s(t){return a(t)&&t>0}n.canvas.get=function(){return this.context.canvas},n.sizeX.get=function(){return this.canvas.width},n.sizeY.get=function(){return this.canvas.height},n.size.get=function(){return{x:this.sizeX,y:this.sizeY}},n.minSize.get=function(){return Math.min(this.sizeX,this.sizeY)},n.maxSize.get=function(){return Math.max(this.sizeX,this.sizeY)},Object.defineProperties(t.prototype,n),t.blank=function(t,n){t=s(t)?Math.round(t):0,n=s(n)?Math.round(n):0;var e=i();return e.width=t,e.height=n,new this(e.getContext("2d"))},t.isDearImage=(t.is=function(t){return t instanceof this}).bind(t);var o="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;function u(t){return function(t){var n=o.HTMLCanvasElement;return!!n&&t instanceof n}(t)||function(t){var n=o.OffscreenCanvas;return!!n&&t instanceof n}(t)||function(t){try{return t instanceof require("canvas").Canvas}catch(t){}return!1}(t)}function c(t){return"string"==typeof t}var f=/^data:(.*?)(;base64)?,(.*)$/;var h={parse:function(t){if(c(t)){var n=f.exec(t);if(n){var e=n[1],r=n[3];return{type:e,data:r,get isEmpty(){return!r},toString:function(){return t}}}}return!1}};function l(){return new Image}function v(){try{return l()}catch(t){}try{return new(0,require("canvas").Image)}catch(t){}throw new Error}function p(t){return function(t){var n=o.HTMLImageElement;return!!n&&t instanceof n}(t)||function(t){try{return t instanceof require("canvas").Image}catch(t){}return!1}(t)}function z(t){return new Promise(function(n){n(t())})}function m(t){var n=o.ImageData;return!!n&&t instanceof n||function(t){try{return t instanceof require("canvas").ImageData}catch(t){}return!1}(t)}var d=function(t){var n=this.blank(t.width,t.height);return n.sizeX&&n.sizeY&&n.context.putImageData(t,0,0),n},g=function(t,n,e){var r=this.blank(n,e);return r.sizeX&&r.sizeY&&r.context.drawImage(t,0,0),r},y=function(t){return g.call(this,t,t.width,t.height)},w=function(t){return g.call(this,t,t.naturalWidth,t.naturalHeight)},b=function(t){return y.call(this,t.canvas)},x=function(n){if(t.is(n))return b.call(this,n);if(m(n))return d.call(this,n);if(u(n))return y.call(this,n);if(p(n))return w.call(this,n);throw new TypeError},X=function(t){var n,e=this;return(n=t,z(function(){if(!n.complete)return new Promise(function(t,e){n.onload=t,n.onerror=e}).finally(function(){n.onload=null,n.onerror=null})})).then(function(){return w.call(e,t)})},Y=function(t){var n=v();return n.src=t,X.call(this,n)},M=function(t){return t.length?Y.call(this,t):this.blank()},I=function(t){var n=this;if(!t.size)return this.blank();var e=URL.createObjectURL(t);return z(function(){return Y.call(n,e)}).finally(function(){URL.revokeObjectURL(e)})},C=function(t){return t.isEmpty?this.blank():Y.call(this,""+t)},E=function(t){var n=h.parse(t);return n?C.call(this,n):Y.call(this,t)},L=function(t){return Y.call(this,""+t)};function S(t){if(t){var n=typeof t;return"object"===n||"function"===n}return!1}function O(){}Object.assign(t,{from:x,loadFrom:function(t){var n=this;return z(function(){return c(t)?E.call(n,t):function(t){var n=o.URL;return!!n&&t instanceof n}(t)?L.call(n,t):function(t){var n=o.Buffer;return!!n&&t instanceof n}(t)?M.call(n,t):function(t){var n=o.Blob;return!!n&&t instanceof n}(t)?I.call(n,t):p(t)?X.call(n,t):x.call(n,t)})}}),t.fromExcept=function(t){return this.is(t)?t:this.from(t)},t.loadFromExcept=function(t){var n=this;return z(function(){return n.is(t)?t:n.loadFrom(t)})};var k="sans-serif",D="normal";function j(t){return c(t)&&!function(t){return!t}(t)}var U=new Set([D,"italic","oblique"]);var T=new Set([D,"small-caps"]);function B(t,n,e,r,i){return(r?t>=n:t>n)&&(i?t<=e:t<e)}function R(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return function(t){return"number"==typeof t&&!Number.isNaN(t)}(t)&&B.apply(void 0,[t].concat(n))}var q=new Set([D,"bold"]);function F(t){var n=k,e=D,r=D,i=D;return S(t)&&(n=function(t){return j(t)?t:k}(t.family),e=function(t){return j(t)&&(t=t.toLowerCase(),U.has(t))?t:D}(t.style),r=function(t){return j(t)&&(t=t.toLowerCase(),T.has(t))?t:D}(t.variant),i=function(t){if(j(t)){if(t=t.toLowerCase(),q.has(t))return t}else if(R(t,1,1e3,!0,!0))return t=Math.round(t);return D}(t.weight)),Object.assign(new O,{family:n,style:e,variant:r,weight:i})}var H={default:F(),from:F,fromExcept:function(t){return function(t){return t instanceof O}(t)?t:F(t)}};function P(){}var N=10;function A(t){return a(t)&&!function(t){return t<0}(t)}function W(t){var n=H.from(t),e=n.family,r=n.style,i=n.variant,a=n.weight,s=N;return S(t)&&(s=function(t){return A(t)?t=Math.round(t):N}(t.size)),Object.assign(new P,{family:e,size:s,style:r,variant:i,weight:a,toCSS:function(){return[r,i,a,s+"px",'"'+e+'"'].join(" ")}})}var $={default:W(),from:W,fromExcept:function(t){return function(t){return t instanceof P}(t)?t:W(t)}};function G(t){return function(t){return void 0===t}(t)||function(t){return null===t}(t)}function J(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return t.call.apply(t,[this].concat(n,e))}}t.measureText=function(t,n){t=G(t)?"":""+t;var e=this.blank().context;return e.font=$.fromExcept(n).toCSS(),e.measureText(t)},t.prototype.crop=function(t,n,e,r){if(a(t)?(t=Math.round(t))<0&&(t+=this.sizeX):t=0,a(n)?(n=Math.round(n))<0&&(n+=this.sizeY):n=0,a(e)?(e=Math.round(e))<0&&(t+=e,e*=-1):e=this.sizeX,a(r)?(r=Math.round(r))<0&&(n+=r,r*=-1):r=this.sizeY,t||n||e!==this.sizeX||r!==this.sizeY){var i=this.constructor.blank(e,r);return e&&r&&this.sizeX&&this.sizeY&&i.context.drawImage(this.canvas,-t,-n),i}return this};var K=function(t,n){if(this.sizeX&&this.sizeY){var e=this.constructor.blank(this.sizeX,this.sizeY),r=e.context;return r.save(),r.translate(t?this.sizeX:0,n?this.sizeY:0),r.scale(t?-1:1,n?-1:1),r.drawImage(this.canvas,0,0),r.restore(),e}return this};Object.assign(t.prototype,{flipX:J(K,!0,!1),flipY:J(K,!1,!0),rotate180:J(K,!0,!0)}),t.prototype.reframe=function(t,n,e,r){var i=this;t=A(t)?Math.round(t):this.sizeX,n=A(n)?Math.round(n):this.sizeY;var a=function(){switch(e){case"start":return 0;case"end":return-t}return(i.sizeX+t)/-2}(),s=function(){switch(r){case"start":return 0;case"end":return-n}return(i.sizeY+n)/-2}();return this.crop(a,s,t,n)},t.prototype.resize=function(t,n){if(t=A(t)?Math.round(t):this.sizeX,n=A(n)?Math.round(n):this.sizeY,t!==this.sizeX||n!==this.sizeY){var e=this.constructor.blank(t,n);if(t&&n&&this.sizeX&&this.sizeY){var r=t/this.sizeX,i=n/this.sizeY,a=e.context;a.save(),a.scale(r,i),a.drawImage(this.canvas,0,0),a.restore()}return e}return this},t.prototype.rescale=function(t,n){var e=this.sizeX,r=this.sizeY;return a(t)&&(e*=t),a(n)&&(r*=n),this.resize(e,r)},t.prototype.resizeX=function(t,n){var e=this,r=function(){if(n){if(!e.sizeX)return 0;if(a(t))return t*e.sizeY/e.sizeX}return e.sizeY}();return this.resize(t,r)},t.prototype.resizeY=function(t,n){var e=this,r=function(){if(n){if(!e.sizeY)return 0;if(a(t))return t*e.sizeX/e.sizeY}return e.sizeX}();return this.resize(r,t)};var Q=function(t){if(this.sizeX||this.sizeY){var n=this.constructor.blank(this.sizeY,this.sizeX);if(this.sizeX&&this.sizeY){var e=n.context;e.save(),e.translate(this.sizeY/2,this.sizeX/2),e.rotate(Math.PI/(t?2:-2)),e.drawImage(this.canvas,this.sizeX/-2,this.sizeY/-2),e.restore()}return n}return this};function V(t){return t}Object.assign(t.prototype,{rotate90:J(Q,!0),rotate270:J(Q,!1)}),t.prototype.toBuffer=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];return this.sizeX&&this.sizeY?(t=this.canvas).toBuffer.apply(t,n):Buffer.alloc(0)},t.prototype.saveToFileSystem=function(t){for(var n=this,e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return new Promise(function(r,i){var a,s=require("fs"),o=require("path"),u=(a=n).toBuffer.apply(a,e);s.mkdir(o.dirname(t),{recursive:!0},function(n){n?i(n):s.writeFile(t,u,function(t){t?i(t):r()})})})},t.prototype.scale=function(t){return this.rescale(t,t)};var Z=function(t,n,e,r){if(this.sizeX&&this.sizeY){var i=n(t(A(e)?e/this.sizeX:1,A(r)?r/this.sizeY:1),1);return this.scale(i)}return this.resize(e,r)};function _(t){for(var n=t.length,e=new Uint8Array(n),r=0;r<n;r++)e[r]=t.charCodeAt(r);return e}return Object.assign(t.prototype,{scaleIn:J(Z,Math.min,V),scaleOut:J(Z,Math.max,V),scaleDownIn:J(Z,Math.min,Math.min),scaleDownOut:J(Z,Math.max,Math.min),scaleUpIn:J(Z,Math.min,Math.max),scaleUpOut:J(Z,Math.max,Math.max)}),t.prototype.toDataURL=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];return(t=this.canvas).toDataURL.apply(t,n)},t.prototype.toBlob=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];var r=(t=this).toDataURL.apply(t,n),i=h.parse(r),a=_(atob(i.data));return new Blob([a],{type:i.type})},t.prototype.toHTMLCanvasElement=function(){var t=e();return t.width=this.sizeX,t.height=this.sizeY,t.getContext("2d").drawImage(this.canvas,0,0),t},t.prototype.toHTMLImageElement=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];var r=l();return r.src=(t=this).toDataURL.apply(t,n),r},t.prototype.toImageData=function(){return this.context.getImageData(0,0,this.sizeX,this.sizeY)},t.prototype.toOffscreenCanvas=function(){var t=r();return t.width=sizeX,t.height=sizeY,t.context.drawImage(this.canvas,0,0),t},t.text=function(t,n){t=G(t)?"":""+t;var e="#000",r=$.default,i=.28;S(n)&&(j(n.fill)&&(e=n.fill),r=$.fromExcept(n.font),A(n.padding)&&(i=n.padding)),i=Math.ceil(i*r.size);var a=this.blank(this.measureText(t,r).width+2*i,r.size+2*i),s=a.context;return s.save(),s.font=r.toCSS(),s.textBaseline="top",s.textAlign="left",s.fillStyle=e,s.fillText(t,i,i),s.restore(),a},t});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).DearImage=n()}(this,function(){"use strict";var t=function(t){this.context=t},n={canvas:{configurable:!0},sizeX:{configurable:!0},sizeY:{configurable:!0},size:{configurable:!0},minSize:{configurable:!0},maxSize:{configurable:!0}};function e(){return document.createElement("canvas")}function r(){return new OffscreenCanvas}function i(){try{return e()}catch(t){}try{return r()}catch(t){}try{return new(0,require("canvas").Canvas)}catch(t){}throw new Error}function a(t){return Number.isFinite(t)}function s(t){return a(t)&&t>0}n.canvas.get=function(){return this.context.canvas},n.sizeX.get=function(){return this.canvas.width},n.sizeY.get=function(){return this.canvas.height},n.size.get=function(){return{x:this.sizeX,y:this.sizeY}},n.minSize.get=function(){return Math.min(this.sizeX,this.sizeY)},n.maxSize.get=function(){return Math.max(this.sizeX,this.sizeY)},Object.defineProperties(t.prototype,n),t.blank=function(t,n){t=s(t)?Math.round(t):0,n=s(n)?Math.round(n):0;var e=i();return e.width=t,e.height=n,new this(e.getContext("2d"))},t.isDearImage=(t.is=function(t){return t instanceof this}).bind(t);var o="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;function u(t){return function(t){var n=o.HTMLCanvasElement;return!!n&&t instanceof n}(t)||function(t){var n=o.OffscreenCanvas;return!!n&&t instanceof n}(t)||function(t){try{return t instanceof require("canvas").Canvas}catch(t){}return!1}(t)}function c(){}function f(t){return"string"==typeof t}var h=/^data:(.*?)(;base64)?,(.*)$/;function l(t){if(f(t)){var n=h.exec(t);if(n){var e=n[1],r=n[3];return Object.assign(new c,{type:e,data:r,isEmpty:function(){return!r},toString:function(){return t}})}}return!1}var v={is:function(t){return t instanceof c},isString:function(t){return!!l(t)},parse:l};function p(){return new Image}function z(){try{return p()}catch(t){}try{return new(0,require("canvas").Image)}catch(t){}throw new Error}function m(t){return function(t){var n=o.HTMLImageElement;return!!n&&t instanceof n}(t)||function(t){try{return t instanceof require("canvas").Image}catch(t){}return!1}(t)}function d(t){return new Promise(function(n){n(t())})}function g(t){var n=o.ImageData;return!!n&&t instanceof n||function(t){try{return t instanceof require("canvas").ImageData}catch(t){}return!1}(t)}function y(t){var n=o.URL;return!!n&&t instanceof n}var w=function(t){var n=this.blank(t.width,t.height);return n.sizeX&&n.sizeY&&n.context.putImageData(t,0,0),n},b=function(t,n,e){var r=this.blank(n,e);return r.sizeX&&r.sizeY&&r.context.drawImage(t,0,0),r},x=function(t){return b.call(this,t,t.width,t.height)},X=function(t){return b.call(this,t,t.naturalWidth,t.naturalHeight)},Y=function(t){return x.call(this,t.canvas)},M=function(n){if(t.is(n))return Y.call(this,n);if(g(n))return w.call(this,n);if(u(n))return x.call(this,n);if(m(n))return X.call(this,n);throw new TypeError},I=function(t){var n,e=this;return(n=t,d(function(){if(!n.complete)return new Promise(function(t,e){n.onload=t,n.onerror=e}).finally(function(){n.onload=null,n.onerror=null})})).then(function(){return X.call(e,t)})},L=function(t){var n=z();return n.src=t,I.call(this,n)},S=function(t){return t.length?L.call(this,t):this.blank()},C=function(t){var n=this;if(!t.size)return this.blank();var e=URL.createObjectURL(t);return d(function(){return L.call(n,e)}).finally(function(){URL.revokeObjectURL(e)})},E=function(t){return t.isEmpty()?this.blank():L.call(this,""+t)},O=function(t){var n=v.parse(t);return n?E.call(this,n):L.call(this,t)},U=function(t){return L.call(this,""+t)};function k(t){if(t){var n=typeof t;return"object"===n||"function"===n}return!1}function D(){}Object.assign(t,{from:M,loadFrom:function(t){var n=this;return d(function(){return f(t)?O.call(n,t):y(t)?U.call(n,t):function(t){var n=o.Buffer;return!!n&&t instanceof n}(t)?S.call(n,t):function(t){var n=o.Blob;return!!n&&t instanceof n}(t)?C.call(n,t):m(t)?I.call(n,t):M.call(n,t)})}}),t.fromExcept=function(t){return this.is(t)?t:this.from(t)},t.loadFromExcept=function(t){var n=this;return d(function(){return n.is(t)?t:n.loadFrom(t)})};var j="sans-serif",R="normal";function T(t){return f(t)&&!function(t){return!t}(t)}var B=new Set([R,"italic","oblique"]);var q=new Set([R,"small-caps"]);function F(t,n,e,r,i){return(r?t>=n:t>n)&&(i?t<=e:t<e)}function H(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return function(t){return"number"==typeof t&&!Number.isNaN(t)}(t)&&F.apply(void 0,[t].concat(n))}var P=new Set([R,"bold"]);function N(t){var n=j,e=R,r=R,i=R;return k(t)&&(n=function(t){return T(t)?t:j}(t.family),e=function(t){return T(t)&&(t=t.toLowerCase(),B.has(t))?t:R}(t.style),r=function(t){return T(t)&&(t=t.toLowerCase(),q.has(t))?t:R}(t.variant),i=function(t){if(T(t)){if(t=t.toLowerCase(),P.has(t))return t}else if(H(t,1,1e3,!0,!0))return t=Math.round(t);return R}(t.weight)),Object.assign(new D,{family:n,style:e,variant:r,weight:i})}var A={default:N(),from:N,fromExcept:function(t){return function(t){return t instanceof D}(t)?t:N(t)}};function W(){}var $=10;function G(t){return a(t)&&!function(t){return t<0}(t)}function J(t){var n=A.from(t),e=n.family,r=n.style,i=n.variant,a=n.weight,s=$;return k(t)&&(s=function(t){return G(t)?t=Math.round(t):$}(t.size)),Object.assign(new W,{family:e,size:s,style:r,variant:i,weight:a,toCSS:function(){return[r,i,a,s+"px",'"'+e+'"'].join(" ")}})}var K={default:J(),from:J,fromExcept:function(t){return function(t){return t instanceof W}(t)?t:J(t)}};function Q(t){return function(t){return void 0===t}(t)||function(t){return null===t}(t)}function V(t){for(var n=[],e=arguments.length-1;e-- >0;)n[e]=arguments[e+1];return function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return t.call.apply(t,[this].concat(n,e))}}t.measureText=function(t,n){t=Q(t)?"":""+t;var e=this.blank().context;return e.font=K.fromExcept(n).toCSS(),e.measureText(t)},t.prototype.crop=function(t,n,e,r){if(a(t)?(t=Math.round(t))<0&&(t+=this.sizeX):t=0,a(n)?(n=Math.round(n))<0&&(n+=this.sizeY):n=0,a(e)?(e=Math.round(e))<0&&(t+=e,e*=-1):e=this.sizeX,a(r)?(r=Math.round(r))<0&&(n+=r,r*=-1):r=this.sizeY,t||n||e!==this.sizeX||r!==this.sizeY){var i=this.constructor.blank(e,r);return e&&r&&this.sizeX&&this.sizeY&&i.context.drawImage(this.canvas,-t,-n),i}return this};var Z=function(t,n){if(this.sizeX&&this.sizeY){var e=this.constructor.blank(this.sizeX,this.sizeY),r=e.context;return r.save(),r.translate(t?this.sizeX:0,n?this.sizeY:0),r.scale(t?-1:1,n?-1:1),r.drawImage(this.canvas,0,0),r.restore(),e}return this};Object.assign(t.prototype,{flipX:V(Z,!0,!1),flipY:V(Z,!1,!0),rotate180:V(Z,!0,!0)}),t.prototype.reframe=function(t,n,e,r){var i=this;t=G(t)?Math.round(t):this.sizeX,n=G(n)?Math.round(n):this.sizeY;var a=function(){switch(e){case"start":return 0;case"end":return-t}return(i.sizeX+t)/-2}(),s=function(){switch(r){case"start":return 0;case"end":return-n}return(i.sizeY+n)/-2}();return this.crop(a,s,t,n)},t.prototype.resize=function(t,n){if(t=G(t)?Math.round(t):this.sizeX,n=G(n)?Math.round(n):this.sizeY,t!==this.sizeX||n!==this.sizeY){var e=this.constructor.blank(t,n);if(t&&n&&this.sizeX&&this.sizeY){var r=t/this.sizeX,i=n/this.sizeY,a=e.context;a.save(),a.scale(r,i),a.drawImage(this.canvas,0,0),a.restore()}return e}return this},t.prototype.rescale=function(t,n){var e=this.sizeX,r=this.sizeY;return a(t)&&(e*=t),a(n)&&(r*=n),this.resize(e,r)},t.prototype.resizeX=function(t,n){var e=this,r=function(){if(n){if(!e.sizeX)return 0;if(a(t))return t*e.sizeY/e.sizeX}return e.sizeY}();return this.resize(t,r)},t.prototype.resizeY=function(t,n){var e=this,r=function(){if(n){if(!e.sizeY)return 0;if(a(t))return t*e.sizeX/e.sizeY}return e.sizeX}();return this.resize(r,t)};var _=function(t){if(this.sizeX||this.sizeY){var n=this.constructor.blank(this.sizeY,this.sizeX);if(this.sizeX&&this.sizeY){var e=n.context;e.save(),e.translate(this.sizeY/2,this.sizeX/2),e.rotate(Math.PI/(t?2:-2)),e.drawImage(this.canvas,this.sizeX/-2,this.sizeY/-2),e.restore()}return n}return this};function tt(t){return t}Object.assign(t.prototype,{rotate90:V(_,!0),rotate270:V(_,!1)}),t.prototype.toBuffer=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];return this.sizeX&&this.sizeY?(t=this.canvas).toBuffer.apply(t,n):Buffer.alloc(0)},t.prototype.saveToFileSystem=function(t){for(var n=this,e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return new Promise(function(r,i){var a,s=require("fs"),o=require("path"),u=(a=n).toBuffer.apply(a,e);s.mkdir(o.dirname(t),{recursive:!0},function(n){n?i(n):s.writeFile(t,u,function(t){t?i(t):r()})})})},t.prototype.scale=function(t){return this.rescale(t,t)};var nt=function(t,n,e,r){if(e=G(e)?Math.round(e):this.sizeX,r=G(r)?Math.round(r):this.sizeY,this.sizeX&&this.sizeY){var i=n(t(G(e)?e/this.sizeX:1,G(r)?r/this.sizeY:1),1);return this.scale(i)}return this.resize(e,r)};function et(t){for(var n=t.length,e=new Uint8Array(n),r=0;r<n;r++)e[r]=t.charCodeAt(r);return e}function rt(t){return!!function(t){if(f(t)){var n=o.URL;if(n){var e=o.document,r=e&&e.location&&e.location.origin;try{return new n(t,r)}catch(t){}}}return!1}(t)}return Object.assign(t.prototype,{scaleIn:V(nt,Math.min,tt),scaleOut:V(nt,Math.max,tt),scaleDownIn:V(nt,Math.min,Math.min),scaleDownOut:V(nt,Math.max,Math.min),scaleUpIn:V(nt,Math.min,Math.max),scaleUpOut:V(nt,Math.max,Math.max)}),t.prototype.toDataURL=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];return(t=this.canvas).toDataURL.apply(t,n)},t.prototype.toBlob=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];var r=(t=this).toDataURL.apply(t,n),i=v.parse(r),a=et(atob(i.data));return new Blob([a],{type:i.type})},t.prototype.toHTMLCanvasElement=function(){var t=e();return t.width=this.sizeX,t.height=this.sizeY,t.getContext("2d").drawImage(this.canvas,0,0),t},t.prototype.toHTMLImageElement=function(){for(var t,n=[],e=arguments.length;e--;)n[e]=arguments[e];var r=p();return r.src=(t=this).toDataURL.apply(t,n),r},t.prototype.toImageData=function(){return this.context.getImageData(0,0,this.sizeX,this.sizeY)},t.prototype.toOffscreenCanvas=function(){var t=r();return t.width=sizeX,t.height=sizeY,t.context.drawImage(this.canvas,0,0),t},t.text=function(t,n){t=Q(t)?"":""+t;var e="#000",r=K.default,i=.28;k(n)&&(T(n.fill)&&(e=n.fill),r=K.fromExcept(n.font),G(n.padding)&&(i=n.padding)),i=Math.ceil(i*r.size);var a=this.blank(this.measureText(t,r).width+2*i,r.size+2*i),s=a.context;return s.save(),s.font=r.toCSS(),s.textBaseline="top",s.textAlign="left",s.fillStyle=e,s.fillText(t,i,i),s.restore(),a},(t.utils={}).isDataURL=function(t){return v.is(t)||v.isString(t)},t.utils.isURL=function(t){return y(t)||rt(t)},t});
{
"name": "dear-image",
"version": "1.1.0",
"version": "1.2.0",
"description": "A class that represents a graphical image.",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc