9
9
* - add FORCE
10
10
* 29/5/17
11
11
* - don't cache (thanks tomasc)
12
+ * 30/8/17
13
+ * - add intent option, thanks kleisauke
12
14
*/
13
15
14
16
/*
@@ -81,6 +83,7 @@ typedef struct _VipsThumbnail {
81
83
gboolean linear ;
82
84
char * export_profile ;
83
85
char * import_profile ;
86
+ VipsIntent intent ;
84
87
85
88
/* Set by subclasses to the input image.
86
89
*/
@@ -375,6 +378,7 @@ vips_thumbnail_build( VipsObject *object )
375
378
if ( vips_icc_import ( in , & t [1 ],
376
379
"input_profile" , thumbnail -> import_profile ,
377
380
"embedded" , TRUE,
381
+ "intent" , thumbnail -> intent ,
378
382
"pcs" , VIPS_PCS_XYZ ,
379
383
NULL ) )
380
384
return ( -1 );
@@ -442,6 +446,7 @@ vips_thumbnail_build( VipsObject *object )
442
446
g_info ( "exporting to device space with a profile" );
443
447
if ( vips_icc_export ( in , & t [7 ],
444
448
"output_profile" , thumbnail -> export_profile ,
449
+ "intent" , thumbnail -> intent ,
445
450
NULL ) )
446
451
return ( -1 );
447
452
in = t [7 ];
@@ -470,6 +475,7 @@ vips_thumbnail_build( VipsObject *object )
470
475
471
476
if ( vips_icc_transform ( in , & t [7 ],
472
477
thumbnail -> export_profile ,
478
+ "intent" , thumbnail -> intent ,
473
479
"embedded" , TRUE,
474
480
NULL ) ) {
475
481
g_warning ( _ ( "unable to import with "
@@ -489,6 +495,7 @@ vips_thumbnail_build( VipsObject *object )
489
495
if ( vips_icc_transform ( in , & t [7 ],
490
496
thumbnail -> export_profile ,
491
497
"input_profile" , thumbnail -> import_profile ,
498
+ "intent" , thumbnail -> intent ,
492
499
"embedded" , FALSE,
493
500
NULL ) )
494
501
return ( -1 );
@@ -630,6 +637,13 @@ vips_thumbnail_class_init( VipsThumbnailClass *class )
630
637
G_STRUCT_OFFSET ( VipsThumbnail , export_profile ),
631
638
NULL );
632
639
640
+ VIPS_ARG_ENUM ( class , "intent" , 120 ,
641
+ _ ( "Intent" ),
642
+ _ ( "Rendering intent" ),
643
+ VIPS_ARGUMENT_OPTIONAL_INPUT ,
644
+ G_STRUCT_OFFSET ( VipsThumbnail , intent ),
645
+ VIPS_TYPE_INTENT , VIPS_INTENT_RELATIVE );
646
+
633
647
}
634
648
635
649
static void
@@ -638,6 +652,7 @@ vips_thumbnail_init( VipsThumbnail *thumbnail )
638
652
thumbnail -> width = 1 ;
639
653
thumbnail -> height = 1 ;
640
654
thumbnail -> auto_rotate = TRUE;
655
+ thumbnail -> intent = VIPS_INTENT_RELATIVE ;
641
656
}
642
657
643
658
typedef struct _VipsThumbnailFile {
@@ -745,6 +760,7 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
745
760
* * @linear: %gboolean, perform shrink in linear light
746
761
* * @import_profile: %gchararray, fallback import ICC profile
747
762
* * @export_profile: %gchararray, export ICC profile
763
+ * * @intent: #VipsIntent, rendering intent
748
764
*
749
765
* Make a thumbnail from a file. Shrinking is done in three stages: using any
750
766
* shrink-on-load features available in the file import library, using a block
@@ -786,6 +802,9 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
786
802
* input image has no ICC profile, or if the profile embedded in the
787
803
* input image is broken.
788
804
*
805
+ * Use @intent to set the rendering intent for any ICC transform. The default
806
+ * is #VIPS_INTENT_RELATIVE.
807
+ *
789
808
* See also: vips_thumbnail_buffer().
790
809
*
791
810
* Returns: 0 on success, -1 on error.
@@ -917,6 +936,7 @@ vips_thumbnail_buffer_init( VipsThumbnailBuffer *buffer )
917
936
* * @linear: %gboolean, perform shrink in linear light
918
937
* * @import_profile: %gchararray, fallback import ICC profile
919
938
* * @export_profile: %gchararray, export ICC profile
939
+ * * @intent: #VipsIntent, rendering intent
920
940
*
921
941
* Exacty as vips_thumbnail(), but read from a memory buffer.
922
942
*
@@ -1031,6 +1051,7 @@ vips_thumbnail_image_init( VipsThumbnailImage *image )
1031
1051
* * @linear: %gboolean, perform shrink in linear light
1032
1052
* * @import_profile: %gchararray, fallback import ICC profile
1033
1053
* * @export_profile: %gchararray, export ICC profile
1054
+ * * @intent: #VipsIntent, rendering intent
1034
1055
*
1035
1056
* Exacty as vips_thumbnail(), but read from an existing image.
1036
1057
*
0 commit comments