Skip to content

Commit

Permalink
Added syncImageWithTiffProperties to the MagickReadSettings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Oct 23, 2024
1 parent 6c67e19 commit 34da002
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/settings/magick-read-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ export class MagickReadSettings extends MagickSettings {
this.setDefine('exif:sync-image', value.toString());
}

/**
* Gets or sets a value indicating whether the tiff profile should be used to update
* some of the properties of the image (e.g. {@link MagickImage#density},
* {@link MagickImage#orientation}).
*/
get syncImageWithTiffProperties(): boolean {
const value = this.getDefine('tiff:sync-image');
if (value === null)
return true;

return value.toLowerCase() === 'true';
}
set syncImageWithTiffProperties(value: boolean) {
this.setDefine('tiff:sync-image', value.toString());
}

/**
* Gets or sets the width.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm.
Licensed under the Apache License, Version 2.0.
*/

import { MagickReadSettings } from '@src/settings/magick-read-settings';

describe('MagickReadSettings#syncImageWithTiffProperties', () => {
it('should return true as the default value', () => {
const settings = new MagickReadSettings();

expect(settings.syncImageWithTiffProperties).toBe(true);
});

it('should not set the define when the value is not set', () => {
const settings = new MagickReadSettings();
const value = settings.getDefine('tiff:sync-image');

expect(value).toBeNull();
});

it('should change the image option', () => {
const settings = new MagickReadSettings();
settings.syncImageWithTiffProperties = false;

const value = settings.getDefine('tiff:sync-image');
expect(value).toBe('false');
});
});

0 comments on commit 34da002

Please sign in to comment.