image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
31 lines • 1.22 kB
JavaScript
export class PngPhysicalPixelDimensions {
get xPxPerUnit() {
return this._xPxPerUnit;
}
get yPxPerUnit() {
return this._yPxPerUnit;
}
get unitSpecifier() {
return this._unitSpecifier;
}
constructor(xPxPerUnit, yPxPerUnit, unitSpecifier) {
this._xPxPerUnit = xPxPerUnit;
this._yPxPerUnit = yPxPerUnit;
this._unitSpecifier = unitSpecifier;
}
static fromDPI(dpiX, dpiY) {
const xPxPerUnit = Math.round(dpiX * PngPhysicalPixelDimensions._inchesPerM);
const yPxPerUnit = Math.round((dpiY !== null && dpiY !== void 0 ? dpiY : dpiX) * PngPhysicalPixelDimensions._inchesPerM);
const unitSpecifier = PngPhysicalPixelDimensions.unitMeter;
return new PngPhysicalPixelDimensions(xPxPerUnit, yPxPerUnit, unitSpecifier);
}
equals(other) {
return (this._xPxPerUnit === other._xPxPerUnit &&
this._yPxPerUnit === other._yPxPerUnit &&
this._unitSpecifier === other._unitSpecifier);
}
}
PngPhysicalPixelDimensions._inchesPerM = 39.3701;
PngPhysicalPixelDimensions.unitUnknown = 0;
PngPhysicalPixelDimensions.unitMeter = 1;
//# sourceMappingURL=png-physical-pixel-dimensions.js.map