Skip to content

Commit

Permalink
Added orientation to MagickImageInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Mar 18, 2024
1 parent 43c590b commit f3fac90
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/magick-image-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Interlace } from "./enums/interlace";
import { MagickFormat } from "./enums/magick-format";
import { MagickReadSettings } from "./settings/magick-read-settings";
import { MagickImage } from "./magick-image";
import { OrientationType } from "./enums/orientation-type";

export interface IMagickImageInfo {
/**
Expand Down Expand Up @@ -41,6 +42,11 @@ export interface IMagickImageInfo {
*/
readonly interlace: Interlace;

/**
* Gets the orientation of the image.
*/
readonly orientation: OrientationType;

/**
* Gets the JPEG/MIFF/PNG compression level.
*/
Expand All @@ -66,6 +72,7 @@ export class MagickImageInfo implements IMagickImageInfo {
private _format: MagickFormat = MagickFormat.Unknown;
private _height: number = 0;
private _interlace: Interlace = Interlace.Undefined;
private _orientation: OrientationType = OrientationType.Undefined;
private _quality: number = 0;
private _width: number = 0;

Expand Down Expand Up @@ -93,6 +100,10 @@ export class MagickImageInfo implements IMagickImageInfo {
return this._interlace;
}

get orientation(): OrientationType {
return this._orientation;
}

get quality(): number {
return this._quality;
}
Expand All @@ -114,6 +125,7 @@ export class MagickImageInfo implements IMagickImageInfo {
this._format = image.format;
this._height = image.height;
this._interlace = image.interlace;
this._orientation = image.orientation;
this._quality = image.quality;
this._width = image.width;
});
Expand Down
2 changes: 2 additions & 0 deletions tests/magick-image-info/constructor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DensityUnit } from '@src/enums/density-unit';
import { Interlace } from '@src/enums/interlace';
import { MagickFormat } from '@src/enums/magick-format';
import { MagickImageInfo } from '@src/magick-image-info';
import { OrientationType } from '@src/enums/orientation-type';

describe('MagickImageInfo#constructor', () => {
it('should create empty uninitialized instance', () => {
Expand All @@ -19,6 +20,7 @@ describe('MagickImageInfo#constructor', () => {
expect(magickImageInfo.format).toBe(MagickFormat.Unknown);
expect(magickImageInfo.height).toBe(0);
expect(magickImageInfo.interlace).toBe(Interlace.Undefined);
expect(magickImageInfo.orientation).toBe(OrientationType.Undefined);
expect(magickImageInfo.quality).toBe(0);
expect(magickImageInfo.width).toBe(0);
});
Expand Down
2 changes: 2 additions & 0 deletions tests/magick-image-info/create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DensityUnit } from '@src/enums/density-unit';
import { Interlace } from '@src/enums/interlace';
import { MagickFormat } from '@src/enums/magick-format';
import { MagickImageInfo } from '@src/magick-image-info';
import { OrientationType } from '@src/enums/orientation-type';
import { TestImages } from '@test/test-images';

describe('MagickImageInfo#constructor', () => {
Expand All @@ -20,6 +21,7 @@ describe('MagickImageInfo#constructor', () => {
expect(magickImageInfo.format).toBe(MagickFormat.Jpeg);
expect(magickImageInfo.height).toBe(350);
expect(magickImageInfo.interlace).toBe(Interlace.Jpeg);
expect(magickImageInfo.orientation).toBe(OrientationType.Undefined);
expect(magickImageInfo.quality).toBe(91);
expect(magickImageInfo.width).toBe(1400);
});
Expand Down
2 changes: 2 additions & 0 deletions tests/magick-image-info/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DensityUnit } from '@src/enums/density-unit';
import { Interlace } from '@src/enums/interlace';
import { MagickFormat } from '@src/enums/magick-format';
import { MagickImageInfo } from '@src/magick-image-info';
import { OrientationType } from '@src/enums/orientation-type';
import { TestImages } from '@test/test-images';

describe('MagickImageInfo#constructor', () => {
Expand All @@ -21,6 +22,7 @@ describe('MagickImageInfo#constructor', () => {
expect(magickImageInfo.format).toBe(MagickFormat.Jpeg);
expect(magickImageInfo.height).toBe(400);
expect(magickImageInfo.interlace).toBe(Interlace.NoInterlace);
expect(magickImageInfo.orientation).toBe(OrientationType.TopLeft);
expect(magickImageInfo.quality).toBe(70);
expect(magickImageInfo.width).toBe(600);
});
Expand Down

0 comments on commit f3fac90

Please sign in to comment.