@@ -12,6 +12,7 @@ import { ChromaticityInfo } from './types/chromaticity-info';
12
12
import { ClassType } from './enums/class-type' ;
13
13
import { ColorProfile , IColorProfile } from './profiles/color/color-profile' ;
14
14
import { ColorSpace } from './enums/color-space' ;
15
+ import { ColorTransformMode } from './enums/color-transform-mode' ;
15
16
import { ColorType } from './enums/color-type' ;
16
17
import { CompareResult } from './types/compare-result' ;
17
18
import { CompareSettings } from './settings/compare-settings' ;
@@ -1705,6 +1706,15 @@ export interface IMagickImage extends IDisposable {
1705
1706
*/
1706
1707
transformColorSpace ( target : IColorProfile ) : boolean ;
1707
1708
1709
+ /**
1710
+ * Transforms the image from the colorspace of the source profile to the target profile. This
1711
+ * requires the image to have a color profile. Nothing will happen if the image has no color profile.
1712
+ * @param target The target color profile.
1713
+ * @param mode The color transform node.
1714
+ * @returns A value indicating whether the transformation was successful.
1715
+ */
1716
+ transformColorSpace ( target : IColorProfile , mode : ColorTransformMode ) : boolean ;
1717
+
1708
1718
/**
1709
1719
* Transforms the image from the colorspace of the source profile to the target profile. The
1710
1720
* source profile will only be used if the image does not contain a color profile. Nothing
@@ -1715,6 +1725,17 @@ export interface IMagickImage extends IDisposable {
1715
1725
*/
1716
1726
transformColorSpace ( source : IColorProfile , target : IColorProfile ) : boolean ;
1717
1727
1728
+ /**
1729
+ * Transforms the image from the colorspace of the source profile to the target profile. The
1730
+ * source profile will only be used if the image does not contain a color profile. Nothing
1731
+ * will happen if the source profile has a different colorspace then that of the image.
1732
+ * @param source The source color profile.
1733
+ * @param target The target color profile.
1734
+ * @param mode The color transform node.
1735
+ * @returns A value indicating whether the transformation was successful.
1736
+ */
1737
+ transformColorSpace ( source : IColorProfile , target : IColorProfile , mode : ColorTransformMode ) : boolean ;
1738
+
1718
1739
/**
1719
1740
* Threshold image.
1720
1741
* @param percentage The threshold percentage.
@@ -3281,12 +3302,21 @@ export class MagickImage extends NativeInstance implements IMagickImage {
3281
3302
}
3282
3303
3283
3304
transformColorSpace ( target : IColorProfile ) : boolean ;
3305
+ transformColorSpace ( target : IColorProfile , mode : ColorTransformMode ) : boolean ;
3284
3306
transformColorSpace ( source : IColorProfile , target : IColorProfile ) : boolean ;
3285
- transformColorSpace ( sourceOrTarget : IColorProfile , targetOrUndefined ?: IColorProfile ) : boolean {
3307
+ transformColorSpace ( source : IColorProfile , target : IColorProfile , mode : ColorTransformMode ) : boolean ;
3308
+ transformColorSpace ( sourceOrTarget : IColorProfile , targetModeOrUndefined ?: IColorProfile | ColorTransformMode , modeOrUndefined ?: ColorTransformMode ) : boolean {
3286
3309
const source = sourceOrTarget ;
3287
3310
let target : IColorProfile | undefined ;
3288
- if ( targetOrUndefined !== undefined )
3289
- target = targetOrUndefined ;
3311
+ let mode = ColorTransformMode . Quantum ;
3312
+ if ( targetModeOrUndefined !== undefined ) {
3313
+ if ( typeof targetModeOrUndefined === 'number' )
3314
+ mode = targetModeOrUndefined ;
3315
+ else
3316
+ target = targetModeOrUndefined ;
3317
+ }
3318
+ if ( modeOrUndefined !== undefined )
3319
+ mode = modeOrUndefined ;
3290
3320
3291
3321
const hasColorProfile = this . hasProfile ( 'icc' ) || this . hasProfile ( 'icm' ) ;
3292
3322
if ( target === undefined ) {
@@ -3303,7 +3333,15 @@ export class MagickImage extends NativeInstance implements IMagickImage {
3303
3333
this . setProfile ( source ) ;
3304
3334
}
3305
3335
3306
- this . setProfile ( target ) ;
3336
+ if ( mode === ColorTransformMode . Quantum ) {
3337
+ TemporaryDefines . use ( this , temporaryDefines => {
3338
+ temporaryDefines . setArtifact ( 'profile:highres-transform' , false ) ;
3339
+ this . setProfile ( target ) ;
3340
+ } ) ;
3341
+ }
3342
+ else {
3343
+ this . setProfile ( target ) ;
3344
+ }
3307
3345
3308
3346
return true ;
3309
3347
}
0 commit comments