1use crate::bindings;
3use crate::error::*;
4use crate::utils;
5use crate::Result;
6use crate::VipsBlob;
7use crate::VipsImage;
8use crate::VipsInterpolate;
9use crate::VipsSource;
10use crate::VipsTarget;
11use std::convert::TryInto;
12use std::ffi::*;
13use std::ptr::null_mut;
14
15const NULL: *const c_void = null_mut();
16
17include!("manual.rs");
18
19#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
20pub enum Access {
21 Random = 0,
23 Sequential = 1,
25 SequentialUnbuffered = 2,
27}
28
29#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
30pub enum Align {
31 Low = 0,
33 Centre = 1,
35 High = 2,
37}
38
39#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
40pub enum Angle {
41 D0 = 0,
43 D90 = 1,
45 D180 = 2,
47 D270 = 3,
49}
50
51#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
52pub enum Angle45 {
53 D0 = 0,
55 D45 = 1,
57 D90 = 2,
59 D135 = 3,
61 D180 = 4,
63 D225 = 5,
65 D270 = 6,
67 D315 = 7,
69}
70
71#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
72pub enum BandFormat {
73 Notset = -1,
75 Uchar = 0,
77 Char = 1,
79 Ushort = 2,
81 Short = 3,
83 Uint = 4,
85 Int = 5,
87 Float = 6,
89 Complex = 7,
91 Double = 8,
93 Dpcomplex = 9,
95}
96
97#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
98pub enum BlendMode {
99 Clear = 0,
101 Source = 1,
103 Over = 2,
105 In = 3,
107 Out = 4,
109 Atop = 5,
111 Dest = 6,
113 DestOver = 7,
115 DestIn = 8,
117 DestOut = 9,
119 DestAtop = 10,
121 Xor = 11,
123 Add = 12,
125 Saturate = 13,
127 Multiply = 14,
129 Screen = 15,
131 Overlay = 16,
133 Darken = 17,
135 Lighten = 18,
137 ColourDodge = 19,
139 ColourBurn = 20,
141 HardLight = 21,
143 SoftLight = 22,
145 Difference = 23,
147 Exclusion = 24,
149}
150
151#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
152pub enum Coding {
153 Error = -1,
155 None = 0,
157 Labq = 2,
159 Rad = 6,
161}
162
163#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
164pub enum Combine {
165 Max = 0,
167 Sum = 1,
169 Min = 2,
171}
172
173#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
174pub enum CombineMode {
175 Set = 0,
177 Add = 1,
179}
180
181#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
182pub enum CompassDirection {
183 Centre = 0,
185 North = 1,
187 East = 2,
189 South = 3,
191 West = 4,
193 NorthEast = 5,
195 SouthEast = 6,
197 SouthWest = 7,
199 NorthWest = 8,
201}
202
203#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
204pub enum Direction {
205 Horizontal = 0,
207 Vertical = 1,
209}
210
211#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
212pub enum Extend {
213 Black = 0,
215 Copy = 1,
217 Repeat = 2,
219 Mirror = 3,
221 White = 4,
223 Background = 5,
225}
226
227#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
228pub enum FailOn {
229 None = 0,
231 Truncated = 1,
233 Error = 2,
235 Warning = 3,
237}
238
239#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
240pub enum ForeignDzDepth {
241 Onepixel = 0,
243 Onetile = 1,
245 One = 2,
247}
248
249#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
250pub enum ForeignFlags {
251 None = 0,
253 Partial = 1,
255 Bigendian = 2,
257 Sequential = 4,
259 All = 7,
261}
262
263#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
264pub enum ForeignHeifCompression {
265 Hevc = 1,
267 Avc = 2,
269 Jpeg = 3,
271 Av1 = 4,
273}
274
275#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
276pub enum ForeignHeifEncoder {
277 Auto = 0,
279 Aom = 1,
281 Rav1E = 2,
283 Svt = 3,
285 X265 = 4,
287}
288
289#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
290pub enum ForeignKeep {
291 None = 0,
293 Exif = 1,
295 Xmp = 2,
297 Iptc = 4,
299 Icc = 8,
301 Other = 16,
303 Gainmap = 32,
305 All = 63,
307}
308
309#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
310pub enum ForeignPngFilter {
311 None = 8,
313 Sub = 16,
315 Up = 32,
317 Avg = 64,
319 Paeth = 128,
321 All = 248,
323}
324
325#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
326pub enum ForeignPpmFormat {
327 Pbm = 0,
329 Pgm = 1,
331 Ppm = 2,
333 Pfm = 3,
335 Pnm = 4,
337}
338
339#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
340pub enum ForeignSubsample {
341 Auto = 0,
343 On = 1,
345 Off = 2,
347}
348
349#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
350pub enum ForeignTiffCompression {
351 None = 0,
353 Jpeg = 1,
355 Deflate = 2,
357 Packbit = 3,
359 Ccittfax4 = 4,
361 Lzw = 5,
363 Webp = 6,
365 Zstd = 7,
367 Jp2K = 8,
369}
370
371#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
372pub enum ForeignTiffPredictor {
373 None = 1,
375 Horizontal = 2,
377 Float = 3,
379}
380
381#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
382pub enum ForeignTiffResunit {
383 Cm = 0,
385 Inch = 1,
387}
388
389#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
390pub enum ForeignWebpPreset {
391 Default = 0,
393 Picture = 1,
395 Photo = 2,
397 Drawing = 3,
399 Icon = 4,
401 Text = 5,
403}
404
405#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
406pub enum Intent {
407 Perceptual = 0,
409 Relative = 1,
411 Saturation = 2,
413 Absolute = 3,
415 Auto = 32,
417}
418
419#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
420pub enum Interesting {
421 None = 0,
423 Centre = 1,
425 Entropy = 2,
427 Attention = 3,
429 Low = 4,
431 High = 5,
433 All = 6,
435}
436
437#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
438pub enum Interpretation {
439 Error = -1,
441 Multiband = 0,
443 BW = 1,
445 Histogram = 10,
447 Xyz = 12,
449 Lab = 13,
451 Cmyk = 15,
453 Labq = 16,
455 Rgb = 17,
457 Cmc = 18,
459 Lch = 19,
461 Labs = 21,
463 Srgb = 22,
465 Yxy = 23,
467 Fourier = 24,
469 Rgb16 = 25,
471 Grey16 = 26,
473 Matrix = 27,
475 Scrgb = 28,
477 Hsv = 29,
479 Oklab = 30,
481 Oklch = 31,
483}
484
485#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
486pub enum Kernel {
487 Nearest = 0,
489 Linear = 1,
491 Cubic = 2,
493 Mitchell = 3,
495 Lanczos2 = 4,
497 Lanczos3 = 5,
499 Mks2013 = 6,
501 Mks2021 = 7,
503}
504
505#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
506pub enum OperationBoolean {
507 And = 0,
509 Or = 1,
511 Eor = 2,
513 Lshift = 3,
515 Rshift = 4,
517}
518
519#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
520pub enum OperationComplex {
521 Polar = 0,
523 Rect = 1,
525 Conj = 2,
527}
528
529#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
530pub enum OperationComplex2 {
531 CrossPhase = 0,
533}
534
535#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
536pub enum OperationComplexget {
537 Real = 0,
539 Imag = 1,
541}
542
543#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
544pub enum OperationMath {
545 Sin = 0,
547 Co = 1,
549 Tan = 2,
551 Asin = 3,
553 Aco = 4,
555 Atan = 5,
557 Log = 6,
559 Log10 = 7,
561 Exp = 8,
563 Exp10 = 9,
565 Sinh = 10,
567 Cosh = 11,
569 Tanh = 12,
571 Asinh = 13,
573 Acosh = 14,
575 Atanh = 15,
577}
578
579#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
580pub enum OperationMath2 {
581 Pow = 0,
583 Wop = 1,
585 Atan2 = 2,
587}
588
589#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
590pub enum OperationMorphology {
591 Erode = 0,
593 Dilate = 1,
595}
596
597#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
598pub enum OperationRelational {
599 Equal = 0,
601 Noteq = 1,
603 Less = 2,
605 Lesseq = 3,
607 More = 4,
609 Moreeq = 5,
611}
612
613#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
614pub enum OperationRound {
615 Rint = 0,
617 Ceil = 1,
619 Floor = 2,
621}
622
623#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
624pub enum PCS {
625 Lab = 0,
627 Xyz = 1,
629}
630
631#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
632pub enum Precision {
633 Integer = 0,
635 Float = 1,
637 Approximate = 2,
639}
640
641#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
642pub enum RegionShrink {
643 Mean = 0,
645 Median = 1,
647 Mode = 2,
649 Max = 3,
651 Min = 4,
653 Nearest = 5,
655}
656
657#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
658pub enum SdfShape {
659 Circle = 0,
661 Box = 1,
663 RoundedBox = 2,
665 Line = 3,
667}
668
669#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
670pub enum Size {
671 Both = 0,
673 Up = 1,
675 Down = 2,
677 Force = 3,
679}
680
681#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
682pub enum TextWrap {
683 Word = 0,
685 Char = 1,
687 WordChar = 2,
689 None = 3,
691}
692
693pub fn system(cmd_format: &str) -> Result<()> {
697 unsafe {
698 let cmd_format_in: CString = utils::new_c_string(cmd_format)?;
699
700 let vips_op_response = bindings::vips_system(cmd_format_in.as_ptr(), NULL);
701 utils::result(vips_op_response, (), Error::SystemError)
702 }
703}
704
705#[derive(Clone, Debug)]
707pub struct SystemOptions {
708 pub inp: Vec<VipsImage>,
710 pub out: VipsImage,
712 pub in_format: String,
714 pub out_format: String,
716 pub cache: bool,
719 pub log: String,
721}
722
723impl std::default::Default for SystemOptions {
724 fn default() -> Self {
725 SystemOptions {
726 inp: Vec::new(),
727 out: VipsImage::new(),
728 in_format: String::new(),
729 out_format: String::new(),
730 cache: false,
731 log: String::new(),
732 }
733 }
734}
735
736pub fn system_with_opts(cmd_format: &str, system_options: &SystemOptions) -> Result<()> {
741 unsafe {
742 let cmd_format_in: CString = utils::new_c_string(cmd_format)?;
743
744 let inp_wrapper = utils::VipsArrayImageWrapper::from(&system_options.inp[..]);
745 let inp_in = inp_wrapper.ctx;
746 let inp_in_name = utils::new_c_string("inp")?;
747
748 let out_in: *mut bindings::VipsImage = system_options.out.ctx;
749 let out_in_name = utils::new_c_string("out")?;
750
751 let in_format_in: CString = utils::new_c_string(&system_options.in_format)?;
752 let in_format_in_name = utils::new_c_string("in-format")?;
753
754 let out_format_in: CString = utils::new_c_string(&system_options.out_format)?;
755 let out_format_in_name = utils::new_c_string("out-format")?;
756
757 let cache_in: i32 = if system_options.cache { 1 } else { 0 };
758 let cache_in_name = utils::new_c_string("cache")?;
759
760 let log_in: CString = utils::new_c_string(&system_options.log)?;
761 let log_in_name = utils::new_c_string("log")?;
762
763 let vips_op_response = bindings::vips_system(
764 cmd_format_in.as_ptr(),
765 inp_in_name.as_ptr(),
766 inp_in,
767 out_in_name.as_ptr(),
768 out_in,
769 in_format_in_name.as_ptr(),
770 in_format_in.as_ptr(),
771 out_format_in_name.as_ptr(),
772 out_format_in.as_ptr(),
773 cache_in_name.as_ptr(),
774 cache_in,
775 log_in_name.as_ptr(),
776 log_in.as_ptr(),
777 NULL,
778 );
779 utils::result(vips_op_response, (), Error::SystemError)
780 }
781}
782
783pub fn add(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
788 unsafe {
789 let left_in: *mut bindings::VipsImage = left.ctx;
790 let right_in: *mut bindings::VipsImage = right.ctx;
791 let mut out_out: *mut bindings::VipsImage = null_mut();
792
793 let vips_op_response = bindings::vips_add(left_in, right_in, &mut out_out, NULL);
794 utils::result(
795 vips_op_response,
796 VipsImage { ctx: out_out },
797 Error::AddError,
798 )
799 }
800}
801
802pub fn minpair(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
807 unsafe {
808 let left_in: *mut bindings::VipsImage = left.ctx;
809 let right_in: *mut bindings::VipsImage = right.ctx;
810 let mut out_out: *mut bindings::VipsImage = null_mut();
811
812 let vips_op_response = bindings::vips_minpair(left_in, right_in, &mut out_out, NULL);
813 utils::result(
814 vips_op_response,
815 VipsImage { ctx: out_out },
816 Error::MinpairError,
817 )
818 }
819}
820
821pub fn maxpair(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
826 unsafe {
827 let left_in: *mut bindings::VipsImage = left.ctx;
828 let right_in: *mut bindings::VipsImage = right.ctx;
829 let mut out_out: *mut bindings::VipsImage = null_mut();
830
831 let vips_op_response = bindings::vips_maxpair(left_in, right_in, &mut out_out, NULL);
832 utils::result(
833 vips_op_response,
834 VipsImage { ctx: out_out },
835 Error::MaxpairError,
836 )
837 }
838}
839
840pub fn subtract(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
845 unsafe {
846 let left_in: *mut bindings::VipsImage = left.ctx;
847 let right_in: *mut bindings::VipsImage = right.ctx;
848 let mut out_out: *mut bindings::VipsImage = null_mut();
849
850 let vips_op_response = bindings::vips_subtract(left_in, right_in, &mut out_out, NULL);
851 utils::result(
852 vips_op_response,
853 VipsImage { ctx: out_out },
854 Error::SubtractError,
855 )
856 }
857}
858
859pub fn multiply(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
864 unsafe {
865 let left_in: *mut bindings::VipsImage = left.ctx;
866 let right_in: *mut bindings::VipsImage = right.ctx;
867 let mut out_out: *mut bindings::VipsImage = null_mut();
868
869 let vips_op_response = bindings::vips_multiply(left_in, right_in, &mut out_out, NULL);
870 utils::result(
871 vips_op_response,
872 VipsImage { ctx: out_out },
873 Error::MultiplyError,
874 )
875 }
876}
877
878pub fn divide(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
883 unsafe {
884 let left_in: *mut bindings::VipsImage = left.ctx;
885 let right_in: *mut bindings::VipsImage = right.ctx;
886 let mut out_out: *mut bindings::VipsImage = null_mut();
887
888 let vips_op_response = bindings::vips_divide(left_in, right_in, &mut out_out, NULL);
889 utils::result(
890 vips_op_response,
891 VipsImage { ctx: out_out },
892 Error::DivideError,
893 )
894 }
895}
896
897pub fn relational(
909 left: &VipsImage,
910 right: &VipsImage,
911 relational: OperationRelational,
912) -> Result<VipsImage> {
913 unsafe {
914 let left_in: *mut bindings::VipsImage = left.ctx;
915 let right_in: *mut bindings::VipsImage = right.ctx;
916 let relational_in: i32 = relational as i32;
917 let mut out_out: *mut bindings::VipsImage = null_mut();
918
919 let vips_op_response = bindings::vips_relational(
920 left_in,
921 right_in,
922 &mut out_out,
923 relational_in.try_into().unwrap(),
924 NULL,
925 );
926 utils::result(
927 vips_op_response,
928 VipsImage { ctx: out_out },
929 Error::RelationalError,
930 )
931 }
932}
933
934pub fn remainder(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
939 unsafe {
940 let left_in: *mut bindings::VipsImage = left.ctx;
941 let right_in: *mut bindings::VipsImage = right.ctx;
942 let mut out_out: *mut bindings::VipsImage = null_mut();
943
944 let vips_op_response = bindings::vips_remainder(left_in, right_in, &mut out_out, NULL);
945 utils::result(
946 vips_op_response,
947 VipsImage { ctx: out_out },
948 Error::RemainderError,
949 )
950 }
951}
952
953pub fn boolean(
964 left: &VipsImage,
965 right: &VipsImage,
966 boolean: OperationBoolean,
967) -> Result<VipsImage> {
968 unsafe {
969 let left_in: *mut bindings::VipsImage = left.ctx;
970 let right_in: *mut bindings::VipsImage = right.ctx;
971 let boolean_in: i32 = boolean as i32;
972 let mut out_out: *mut bindings::VipsImage = null_mut();
973
974 let vips_op_response = bindings::vips_boolean(
975 left_in,
976 right_in,
977 &mut out_out,
978 boolean_in.try_into().unwrap(),
979 NULL,
980 );
981 utils::result(
982 vips_op_response,
983 VipsImage { ctx: out_out },
984 Error::BooleanError,
985 )
986 }
987}
988
989pub fn math_2(left: &VipsImage, right: &VipsImage, math_2: OperationMath2) -> Result<VipsImage> {
998 unsafe {
999 let left_in: *mut bindings::VipsImage = left.ctx;
1000 let right_in: *mut bindings::VipsImage = right.ctx;
1001 let math_2_in: i32 = math_2 as i32;
1002 let mut out_out: *mut bindings::VipsImage = null_mut();
1003
1004 let vips_op_response = bindings::vips_math2(
1005 left_in,
1006 right_in,
1007 &mut out_out,
1008 math_2_in.try_into().unwrap(),
1009 NULL,
1010 );
1011 utils::result(
1012 vips_op_response,
1013 VipsImage { ctx: out_out },
1014 Error::Math2Error,
1015 )
1016 }
1017}
1018
1019pub fn complex_2(
1026 left: &VipsImage,
1027 right: &VipsImage,
1028 cmplx: OperationComplex2,
1029) -> Result<VipsImage> {
1030 unsafe {
1031 let left_in: *mut bindings::VipsImage = left.ctx;
1032 let right_in: *mut bindings::VipsImage = right.ctx;
1033 let cmplx_in: i32 = cmplx as i32;
1034 let mut out_out: *mut bindings::VipsImage = null_mut();
1035
1036 let vips_op_response = bindings::vips_complex2(
1037 left_in,
1038 right_in,
1039 &mut out_out,
1040 cmplx_in.try_into().unwrap(),
1041 NULL,
1042 );
1043 utils::result(
1044 vips_op_response,
1045 VipsImage { ctx: out_out },
1046 Error::Complex2Error,
1047 )
1048 }
1049}
1050
1051pub fn complexform(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
1056 unsafe {
1057 let left_in: *mut bindings::VipsImage = left.ctx;
1058 let right_in: *mut bindings::VipsImage = right.ctx;
1059 let mut out_out: *mut bindings::VipsImage = null_mut();
1060
1061 let vips_op_response = bindings::vips_complexform(left_in, right_in, &mut out_out, NULL);
1062 utils::result(
1063 vips_op_response,
1064 VipsImage { ctx: out_out },
1065 Error::ComplexformError,
1066 )
1067 }
1068}
1069
1070pub fn clamp(inp: &VipsImage) -> Result<VipsImage> {
1074 unsafe {
1075 let inp_in: *mut bindings::VipsImage = inp.ctx;
1076 let mut out_out: *mut bindings::VipsImage = null_mut();
1077
1078 let vips_op_response = bindings::vips_clamp(inp_in, &mut out_out, NULL);
1079 utils::result(
1080 vips_op_response,
1081 VipsImage { ctx: out_out },
1082 Error::ClampError,
1083 )
1084 }
1085}
1086
1087#[derive(Clone, Debug)]
1089pub struct ClampOptions {
1090 pub min: f64,
1093 pub max: f64,
1096}
1097
1098impl std::default::Default for ClampOptions {
1099 fn default() -> Self {
1100 ClampOptions {
1101 min: f64::from(0),
1102 max: f64::from(1),
1103 }
1104 }
1105}
1106
1107pub fn clamp_with_opts(inp: &VipsImage, clamp_options: &ClampOptions) -> Result<VipsImage> {
1112 unsafe {
1113 let inp_in: *mut bindings::VipsImage = inp.ctx;
1114 let mut out_out: *mut bindings::VipsImage = null_mut();
1115
1116 let min_in: f64 = clamp_options.min;
1117 let min_in_name = utils::new_c_string("min")?;
1118
1119 let max_in: f64 = clamp_options.max;
1120 let max_in_name = utils::new_c_string("max")?;
1121
1122 let vips_op_response = bindings::vips_clamp(
1123 inp_in,
1124 &mut out_out,
1125 min_in_name.as_ptr(),
1126 min_in,
1127 max_in_name.as_ptr(),
1128 max_in,
1129 NULL,
1130 );
1131 utils::result(
1132 vips_op_response,
1133 VipsImage { ctx: out_out },
1134 Error::ClampError,
1135 )
1136 }
1137}
1138
1139pub fn invert(inp: &VipsImage) -> Result<VipsImage> {
1143 unsafe {
1144 let inp_in: *mut bindings::VipsImage = inp.ctx;
1145 let mut out_out: *mut bindings::VipsImage = null_mut();
1146
1147 let vips_op_response = bindings::vips_invert(inp_in, &mut out_out, NULL);
1148 utils::result(
1149 vips_op_response,
1150 VipsImage { ctx: out_out },
1151 Error::InvertError,
1152 )
1153 }
1154}
1155
1156pub fn math(inp: &VipsImage, math: OperationMath) -> Result<VipsImage> {
1177 unsafe {
1178 let inp_in: *mut bindings::VipsImage = inp.ctx;
1179 let math_in: i32 = math as i32;
1180 let mut out_out: *mut bindings::VipsImage = null_mut();
1181
1182 let vips_op_response =
1183 bindings::vips_math(inp_in, &mut out_out, math_in.try_into().unwrap(), NULL);
1184 utils::result(
1185 vips_op_response,
1186 VipsImage { ctx: out_out },
1187 Error::MathError,
1188 )
1189 }
1190}
1191
1192pub fn abs(inp: &VipsImage) -> Result<VipsImage> {
1196 unsafe {
1197 let inp_in: *mut bindings::VipsImage = inp.ctx;
1198 let mut out_out: *mut bindings::VipsImage = null_mut();
1199
1200 let vips_op_response = bindings::vips_abs(inp_in, &mut out_out, NULL);
1201 utils::result(vips_op_response, VipsImage { ctx: out_out }, Error::AbError)
1202 }
1203}
1204
1205pub fn sign(inp: &VipsImage) -> Result<VipsImage> {
1209 unsafe {
1210 let inp_in: *mut bindings::VipsImage = inp.ctx;
1211 let mut out_out: *mut bindings::VipsImage = null_mut();
1212
1213 let vips_op_response = bindings::vips_sign(inp_in, &mut out_out, NULL);
1214 utils::result(
1215 vips_op_response,
1216 VipsImage { ctx: out_out },
1217 Error::SignError,
1218 )
1219 }
1220}
1221
1222pub fn round(inp: &VipsImage, round: OperationRound) -> Result<VipsImage> {
1230 unsafe {
1231 let inp_in: *mut bindings::VipsImage = inp.ctx;
1232 let round_in: i32 = round as i32;
1233 let mut out_out: *mut bindings::VipsImage = null_mut();
1234
1235 let vips_op_response =
1236 bindings::vips_round(inp_in, &mut out_out, round_in.try_into().unwrap(), NULL);
1237 utils::result(
1238 vips_op_response,
1239 VipsImage { ctx: out_out },
1240 Error::RoundError,
1241 )
1242 }
1243}
1244
1245pub fn relational_const(
1257 inp: &VipsImage,
1258 relational: OperationRelational,
1259 c: &mut [f64],
1260) -> Result<VipsImage> {
1261 unsafe {
1262 let inp_in: *mut bindings::VipsImage = inp.ctx;
1263 let relational_in: i32 = relational as i32;
1264 let c_in: *mut f64 = c.as_mut_ptr();
1265 let mut out_out: *mut bindings::VipsImage = null_mut();
1266
1267 let vips_op_response = bindings::vips_relational_const(
1268 inp_in,
1269 &mut out_out,
1270 relational_in.try_into().unwrap(),
1271 c_in,
1272 c.len() as i32,
1273 NULL,
1274 );
1275 utils::result(
1276 vips_op_response,
1277 VipsImage { ctx: out_out },
1278 Error::RelationalConstError,
1279 )
1280 }
1281}
1282
1283pub fn remainder_const(inp: &VipsImage, c: &mut [f64]) -> Result<VipsImage> {
1288 unsafe {
1289 let inp_in: *mut bindings::VipsImage = inp.ctx;
1290 let c_in: *mut f64 = c.as_mut_ptr();
1291 let mut out_out: *mut bindings::VipsImage = null_mut();
1292
1293 let vips_op_response =
1294 bindings::vips_remainder_const(inp_in, &mut out_out, c_in, c.len() as i32, NULL);
1295 utils::result(
1296 vips_op_response,
1297 VipsImage { ctx: out_out },
1298 Error::RemainderConstError,
1299 )
1300 }
1301}
1302
1303pub fn boolean_const(
1314 inp: &VipsImage,
1315 boolean: OperationBoolean,
1316 c: &mut [f64],
1317) -> Result<VipsImage> {
1318 unsafe {
1319 let inp_in: *mut bindings::VipsImage = inp.ctx;
1320 let boolean_in: i32 = boolean as i32;
1321 let c_in: *mut f64 = c.as_mut_ptr();
1322 let mut out_out: *mut bindings::VipsImage = null_mut();
1323
1324 let vips_op_response = bindings::vips_boolean_const(
1325 inp_in,
1326 &mut out_out,
1327 boolean_in.try_into().unwrap(),
1328 c_in,
1329 c.len() as i32,
1330 NULL,
1331 );
1332 utils::result(
1333 vips_op_response,
1334 VipsImage { ctx: out_out },
1335 Error::BooleanConstError,
1336 )
1337 }
1338}
1339
1340pub fn math_2_const(inp: &VipsImage, math_2: OperationMath2, c: &mut [f64]) -> Result<VipsImage> {
1349 unsafe {
1350 let inp_in: *mut bindings::VipsImage = inp.ctx;
1351 let math_2_in: i32 = math_2 as i32;
1352 let c_in: *mut f64 = c.as_mut_ptr();
1353 let mut out_out: *mut bindings::VipsImage = null_mut();
1354
1355 let vips_op_response = bindings::vips_math2_const(
1356 inp_in,
1357 &mut out_out,
1358 math_2_in.try_into().unwrap(),
1359 c_in,
1360 c.len() as i32,
1361 NULL,
1362 );
1363 utils::result(
1364 vips_op_response,
1365 VipsImage { ctx: out_out },
1366 Error::Math2ConstError,
1367 )
1368 }
1369}
1370
1371pub fn complex(inp: &VipsImage, cmplx: OperationComplex) -> Result<VipsImage> {
1379 unsafe {
1380 let inp_in: *mut bindings::VipsImage = inp.ctx;
1381 let cmplx_in: i32 = cmplx as i32;
1382 let mut out_out: *mut bindings::VipsImage = null_mut();
1383
1384 let vips_op_response =
1385 bindings::vips_complex(inp_in, &mut out_out, cmplx_in.try_into().unwrap(), NULL);
1386 utils::result(
1387 vips_op_response,
1388 VipsImage { ctx: out_out },
1389 Error::ComplexError,
1390 )
1391 }
1392}
1393
1394pub fn complexget(inp: &VipsImage, get: OperationComplexget) -> Result<VipsImage> {
1401 unsafe {
1402 let inp_in: *mut bindings::VipsImage = inp.ctx;
1403 let get_in: i32 = get as i32;
1404 let mut out_out: *mut bindings::VipsImage = null_mut();
1405
1406 let vips_op_response =
1407 bindings::vips_complexget(inp_in, &mut out_out, get_in.try_into().unwrap(), NULL);
1408 utils::result(
1409 vips_op_response,
1410 VipsImage { ctx: out_out },
1411 Error::ComplexgetError,
1412 )
1413 }
1414}
1415
1416pub fn sum(inp: &mut [VipsImage]) -> Result<VipsImage> {
1420 unsafe {
1421 let (inp_len, mut inp_in) = {
1422 let len = inp.len();
1423 let mut input = Vec::new();
1424 for img in inp {
1425 input.push(img.ctx)
1426 }
1427 (len as i32, input)
1428 };
1429 let mut out_out: *mut bindings::VipsImage = null_mut();
1430
1431 let vips_op_response = bindings::vips_sum(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
1432 utils::result(
1433 vips_op_response,
1434 VipsImage { ctx: out_out },
1435 Error::SumError,
1436 )
1437 }
1438}
1439
1440pub fn avg(inp: &VipsImage) -> Result<f64> {
1444 unsafe {
1445 let inp_in: *mut bindings::VipsImage = inp.ctx;
1446 let mut out_out: f64 = f64::from(0);
1447
1448 let vips_op_response = bindings::vips_avg(inp_in, &mut out_out, NULL);
1449 utils::result(vips_op_response, out_out, Error::AvgError)
1450 }
1451}
1452
1453pub fn min(inp: &VipsImage) -> Result<f64> {
1457 unsafe {
1458 let inp_in: *mut bindings::VipsImage = inp.ctx;
1459 let mut out_out: f64 = f64::from(0);
1460
1461 let vips_op_response = bindings::vips_min(inp_in, &mut out_out, NULL);
1462 utils::result(vips_op_response, out_out, Error::MinError)
1463 }
1464}
1465
1466#[derive(Clone, Debug)]
1468pub struct MinOptions {
1469 pub x: i32,
1472 pub y: i32,
1475 pub size: i32,
1478 pub out_array: Vec<f64>,
1480 pub x_array: Vec<i32>,
1482 pub y_array: Vec<i32>,
1484}
1485
1486impl std::default::Default for MinOptions {
1487 fn default() -> Self {
1488 MinOptions {
1489 x: i32::from(0),
1490 y: i32::from(0),
1491 size: i32::from(1),
1492 out_array: Vec::new(),
1493 x_array: Vec::new(),
1494 y_array: Vec::new(),
1495 }
1496 }
1497}
1498
1499pub fn min_with_opts(inp: &VipsImage, min_options: &MinOptions) -> Result<f64> {
1504 unsafe {
1505 let inp_in: *mut bindings::VipsImage = inp.ctx;
1506 let mut out_out: f64 = f64::from(0);
1507
1508 let x_in: i32 = min_options.x;
1509 let x_in_name = utils::new_c_string("x")?;
1510
1511 let y_in: i32 = min_options.y;
1512 let y_in_name = utils::new_c_string("y")?;
1513
1514 let size_in: i32 = min_options.size;
1515 let size_in_name = utils::new_c_string("size")?;
1516
1517 let out_array_wrapper = utils::VipsArrayDoubleWrapper::from(&min_options.out_array[..]);
1518 let out_array_in = out_array_wrapper.ctx;
1519 let out_array_in_name = utils::new_c_string("out-array")?;
1520
1521 let x_array_wrapper = utils::VipsArrayIntWrapper::from(&min_options.x_array[..]);
1522 let x_array_in = x_array_wrapper.ctx;
1523 let x_array_in_name = utils::new_c_string("x-array")?;
1524
1525 let y_array_wrapper = utils::VipsArrayIntWrapper::from(&min_options.y_array[..]);
1526 let y_array_in = y_array_wrapper.ctx;
1527 let y_array_in_name = utils::new_c_string("y-array")?;
1528
1529 let vips_op_response = bindings::vips_min(
1530 inp_in,
1531 &mut out_out,
1532 x_in_name.as_ptr(),
1533 x_in,
1534 y_in_name.as_ptr(),
1535 y_in,
1536 size_in_name.as_ptr(),
1537 size_in,
1538 out_array_in_name.as_ptr(),
1539 out_array_in,
1540 x_array_in_name.as_ptr(),
1541 x_array_in,
1542 y_array_in_name.as_ptr(),
1543 y_array_in,
1544 NULL,
1545 );
1546 utils::result(vips_op_response, out_out, Error::MinError)
1547 }
1548}
1549
1550pub fn max(inp: &VipsImage) -> Result<f64> {
1554 unsafe {
1555 let inp_in: *mut bindings::VipsImage = inp.ctx;
1556 let mut out_out: f64 = f64::from(0);
1557
1558 let vips_op_response = bindings::vips_max(inp_in, &mut out_out, NULL);
1559 utils::result(vips_op_response, out_out, Error::MaxError)
1560 }
1561}
1562
1563#[derive(Clone, Debug)]
1565pub struct MaxOptions {
1566 pub x: i32,
1569 pub y: i32,
1572 pub size: i32,
1575 pub out_array: Vec<f64>,
1577 pub x_array: Vec<i32>,
1579 pub y_array: Vec<i32>,
1581}
1582
1583impl std::default::Default for MaxOptions {
1584 fn default() -> Self {
1585 MaxOptions {
1586 x: i32::from(0),
1587 y: i32::from(0),
1588 size: i32::from(1),
1589 out_array: Vec::new(),
1590 x_array: Vec::new(),
1591 y_array: Vec::new(),
1592 }
1593 }
1594}
1595
1596pub fn max_with_opts(inp: &VipsImage, max_options: &MaxOptions) -> Result<f64> {
1601 unsafe {
1602 let inp_in: *mut bindings::VipsImage = inp.ctx;
1603 let mut out_out: f64 = f64::from(0);
1604
1605 let x_in: i32 = max_options.x;
1606 let x_in_name = utils::new_c_string("x")?;
1607
1608 let y_in: i32 = max_options.y;
1609 let y_in_name = utils::new_c_string("y")?;
1610
1611 let size_in: i32 = max_options.size;
1612 let size_in_name = utils::new_c_string("size")?;
1613
1614 let out_array_wrapper = utils::VipsArrayDoubleWrapper::from(&max_options.out_array[..]);
1615 let out_array_in = out_array_wrapper.ctx;
1616 let out_array_in_name = utils::new_c_string("out-array")?;
1617
1618 let x_array_wrapper = utils::VipsArrayIntWrapper::from(&max_options.x_array[..]);
1619 let x_array_in = x_array_wrapper.ctx;
1620 let x_array_in_name = utils::new_c_string("x-array")?;
1621
1622 let y_array_wrapper = utils::VipsArrayIntWrapper::from(&max_options.y_array[..]);
1623 let y_array_in = y_array_wrapper.ctx;
1624 let y_array_in_name = utils::new_c_string("y-array")?;
1625
1626 let vips_op_response = bindings::vips_max(
1627 inp_in,
1628 &mut out_out,
1629 x_in_name.as_ptr(),
1630 x_in,
1631 y_in_name.as_ptr(),
1632 y_in,
1633 size_in_name.as_ptr(),
1634 size_in,
1635 out_array_in_name.as_ptr(),
1636 out_array_in,
1637 x_array_in_name.as_ptr(),
1638 x_array_in,
1639 y_array_in_name.as_ptr(),
1640 y_array_in,
1641 NULL,
1642 );
1643 utils::result(vips_op_response, out_out, Error::MaxError)
1644 }
1645}
1646
1647pub fn deviate(inp: &VipsImage) -> Result<f64> {
1651 unsafe {
1652 let inp_in: *mut bindings::VipsImage = inp.ctx;
1653 let mut out_out: f64 = f64::from(0);
1654
1655 let vips_op_response = bindings::vips_deviate(inp_in, &mut out_out, NULL);
1656 utils::result(vips_op_response, out_out, Error::DeviateError)
1657 }
1658}
1659
1660pub fn stats(inp: &VipsImage) -> Result<VipsImage> {
1664 unsafe {
1665 let inp_in: *mut bindings::VipsImage = inp.ctx;
1666 let mut out_out: *mut bindings::VipsImage = null_mut();
1667
1668 let vips_op_response = bindings::vips_stats(inp_in, &mut out_out, NULL);
1669 utils::result(
1670 vips_op_response,
1671 VipsImage { ctx: out_out },
1672 Error::StatError,
1673 )
1674 }
1675}
1676
1677pub fn hist_find(inp: &VipsImage) -> Result<VipsImage> {
1681 unsafe {
1682 let inp_in: *mut bindings::VipsImage = inp.ctx;
1683 let mut out_out: *mut bindings::VipsImage = null_mut();
1684
1685 let vips_op_response = bindings::vips_hist_find(inp_in, &mut out_out, NULL);
1686 utils::result(
1687 vips_op_response,
1688 VipsImage { ctx: out_out },
1689 Error::HistFindError,
1690 )
1691 }
1692}
1693
1694#[derive(Clone, Debug)]
1696pub struct HistFindOptions {
1697 pub band: i32,
1700}
1701
1702impl std::default::Default for HistFindOptions {
1703 fn default() -> Self {
1704 HistFindOptions {
1705 band: i32::from(-1),
1706 }
1707 }
1708}
1709
1710pub fn hist_find_with_opts(
1715 inp: &VipsImage,
1716 hist_find_options: &HistFindOptions,
1717) -> Result<VipsImage> {
1718 unsafe {
1719 let inp_in: *mut bindings::VipsImage = inp.ctx;
1720 let mut out_out: *mut bindings::VipsImage = null_mut();
1721
1722 let band_in: i32 = hist_find_options.band;
1723 let band_in_name = utils::new_c_string("band")?;
1724
1725 let vips_op_response =
1726 bindings::vips_hist_find(inp_in, &mut out_out, band_in_name.as_ptr(), band_in, NULL);
1727 utils::result(
1728 vips_op_response,
1729 VipsImage { ctx: out_out },
1730 Error::HistFindError,
1731 )
1732 }
1733}
1734
1735pub fn hist_find_ndim(inp: &VipsImage) -> Result<VipsImage> {
1739 unsafe {
1740 let inp_in: *mut bindings::VipsImage = inp.ctx;
1741 let mut out_out: *mut bindings::VipsImage = null_mut();
1742
1743 let vips_op_response = bindings::vips_hist_find_ndim(inp_in, &mut out_out, NULL);
1744 utils::result(
1745 vips_op_response,
1746 VipsImage { ctx: out_out },
1747 Error::HistFindNdimError,
1748 )
1749 }
1750}
1751
1752#[derive(Clone, Debug)]
1754pub struct HistFindNdimOptions {
1755 pub bins: i32,
1758}
1759
1760impl std::default::Default for HistFindNdimOptions {
1761 fn default() -> Self {
1762 HistFindNdimOptions {
1763 bins: i32::from(10),
1764 }
1765 }
1766}
1767
1768pub fn hist_find_ndim_with_opts(
1773 inp: &VipsImage,
1774 hist_find_ndim_options: &HistFindNdimOptions,
1775) -> Result<VipsImage> {
1776 unsafe {
1777 let inp_in: *mut bindings::VipsImage = inp.ctx;
1778 let mut out_out: *mut bindings::VipsImage = null_mut();
1779
1780 let bins_in: i32 = hist_find_ndim_options.bins;
1781 let bins_in_name = utils::new_c_string("bins")?;
1782
1783 let vips_op_response = bindings::vips_hist_find_ndim(
1784 inp_in,
1785 &mut out_out,
1786 bins_in_name.as_ptr(),
1787 bins_in,
1788 NULL,
1789 );
1790 utils::result(
1791 vips_op_response,
1792 VipsImage { ctx: out_out },
1793 Error::HistFindNdimError,
1794 )
1795 }
1796}
1797
1798pub fn hist_find_indexed(inp: &VipsImage, index: &VipsImage) -> Result<VipsImage> {
1803 unsafe {
1804 let inp_in: *mut bindings::VipsImage = inp.ctx;
1805 let index_in: *mut bindings::VipsImage = index.ctx;
1806 let mut out_out: *mut bindings::VipsImage = null_mut();
1807
1808 let vips_op_response =
1809 bindings::vips_hist_find_indexed(inp_in, index_in, &mut out_out, NULL);
1810 utils::result(
1811 vips_op_response,
1812 VipsImage { ctx: out_out },
1813 Error::HistFindIndexedError,
1814 )
1815 }
1816}
1817
1818#[derive(Clone, Debug)]
1820pub struct HistFindIndexedOptions {
1821 pub combine: Combine,
1826}
1827
1828impl std::default::Default for HistFindIndexedOptions {
1829 fn default() -> Self {
1830 HistFindIndexedOptions {
1831 combine: Combine::Sum,
1832 }
1833 }
1834}
1835
1836pub fn hist_find_indexed_with_opts(
1842 inp: &VipsImage,
1843 index: &VipsImage,
1844 hist_find_indexed_options: &HistFindIndexedOptions,
1845) -> Result<VipsImage> {
1846 unsafe {
1847 let inp_in: *mut bindings::VipsImage = inp.ctx;
1848 let index_in: *mut bindings::VipsImage = index.ctx;
1849 let mut out_out: *mut bindings::VipsImage = null_mut();
1850
1851 let combine_in: i32 = hist_find_indexed_options.combine as i32;
1852 let combine_in_name = utils::new_c_string("combine")?;
1853
1854 let vips_op_response = bindings::vips_hist_find_indexed(
1855 inp_in,
1856 index_in,
1857 &mut out_out,
1858 combine_in_name.as_ptr(),
1859 combine_in,
1860 NULL,
1861 );
1862 utils::result(
1863 vips_op_response,
1864 VipsImage { ctx: out_out },
1865 Error::HistFindIndexedError,
1866 )
1867 }
1868}
1869
1870pub fn hough_line(inp: &VipsImage) -> Result<VipsImage> {
1874 unsafe {
1875 let inp_in: *mut bindings::VipsImage = inp.ctx;
1876 let mut out_out: *mut bindings::VipsImage = null_mut();
1877
1878 let vips_op_response = bindings::vips_hough_line(inp_in, &mut out_out, NULL);
1879 utils::result(
1880 vips_op_response,
1881 VipsImage { ctx: out_out },
1882 Error::HoughLineError,
1883 )
1884 }
1885}
1886
1887#[derive(Clone, Debug)]
1889pub struct HoughLineOptions {
1890 pub width: i32,
1893 pub height: i32,
1896}
1897
1898impl std::default::Default for HoughLineOptions {
1899 fn default() -> Self {
1900 HoughLineOptions {
1901 width: i32::from(256),
1902 height: i32::from(256),
1903 }
1904 }
1905}
1906
1907pub fn hough_line_with_opts(
1912 inp: &VipsImage,
1913 hough_line_options: &HoughLineOptions,
1914) -> Result<VipsImage> {
1915 unsafe {
1916 let inp_in: *mut bindings::VipsImage = inp.ctx;
1917 let mut out_out: *mut bindings::VipsImage = null_mut();
1918
1919 let width_in: i32 = hough_line_options.width;
1920 let width_in_name = utils::new_c_string("width")?;
1921
1922 let height_in: i32 = hough_line_options.height;
1923 let height_in_name = utils::new_c_string("height")?;
1924
1925 let vips_op_response = bindings::vips_hough_line(
1926 inp_in,
1927 &mut out_out,
1928 width_in_name.as_ptr(),
1929 width_in,
1930 height_in_name.as_ptr(),
1931 height_in,
1932 NULL,
1933 );
1934 utils::result(
1935 vips_op_response,
1936 VipsImage { ctx: out_out },
1937 Error::HoughLineError,
1938 )
1939 }
1940}
1941
1942pub fn hough_circle(inp: &VipsImage) -> Result<VipsImage> {
1946 unsafe {
1947 let inp_in: *mut bindings::VipsImage = inp.ctx;
1948 let mut out_out: *mut bindings::VipsImage = null_mut();
1949
1950 let vips_op_response = bindings::vips_hough_circle(inp_in, &mut out_out, NULL);
1951 utils::result(
1952 vips_op_response,
1953 VipsImage { ctx: out_out },
1954 Error::HoughCircleError,
1955 )
1956 }
1957}
1958
1959#[derive(Clone, Debug)]
1961pub struct HoughCircleOptions {
1962 pub scale: i32,
1965 pub min_radius: i32,
1968 pub max_radius: i32,
1971}
1972
1973impl std::default::Default for HoughCircleOptions {
1974 fn default() -> Self {
1975 HoughCircleOptions {
1976 scale: i32::from(1),
1977 min_radius: i32::from(10),
1978 max_radius: i32::from(20),
1979 }
1980 }
1981}
1982
1983pub fn hough_circle_with_opts(
1988 inp: &VipsImage,
1989 hough_circle_options: &HoughCircleOptions,
1990) -> Result<VipsImage> {
1991 unsafe {
1992 let inp_in: *mut bindings::VipsImage = inp.ctx;
1993 let mut out_out: *mut bindings::VipsImage = null_mut();
1994
1995 let scale_in: i32 = hough_circle_options.scale;
1996 let scale_in_name = utils::new_c_string("scale")?;
1997
1998 let min_radius_in: i32 = hough_circle_options.min_radius;
1999 let min_radius_in_name = utils::new_c_string("min-radius")?;
2000
2001 let max_radius_in: i32 = hough_circle_options.max_radius;
2002 let max_radius_in_name = utils::new_c_string("max-radius")?;
2003
2004 let vips_op_response = bindings::vips_hough_circle(
2005 inp_in,
2006 &mut out_out,
2007 scale_in_name.as_ptr(),
2008 scale_in,
2009 min_radius_in_name.as_ptr(),
2010 min_radius_in,
2011 max_radius_in_name.as_ptr(),
2012 max_radius_in,
2013 NULL,
2014 );
2015 utils::result(
2016 vips_op_response,
2017 VipsImage { ctx: out_out },
2018 Error::HoughCircleError,
2019 )
2020 }
2021}
2022
2023pub fn project(inp: &VipsImage) -> Result<(VipsImage, VipsImage)> {
2030 unsafe {
2031 let inp_in: *mut bindings::VipsImage = inp.ctx;
2032 let mut columns_out: *mut bindings::VipsImage = null_mut();
2033 let mut rows_out: *mut bindings::VipsImage = null_mut();
2034
2035 let vips_op_response =
2036 bindings::vips_project(inp_in, &mut columns_out, &mut rows_out, NULL);
2037 utils::result(
2038 vips_op_response,
2039 (VipsImage { ctx: columns_out }, VipsImage { ctx: rows_out }),
2040 Error::ProjectError,
2041 )
2042 }
2043}
2044
2045pub fn profile(inp: &VipsImage) -> Result<(VipsImage, VipsImage)> {
2052 unsafe {
2053 let inp_in: *mut bindings::VipsImage = inp.ctx;
2054 let mut columns_out: *mut bindings::VipsImage = null_mut();
2055 let mut rows_out: *mut bindings::VipsImage = null_mut();
2056
2057 let vips_op_response =
2058 bindings::vips_profile(inp_in, &mut columns_out, &mut rows_out, NULL);
2059 utils::result(
2060 vips_op_response,
2061 (VipsImage { ctx: columns_out }, VipsImage { ctx: rows_out }),
2062 Error::ProfileError,
2063 )
2064 }
2065}
2066
2067pub fn measure(inp: &VipsImage, h: i32, v: i32) -> Result<VipsImage> {
2075 unsafe {
2076 let inp_in: *mut bindings::VipsImage = inp.ctx;
2077 let h_in: i32 = h;
2078 let v_in: i32 = v;
2079 let mut out_out: *mut bindings::VipsImage = null_mut();
2080
2081 let vips_op_response = bindings::vips_measure(inp_in, &mut out_out, h_in, v_in, NULL);
2082 utils::result(
2083 vips_op_response,
2084 VipsImage { ctx: out_out },
2085 Error::MeasureError,
2086 )
2087 }
2088}
2089
2090#[derive(Clone, Debug)]
2092pub struct MeasureOptions {
2093 pub left: i32,
2096 pub top: i32,
2099 pub width: i32,
2102 pub height: i32,
2105}
2106
2107impl std::default::Default for MeasureOptions {
2108 fn default() -> Self {
2109 MeasureOptions {
2110 left: i32::from(0),
2111 top: i32::from(0),
2112 width: i32::from(1),
2113 height: i32::from(1),
2114 }
2115 }
2116}
2117
2118pub fn measure_with_opts(
2127 inp: &VipsImage,
2128 h: i32,
2129 v: i32,
2130 measure_options: &MeasureOptions,
2131) -> Result<VipsImage> {
2132 unsafe {
2133 let inp_in: *mut bindings::VipsImage = inp.ctx;
2134 let h_in: i32 = h;
2135 let v_in: i32 = v;
2136 let mut out_out: *mut bindings::VipsImage = null_mut();
2137
2138 let left_in: i32 = measure_options.left;
2139 let left_in_name = utils::new_c_string("left")?;
2140
2141 let top_in: i32 = measure_options.top;
2142 let top_in_name = utils::new_c_string("top")?;
2143
2144 let width_in: i32 = measure_options.width;
2145 let width_in_name = utils::new_c_string("width")?;
2146
2147 let height_in: i32 = measure_options.height;
2148 let height_in_name = utils::new_c_string("height")?;
2149
2150 let vips_op_response = bindings::vips_measure(
2151 inp_in,
2152 &mut out_out,
2153 h_in,
2154 v_in,
2155 left_in_name.as_ptr(),
2156 left_in,
2157 top_in_name.as_ptr(),
2158 top_in,
2159 width_in_name.as_ptr(),
2160 width_in,
2161 height_in_name.as_ptr(),
2162 height_in,
2163 NULL,
2164 );
2165 utils::result(
2166 vips_op_response,
2167 VipsImage { ctx: out_out },
2168 Error::MeasureError,
2169 )
2170 }
2171}
2172
2173pub fn find_trim(inp: &VipsImage) -> Result<(i32, i32, i32, i32)> {
2182 unsafe {
2183 let inp_in: *mut bindings::VipsImage = inp.ctx;
2184 let mut left_out: i32 = i32::from(1);
2185 let mut top_out: i32 = i32::from(0);
2186 let mut width_out: i32 = i32::from(1);
2187 let mut height_out: i32 = i32::from(1);
2188
2189 let vips_op_response = bindings::vips_find_trim(
2190 inp_in,
2191 &mut left_out,
2192 &mut top_out,
2193 &mut width_out,
2194 &mut height_out,
2195 NULL,
2196 );
2197 utils::result(
2198 vips_op_response,
2199 (left_out, top_out, width_out, height_out),
2200 Error::FindTrimError,
2201 )
2202 }
2203}
2204
2205#[derive(Clone, Debug)]
2207pub struct FindTrimOptions {
2208 pub threshold: f64,
2211 pub background: Vec<f64>,
2213 pub line_art: bool,
2216}
2217
2218impl std::default::Default for FindTrimOptions {
2219 fn default() -> Self {
2220 FindTrimOptions {
2221 threshold: f64::from(10),
2222 background: Vec::new(),
2223 line_art: false,
2224 }
2225 }
2226}
2227
2228pub fn find_trim_with_opts(
2238 inp: &VipsImage,
2239 find_trim_options: &FindTrimOptions,
2240) -> Result<(i32, i32, i32, i32)> {
2241 unsafe {
2242 let inp_in: *mut bindings::VipsImage = inp.ctx;
2243 let mut left_out: i32 = i32::from(1);
2244 let mut top_out: i32 = i32::from(0);
2245 let mut width_out: i32 = i32::from(1);
2246 let mut height_out: i32 = i32::from(1);
2247
2248 let threshold_in: f64 = find_trim_options.threshold;
2249 let threshold_in_name = utils::new_c_string("threshold")?;
2250
2251 let background_wrapper =
2252 utils::VipsArrayDoubleWrapper::from(&find_trim_options.background[..]);
2253 let background_in = background_wrapper.ctx;
2254 let background_in_name = utils::new_c_string("background")?;
2255
2256 let line_art_in: i32 = if find_trim_options.line_art { 1 } else { 0 };
2257 let line_art_in_name = utils::new_c_string("line-art")?;
2258
2259 let vips_op_response = bindings::vips_find_trim(
2260 inp_in,
2261 &mut left_out,
2262 &mut top_out,
2263 &mut width_out,
2264 &mut height_out,
2265 threshold_in_name.as_ptr(),
2266 threshold_in,
2267 background_in_name.as_ptr(),
2268 background_in,
2269 line_art_in_name.as_ptr(),
2270 line_art_in,
2271 NULL,
2272 );
2273 utils::result(
2274 vips_op_response,
2275 (left_out, top_out, width_out, height_out),
2276 Error::FindTrimError,
2277 )
2278 }
2279}
2280
2281pub fn copy(inp: &VipsImage) -> Result<VipsImage> {
2285 unsafe {
2286 let inp_in: *mut bindings::VipsImage = inp.ctx;
2287 let mut out_out: *mut bindings::VipsImage = null_mut();
2288
2289 let vips_op_response = bindings::vips_copy(inp_in, &mut out_out, NULL);
2290 utils::result(
2291 vips_op_response,
2292 VipsImage { ctx: out_out },
2293 Error::CopyError,
2294 )
2295 }
2296}
2297
2298#[derive(Clone, Debug)]
2300pub struct CopyOptions {
2301 pub width: i32,
2304 pub height: i32,
2307 pub bands: i32,
2310 pub format: BandFormat,
2323 pub coding: Coding,
2329 pub interpretation: Interpretation,
2353 pub xres: f64,
2356 pub yres: f64,
2359 pub xoffset: i32,
2362 pub yoffset: i32,
2365}
2366
2367impl std::default::Default for CopyOptions {
2368 fn default() -> Self {
2369 CopyOptions {
2370 width: i32::from(0),
2371 height: i32::from(0),
2372 bands: i32::from(0),
2373 format: BandFormat::Uchar,
2374 coding: Coding::None,
2375 interpretation: Interpretation::Multiband,
2376 xres: f64::from(0),
2377 yres: f64::from(0),
2378 xoffset: i32::from(0),
2379 yoffset: i32::from(0),
2380 }
2381 }
2382}
2383
2384pub fn copy_with_opts(inp: &VipsImage, copy_options: &CopyOptions) -> Result<VipsImage> {
2389 unsafe {
2390 let inp_in: *mut bindings::VipsImage = inp.ctx;
2391 let mut out_out: *mut bindings::VipsImage = null_mut();
2392
2393 let width_in: i32 = copy_options.width;
2394 let width_in_name = utils::new_c_string("width")?;
2395
2396 let height_in: i32 = copy_options.height;
2397 let height_in_name = utils::new_c_string("height")?;
2398
2399 let bands_in: i32 = copy_options.bands;
2400 let bands_in_name = utils::new_c_string("bands")?;
2401
2402 let format_in: i32 = copy_options.format as i32;
2403 let format_in_name = utils::new_c_string("format")?;
2404
2405 let coding_in: i32 = copy_options.coding as i32;
2406 let coding_in_name = utils::new_c_string("coding")?;
2407
2408 let interpretation_in: i32 = copy_options.interpretation as i32;
2409 let interpretation_in_name = utils::new_c_string("interpretation")?;
2410
2411 let xres_in: f64 = copy_options.xres;
2412 let xres_in_name = utils::new_c_string("xres")?;
2413
2414 let yres_in: f64 = copy_options.yres;
2415 let yres_in_name = utils::new_c_string("yres")?;
2416
2417 let xoffset_in: i32 = copy_options.xoffset;
2418 let xoffset_in_name = utils::new_c_string("xoffset")?;
2419
2420 let yoffset_in: i32 = copy_options.yoffset;
2421 let yoffset_in_name = utils::new_c_string("yoffset")?;
2422
2423 let vips_op_response = bindings::vips_copy(
2424 inp_in,
2425 &mut out_out,
2426 width_in_name.as_ptr(),
2427 width_in,
2428 height_in_name.as_ptr(),
2429 height_in,
2430 bands_in_name.as_ptr(),
2431 bands_in,
2432 format_in_name.as_ptr(),
2433 format_in,
2434 coding_in_name.as_ptr(),
2435 coding_in,
2436 interpretation_in_name.as_ptr(),
2437 interpretation_in,
2438 xres_in_name.as_ptr(),
2439 xres_in,
2440 yres_in_name.as_ptr(),
2441 yres_in,
2442 xoffset_in_name.as_ptr(),
2443 xoffset_in,
2444 yoffset_in_name.as_ptr(),
2445 yoffset_in,
2446 NULL,
2447 );
2448 utils::result(
2449 vips_op_response,
2450 VipsImage { ctx: out_out },
2451 Error::CopyError,
2452 )
2453 }
2454}
2455
2456pub fn tilecache(inp: &VipsImage) -> Result<VipsImage> {
2460 unsafe {
2461 let inp_in: *mut bindings::VipsImage = inp.ctx;
2462 let mut out_out: *mut bindings::VipsImage = null_mut();
2463
2464 let vips_op_response = bindings::vips_tilecache(inp_in, &mut out_out, NULL);
2465 utils::result(
2466 vips_op_response,
2467 VipsImage { ctx: out_out },
2468 Error::TilecacheError,
2469 )
2470 }
2471}
2472
2473#[derive(Clone, Debug)]
2475pub struct TilecacheOptions {
2476 pub tile_width: i32,
2479 pub tile_height: i32,
2482 pub max_tiles: i32,
2485 pub access: Access,
2490 pub threaded: bool,
2493 pub persistent: bool,
2496}
2497
2498impl std::default::Default for TilecacheOptions {
2499 fn default() -> Self {
2500 TilecacheOptions {
2501 tile_width: i32::from(128),
2502 tile_height: i32::from(128),
2503 max_tiles: i32::from(1000),
2504 access: Access::Random,
2505 threaded: false,
2506 persistent: false,
2507 }
2508 }
2509}
2510
2511pub fn tilecache_with_opts(
2516 inp: &VipsImage,
2517 tilecache_options: &TilecacheOptions,
2518) -> Result<VipsImage> {
2519 unsafe {
2520 let inp_in: *mut bindings::VipsImage = inp.ctx;
2521 let mut out_out: *mut bindings::VipsImage = null_mut();
2522
2523 let tile_width_in: i32 = tilecache_options.tile_width;
2524 let tile_width_in_name = utils::new_c_string("tile-width")?;
2525
2526 let tile_height_in: i32 = tilecache_options.tile_height;
2527 let tile_height_in_name = utils::new_c_string("tile-height")?;
2528
2529 let max_tiles_in: i32 = tilecache_options.max_tiles;
2530 let max_tiles_in_name = utils::new_c_string("max-tiles")?;
2531
2532 let access_in: i32 = tilecache_options.access as i32;
2533 let access_in_name = utils::new_c_string("access")?;
2534
2535 let threaded_in: i32 = if tilecache_options.threaded { 1 } else { 0 };
2536 let threaded_in_name = utils::new_c_string("threaded")?;
2537
2538 let persistent_in: i32 = if tilecache_options.persistent { 1 } else { 0 };
2539 let persistent_in_name = utils::new_c_string("persistent")?;
2540
2541 let vips_op_response = bindings::vips_tilecache(
2542 inp_in,
2543 &mut out_out,
2544 tile_width_in_name.as_ptr(),
2545 tile_width_in,
2546 tile_height_in_name.as_ptr(),
2547 tile_height_in,
2548 max_tiles_in_name.as_ptr(),
2549 max_tiles_in,
2550 access_in_name.as_ptr(),
2551 access_in,
2552 threaded_in_name.as_ptr(),
2553 threaded_in,
2554 persistent_in_name.as_ptr(),
2555 persistent_in,
2556 NULL,
2557 );
2558 utils::result(
2559 vips_op_response,
2560 VipsImage { ctx: out_out },
2561 Error::TilecacheError,
2562 )
2563 }
2564}
2565
2566pub fn linecache(inp: &VipsImage) -> Result<VipsImage> {
2570 unsafe {
2571 let inp_in: *mut bindings::VipsImage = inp.ctx;
2572 let mut out_out: *mut bindings::VipsImage = null_mut();
2573
2574 let vips_op_response = bindings::vips_linecache(inp_in, &mut out_out, NULL);
2575 utils::result(
2576 vips_op_response,
2577 VipsImage { ctx: out_out },
2578 Error::LinecacheError,
2579 )
2580 }
2581}
2582
2583#[derive(Clone, Debug)]
2585pub struct LinecacheOptions {
2586 pub tile_height: i32,
2589 pub access: Access,
2594 pub threaded: bool,
2597 pub persistent: bool,
2600}
2601
2602impl std::default::Default for LinecacheOptions {
2603 fn default() -> Self {
2604 LinecacheOptions {
2605 tile_height: i32::from(128),
2606 access: Access::Random,
2607 threaded: false,
2608 persistent: false,
2609 }
2610 }
2611}
2612
2613pub fn linecache_with_opts(
2618 inp: &VipsImage,
2619 linecache_options: &LinecacheOptions,
2620) -> Result<VipsImage> {
2621 unsafe {
2622 let inp_in: *mut bindings::VipsImage = inp.ctx;
2623 let mut out_out: *mut bindings::VipsImage = null_mut();
2624
2625 let tile_height_in: i32 = linecache_options.tile_height;
2626 let tile_height_in_name = utils::new_c_string("tile-height")?;
2627
2628 let access_in: i32 = linecache_options.access as i32;
2629 let access_in_name = utils::new_c_string("access")?;
2630
2631 let threaded_in: i32 = if linecache_options.threaded { 1 } else { 0 };
2632 let threaded_in_name = utils::new_c_string("threaded")?;
2633
2634 let persistent_in: i32 = if linecache_options.persistent { 1 } else { 0 };
2635 let persistent_in_name = utils::new_c_string("persistent")?;
2636
2637 let vips_op_response = bindings::vips_linecache(
2638 inp_in,
2639 &mut out_out,
2640 tile_height_in_name.as_ptr(),
2641 tile_height_in,
2642 access_in_name.as_ptr(),
2643 access_in,
2644 threaded_in_name.as_ptr(),
2645 threaded_in,
2646 persistent_in_name.as_ptr(),
2647 persistent_in,
2648 NULL,
2649 );
2650 utils::result(
2651 vips_op_response,
2652 VipsImage { ctx: out_out },
2653 Error::LinecacheError,
2654 )
2655 }
2656}
2657
2658pub fn sequential(inp: &VipsImage) -> Result<VipsImage> {
2662 unsafe {
2663 let inp_in: *mut bindings::VipsImage = inp.ctx;
2664 let mut out_out: *mut bindings::VipsImage = null_mut();
2665
2666 let vips_op_response = bindings::vips_sequential(inp_in, &mut out_out, NULL);
2667 utils::result(
2668 vips_op_response,
2669 VipsImage { ctx: out_out },
2670 Error::SequentialError,
2671 )
2672 }
2673}
2674
2675#[derive(Clone, Debug)]
2677pub struct SequentialOptions {
2678 pub tile_height: i32,
2681}
2682
2683impl std::default::Default for SequentialOptions {
2684 fn default() -> Self {
2685 SequentialOptions {
2686 tile_height: i32::from(1),
2687 }
2688 }
2689}
2690
2691pub fn sequential_with_opts(
2696 inp: &VipsImage,
2697 sequential_options: &SequentialOptions,
2698) -> Result<VipsImage> {
2699 unsafe {
2700 let inp_in: *mut bindings::VipsImage = inp.ctx;
2701 let mut out_out: *mut bindings::VipsImage = null_mut();
2702
2703 let tile_height_in: i32 = sequential_options.tile_height;
2704 let tile_height_in_name = utils::new_c_string("tile-height")?;
2705
2706 let vips_op_response = bindings::vips_sequential(
2707 inp_in,
2708 &mut out_out,
2709 tile_height_in_name.as_ptr(),
2710 tile_height_in,
2711 NULL,
2712 );
2713 utils::result(
2714 vips_op_response,
2715 VipsImage { ctx: out_out },
2716 Error::SequentialError,
2717 )
2718 }
2719}
2720
2721pub fn embed(inp: &VipsImage, x: i32, y: i32, width: i32, height: i32) -> Result<VipsImage> {
2733 unsafe {
2734 let inp_in: *mut bindings::VipsImage = inp.ctx;
2735 let x_in: i32 = x;
2736 let y_in: i32 = y;
2737 let width_in: i32 = width;
2738 let height_in: i32 = height;
2739 let mut out_out: *mut bindings::VipsImage = null_mut();
2740
2741 let vips_op_response =
2742 bindings::vips_embed(inp_in, &mut out_out, x_in, y_in, width_in, height_in, NULL);
2743 utils::result(
2744 vips_op_response,
2745 VipsImage { ctx: out_out },
2746 Error::EmbedError,
2747 )
2748 }
2749}
2750
2751#[derive(Clone, Debug)]
2753pub struct EmbedOptions {
2754 pub extend: Extend,
2762 pub background: Vec<f64>,
2764}
2765
2766impl std::default::Default for EmbedOptions {
2767 fn default() -> Self {
2768 EmbedOptions {
2769 extend: Extend::Black,
2770 background: Vec::new(),
2771 }
2772 }
2773}
2774
2775pub fn embed_with_opts(
2788 inp: &VipsImage,
2789 x: i32,
2790 y: i32,
2791 width: i32,
2792 height: i32,
2793 embed_options: &EmbedOptions,
2794) -> Result<VipsImage> {
2795 unsafe {
2796 let inp_in: *mut bindings::VipsImage = inp.ctx;
2797 let x_in: i32 = x;
2798 let y_in: i32 = y;
2799 let width_in: i32 = width;
2800 let height_in: i32 = height;
2801 let mut out_out: *mut bindings::VipsImage = null_mut();
2802
2803 let extend_in: i32 = embed_options.extend as i32;
2804 let extend_in_name = utils::new_c_string("extend")?;
2805
2806 let background_wrapper = utils::VipsArrayDoubleWrapper::from(&embed_options.background[..]);
2807 let background_in = background_wrapper.ctx;
2808 let background_in_name = utils::new_c_string("background")?;
2809
2810 let vips_op_response = bindings::vips_embed(
2811 inp_in,
2812 &mut out_out,
2813 x_in,
2814 y_in,
2815 width_in,
2816 height_in,
2817 extend_in_name.as_ptr(),
2818 extend_in,
2819 background_in_name.as_ptr(),
2820 background_in,
2821 NULL,
2822 );
2823 utils::result(
2824 vips_op_response,
2825 VipsImage { ctx: out_out },
2826 Error::EmbedError,
2827 )
2828 }
2829}
2830
2831pub fn gravity(
2849 inp: &VipsImage,
2850 direction: CompassDirection,
2851 width: i32,
2852 height: i32,
2853) -> Result<VipsImage> {
2854 unsafe {
2855 let inp_in: *mut bindings::VipsImage = inp.ctx;
2856 let direction_in: i32 = direction as i32;
2857 let width_in: i32 = width;
2858 let height_in: i32 = height;
2859 let mut out_out: *mut bindings::VipsImage = null_mut();
2860
2861 let vips_op_response = bindings::vips_gravity(
2862 inp_in,
2863 &mut out_out,
2864 direction_in.try_into().unwrap(),
2865 width_in,
2866 height_in,
2867 NULL,
2868 );
2869 utils::result(
2870 vips_op_response,
2871 VipsImage { ctx: out_out },
2872 Error::GravityError,
2873 )
2874 }
2875}
2876
2877#[derive(Clone, Debug)]
2879pub struct GravityOptions {
2880 pub extend: Extend,
2888 pub background: Vec<f64>,
2890}
2891
2892impl std::default::Default for GravityOptions {
2893 fn default() -> Self {
2894 GravityOptions {
2895 extend: Extend::Black,
2896 background: Vec::new(),
2897 }
2898 }
2899}
2900
2901pub fn gravity_with_opts(
2920 inp: &VipsImage,
2921 direction: CompassDirection,
2922 width: i32,
2923 height: i32,
2924 gravity_options: &GravityOptions,
2925) -> Result<VipsImage> {
2926 unsafe {
2927 let inp_in: *mut bindings::VipsImage = inp.ctx;
2928 let direction_in: i32 = direction as i32;
2929 let width_in: i32 = width;
2930 let height_in: i32 = height;
2931 let mut out_out: *mut bindings::VipsImage = null_mut();
2932
2933 let extend_in: i32 = gravity_options.extend as i32;
2934 let extend_in_name = utils::new_c_string("extend")?;
2935
2936 let background_wrapper =
2937 utils::VipsArrayDoubleWrapper::from(&gravity_options.background[..]);
2938 let background_in = background_wrapper.ctx;
2939 let background_in_name = utils::new_c_string("background")?;
2940
2941 let vips_op_response = bindings::vips_gravity(
2942 inp_in,
2943 &mut out_out,
2944 direction_in.try_into().unwrap(),
2945 width_in,
2946 height_in,
2947 extend_in_name.as_ptr(),
2948 extend_in,
2949 background_in_name.as_ptr(),
2950 background_in,
2951 NULL,
2952 );
2953 utils::result(
2954 vips_op_response,
2955 VipsImage { ctx: out_out },
2956 Error::GravityError,
2957 )
2958 }
2959}
2960
2961pub fn flip(inp: &VipsImage, direction: Direction) -> Result<VipsImage> {
2968 unsafe {
2969 let inp_in: *mut bindings::VipsImage = inp.ctx;
2970 let direction_in: i32 = direction as i32;
2971 let mut out_out: *mut bindings::VipsImage = null_mut();
2972
2973 let vips_op_response =
2974 bindings::vips_flip(inp_in, &mut out_out, direction_in.try_into().unwrap(), NULL);
2975 utils::result(
2976 vips_op_response,
2977 VipsImage { ctx: out_out },
2978 Error::FlipError,
2979 )
2980 }
2981}
2982
2983pub fn insert(main: &VipsImage, sub: &VipsImage, x: i32, y: i32) -> Result<VipsImage> {
2992 unsafe {
2993 let main_in: *mut bindings::VipsImage = main.ctx;
2994 let sub_in: *mut bindings::VipsImage = sub.ctx;
2995 let x_in: i32 = x;
2996 let y_in: i32 = y;
2997 let mut out_out: *mut bindings::VipsImage = null_mut();
2998
2999 let vips_op_response =
3000 bindings::vips_insert(main_in, sub_in, &mut out_out, x_in, y_in, NULL);
3001 utils::result(
3002 vips_op_response,
3003 VipsImage { ctx: out_out },
3004 Error::InsertError,
3005 )
3006 }
3007}
3008
3009#[derive(Clone, Debug)]
3011pub struct InsertOptions {
3012 pub expand: bool,
3015 pub background: Vec<f64>,
3017}
3018
3019impl std::default::Default for InsertOptions {
3020 fn default() -> Self {
3021 InsertOptions {
3022 expand: false,
3023 background: Vec::new(),
3024 }
3025 }
3026}
3027
3028pub fn insert_with_opts(
3038 main: &VipsImage,
3039 sub: &VipsImage,
3040 x: i32,
3041 y: i32,
3042 insert_options: &InsertOptions,
3043) -> Result<VipsImage> {
3044 unsafe {
3045 let main_in: *mut bindings::VipsImage = main.ctx;
3046 let sub_in: *mut bindings::VipsImage = sub.ctx;
3047 let x_in: i32 = x;
3048 let y_in: i32 = y;
3049 let mut out_out: *mut bindings::VipsImage = null_mut();
3050
3051 let expand_in: i32 = if insert_options.expand { 1 } else { 0 };
3052 let expand_in_name = utils::new_c_string("expand")?;
3053
3054 let background_wrapper =
3055 utils::VipsArrayDoubleWrapper::from(&insert_options.background[..]);
3056 let background_in = background_wrapper.ctx;
3057 let background_in_name = utils::new_c_string("background")?;
3058
3059 let vips_op_response = bindings::vips_insert(
3060 main_in,
3061 sub_in,
3062 &mut out_out,
3063 x_in,
3064 y_in,
3065 expand_in_name.as_ptr(),
3066 expand_in,
3067 background_in_name.as_ptr(),
3068 background_in,
3069 NULL,
3070 );
3071 utils::result(
3072 vips_op_response,
3073 VipsImage { ctx: out_out },
3074 Error::InsertError,
3075 )
3076 }
3077}
3078
3079pub fn join(in_1: &VipsImage, in_2: &VipsImage, direction: Direction) -> Result<VipsImage> {
3087 unsafe {
3088 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
3089 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
3090 let direction_in: i32 = direction as i32;
3091 let mut out_out: *mut bindings::VipsImage = null_mut();
3092
3093 let vips_op_response = bindings::vips_join(
3094 in_1_in,
3095 in_2_in,
3096 &mut out_out,
3097 direction_in.try_into().unwrap(),
3098 NULL,
3099 );
3100 utils::result(
3101 vips_op_response,
3102 VipsImage { ctx: out_out },
3103 Error::JoinError,
3104 )
3105 }
3106}
3107
3108#[derive(Clone, Debug)]
3110pub struct JoinOptions {
3111 pub expand: bool,
3114 pub shim: i32,
3117 pub background: Vec<f64>,
3119 pub align: Align,
3124}
3125
3126impl std::default::Default for JoinOptions {
3127 fn default() -> Self {
3128 JoinOptions {
3129 expand: false,
3130 shim: i32::from(0),
3131 background: Vec::new(),
3132 align: Align::Low,
3133 }
3134 }
3135}
3136
3137pub fn join_with_opts(
3146 in_1: &VipsImage,
3147 in_2: &VipsImage,
3148 direction: Direction,
3149 join_options: &JoinOptions,
3150) -> Result<VipsImage> {
3151 unsafe {
3152 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
3153 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
3154 let direction_in: i32 = direction as i32;
3155 let mut out_out: *mut bindings::VipsImage = null_mut();
3156
3157 let expand_in: i32 = if join_options.expand { 1 } else { 0 };
3158 let expand_in_name = utils::new_c_string("expand")?;
3159
3160 let shim_in: i32 = join_options.shim;
3161 let shim_in_name = utils::new_c_string("shim")?;
3162
3163 let background_wrapper = utils::VipsArrayDoubleWrapper::from(&join_options.background[..]);
3164 let background_in = background_wrapper.ctx;
3165 let background_in_name = utils::new_c_string("background")?;
3166
3167 let align_in: i32 = join_options.align as i32;
3168 let align_in_name = utils::new_c_string("align")?;
3169
3170 let vips_op_response = bindings::vips_join(
3171 in_1_in,
3172 in_2_in,
3173 &mut out_out,
3174 direction_in.try_into().unwrap(),
3175 expand_in_name.as_ptr(),
3176 expand_in,
3177 shim_in_name.as_ptr(),
3178 shim_in,
3179 background_in_name.as_ptr(),
3180 background_in,
3181 align_in_name.as_ptr(),
3182 align_in,
3183 NULL,
3184 );
3185 utils::result(
3186 vips_op_response,
3187 VipsImage { ctx: out_out },
3188 Error::JoinError,
3189 )
3190 }
3191}
3192
3193pub fn arrayjoin(inp: &mut [VipsImage]) -> Result<VipsImage> {
3197 unsafe {
3198 let (inp_len, mut inp_in) = {
3199 let len = inp.len();
3200 let mut input = Vec::new();
3201 for img in inp {
3202 input.push(img.ctx)
3203 }
3204 (len as i32, input)
3205 };
3206 let mut out_out: *mut bindings::VipsImage = null_mut();
3207
3208 let vips_op_response =
3209 bindings::vips_arrayjoin(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
3210 utils::result(
3211 vips_op_response,
3212 VipsImage { ctx: out_out },
3213 Error::ArrayjoinError,
3214 )
3215 }
3216}
3217
3218#[derive(Clone, Debug)]
3220pub struct ArrayjoinOptions {
3221 pub across: i32,
3224 pub shim: i32,
3227 pub background: Vec<f64>,
3229 pub halign: Align,
3234 pub valign: Align,
3239 pub hspacing: i32,
3242 pub vspacing: i32,
3245}
3246
3247impl std::default::Default for ArrayjoinOptions {
3248 fn default() -> Self {
3249 ArrayjoinOptions {
3250 across: i32::from(1),
3251 shim: i32::from(0),
3252 background: Vec::new(),
3253 halign: Align::Low,
3254 valign: Align::Low,
3255 hspacing: i32::from(1),
3256 vspacing: i32::from(1),
3257 }
3258 }
3259}
3260
3261pub fn arrayjoin_with_opts(
3266 inp: &mut [VipsImage],
3267 arrayjoin_options: &ArrayjoinOptions,
3268) -> Result<VipsImage> {
3269 unsafe {
3270 let (inp_len, mut inp_in) = {
3271 let len = inp.len();
3272 let mut input = Vec::new();
3273 for img in inp {
3274 input.push(img.ctx)
3275 }
3276 (len as i32, input)
3277 };
3278 let mut out_out: *mut bindings::VipsImage = null_mut();
3279
3280 let across_in: i32 = arrayjoin_options.across;
3281 let across_in_name = utils::new_c_string("across")?;
3282
3283 let shim_in: i32 = arrayjoin_options.shim;
3284 let shim_in_name = utils::new_c_string("shim")?;
3285
3286 let background_wrapper =
3287 utils::VipsArrayDoubleWrapper::from(&arrayjoin_options.background[..]);
3288 let background_in = background_wrapper.ctx;
3289 let background_in_name = utils::new_c_string("background")?;
3290
3291 let halign_in: i32 = arrayjoin_options.halign as i32;
3292 let halign_in_name = utils::new_c_string("halign")?;
3293
3294 let valign_in: i32 = arrayjoin_options.valign as i32;
3295 let valign_in_name = utils::new_c_string("valign")?;
3296
3297 let hspacing_in: i32 = arrayjoin_options.hspacing;
3298 let hspacing_in_name = utils::new_c_string("hspacing")?;
3299
3300 let vspacing_in: i32 = arrayjoin_options.vspacing;
3301 let vspacing_in_name = utils::new_c_string("vspacing")?;
3302
3303 let vips_op_response = bindings::vips_arrayjoin(
3304 inp_in.as_mut_ptr(),
3305 &mut out_out,
3306 inp_len,
3307 across_in_name.as_ptr(),
3308 across_in,
3309 shim_in_name.as_ptr(),
3310 shim_in,
3311 background_in_name.as_ptr(),
3312 background_in,
3313 halign_in_name.as_ptr(),
3314 halign_in,
3315 valign_in_name.as_ptr(),
3316 valign_in,
3317 hspacing_in_name.as_ptr(),
3318 hspacing_in,
3319 vspacing_in_name.as_ptr(),
3320 vspacing_in,
3321 NULL,
3322 );
3323 utils::result(
3324 vips_op_response,
3325 VipsImage { ctx: out_out },
3326 Error::ArrayjoinError,
3327 )
3328 }
3329}
3330
3331pub fn extract_area(
3343 input: &VipsImage,
3344 left: i32,
3345 top: i32,
3346 width: i32,
3347 height: i32,
3348) -> Result<VipsImage> {
3349 unsafe {
3350 let input_in: *mut bindings::VipsImage = input.ctx;
3351 let left_in: i32 = left;
3352 let top_in: i32 = top;
3353 let width_in: i32 = width;
3354 let height_in: i32 = height;
3355 let mut out_out: *mut bindings::VipsImage = null_mut();
3356
3357 let vips_op_response = bindings::vips_extract_area(
3358 input_in,
3359 &mut out_out,
3360 left_in,
3361 top_in,
3362 width_in,
3363 height_in,
3364 NULL,
3365 );
3366 utils::result(
3367 vips_op_response,
3368 VipsImage { ctx: out_out },
3369 Error::ExtractAreaError,
3370 )
3371 }
3372}
3373
3374pub fn smartcrop(input: &VipsImage, width: i32, height: i32) -> Result<VipsImage> {
3382 unsafe {
3383 let input_in: *mut bindings::VipsImage = input.ctx;
3384 let width_in: i32 = width;
3385 let height_in: i32 = height;
3386 let mut out_out: *mut bindings::VipsImage = null_mut();
3387
3388 let vips_op_response =
3389 bindings::vips_smartcrop(input_in, &mut out_out, width_in, height_in, NULL);
3390 utils::result(
3391 vips_op_response,
3392 VipsImage { ctx: out_out },
3393 Error::SmartcropError,
3394 )
3395 }
3396}
3397
3398#[derive(Clone, Debug)]
3400pub struct SmartcropOptions {
3401 pub attention_x: i32,
3404 pub attention_y: i32,
3407 pub interesting: Interesting,
3416 pub premultiplied: bool,
3419}
3420
3421impl std::default::Default for SmartcropOptions {
3422 fn default() -> Self {
3423 SmartcropOptions {
3424 attention_x: i32::from(0),
3425 attention_y: i32::from(0),
3426 interesting: Interesting::Attention,
3427 premultiplied: false,
3428 }
3429 }
3430}
3431
3432pub fn smartcrop_with_opts(
3441 input: &VipsImage,
3442 width: i32,
3443 height: i32,
3444 smartcrop_options: &SmartcropOptions,
3445) -> Result<VipsImage> {
3446 unsafe {
3447 let input_in: *mut bindings::VipsImage = input.ctx;
3448 let width_in: i32 = width;
3449 let height_in: i32 = height;
3450 let mut out_out: *mut bindings::VipsImage = null_mut();
3451
3452 let attention_x_in: i32 = smartcrop_options.attention_x;
3453 let attention_x_in_name = utils::new_c_string("attention-x")?;
3454
3455 let attention_y_in: i32 = smartcrop_options.attention_y;
3456 let attention_y_in_name = utils::new_c_string("attention-y")?;
3457
3458 let interesting_in: i32 = smartcrop_options.interesting as i32;
3459 let interesting_in_name = utils::new_c_string("interesting")?;
3460
3461 let premultiplied_in: i32 = if smartcrop_options.premultiplied {
3462 1
3463 } else {
3464 0
3465 };
3466 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
3467
3468 let vips_op_response = bindings::vips_smartcrop(
3469 input_in,
3470 &mut out_out,
3471 width_in,
3472 height_in,
3473 attention_x_in_name.as_ptr(),
3474 attention_x_in,
3475 attention_y_in_name.as_ptr(),
3476 attention_y_in,
3477 interesting_in_name.as_ptr(),
3478 interesting_in,
3479 premultiplied_in_name.as_ptr(),
3480 premultiplied_in,
3481 NULL,
3482 );
3483 utils::result(
3484 vips_op_response,
3485 VipsImage { ctx: out_out },
3486 Error::SmartcropError,
3487 )
3488 }
3489}
3490
3491pub fn extract_band(inp: &VipsImage, band: i32) -> Result<VipsImage> {
3497 unsafe {
3498 let inp_in: *mut bindings::VipsImage = inp.ctx;
3499 let band_in: i32 = band;
3500 let mut out_out: *mut bindings::VipsImage = null_mut();
3501
3502 let vips_op_response = bindings::vips_extract_band(inp_in, &mut out_out, band_in, NULL);
3503 utils::result(
3504 vips_op_response,
3505 VipsImage { ctx: out_out },
3506 Error::ExtractBandError,
3507 )
3508 }
3509}
3510
3511#[derive(Clone, Debug)]
3513pub struct ExtractBandOptions {
3514 pub n: i32,
3517}
3518
3519impl std::default::Default for ExtractBandOptions {
3520 fn default() -> Self {
3521 ExtractBandOptions { n: i32::from(1) }
3522 }
3523}
3524
3525pub fn extract_band_with_opts(
3532 inp: &VipsImage,
3533 band: i32,
3534 extract_band_options: &ExtractBandOptions,
3535) -> Result<VipsImage> {
3536 unsafe {
3537 let inp_in: *mut bindings::VipsImage = inp.ctx;
3538 let band_in: i32 = band;
3539 let mut out_out: *mut bindings::VipsImage = null_mut();
3540
3541 let n_in: i32 = extract_band_options.n;
3542 let n_in_name = utils::new_c_string("n")?;
3543
3544 let vips_op_response = bindings::vips_extract_band(
3545 inp_in,
3546 &mut out_out,
3547 band_in,
3548 n_in_name.as_ptr(),
3549 n_in,
3550 NULL,
3551 );
3552 utils::result(
3553 vips_op_response,
3554 VipsImage { ctx: out_out },
3555 Error::ExtractBandError,
3556 )
3557 }
3558}
3559
3560pub fn bandjoin(inp: &mut [VipsImage]) -> Result<VipsImage> {
3564 unsafe {
3565 let (inp_len, mut inp_in) = {
3566 let len = inp.len();
3567 let mut input = Vec::new();
3568 for img in inp {
3569 input.push(img.ctx)
3570 }
3571 (len as i32, input)
3572 };
3573 let mut out_out: *mut bindings::VipsImage = null_mut();
3574
3575 let vips_op_response =
3576 bindings::vips_bandjoin(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
3577 utils::result(
3578 vips_op_response,
3579 VipsImage { ctx: out_out },
3580 Error::BandjoinError,
3581 )
3582 }
3583}
3584
3585pub fn bandjoin_const(inp: &VipsImage, c: &mut [f64]) -> Result<VipsImage> {
3590 unsafe {
3591 let inp_in: *mut bindings::VipsImage = inp.ctx;
3592 let c_in: *mut f64 = c.as_mut_ptr();
3593 let mut out_out: *mut bindings::VipsImage = null_mut();
3594
3595 let vips_op_response =
3596 bindings::vips_bandjoin_const(inp_in, &mut out_out, c_in, c.len() as i32, NULL);
3597 utils::result(
3598 vips_op_response,
3599 VipsImage { ctx: out_out },
3600 Error::BandjoinConstError,
3601 )
3602 }
3603}
3604
3605pub fn bandrank(inp: &mut [VipsImage]) -> Result<VipsImage> {
3609 unsafe {
3610 let (inp_len, mut inp_in) = {
3611 let len = inp.len();
3612 let mut input = Vec::new();
3613 for img in inp {
3614 input.push(img.ctx)
3615 }
3616 (len as i32, input)
3617 };
3618 let mut out_out: *mut bindings::VipsImage = null_mut();
3619
3620 let vips_op_response =
3621 bindings::vips_bandrank(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
3622 utils::result(
3623 vips_op_response,
3624 VipsImage { ctx: out_out },
3625 Error::BandrankError,
3626 )
3627 }
3628}
3629
3630#[derive(Clone, Debug)]
3632pub struct BandrankOptions {
3633 pub index: i32,
3636}
3637
3638impl std::default::Default for BandrankOptions {
3639 fn default() -> Self {
3640 BandrankOptions {
3641 index: i32::from(-1),
3642 }
3643 }
3644}
3645
3646pub fn bandrank_with_opts(
3651 inp: &mut [VipsImage],
3652 bandrank_options: &BandrankOptions,
3653) -> Result<VipsImage> {
3654 unsafe {
3655 let (inp_len, mut inp_in) = {
3656 let len = inp.len();
3657 let mut input = Vec::new();
3658 for img in inp {
3659 input.push(img.ctx)
3660 }
3661 (len as i32, input)
3662 };
3663 let mut out_out: *mut bindings::VipsImage = null_mut();
3664
3665 let index_in: i32 = bandrank_options.index;
3666 let index_in_name = utils::new_c_string("index")?;
3667
3668 let vips_op_response = bindings::vips_bandrank(
3669 inp_in.as_mut_ptr(),
3670 &mut out_out,
3671 inp_len,
3672 index_in_name.as_ptr(),
3673 index_in,
3674 NULL,
3675 );
3676 utils::result(
3677 vips_op_response,
3678 VipsImage { ctx: out_out },
3679 Error::BandrankError,
3680 )
3681 }
3682}
3683
3684pub fn bandmean(inp: &VipsImage) -> Result<VipsImage> {
3688 unsafe {
3689 let inp_in: *mut bindings::VipsImage = inp.ctx;
3690 let mut out_out: *mut bindings::VipsImage = null_mut();
3691
3692 let vips_op_response = bindings::vips_bandmean(inp_in, &mut out_out, NULL);
3693 utils::result(
3694 vips_op_response,
3695 VipsImage { ctx: out_out },
3696 Error::BandmeanError,
3697 )
3698 }
3699}
3700
3701pub fn bandbool(inp: &VipsImage, boolean: OperationBoolean) -> Result<VipsImage> {
3711 unsafe {
3712 let inp_in: *mut bindings::VipsImage = inp.ctx;
3713 let boolean_in: i32 = boolean as i32;
3714 let mut out_out: *mut bindings::VipsImage = null_mut();
3715
3716 let vips_op_response =
3717 bindings::vips_bandbool(inp_in, &mut out_out, boolean_in.try_into().unwrap(), NULL);
3718 utils::result(
3719 vips_op_response,
3720 VipsImage { ctx: out_out },
3721 Error::BandboolError,
3722 )
3723 }
3724}
3725
3726pub fn replicate(inp: &VipsImage, across: i32, down: i32) -> Result<VipsImage> {
3734 unsafe {
3735 let inp_in: *mut bindings::VipsImage = inp.ctx;
3736 let across_in: i32 = across;
3737 let down_in: i32 = down;
3738 let mut out_out: *mut bindings::VipsImage = null_mut();
3739
3740 let vips_op_response =
3741 bindings::vips_replicate(inp_in, &mut out_out, across_in, down_in, NULL);
3742 utils::result(
3743 vips_op_response,
3744 VipsImage { ctx: out_out },
3745 Error::ReplicateError,
3746 )
3747 }
3748}
3749
3750pub fn cast(inp: &VipsImage, format: BandFormat) -> Result<VipsImage> {
3766 unsafe {
3767 let inp_in: *mut bindings::VipsImage = inp.ctx;
3768 let format_in: i32 = format as i32;
3769 let mut out_out: *mut bindings::VipsImage = null_mut();
3770
3771 let vips_op_response =
3772 bindings::vips_cast(inp_in, &mut out_out, format_in.try_into().unwrap(), NULL);
3773 utils::result(
3774 vips_op_response,
3775 VipsImage { ctx: out_out },
3776 Error::CastError,
3777 )
3778 }
3779}
3780
3781#[derive(Clone, Debug)]
3783pub struct CastOptions {
3784 pub shift: bool,
3787}
3788
3789impl std::default::Default for CastOptions {
3790 fn default() -> Self {
3791 CastOptions { shift: false }
3792 }
3793}
3794
3795pub fn cast_with_opts(
3812 inp: &VipsImage,
3813 format: BandFormat,
3814 cast_options: &CastOptions,
3815) -> Result<VipsImage> {
3816 unsafe {
3817 let inp_in: *mut bindings::VipsImage = inp.ctx;
3818 let format_in: i32 = format as i32;
3819 let mut out_out: *mut bindings::VipsImage = null_mut();
3820
3821 let shift_in: i32 = if cast_options.shift { 1 } else { 0 };
3822 let shift_in_name = utils::new_c_string("shift")?;
3823
3824 let vips_op_response = bindings::vips_cast(
3825 inp_in,
3826 &mut out_out,
3827 format_in.try_into().unwrap(),
3828 shift_in_name.as_ptr(),
3829 shift_in,
3830 NULL,
3831 );
3832 utils::result(
3833 vips_op_response,
3834 VipsImage { ctx: out_out },
3835 Error::CastError,
3836 )
3837 }
3838}
3839
3840pub fn rot(inp: &VipsImage, angle: Angle) -> Result<VipsImage> {
3849 unsafe {
3850 let inp_in: *mut bindings::VipsImage = inp.ctx;
3851 let angle_in: i32 = angle as i32;
3852 let mut out_out: *mut bindings::VipsImage = null_mut();
3853
3854 let vips_op_response =
3855 bindings::vips_rot(inp_in, &mut out_out, angle_in.try_into().unwrap(), NULL);
3856 utils::result(
3857 vips_op_response,
3858 VipsImage { ctx: out_out },
3859 Error::RotError,
3860 )
3861 }
3862}
3863
3864pub fn rot_45(inp: &VipsImage) -> Result<VipsImage> {
3868 unsafe {
3869 let inp_in: *mut bindings::VipsImage = inp.ctx;
3870 let mut out_out: *mut bindings::VipsImage = null_mut();
3871
3872 let vips_op_response = bindings::vips_rot45(inp_in, &mut out_out, NULL);
3873 utils::result(
3874 vips_op_response,
3875 VipsImage { ctx: out_out },
3876 Error::Rot45Error,
3877 )
3878 }
3879}
3880
3881#[derive(Clone, Debug)]
3883pub struct Rot45Options {
3884 pub angle: Angle45,
3894}
3895
3896impl std::default::Default for Rot45Options {
3897 fn default() -> Self {
3898 Rot45Options {
3899 angle: Angle45::D45,
3900 }
3901 }
3902}
3903
3904pub fn rot_45_with_opts(inp: &VipsImage, rot_45_options: &Rot45Options) -> Result<VipsImage> {
3909 unsafe {
3910 let inp_in: *mut bindings::VipsImage = inp.ctx;
3911 let mut out_out: *mut bindings::VipsImage = null_mut();
3912
3913 let angle_in: i32 = rot_45_options.angle as i32;
3914 let angle_in_name = utils::new_c_string("angle")?;
3915
3916 let vips_op_response =
3917 bindings::vips_rot45(inp_in, &mut out_out, angle_in_name.as_ptr(), angle_in, NULL);
3918 utils::result(
3919 vips_op_response,
3920 VipsImage { ctx: out_out },
3921 Error::Rot45Error,
3922 )
3923 }
3924}
3925
3926pub fn autorot(inp: &VipsImage) -> Result<VipsImage> {
3930 unsafe {
3931 let inp_in: *mut bindings::VipsImage = inp.ctx;
3932 let mut out_out: *mut bindings::VipsImage = null_mut();
3933
3934 let vips_op_response = bindings::vips_autorot(inp_in, &mut out_out, NULL);
3935 utils::result(
3936 vips_op_response,
3937 VipsImage { ctx: out_out },
3938 Error::AutorotError,
3939 )
3940 }
3941}
3942
3943#[derive(Clone, Debug)]
3945pub struct AutorotOptions {
3946 pub angle: Angle,
3952 pub flip: bool,
3955}
3956
3957impl std::default::Default for AutorotOptions {
3958 fn default() -> Self {
3959 AutorotOptions {
3960 angle: Angle::D0,
3961 flip: false,
3962 }
3963 }
3964}
3965
3966pub fn autorot_with_opts(inp: &VipsImage, autorot_options: &AutorotOptions) -> Result<VipsImage> {
3971 unsafe {
3972 let inp_in: *mut bindings::VipsImage = inp.ctx;
3973 let mut out_out: *mut bindings::VipsImage = null_mut();
3974
3975 let angle_in: i32 = autorot_options.angle as i32;
3976 let angle_in_name = utils::new_c_string("angle")?;
3977
3978 let flip_in: i32 = if autorot_options.flip { 1 } else { 0 };
3979 let flip_in_name = utils::new_c_string("flip")?;
3980
3981 let vips_op_response = bindings::vips_autorot(
3982 inp_in,
3983 &mut out_out,
3984 angle_in_name.as_ptr(),
3985 angle_in,
3986 flip_in_name.as_ptr(),
3987 flip_in,
3988 NULL,
3989 );
3990 utils::result(
3991 vips_op_response,
3992 VipsImage { ctx: out_out },
3993 Error::AutorotError,
3994 )
3995 }
3996}
3997
3998pub fn ifthenelse(cond: &VipsImage, in_1: &VipsImage, in_2: &VipsImage) -> Result<VipsImage> {
4004 unsafe {
4005 let cond_in: *mut bindings::VipsImage = cond.ctx;
4006 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
4007 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
4008 let mut out_out: *mut bindings::VipsImage = null_mut();
4009
4010 let vips_op_response =
4011 bindings::vips_ifthenelse(cond_in, in_1_in, in_2_in, &mut out_out, NULL);
4012 utils::result(
4013 vips_op_response,
4014 VipsImage { ctx: out_out },
4015 Error::IfthenelseError,
4016 )
4017 }
4018}
4019
4020#[derive(Clone, Debug)]
4022pub struct IfthenelseOptions {
4023 pub blend: bool,
4026}
4027
4028impl std::default::Default for IfthenelseOptions {
4029 fn default() -> Self {
4030 IfthenelseOptions { blend: false }
4031 }
4032}
4033
4034pub fn ifthenelse_with_opts(
4041 cond: &VipsImage,
4042 in_1: &VipsImage,
4043 in_2: &VipsImage,
4044 ifthenelse_options: &IfthenelseOptions,
4045) -> Result<VipsImage> {
4046 unsafe {
4047 let cond_in: *mut bindings::VipsImage = cond.ctx;
4048 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
4049 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
4050 let mut out_out: *mut bindings::VipsImage = null_mut();
4051
4052 let blend_in: i32 = if ifthenelse_options.blend { 1 } else { 0 };
4053 let blend_in_name = utils::new_c_string("blend")?;
4054
4055 let vips_op_response = bindings::vips_ifthenelse(
4056 cond_in,
4057 in_1_in,
4058 in_2_in,
4059 &mut out_out,
4060 blend_in_name.as_ptr(),
4061 blend_in,
4062 NULL,
4063 );
4064 utils::result(
4065 vips_op_response,
4066 VipsImage { ctx: out_out },
4067 Error::IfthenelseError,
4068 )
4069 }
4070}
4071
4072pub fn recomb(inp: &VipsImage, m: &VipsImage) -> Result<VipsImage> {
4077 unsafe {
4078 let inp_in: *mut bindings::VipsImage = inp.ctx;
4079 let m_in: *mut bindings::VipsImage = m.ctx;
4080 let mut out_out: *mut bindings::VipsImage = null_mut();
4081
4082 let vips_op_response = bindings::vips_recomb(inp_in, &mut out_out, m_in, NULL);
4083 utils::result(
4084 vips_op_response,
4085 VipsImage { ctx: out_out },
4086 Error::RecombError,
4087 )
4088 }
4089}
4090
4091pub fn bandfold(inp: &VipsImage) -> Result<VipsImage> {
4095 unsafe {
4096 let inp_in: *mut bindings::VipsImage = inp.ctx;
4097 let mut out_out: *mut bindings::VipsImage = null_mut();
4098
4099 let vips_op_response = bindings::vips_bandfold(inp_in, &mut out_out, NULL);
4100 utils::result(
4101 vips_op_response,
4102 VipsImage { ctx: out_out },
4103 Error::BandfoldError,
4104 )
4105 }
4106}
4107
4108#[derive(Clone, Debug)]
4110pub struct BandfoldOptions {
4111 pub factor: i32,
4114}
4115
4116impl std::default::Default for BandfoldOptions {
4117 fn default() -> Self {
4118 BandfoldOptions {
4119 factor: i32::from(0),
4120 }
4121 }
4122}
4123
4124pub fn bandfold_with_opts(
4129 inp: &VipsImage,
4130 bandfold_options: &BandfoldOptions,
4131) -> Result<VipsImage> {
4132 unsafe {
4133 let inp_in: *mut bindings::VipsImage = inp.ctx;
4134 let mut out_out: *mut bindings::VipsImage = null_mut();
4135
4136 let factor_in: i32 = bandfold_options.factor;
4137 let factor_in_name = utils::new_c_string("factor")?;
4138
4139 let vips_op_response = bindings::vips_bandfold(
4140 inp_in,
4141 &mut out_out,
4142 factor_in_name.as_ptr(),
4143 factor_in,
4144 NULL,
4145 );
4146 utils::result(
4147 vips_op_response,
4148 VipsImage { ctx: out_out },
4149 Error::BandfoldError,
4150 )
4151 }
4152}
4153
4154pub fn bandunfold(inp: &VipsImage) -> Result<VipsImage> {
4158 unsafe {
4159 let inp_in: *mut bindings::VipsImage = inp.ctx;
4160 let mut out_out: *mut bindings::VipsImage = null_mut();
4161
4162 let vips_op_response = bindings::vips_bandunfold(inp_in, &mut out_out, NULL);
4163 utils::result(
4164 vips_op_response,
4165 VipsImage { ctx: out_out },
4166 Error::BandunfoldError,
4167 )
4168 }
4169}
4170
4171#[derive(Clone, Debug)]
4173pub struct BandunfoldOptions {
4174 pub factor: i32,
4177}
4178
4179impl std::default::Default for BandunfoldOptions {
4180 fn default() -> Self {
4181 BandunfoldOptions {
4182 factor: i32::from(0),
4183 }
4184 }
4185}
4186
4187pub fn bandunfold_with_opts(
4192 inp: &VipsImage,
4193 bandunfold_options: &BandunfoldOptions,
4194) -> Result<VipsImage> {
4195 unsafe {
4196 let inp_in: *mut bindings::VipsImage = inp.ctx;
4197 let mut out_out: *mut bindings::VipsImage = null_mut();
4198
4199 let factor_in: i32 = bandunfold_options.factor;
4200 let factor_in_name = utils::new_c_string("factor")?;
4201
4202 let vips_op_response = bindings::vips_bandunfold(
4203 inp_in,
4204 &mut out_out,
4205 factor_in_name.as_ptr(),
4206 factor_in,
4207 NULL,
4208 );
4209 utils::result(
4210 vips_op_response,
4211 VipsImage { ctx: out_out },
4212 Error::BandunfoldError,
4213 )
4214 }
4215}
4216
4217pub fn flatten(inp: &VipsImage) -> Result<VipsImage> {
4221 unsafe {
4222 let inp_in: *mut bindings::VipsImage = inp.ctx;
4223 let mut out_out: *mut bindings::VipsImage = null_mut();
4224
4225 let vips_op_response = bindings::vips_flatten(inp_in, &mut out_out, NULL);
4226 utils::result(
4227 vips_op_response,
4228 VipsImage { ctx: out_out },
4229 Error::FlattenError,
4230 )
4231 }
4232}
4233
4234#[derive(Clone, Debug)]
4236pub struct FlattenOptions {
4237 pub background: Vec<f64>,
4239 pub max_alpha: f64,
4242}
4243
4244impl std::default::Default for FlattenOptions {
4245 fn default() -> Self {
4246 FlattenOptions {
4247 background: Vec::new(),
4248 max_alpha: f64::from(255),
4249 }
4250 }
4251}
4252
4253pub fn flatten_with_opts(inp: &VipsImage, flatten_options: &FlattenOptions) -> Result<VipsImage> {
4258 unsafe {
4259 let inp_in: *mut bindings::VipsImage = inp.ctx;
4260 let mut out_out: *mut bindings::VipsImage = null_mut();
4261
4262 let background_wrapper =
4263 utils::VipsArrayDoubleWrapper::from(&flatten_options.background[..]);
4264 let background_in = background_wrapper.ctx;
4265 let background_in_name = utils::new_c_string("background")?;
4266
4267 let max_alpha_in: f64 = flatten_options.max_alpha;
4268 let max_alpha_in_name = utils::new_c_string("max-alpha")?;
4269
4270 let vips_op_response = bindings::vips_flatten(
4271 inp_in,
4272 &mut out_out,
4273 background_in_name.as_ptr(),
4274 background_in,
4275 max_alpha_in_name.as_ptr(),
4276 max_alpha_in,
4277 NULL,
4278 );
4279 utils::result(
4280 vips_op_response,
4281 VipsImage { ctx: out_out },
4282 Error::FlattenError,
4283 )
4284 }
4285}
4286
4287pub fn premultiply(inp: &VipsImage) -> Result<VipsImage> {
4291 unsafe {
4292 let inp_in: *mut bindings::VipsImage = inp.ctx;
4293 let mut out_out: *mut bindings::VipsImage = null_mut();
4294
4295 let vips_op_response = bindings::vips_premultiply(inp_in, &mut out_out, NULL);
4296 utils::result(
4297 vips_op_response,
4298 VipsImage { ctx: out_out },
4299 Error::PremultiplyError,
4300 )
4301 }
4302}
4303
4304#[derive(Clone, Debug)]
4306pub struct PremultiplyOptions {
4307 pub max_alpha: f64,
4310}
4311
4312impl std::default::Default for PremultiplyOptions {
4313 fn default() -> Self {
4314 PremultiplyOptions {
4315 max_alpha: f64::from(255),
4316 }
4317 }
4318}
4319
4320pub fn premultiply_with_opts(
4325 inp: &VipsImage,
4326 premultiply_options: &PremultiplyOptions,
4327) -> Result<VipsImage> {
4328 unsafe {
4329 let inp_in: *mut bindings::VipsImage = inp.ctx;
4330 let mut out_out: *mut bindings::VipsImage = null_mut();
4331
4332 let max_alpha_in: f64 = premultiply_options.max_alpha;
4333 let max_alpha_in_name = utils::new_c_string("max-alpha")?;
4334
4335 let vips_op_response = bindings::vips_premultiply(
4336 inp_in,
4337 &mut out_out,
4338 max_alpha_in_name.as_ptr(),
4339 max_alpha_in,
4340 NULL,
4341 );
4342 utils::result(
4343 vips_op_response,
4344 VipsImage { ctx: out_out },
4345 Error::PremultiplyError,
4346 )
4347 }
4348}
4349
4350pub fn unpremultiply(inp: &VipsImage) -> Result<VipsImage> {
4354 unsafe {
4355 let inp_in: *mut bindings::VipsImage = inp.ctx;
4356 let mut out_out: *mut bindings::VipsImage = null_mut();
4357
4358 let vips_op_response = bindings::vips_unpremultiply(inp_in, &mut out_out, NULL);
4359 utils::result(
4360 vips_op_response,
4361 VipsImage { ctx: out_out },
4362 Error::UnpremultiplyError,
4363 )
4364 }
4365}
4366
4367#[derive(Clone, Debug)]
4369pub struct UnpremultiplyOptions {
4370 pub max_alpha: f64,
4373 pub alpha_band: i32,
4376}
4377
4378impl std::default::Default for UnpremultiplyOptions {
4379 fn default() -> Self {
4380 UnpremultiplyOptions {
4381 max_alpha: f64::from(255),
4382 alpha_band: i32::from(3),
4383 }
4384 }
4385}
4386
4387pub fn unpremultiply_with_opts(
4392 inp: &VipsImage,
4393 unpremultiply_options: &UnpremultiplyOptions,
4394) -> Result<VipsImage> {
4395 unsafe {
4396 let inp_in: *mut bindings::VipsImage = inp.ctx;
4397 let mut out_out: *mut bindings::VipsImage = null_mut();
4398
4399 let max_alpha_in: f64 = unpremultiply_options.max_alpha;
4400 let max_alpha_in_name = utils::new_c_string("max-alpha")?;
4401
4402 let alpha_band_in: i32 = unpremultiply_options.alpha_band;
4403 let alpha_band_in_name = utils::new_c_string("alpha-band")?;
4404
4405 let vips_op_response = bindings::vips_unpremultiply(
4406 inp_in,
4407 &mut out_out,
4408 max_alpha_in_name.as_ptr(),
4409 max_alpha_in,
4410 alpha_band_in_name.as_ptr(),
4411 alpha_band_in,
4412 NULL,
4413 );
4414 utils::result(
4415 vips_op_response,
4416 VipsImage { ctx: out_out },
4417 Error::UnpremultiplyError,
4418 )
4419 }
4420}
4421
4422pub fn grid(inp: &VipsImage, tile_height: i32, across: i32, down: i32) -> Result<VipsImage> {
4432 unsafe {
4433 let inp_in: *mut bindings::VipsImage = inp.ctx;
4434 let tile_height_in: i32 = tile_height;
4435 let across_in: i32 = across;
4436 let down_in: i32 = down;
4437 let mut out_out: *mut bindings::VipsImage = null_mut();
4438
4439 let vips_op_response = bindings::vips_grid(
4440 inp_in,
4441 &mut out_out,
4442 tile_height_in,
4443 across_in,
4444 down_in,
4445 NULL,
4446 );
4447 utils::result(
4448 vips_op_response,
4449 VipsImage { ctx: out_out },
4450 Error::GridError,
4451 )
4452 }
4453}
4454
4455pub fn transpose_3d(inp: &VipsImage) -> Result<VipsImage> {
4459 unsafe {
4460 let inp_in: *mut bindings::VipsImage = inp.ctx;
4461 let mut out_out: *mut bindings::VipsImage = null_mut();
4462
4463 let vips_op_response = bindings::vips_transpose3d(inp_in, &mut out_out, NULL);
4464 utils::result(
4465 vips_op_response,
4466 VipsImage { ctx: out_out },
4467 Error::Transpose3DError,
4468 )
4469 }
4470}
4471
4472#[derive(Clone, Debug)]
4474pub struct Transpose3DOptions {
4475 pub page_height: i32,
4478}
4479
4480impl std::default::Default for Transpose3DOptions {
4481 fn default() -> Self {
4482 Transpose3DOptions {
4483 page_height: i32::from(0),
4484 }
4485 }
4486}
4487
4488pub fn transpose_3d_with_opts(
4493 inp: &VipsImage,
4494 transpose_3d_options: &Transpose3DOptions,
4495) -> Result<VipsImage> {
4496 unsafe {
4497 let inp_in: *mut bindings::VipsImage = inp.ctx;
4498 let mut out_out: *mut bindings::VipsImage = null_mut();
4499
4500 let page_height_in: i32 = transpose_3d_options.page_height;
4501 let page_height_in_name = utils::new_c_string("page-height")?;
4502
4503 let vips_op_response = bindings::vips_transpose3d(
4504 inp_in,
4505 &mut out_out,
4506 page_height_in_name.as_ptr(),
4507 page_height_in,
4508 NULL,
4509 );
4510 utils::result(
4511 vips_op_response,
4512 VipsImage { ctx: out_out },
4513 Error::Transpose3DError,
4514 )
4515 }
4516}
4517
4518pub fn scale(inp: &VipsImage) -> Result<VipsImage> {
4522 unsafe {
4523 let inp_in: *mut bindings::VipsImage = inp.ctx;
4524 let mut out_out: *mut bindings::VipsImage = null_mut();
4525
4526 let vips_op_response = bindings::vips_scale(inp_in, &mut out_out, NULL);
4527 utils::result(
4528 vips_op_response,
4529 VipsImage { ctx: out_out },
4530 Error::ScaleError,
4531 )
4532 }
4533}
4534
4535#[derive(Clone, Debug)]
4537pub struct ScaleOptions {
4538 pub exp: f64,
4541 pub log: bool,
4544}
4545
4546impl std::default::Default for ScaleOptions {
4547 fn default() -> Self {
4548 ScaleOptions {
4549 exp: f64::from(0.25),
4550 log: false,
4551 }
4552 }
4553}
4554
4555pub fn scale_with_opts(inp: &VipsImage, scale_options: &ScaleOptions) -> Result<VipsImage> {
4560 unsafe {
4561 let inp_in: *mut bindings::VipsImage = inp.ctx;
4562 let mut out_out: *mut bindings::VipsImage = null_mut();
4563
4564 let exp_in: f64 = scale_options.exp;
4565 let exp_in_name = utils::new_c_string("exp")?;
4566
4567 let log_in: i32 = if scale_options.log { 1 } else { 0 };
4568 let log_in_name = utils::new_c_string("log")?;
4569
4570 let vips_op_response = bindings::vips_scale(
4571 inp_in,
4572 &mut out_out,
4573 exp_in_name.as_ptr(),
4574 exp_in,
4575 log_in_name.as_ptr(),
4576 log_in,
4577 NULL,
4578 );
4579 utils::result(
4580 vips_op_response,
4581 VipsImage { ctx: out_out },
4582 Error::ScaleError,
4583 )
4584 }
4585}
4586
4587pub fn wrap(inp: &VipsImage) -> Result<VipsImage> {
4591 unsafe {
4592 let inp_in: *mut bindings::VipsImage = inp.ctx;
4593 let mut out_out: *mut bindings::VipsImage = null_mut();
4594
4595 let vips_op_response = bindings::vips_wrap(inp_in, &mut out_out, NULL);
4596 utils::result(
4597 vips_op_response,
4598 VipsImage { ctx: out_out },
4599 Error::WrapError,
4600 )
4601 }
4602}
4603
4604#[derive(Clone, Debug)]
4606pub struct WrapOptions {
4607 pub x: i32,
4610 pub y: i32,
4613}
4614
4615impl std::default::Default for WrapOptions {
4616 fn default() -> Self {
4617 WrapOptions {
4618 x: i32::from(0),
4619 y: i32::from(0),
4620 }
4621 }
4622}
4623
4624pub fn wrap_with_opts(inp: &VipsImage, wrap_options: &WrapOptions) -> Result<VipsImage> {
4629 unsafe {
4630 let inp_in: *mut bindings::VipsImage = inp.ctx;
4631 let mut out_out: *mut bindings::VipsImage = null_mut();
4632
4633 let x_in: i32 = wrap_options.x;
4634 let x_in_name = utils::new_c_string("x")?;
4635
4636 let y_in: i32 = wrap_options.y;
4637 let y_in_name = utils::new_c_string("y")?;
4638
4639 let vips_op_response = bindings::vips_wrap(
4640 inp_in,
4641 &mut out_out,
4642 x_in_name.as_ptr(),
4643 x_in,
4644 y_in_name.as_ptr(),
4645 y_in,
4646 NULL,
4647 );
4648 utils::result(
4649 vips_op_response,
4650 VipsImage { ctx: out_out },
4651 Error::WrapError,
4652 )
4653 }
4654}
4655
4656pub fn zoom(input: &VipsImage, xfac: i32, yfac: i32) -> Result<VipsImage> {
4664 unsafe {
4665 let input_in: *mut bindings::VipsImage = input.ctx;
4666 let xfac_in: i32 = xfac;
4667 let yfac_in: i32 = yfac;
4668 let mut out_out: *mut bindings::VipsImage = null_mut();
4669
4670 let vips_op_response = bindings::vips_zoom(input_in, &mut out_out, xfac_in, yfac_in, NULL);
4671 utils::result(
4672 vips_op_response,
4673 VipsImage { ctx: out_out },
4674 Error::ZoomError,
4675 )
4676 }
4677}
4678
4679pub fn subsample(input: &VipsImage, xfac: i32, yfac: i32) -> Result<VipsImage> {
4687 unsafe {
4688 let input_in: *mut bindings::VipsImage = input.ctx;
4689 let xfac_in: i32 = xfac;
4690 let yfac_in: i32 = yfac;
4691 let mut out_out: *mut bindings::VipsImage = null_mut();
4692
4693 let vips_op_response =
4694 bindings::vips_subsample(input_in, &mut out_out, xfac_in, yfac_in, NULL);
4695 utils::result(
4696 vips_op_response,
4697 VipsImage { ctx: out_out },
4698 Error::SubsampleError,
4699 )
4700 }
4701}
4702
4703#[derive(Clone, Debug)]
4705pub struct SubsampleOptions {
4706 pub point: bool,
4709}
4710
4711impl std::default::Default for SubsampleOptions {
4712 fn default() -> Self {
4713 SubsampleOptions { point: false }
4714 }
4715}
4716
4717pub fn subsample_with_opts(
4726 input: &VipsImage,
4727 xfac: i32,
4728 yfac: i32,
4729 subsample_options: &SubsampleOptions,
4730) -> Result<VipsImage> {
4731 unsafe {
4732 let input_in: *mut bindings::VipsImage = input.ctx;
4733 let xfac_in: i32 = xfac;
4734 let yfac_in: i32 = yfac;
4735 let mut out_out: *mut bindings::VipsImage = null_mut();
4736
4737 let point_in: i32 = if subsample_options.point { 1 } else { 0 };
4738 let point_in_name = utils::new_c_string("point")?;
4739
4740 let vips_op_response = bindings::vips_subsample(
4741 input_in,
4742 &mut out_out,
4743 xfac_in,
4744 yfac_in,
4745 point_in_name.as_ptr(),
4746 point_in,
4747 NULL,
4748 );
4749 utils::result(
4750 vips_op_response,
4751 VipsImage { ctx: out_out },
4752 Error::SubsampleError,
4753 )
4754 }
4755}
4756
4757pub fn msb(inp: &VipsImage) -> Result<VipsImage> {
4761 unsafe {
4762 let inp_in: *mut bindings::VipsImage = inp.ctx;
4763 let mut out_out: *mut bindings::VipsImage = null_mut();
4764
4765 let vips_op_response = bindings::vips_msb(inp_in, &mut out_out, NULL);
4766 utils::result(
4767 vips_op_response,
4768 VipsImage { ctx: out_out },
4769 Error::MsbError,
4770 )
4771 }
4772}
4773
4774#[derive(Clone, Debug)]
4776pub struct MsbOptions {
4777 pub band: i32,
4780}
4781
4782impl std::default::Default for MsbOptions {
4783 fn default() -> Self {
4784 MsbOptions {
4785 band: i32::from(-1),
4786 }
4787 }
4788}
4789
4790pub fn msb_with_opts(inp: &VipsImage, msb_options: &MsbOptions) -> Result<VipsImage> {
4795 unsafe {
4796 let inp_in: *mut bindings::VipsImage = inp.ctx;
4797 let mut out_out: *mut bindings::VipsImage = null_mut();
4798
4799 let band_in: i32 = msb_options.band;
4800 let band_in_name = utils::new_c_string("band")?;
4801
4802 let vips_op_response =
4803 bindings::vips_msb(inp_in, &mut out_out, band_in_name.as_ptr(), band_in, NULL);
4804 utils::result(
4805 vips_op_response,
4806 VipsImage { ctx: out_out },
4807 Error::MsbError,
4808 )
4809 }
4810}
4811
4812pub fn byteswap(inp: &VipsImage) -> Result<VipsImage> {
4816 unsafe {
4817 let inp_in: *mut bindings::VipsImage = inp.ctx;
4818 let mut out_out: *mut bindings::VipsImage = null_mut();
4819
4820 let vips_op_response = bindings::vips_byteswap(inp_in, &mut out_out, NULL);
4821 utils::result(
4822 vips_op_response,
4823 VipsImage { ctx: out_out },
4824 Error::ByteswapError,
4825 )
4826 }
4827}
4828
4829pub fn falsecolour(inp: &VipsImage) -> Result<VipsImage> {
4833 unsafe {
4834 let inp_in: *mut bindings::VipsImage = inp.ctx;
4835 let mut out_out: *mut bindings::VipsImage = null_mut();
4836
4837 let vips_op_response = bindings::vips_falsecolour(inp_in, &mut out_out, NULL);
4838 utils::result(
4839 vips_op_response,
4840 VipsImage { ctx: out_out },
4841 Error::FalsecolourError,
4842 )
4843 }
4844}
4845
4846pub fn gamma(inp: &VipsImage) -> Result<VipsImage> {
4850 unsafe {
4851 let inp_in: *mut bindings::VipsImage = inp.ctx;
4852 let mut out_out: *mut bindings::VipsImage = null_mut();
4853
4854 let vips_op_response = bindings::vips_gamma(inp_in, &mut out_out, NULL);
4855 utils::result(
4856 vips_op_response,
4857 VipsImage { ctx: out_out },
4858 Error::GammaError,
4859 )
4860 }
4861}
4862
4863#[derive(Clone, Debug)]
4865pub struct GammaOptions {
4866 pub exponent: f64,
4869}
4870
4871impl std::default::Default for GammaOptions {
4872 fn default() -> Self {
4873 GammaOptions {
4874 exponent: f64::from(0.416667),
4875 }
4876 }
4877}
4878
4879pub fn gamma_with_opts(inp: &VipsImage, gamma_options: &GammaOptions) -> Result<VipsImage> {
4884 unsafe {
4885 let inp_in: *mut bindings::VipsImage = inp.ctx;
4886 let mut out_out: *mut bindings::VipsImage = null_mut();
4887
4888 let exponent_in: f64 = gamma_options.exponent;
4889 let exponent_in_name = utils::new_c_string("exponent")?;
4890
4891 let vips_op_response = bindings::vips_gamma(
4892 inp_in,
4893 &mut out_out,
4894 exponent_in_name.as_ptr(),
4895 exponent_in,
4896 NULL,
4897 );
4898 utils::result(
4899 vips_op_response,
4900 VipsImage { ctx: out_out },
4901 Error::GammaError,
4902 )
4903 }
4904}
4905
4906pub fn composite(inp: &mut [VipsImage], mode: &mut [i32]) -> Result<VipsImage> {
4911 unsafe {
4912 let (inp_len, mut inp_in) = {
4913 let len = inp.len();
4914 let mut input = Vec::new();
4915 for img in inp {
4916 input.push(img.ctx)
4917 }
4918 (len as i32, input)
4919 };
4920 let mode_in: *mut i32 = mode.as_mut_ptr();
4921 let mut out_out: *mut bindings::VipsImage = null_mut();
4922
4923 let vips_op_response = bindings::vips_composite(
4924 inp_in.as_mut_ptr(),
4925 &mut out_out,
4926 inp_len,
4927 mode_in,
4928 mode.len() as i32,
4929 NULL,
4930 );
4931 utils::result(
4932 vips_op_response,
4933 VipsImage { ctx: out_out },
4934 Error::CompositeError,
4935 )
4936 }
4937}
4938
4939#[derive(Clone, Debug)]
4941pub struct CompositeOptions {
4942 pub x: Vec<i32>,
4944 pub y: Vec<i32>,
4946 pub compositing_space: Interpretation,
4970 pub premultiplied: bool,
4973}
4974
4975impl std::default::Default for CompositeOptions {
4976 fn default() -> Self {
4977 CompositeOptions {
4978 x: Vec::new(),
4979 y: Vec::new(),
4980 compositing_space: Interpretation::Srgb,
4981 premultiplied: false,
4982 }
4983 }
4984}
4985
4986pub fn composite_with_opts(
4992 inp: &mut [VipsImage],
4993 mode: &mut [i32],
4994 composite_options: &CompositeOptions,
4995) -> Result<VipsImage> {
4996 unsafe {
4997 let (inp_len, mut inp_in) = {
4998 let len = inp.len();
4999 let mut input = Vec::new();
5000 for img in inp {
5001 input.push(img.ctx)
5002 }
5003 (len as i32, input)
5004 };
5005 let mode_in: *mut i32 = mode.as_mut_ptr();
5006 let mut out_out: *mut bindings::VipsImage = null_mut();
5007
5008 let x_wrapper = utils::VipsArrayIntWrapper::from(&composite_options.x[..]);
5009 let x_in = x_wrapper.ctx;
5010 let x_in_name = utils::new_c_string("x")?;
5011
5012 let y_wrapper = utils::VipsArrayIntWrapper::from(&composite_options.y[..]);
5013 let y_in = y_wrapper.ctx;
5014 let y_in_name = utils::new_c_string("y")?;
5015
5016 let compositing_space_in: i32 = composite_options.compositing_space as i32;
5017 let compositing_space_in_name = utils::new_c_string("compositing-space")?;
5018
5019 let premultiplied_in: i32 = if composite_options.premultiplied {
5020 1
5021 } else {
5022 0
5023 };
5024 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
5025
5026 let vips_op_response = bindings::vips_composite(
5027 inp_in.as_mut_ptr(),
5028 &mut out_out,
5029 inp_len,
5030 mode_in,
5031 mode.len() as i32,
5032 x_in_name.as_ptr(),
5033 x_in,
5034 y_in_name.as_ptr(),
5035 y_in,
5036 compositing_space_in_name.as_ptr(),
5037 compositing_space_in,
5038 premultiplied_in_name.as_ptr(),
5039 premultiplied_in,
5040 NULL,
5041 );
5042 utils::result(
5043 vips_op_response,
5044 VipsImage { ctx: out_out },
5045 Error::CompositeError,
5046 )
5047 }
5048}
5049
5050pub fn composite_2(base: &VipsImage, overlay: &VipsImage, mode: BlendMode) -> Result<VipsImage> {
5081 unsafe {
5082 let base_in: *mut bindings::VipsImage = base.ctx;
5083 let overlay_in: *mut bindings::VipsImage = overlay.ctx;
5084 let mode_in: i32 = mode as i32;
5085 let mut out_out: *mut bindings::VipsImage = null_mut();
5086
5087 let vips_op_response = bindings::vips_composite2(
5088 base_in,
5089 overlay_in,
5090 &mut out_out,
5091 mode_in.try_into().unwrap(),
5092 NULL,
5093 );
5094 utils::result(
5095 vips_op_response,
5096 VipsImage { ctx: out_out },
5097 Error::Composite2Error,
5098 )
5099 }
5100}
5101
5102#[derive(Clone, Debug)]
5104pub struct Composite2Options {
5105 pub x: i32,
5108 pub y: i32,
5111 pub compositing_space: Interpretation,
5135 pub premultiplied: bool,
5138}
5139
5140impl std::default::Default for Composite2Options {
5141 fn default() -> Self {
5142 Composite2Options {
5143 x: i32::from(0),
5144 y: i32::from(0),
5145 compositing_space: Interpretation::Srgb,
5146 premultiplied: false,
5147 }
5148 }
5149}
5150
5151pub fn composite_2_with_opts(
5183 base: &VipsImage,
5184 overlay: &VipsImage,
5185 mode: BlendMode,
5186 composite_2_options: &Composite2Options,
5187) -> Result<VipsImage> {
5188 unsafe {
5189 let base_in: *mut bindings::VipsImage = base.ctx;
5190 let overlay_in: *mut bindings::VipsImage = overlay.ctx;
5191 let mode_in: i32 = mode as i32;
5192 let mut out_out: *mut bindings::VipsImage = null_mut();
5193
5194 let x_in: i32 = composite_2_options.x;
5195 let x_in_name = utils::new_c_string("x")?;
5196
5197 let y_in: i32 = composite_2_options.y;
5198 let y_in_name = utils::new_c_string("y")?;
5199
5200 let compositing_space_in: i32 = composite_2_options.compositing_space as i32;
5201 let compositing_space_in_name = utils::new_c_string("compositing-space")?;
5202
5203 let premultiplied_in: i32 = if composite_2_options.premultiplied {
5204 1
5205 } else {
5206 0
5207 };
5208 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
5209
5210 let vips_op_response = bindings::vips_composite2(
5211 base_in,
5212 overlay_in,
5213 &mut out_out,
5214 mode_in.try_into().unwrap(),
5215 x_in_name.as_ptr(),
5216 x_in,
5217 y_in_name.as_ptr(),
5218 y_in,
5219 compositing_space_in_name.as_ptr(),
5220 compositing_space_in,
5221 premultiplied_in_name.as_ptr(),
5222 premultiplied_in,
5223 NULL,
5224 );
5225 utils::result(
5226 vips_op_response,
5227 VipsImage { ctx: out_out },
5228 Error::Composite2Error,
5229 )
5230 }
5231}
5232
5233pub fn addalpha(inp: &VipsImage) -> Result<VipsImage> {
5237 unsafe {
5238 let inp_in: *mut bindings::VipsImage = inp.ctx;
5239 let mut out_out: *mut bindings::VipsImage = null_mut();
5240
5241 let vips_op_response = bindings::vips_addalpha(inp_in, &mut out_out, NULL);
5242 utils::result(
5243 vips_op_response,
5244 VipsImage { ctx: out_out },
5245 Error::AddalphaError,
5246 )
5247 }
5248}
5249
5250pub fn black(width: i32, height: i32) -> Result<VipsImage> {
5257 unsafe {
5258 let width_in: i32 = width;
5259 let height_in: i32 = height;
5260 let mut out_out: *mut bindings::VipsImage = null_mut();
5261
5262 let vips_op_response = bindings::vips_black(&mut out_out, width_in, height_in, NULL);
5263 utils::result(
5264 vips_op_response,
5265 VipsImage { ctx: out_out },
5266 Error::BlackError,
5267 )
5268 }
5269}
5270
5271#[derive(Clone, Debug)]
5273pub struct BlackOptions {
5274 pub bands: i32,
5277}
5278
5279impl std::default::Default for BlackOptions {
5280 fn default() -> Self {
5281 BlackOptions {
5282 bands: i32::from(1),
5283 }
5284 }
5285}
5286
5287pub fn black_with_opts(width: i32, height: i32, black_options: &BlackOptions) -> Result<VipsImage> {
5295 unsafe {
5296 let width_in: i32 = width;
5297 let height_in: i32 = height;
5298 let mut out_out: *mut bindings::VipsImage = null_mut();
5299
5300 let bands_in: i32 = black_options.bands;
5301 let bands_in_name = utils::new_c_string("bands")?;
5302
5303 let vips_op_response = bindings::vips_black(
5304 &mut out_out,
5305 width_in,
5306 height_in,
5307 bands_in_name.as_ptr(),
5308 bands_in,
5309 NULL,
5310 );
5311 utils::result(
5312 vips_op_response,
5313 VipsImage { ctx: out_out },
5314 Error::BlackError,
5315 )
5316 }
5317}
5318
5319pub fn gaussnoise(width: i32, height: i32) -> Result<VipsImage> {
5326 unsafe {
5327 let width_in: i32 = width;
5328 let height_in: i32 = height;
5329 let mut out_out: *mut bindings::VipsImage = null_mut();
5330
5331 let vips_op_response = bindings::vips_gaussnoise(&mut out_out, width_in, height_in, NULL);
5332 utils::result(
5333 vips_op_response,
5334 VipsImage { ctx: out_out },
5335 Error::GaussnoiseError,
5336 )
5337 }
5338}
5339
5340#[derive(Clone, Debug)]
5342pub struct GaussnoiseOptions {
5343 pub sigma: f64,
5346 pub mean: f64,
5349 pub seed: i32,
5352}
5353
5354impl std::default::Default for GaussnoiseOptions {
5355 fn default() -> Self {
5356 GaussnoiseOptions {
5357 sigma: f64::from(30),
5358 mean: f64::from(128),
5359 seed: i32::from(0),
5360 }
5361 }
5362}
5363
5364pub fn gaussnoise_with_opts(
5372 width: i32,
5373 height: i32,
5374 gaussnoise_options: &GaussnoiseOptions,
5375) -> Result<VipsImage> {
5376 unsafe {
5377 let width_in: i32 = width;
5378 let height_in: i32 = height;
5379 let mut out_out: *mut bindings::VipsImage = null_mut();
5380
5381 let sigma_in: f64 = gaussnoise_options.sigma;
5382 let sigma_in_name = utils::new_c_string("sigma")?;
5383
5384 let mean_in: f64 = gaussnoise_options.mean;
5385 let mean_in_name = utils::new_c_string("mean")?;
5386
5387 let seed_in: i32 = gaussnoise_options.seed;
5388 let seed_in_name = utils::new_c_string("seed")?;
5389
5390 let vips_op_response = bindings::vips_gaussnoise(
5391 &mut out_out,
5392 width_in,
5393 height_in,
5394 sigma_in_name.as_ptr(),
5395 sigma_in,
5396 mean_in_name.as_ptr(),
5397 mean_in,
5398 seed_in_name.as_ptr(),
5399 seed_in,
5400 NULL,
5401 );
5402 utils::result(
5403 vips_op_response,
5404 VipsImage { ctx: out_out },
5405 Error::GaussnoiseError,
5406 )
5407 }
5408}
5409
5410pub fn xyz(width: i32, height: i32) -> Result<VipsImage> {
5417 unsafe {
5418 let width_in: i32 = width;
5419 let height_in: i32 = height;
5420 let mut out_out: *mut bindings::VipsImage = null_mut();
5421
5422 let vips_op_response = bindings::vips_xyz(&mut out_out, width_in, height_in, NULL);
5423 utils::result(
5424 vips_op_response,
5425 VipsImage { ctx: out_out },
5426 Error::XyzError,
5427 )
5428 }
5429}
5430
5431#[derive(Clone, Debug)]
5433pub struct XyzOptions {
5434 pub csize: i32,
5437 pub dsize: i32,
5440 pub esize: i32,
5443}
5444
5445impl std::default::Default for XyzOptions {
5446 fn default() -> Self {
5447 XyzOptions {
5448 csize: i32::from(1),
5449 dsize: i32::from(1),
5450 esize: i32::from(1),
5451 }
5452 }
5453}
5454
5455pub fn xyz_with_opts(width: i32, height: i32, xyz_options: &XyzOptions) -> Result<VipsImage> {
5463 unsafe {
5464 let width_in: i32 = width;
5465 let height_in: i32 = height;
5466 let mut out_out: *mut bindings::VipsImage = null_mut();
5467
5468 let csize_in: i32 = xyz_options.csize;
5469 let csize_in_name = utils::new_c_string("csize")?;
5470
5471 let dsize_in: i32 = xyz_options.dsize;
5472 let dsize_in_name = utils::new_c_string("dsize")?;
5473
5474 let esize_in: i32 = xyz_options.esize;
5475 let esize_in_name = utils::new_c_string("esize")?;
5476
5477 let vips_op_response = bindings::vips_xyz(
5478 &mut out_out,
5479 width_in,
5480 height_in,
5481 csize_in_name.as_ptr(),
5482 csize_in,
5483 dsize_in_name.as_ptr(),
5484 dsize_in,
5485 esize_in_name.as_ptr(),
5486 esize_in,
5487 NULL,
5488 );
5489 utils::result(
5490 vips_op_response,
5491 VipsImage { ctx: out_out },
5492 Error::XyzError,
5493 )
5494 }
5495}
5496
5497pub fn gaussmat(sigma: f64, min_ampl: f64) -> Result<VipsImage> {
5504 unsafe {
5505 let sigma_in: f64 = sigma;
5506 let min_ampl_in: f64 = min_ampl;
5507 let mut out_out: *mut bindings::VipsImage = null_mut();
5508
5509 let vips_op_response = bindings::vips_gaussmat(&mut out_out, sigma_in, min_ampl_in, NULL);
5510 utils::result(
5511 vips_op_response,
5512 VipsImage { ctx: out_out },
5513 Error::GaussmatError,
5514 )
5515 }
5516}
5517
5518#[derive(Clone, Debug)]
5520pub struct GaussmatOptions {
5521 pub separable: bool,
5524 pub precision: Precision,
5529}
5530
5531impl std::default::Default for GaussmatOptions {
5532 fn default() -> Self {
5533 GaussmatOptions {
5534 separable: false,
5535 precision: Precision::Integer,
5536 }
5537 }
5538}
5539
5540pub fn gaussmat_with_opts(
5548 sigma: f64,
5549 min_ampl: f64,
5550 gaussmat_options: &GaussmatOptions,
5551) -> Result<VipsImage> {
5552 unsafe {
5553 let sigma_in: f64 = sigma;
5554 let min_ampl_in: f64 = min_ampl;
5555 let mut out_out: *mut bindings::VipsImage = null_mut();
5556
5557 let separable_in: i32 = if gaussmat_options.separable { 1 } else { 0 };
5558 let separable_in_name = utils::new_c_string("separable")?;
5559
5560 let precision_in: i32 = gaussmat_options.precision as i32;
5561 let precision_in_name = utils::new_c_string("precision")?;
5562
5563 let vips_op_response = bindings::vips_gaussmat(
5564 &mut out_out,
5565 sigma_in,
5566 min_ampl_in,
5567 separable_in_name.as_ptr(),
5568 separable_in,
5569 precision_in_name.as_ptr(),
5570 precision_in,
5571 NULL,
5572 );
5573 utils::result(
5574 vips_op_response,
5575 VipsImage { ctx: out_out },
5576 Error::GaussmatError,
5577 )
5578 }
5579}
5580
5581pub fn logmat(sigma: f64, min_ampl: f64) -> Result<VipsImage> {
5588 unsafe {
5589 let sigma_in: f64 = sigma;
5590 let min_ampl_in: f64 = min_ampl;
5591 let mut out_out: *mut bindings::VipsImage = null_mut();
5592
5593 let vips_op_response = bindings::vips_logmat(&mut out_out, sigma_in, min_ampl_in, NULL);
5594 utils::result(
5595 vips_op_response,
5596 VipsImage { ctx: out_out },
5597 Error::LogmatError,
5598 )
5599 }
5600}
5601
5602#[derive(Clone, Debug)]
5604pub struct LogmatOptions {
5605 pub separable: bool,
5608 pub precision: Precision,
5613}
5614
5615impl std::default::Default for LogmatOptions {
5616 fn default() -> Self {
5617 LogmatOptions {
5618 separable: false,
5619 precision: Precision::Integer,
5620 }
5621 }
5622}
5623
5624pub fn logmat_with_opts(
5632 sigma: f64,
5633 min_ampl: f64,
5634 logmat_options: &LogmatOptions,
5635) -> Result<VipsImage> {
5636 unsafe {
5637 let sigma_in: f64 = sigma;
5638 let min_ampl_in: f64 = min_ampl;
5639 let mut out_out: *mut bindings::VipsImage = null_mut();
5640
5641 let separable_in: i32 = if logmat_options.separable { 1 } else { 0 };
5642 let separable_in_name = utils::new_c_string("separable")?;
5643
5644 let precision_in: i32 = logmat_options.precision as i32;
5645 let precision_in_name = utils::new_c_string("precision")?;
5646
5647 let vips_op_response = bindings::vips_logmat(
5648 &mut out_out,
5649 sigma_in,
5650 min_ampl_in,
5651 separable_in_name.as_ptr(),
5652 separable_in,
5653 precision_in_name.as_ptr(),
5654 precision_in,
5655 NULL,
5656 );
5657 utils::result(
5658 vips_op_response,
5659 VipsImage { ctx: out_out },
5660 Error::LogmatError,
5661 )
5662 }
5663}
5664
5665pub fn text(text: &str) -> Result<VipsImage> {
5669 unsafe {
5670 let text_in: CString = utils::new_c_string(text)?;
5671 let mut out_out: *mut bindings::VipsImage = null_mut();
5672
5673 let vips_op_response = bindings::vips_text(&mut out_out, text_in.as_ptr(), NULL);
5674 utils::result(
5675 vips_op_response,
5676 VipsImage { ctx: out_out },
5677 Error::TextError,
5678 )
5679 }
5680}
5681
5682#[derive(Clone, Debug)]
5684pub struct TextOptions {
5685 pub font: String,
5687 pub width: i32,
5690 pub height: i32,
5693 pub align: Align,
5698 pub justify: bool,
5701 pub dpi: i32,
5704 pub autofit_dpi: i32,
5707 pub spacing: i32,
5710 pub fontfile: String,
5712 pub rgba: bool,
5715 pub wrap: TextWrap,
5721}
5722
5723impl std::default::Default for TextOptions {
5724 fn default() -> Self {
5725 TextOptions {
5726 font: String::new(),
5727 width: i32::from(0),
5728 height: i32::from(0),
5729 align: Align::Low,
5730 justify: false,
5731 dpi: i32::from(72),
5732 autofit_dpi: i32::from(72),
5733 spacing: i32::from(0),
5734 fontfile: String::new(),
5735 rgba: false,
5736 wrap: TextWrap::Word,
5737 }
5738 }
5739}
5740
5741pub fn text_with_opts(text: &str, text_options: &TextOptions) -> Result<VipsImage> {
5746 unsafe {
5747 let text_in: CString = utils::new_c_string(text)?;
5748 let mut out_out: *mut bindings::VipsImage = null_mut();
5749
5750 let font_in: CString = utils::new_c_string(&text_options.font)?;
5751 let font_in_name = utils::new_c_string("font")?;
5752
5753 let width_in: i32 = text_options.width;
5754 let width_in_name = utils::new_c_string("width")?;
5755
5756 let height_in: i32 = text_options.height;
5757 let height_in_name = utils::new_c_string("height")?;
5758
5759 let align_in: i32 = text_options.align as i32;
5760 let align_in_name = utils::new_c_string("align")?;
5761
5762 let justify_in: i32 = if text_options.justify { 1 } else { 0 };
5763 let justify_in_name = utils::new_c_string("justify")?;
5764
5765 let dpi_in: i32 = text_options.dpi;
5766 let dpi_in_name = utils::new_c_string("dpi")?;
5767
5768 let autofit_dpi_in: i32 = text_options.autofit_dpi;
5769 let autofit_dpi_in_name = utils::new_c_string("autofit-dpi")?;
5770
5771 let spacing_in: i32 = text_options.spacing;
5772 let spacing_in_name = utils::new_c_string("spacing")?;
5773
5774 let fontfile_in: CString = utils::new_c_string(&text_options.fontfile)?;
5775 let fontfile_in_name = utils::new_c_string("fontfile")?;
5776
5777 let rgba_in: i32 = if text_options.rgba { 1 } else { 0 };
5778 let rgba_in_name = utils::new_c_string("rgba")?;
5779
5780 let wrap_in: i32 = text_options.wrap as i32;
5781 let wrap_in_name = utils::new_c_string("wrap")?;
5782
5783 let vips_op_response = bindings::vips_text(
5784 &mut out_out,
5785 text_in.as_ptr(),
5786 font_in_name.as_ptr(),
5787 font_in.as_ptr(),
5788 width_in_name.as_ptr(),
5789 width_in,
5790 height_in_name.as_ptr(),
5791 height_in,
5792 align_in_name.as_ptr(),
5793 align_in,
5794 justify_in_name.as_ptr(),
5795 justify_in,
5796 dpi_in_name.as_ptr(),
5797 dpi_in,
5798 autofit_dpi_in_name.as_ptr(),
5799 autofit_dpi_in,
5800 spacing_in_name.as_ptr(),
5801 spacing_in,
5802 fontfile_in_name.as_ptr(),
5803 fontfile_in.as_ptr(),
5804 rgba_in_name.as_ptr(),
5805 rgba_in,
5806 wrap_in_name.as_ptr(),
5807 wrap_in,
5808 NULL,
5809 );
5810 utils::result(
5811 vips_op_response,
5812 VipsImage { ctx: out_out },
5813 Error::TextError,
5814 )
5815 }
5816}
5817
5818pub fn sdf(width: i32, height: i32, shape: SdfShape) -> Result<VipsImage> {
5830 unsafe {
5831 let width_in: i32 = width;
5832 let height_in: i32 = height;
5833 let shape_in: i32 = shape as i32;
5834 let mut out_out: *mut bindings::VipsImage = null_mut();
5835
5836 let vips_op_response = bindings::vips_sdf(
5837 &mut out_out,
5838 width_in,
5839 height_in,
5840 shape_in.try_into().unwrap(),
5841 NULL,
5842 );
5843 utils::result(
5844 vips_op_response,
5845 VipsImage { ctx: out_out },
5846 Error::SdfError,
5847 )
5848 }
5849}
5850
5851#[derive(Clone, Debug)]
5853pub struct SdfOptions {
5854 pub r: f64,
5857 pub a: Vec<f64>,
5859 pub b: Vec<f64>,
5861 pub corners: Vec<f64>,
5863}
5864
5865impl std::default::Default for SdfOptions {
5866 fn default() -> Self {
5867 SdfOptions {
5868 r: f64::from(50),
5869 a: Vec::new(),
5870 b: Vec::new(),
5871 corners: Vec::new(),
5872 }
5873 }
5874}
5875
5876pub fn sdf_with_opts(
5889 width: i32,
5890 height: i32,
5891 shape: SdfShape,
5892 sdf_options: &SdfOptions,
5893) -> Result<VipsImage> {
5894 unsafe {
5895 let width_in: i32 = width;
5896 let height_in: i32 = height;
5897 let shape_in: i32 = shape as i32;
5898 let mut out_out: *mut bindings::VipsImage = null_mut();
5899
5900 let r_in: f64 = sdf_options.r;
5901 let r_in_name = utils::new_c_string("r")?;
5902
5903 let a_wrapper = utils::VipsArrayDoubleWrapper::from(&sdf_options.a[..]);
5904 let a_in = a_wrapper.ctx;
5905 let a_in_name = utils::new_c_string("a")?;
5906
5907 let b_wrapper = utils::VipsArrayDoubleWrapper::from(&sdf_options.b[..]);
5908 let b_in = b_wrapper.ctx;
5909 let b_in_name = utils::new_c_string("b")?;
5910
5911 let corners_wrapper = utils::VipsArrayDoubleWrapper::from(&sdf_options.corners[..]);
5912 let corners_in = corners_wrapper.ctx;
5913 let corners_in_name = utils::new_c_string("corners")?;
5914
5915 let vips_op_response = bindings::vips_sdf(
5916 &mut out_out,
5917 width_in,
5918 height_in,
5919 shape_in.try_into().unwrap(),
5920 r_in_name.as_ptr(),
5921 r_in,
5922 a_in_name.as_ptr(),
5923 a_in,
5924 b_in_name.as_ptr(),
5925 b_in,
5926 corners_in_name.as_ptr(),
5927 corners_in,
5928 NULL,
5929 );
5930 utils::result(
5931 vips_op_response,
5932 VipsImage { ctx: out_out },
5933 Error::SdfError,
5934 )
5935 }
5936}
5937
5938pub fn eye(width: i32, height: i32) -> Result<VipsImage> {
5945 unsafe {
5946 let width_in: i32 = width;
5947 let height_in: i32 = height;
5948 let mut out_out: *mut bindings::VipsImage = null_mut();
5949
5950 let vips_op_response = bindings::vips_eye(&mut out_out, width_in, height_in, NULL);
5951 utils::result(
5952 vips_op_response,
5953 VipsImage { ctx: out_out },
5954 Error::EyeError,
5955 )
5956 }
5957}
5958
5959#[derive(Clone, Debug)]
5961pub struct EyeOptions {
5962 pub uchar: bool,
5965 pub factor: f64,
5968}
5969
5970impl std::default::Default for EyeOptions {
5971 fn default() -> Self {
5972 EyeOptions {
5973 uchar: false,
5974 factor: f64::from(0.5),
5975 }
5976 }
5977}
5978
5979pub fn eye_with_opts(width: i32, height: i32, eye_options: &EyeOptions) -> Result<VipsImage> {
5987 unsafe {
5988 let width_in: i32 = width;
5989 let height_in: i32 = height;
5990 let mut out_out: *mut bindings::VipsImage = null_mut();
5991
5992 let uchar_in: i32 = if eye_options.uchar { 1 } else { 0 };
5993 let uchar_in_name = utils::new_c_string("uchar")?;
5994
5995 let factor_in: f64 = eye_options.factor;
5996 let factor_in_name = utils::new_c_string("factor")?;
5997
5998 let vips_op_response = bindings::vips_eye(
5999 &mut out_out,
6000 width_in,
6001 height_in,
6002 uchar_in_name.as_ptr(),
6003 uchar_in,
6004 factor_in_name.as_ptr(),
6005 factor_in,
6006 NULL,
6007 );
6008 utils::result(
6009 vips_op_response,
6010 VipsImage { ctx: out_out },
6011 Error::EyeError,
6012 )
6013 }
6014}
6015
6016pub fn grey(width: i32, height: i32) -> Result<VipsImage> {
6023 unsafe {
6024 let width_in: i32 = width;
6025 let height_in: i32 = height;
6026 let mut out_out: *mut bindings::VipsImage = null_mut();
6027
6028 let vips_op_response = bindings::vips_grey(&mut out_out, width_in, height_in, NULL);
6029 utils::result(
6030 vips_op_response,
6031 VipsImage { ctx: out_out },
6032 Error::GreyError,
6033 )
6034 }
6035}
6036
6037#[derive(Clone, Debug)]
6039pub struct GreyOptions {
6040 pub uchar: bool,
6043}
6044
6045impl std::default::Default for GreyOptions {
6046 fn default() -> Self {
6047 GreyOptions { uchar: false }
6048 }
6049}
6050
6051pub fn grey_with_opts(width: i32, height: i32, grey_options: &GreyOptions) -> Result<VipsImage> {
6059 unsafe {
6060 let width_in: i32 = width;
6061 let height_in: i32 = height;
6062 let mut out_out: *mut bindings::VipsImage = null_mut();
6063
6064 let uchar_in: i32 = if grey_options.uchar { 1 } else { 0 };
6065 let uchar_in_name = utils::new_c_string("uchar")?;
6066
6067 let vips_op_response = bindings::vips_grey(
6068 &mut out_out,
6069 width_in,
6070 height_in,
6071 uchar_in_name.as_ptr(),
6072 uchar_in,
6073 NULL,
6074 );
6075 utils::result(
6076 vips_op_response,
6077 VipsImage { ctx: out_out },
6078 Error::GreyError,
6079 )
6080 }
6081}
6082
6083pub fn zone(width: i32, height: i32) -> Result<VipsImage> {
6090 unsafe {
6091 let width_in: i32 = width;
6092 let height_in: i32 = height;
6093 let mut out_out: *mut bindings::VipsImage = null_mut();
6094
6095 let vips_op_response = bindings::vips_zone(&mut out_out, width_in, height_in, NULL);
6096 utils::result(
6097 vips_op_response,
6098 VipsImage { ctx: out_out },
6099 Error::ZoneError,
6100 )
6101 }
6102}
6103
6104#[derive(Clone, Debug)]
6106pub struct ZoneOptions {
6107 pub uchar: bool,
6110}
6111
6112impl std::default::Default for ZoneOptions {
6113 fn default() -> Self {
6114 ZoneOptions { uchar: false }
6115 }
6116}
6117
6118pub fn zone_with_opts(width: i32, height: i32, zone_options: &ZoneOptions) -> Result<VipsImage> {
6126 unsafe {
6127 let width_in: i32 = width;
6128 let height_in: i32 = height;
6129 let mut out_out: *mut bindings::VipsImage = null_mut();
6130
6131 let uchar_in: i32 = if zone_options.uchar { 1 } else { 0 };
6132 let uchar_in_name = utils::new_c_string("uchar")?;
6133
6134 let vips_op_response = bindings::vips_zone(
6135 &mut out_out,
6136 width_in,
6137 height_in,
6138 uchar_in_name.as_ptr(),
6139 uchar_in,
6140 NULL,
6141 );
6142 utils::result(
6143 vips_op_response,
6144 VipsImage { ctx: out_out },
6145 Error::ZoneError,
6146 )
6147 }
6148}
6149
6150pub fn sines(width: i32, height: i32) -> Result<VipsImage> {
6157 unsafe {
6158 let width_in: i32 = width;
6159 let height_in: i32 = height;
6160 let mut out_out: *mut bindings::VipsImage = null_mut();
6161
6162 let vips_op_response = bindings::vips_sines(&mut out_out, width_in, height_in, NULL);
6163 utils::result(
6164 vips_op_response,
6165 VipsImage { ctx: out_out },
6166 Error::SineError,
6167 )
6168 }
6169}
6170
6171#[derive(Clone, Debug)]
6173pub struct SineOptions {
6174 pub uchar: bool,
6177 pub hfreq: f64,
6180 pub vfreq: f64,
6183}
6184
6185impl std::default::Default for SineOptions {
6186 fn default() -> Self {
6187 SineOptions {
6188 uchar: false,
6189 hfreq: f64::from(0.5),
6190 vfreq: f64::from(0.5),
6191 }
6192 }
6193}
6194
6195pub fn sines_with_opts(width: i32, height: i32, sines_options: &SineOptions) -> Result<VipsImage> {
6203 unsafe {
6204 let width_in: i32 = width;
6205 let height_in: i32 = height;
6206 let mut out_out: *mut bindings::VipsImage = null_mut();
6207
6208 let uchar_in: i32 = if sines_options.uchar { 1 } else { 0 };
6209 let uchar_in_name = utils::new_c_string("uchar")?;
6210
6211 let hfreq_in: f64 = sines_options.hfreq;
6212 let hfreq_in_name = utils::new_c_string("hfreq")?;
6213
6214 let vfreq_in: f64 = sines_options.vfreq;
6215 let vfreq_in_name = utils::new_c_string("vfreq")?;
6216
6217 let vips_op_response = bindings::vips_sines(
6218 &mut out_out,
6219 width_in,
6220 height_in,
6221 uchar_in_name.as_ptr(),
6222 uchar_in,
6223 hfreq_in_name.as_ptr(),
6224 hfreq_in,
6225 vfreq_in_name.as_ptr(),
6226 vfreq_in,
6227 NULL,
6228 );
6229 utils::result(
6230 vips_op_response,
6231 VipsImage { ctx: out_out },
6232 Error::SineError,
6233 )
6234 }
6235}
6236
6237pub fn mask_ideal(width: i32, height: i32, frequency_cutoff: f64) -> Result<VipsImage> {
6246 unsafe {
6247 let width_in: i32 = width;
6248 let height_in: i32 = height;
6249 let frequency_cutoff_in: f64 = frequency_cutoff;
6250 let mut out_out: *mut bindings::VipsImage = null_mut();
6251
6252 let vips_op_response =
6253 bindings::vips_mask_ideal(&mut out_out, width_in, height_in, frequency_cutoff_in, NULL);
6254 utils::result(
6255 vips_op_response,
6256 VipsImage { ctx: out_out },
6257 Error::MaskIdealError,
6258 )
6259 }
6260}
6261
6262#[derive(Clone, Debug)]
6264pub struct MaskIdealOptions {
6265 pub uchar: bool,
6268 pub nodc: bool,
6271 pub reject: bool,
6274 pub optical: bool,
6277}
6278
6279impl std::default::Default for MaskIdealOptions {
6280 fn default() -> Self {
6281 MaskIdealOptions {
6282 uchar: false,
6283 nodc: false,
6284 reject: false,
6285 optical: false,
6286 }
6287 }
6288}
6289
6290pub fn mask_ideal_with_opts(
6300 width: i32,
6301 height: i32,
6302 frequency_cutoff: f64,
6303 mask_ideal_options: &MaskIdealOptions,
6304) -> Result<VipsImage> {
6305 unsafe {
6306 let width_in: i32 = width;
6307 let height_in: i32 = height;
6308 let frequency_cutoff_in: f64 = frequency_cutoff;
6309 let mut out_out: *mut bindings::VipsImage = null_mut();
6310
6311 let uchar_in: i32 = if mask_ideal_options.uchar { 1 } else { 0 };
6312 let uchar_in_name = utils::new_c_string("uchar")?;
6313
6314 let nodc_in: i32 = if mask_ideal_options.nodc { 1 } else { 0 };
6315 let nodc_in_name = utils::new_c_string("nodc")?;
6316
6317 let reject_in: i32 = if mask_ideal_options.reject { 1 } else { 0 };
6318 let reject_in_name = utils::new_c_string("reject")?;
6319
6320 let optical_in: i32 = if mask_ideal_options.optical { 1 } else { 0 };
6321 let optical_in_name = utils::new_c_string("optical")?;
6322
6323 let vips_op_response = bindings::vips_mask_ideal(
6324 &mut out_out,
6325 width_in,
6326 height_in,
6327 frequency_cutoff_in,
6328 uchar_in_name.as_ptr(),
6329 uchar_in,
6330 nodc_in_name.as_ptr(),
6331 nodc_in,
6332 reject_in_name.as_ptr(),
6333 reject_in,
6334 optical_in_name.as_ptr(),
6335 optical_in,
6336 NULL,
6337 );
6338 utils::result(
6339 vips_op_response,
6340 VipsImage { ctx: out_out },
6341 Error::MaskIdealError,
6342 )
6343 }
6344}
6345
6346pub fn mask_ideal_ring(
6357 width: i32,
6358 height: i32,
6359 frequency_cutoff: f64,
6360 ringwidth: f64,
6361) -> Result<VipsImage> {
6362 unsafe {
6363 let width_in: i32 = width;
6364 let height_in: i32 = height;
6365 let frequency_cutoff_in: f64 = frequency_cutoff;
6366 let ringwidth_in: f64 = ringwidth;
6367 let mut out_out: *mut bindings::VipsImage = null_mut();
6368
6369 let vips_op_response = bindings::vips_mask_ideal_ring(
6370 &mut out_out,
6371 width_in,
6372 height_in,
6373 frequency_cutoff_in,
6374 ringwidth_in,
6375 NULL,
6376 );
6377 utils::result(
6378 vips_op_response,
6379 VipsImage { ctx: out_out },
6380 Error::MaskIdealRingError,
6381 )
6382 }
6383}
6384
6385#[derive(Clone, Debug)]
6387pub struct MaskIdealRingOptions {
6388 pub uchar: bool,
6391 pub nodc: bool,
6394 pub reject: bool,
6397 pub optical: bool,
6400}
6401
6402impl std::default::Default for MaskIdealRingOptions {
6403 fn default() -> Self {
6404 MaskIdealRingOptions {
6405 uchar: false,
6406 nodc: false,
6407 reject: false,
6408 optical: false,
6409 }
6410 }
6411}
6412
6413pub fn mask_ideal_ring_with_opts(
6425 width: i32,
6426 height: i32,
6427 frequency_cutoff: f64,
6428 ringwidth: f64,
6429 mask_ideal_ring_options: &MaskIdealRingOptions,
6430) -> Result<VipsImage> {
6431 unsafe {
6432 let width_in: i32 = width;
6433 let height_in: i32 = height;
6434 let frequency_cutoff_in: f64 = frequency_cutoff;
6435 let ringwidth_in: f64 = ringwidth;
6436 let mut out_out: *mut bindings::VipsImage = null_mut();
6437
6438 let uchar_in: i32 = if mask_ideal_ring_options.uchar { 1 } else { 0 };
6439 let uchar_in_name = utils::new_c_string("uchar")?;
6440
6441 let nodc_in: i32 = if mask_ideal_ring_options.nodc { 1 } else { 0 };
6442 let nodc_in_name = utils::new_c_string("nodc")?;
6443
6444 let reject_in: i32 = if mask_ideal_ring_options.reject { 1 } else { 0 };
6445 let reject_in_name = utils::new_c_string("reject")?;
6446
6447 let optical_in: i32 = if mask_ideal_ring_options.optical {
6448 1
6449 } else {
6450 0
6451 };
6452 let optical_in_name = utils::new_c_string("optical")?;
6453
6454 let vips_op_response = bindings::vips_mask_ideal_ring(
6455 &mut out_out,
6456 width_in,
6457 height_in,
6458 frequency_cutoff_in,
6459 ringwidth_in,
6460 uchar_in_name.as_ptr(),
6461 uchar_in,
6462 nodc_in_name.as_ptr(),
6463 nodc_in,
6464 reject_in_name.as_ptr(),
6465 reject_in,
6466 optical_in_name.as_ptr(),
6467 optical_in,
6468 NULL,
6469 );
6470 utils::result(
6471 vips_op_response,
6472 VipsImage { ctx: out_out },
6473 Error::MaskIdealRingError,
6474 )
6475 }
6476}
6477
6478pub fn mask_ideal_band(
6491 width: i32,
6492 height: i32,
6493 frequency_cutoff_x: f64,
6494 frequency_cutoff_y: f64,
6495 radius: f64,
6496) -> Result<VipsImage> {
6497 unsafe {
6498 let width_in: i32 = width;
6499 let height_in: i32 = height;
6500 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
6501 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
6502 let radius_in: f64 = radius;
6503 let mut out_out: *mut bindings::VipsImage = null_mut();
6504
6505 let vips_op_response = bindings::vips_mask_ideal_band(
6506 &mut out_out,
6507 width_in,
6508 height_in,
6509 frequency_cutoff_x_in,
6510 frequency_cutoff_y_in,
6511 radius_in,
6512 NULL,
6513 );
6514 utils::result(
6515 vips_op_response,
6516 VipsImage { ctx: out_out },
6517 Error::MaskIdealBandError,
6518 )
6519 }
6520}
6521
6522#[derive(Clone, Debug)]
6524pub struct MaskIdealBandOptions {
6525 pub uchar: bool,
6528 pub nodc: bool,
6531 pub reject: bool,
6534 pub optical: bool,
6537}
6538
6539impl std::default::Default for MaskIdealBandOptions {
6540 fn default() -> Self {
6541 MaskIdealBandOptions {
6542 uchar: false,
6543 nodc: false,
6544 reject: false,
6545 optical: false,
6546 }
6547 }
6548}
6549
6550pub fn mask_ideal_band_with_opts(
6564 width: i32,
6565 height: i32,
6566 frequency_cutoff_x: f64,
6567 frequency_cutoff_y: f64,
6568 radius: f64,
6569 mask_ideal_band_options: &MaskIdealBandOptions,
6570) -> Result<VipsImage> {
6571 unsafe {
6572 let width_in: i32 = width;
6573 let height_in: i32 = height;
6574 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
6575 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
6576 let radius_in: f64 = radius;
6577 let mut out_out: *mut bindings::VipsImage = null_mut();
6578
6579 let uchar_in: i32 = if mask_ideal_band_options.uchar { 1 } else { 0 };
6580 let uchar_in_name = utils::new_c_string("uchar")?;
6581
6582 let nodc_in: i32 = if mask_ideal_band_options.nodc { 1 } else { 0 };
6583 let nodc_in_name = utils::new_c_string("nodc")?;
6584
6585 let reject_in: i32 = if mask_ideal_band_options.reject { 1 } else { 0 };
6586 let reject_in_name = utils::new_c_string("reject")?;
6587
6588 let optical_in: i32 = if mask_ideal_band_options.optical {
6589 1
6590 } else {
6591 0
6592 };
6593 let optical_in_name = utils::new_c_string("optical")?;
6594
6595 let vips_op_response = bindings::vips_mask_ideal_band(
6596 &mut out_out,
6597 width_in,
6598 height_in,
6599 frequency_cutoff_x_in,
6600 frequency_cutoff_y_in,
6601 radius_in,
6602 uchar_in_name.as_ptr(),
6603 uchar_in,
6604 nodc_in_name.as_ptr(),
6605 nodc_in,
6606 reject_in_name.as_ptr(),
6607 reject_in,
6608 optical_in_name.as_ptr(),
6609 optical_in,
6610 NULL,
6611 );
6612 utils::result(
6613 vips_op_response,
6614 VipsImage { ctx: out_out },
6615 Error::MaskIdealBandError,
6616 )
6617 }
6618}
6619
6620pub fn mask_butterworth(
6633 width: i32,
6634 height: i32,
6635 order: f64,
6636 frequency_cutoff: f64,
6637 amplitude_cutoff: f64,
6638) -> Result<VipsImage> {
6639 unsafe {
6640 let width_in: i32 = width;
6641 let height_in: i32 = height;
6642 let order_in: f64 = order;
6643 let frequency_cutoff_in: f64 = frequency_cutoff;
6644 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6645 let mut out_out: *mut bindings::VipsImage = null_mut();
6646
6647 let vips_op_response = bindings::vips_mask_butterworth(
6648 &mut out_out,
6649 width_in,
6650 height_in,
6651 order_in,
6652 frequency_cutoff_in,
6653 amplitude_cutoff_in,
6654 NULL,
6655 );
6656 utils::result(
6657 vips_op_response,
6658 VipsImage { ctx: out_out },
6659 Error::MaskButterworthError,
6660 )
6661 }
6662}
6663
6664#[derive(Clone, Debug)]
6666pub struct MaskButterworthOptions {
6667 pub uchar: bool,
6670 pub nodc: bool,
6673 pub reject: bool,
6676 pub optical: bool,
6679}
6680
6681impl std::default::Default for MaskButterworthOptions {
6682 fn default() -> Self {
6683 MaskButterworthOptions {
6684 uchar: false,
6685 nodc: false,
6686 reject: false,
6687 optical: false,
6688 }
6689 }
6690}
6691
6692pub fn mask_butterworth_with_opts(
6706 width: i32,
6707 height: i32,
6708 order: f64,
6709 frequency_cutoff: f64,
6710 amplitude_cutoff: f64,
6711 mask_butterworth_options: &MaskButterworthOptions,
6712) -> Result<VipsImage> {
6713 unsafe {
6714 let width_in: i32 = width;
6715 let height_in: i32 = height;
6716 let order_in: f64 = order;
6717 let frequency_cutoff_in: f64 = frequency_cutoff;
6718 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6719 let mut out_out: *mut bindings::VipsImage = null_mut();
6720
6721 let uchar_in: i32 = if mask_butterworth_options.uchar { 1 } else { 0 };
6722 let uchar_in_name = utils::new_c_string("uchar")?;
6723
6724 let nodc_in: i32 = if mask_butterworth_options.nodc { 1 } else { 0 };
6725 let nodc_in_name = utils::new_c_string("nodc")?;
6726
6727 let reject_in: i32 = if mask_butterworth_options.reject {
6728 1
6729 } else {
6730 0
6731 };
6732 let reject_in_name = utils::new_c_string("reject")?;
6733
6734 let optical_in: i32 = if mask_butterworth_options.optical {
6735 1
6736 } else {
6737 0
6738 };
6739 let optical_in_name = utils::new_c_string("optical")?;
6740
6741 let vips_op_response = bindings::vips_mask_butterworth(
6742 &mut out_out,
6743 width_in,
6744 height_in,
6745 order_in,
6746 frequency_cutoff_in,
6747 amplitude_cutoff_in,
6748 uchar_in_name.as_ptr(),
6749 uchar_in,
6750 nodc_in_name.as_ptr(),
6751 nodc_in,
6752 reject_in_name.as_ptr(),
6753 reject_in,
6754 optical_in_name.as_ptr(),
6755 optical_in,
6756 NULL,
6757 );
6758 utils::result(
6759 vips_op_response,
6760 VipsImage { ctx: out_out },
6761 Error::MaskButterworthError,
6762 )
6763 }
6764}
6765
6766pub fn mask_butterworth_ring(
6781 width: i32,
6782 height: i32,
6783 order: f64,
6784 frequency_cutoff: f64,
6785 amplitude_cutoff: f64,
6786 ringwidth: f64,
6787) -> Result<VipsImage> {
6788 unsafe {
6789 let width_in: i32 = width;
6790 let height_in: i32 = height;
6791 let order_in: f64 = order;
6792 let frequency_cutoff_in: f64 = frequency_cutoff;
6793 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6794 let ringwidth_in: f64 = ringwidth;
6795 let mut out_out: *mut bindings::VipsImage = null_mut();
6796
6797 let vips_op_response = bindings::vips_mask_butterworth_ring(
6798 &mut out_out,
6799 width_in,
6800 height_in,
6801 order_in,
6802 frequency_cutoff_in,
6803 amplitude_cutoff_in,
6804 ringwidth_in,
6805 NULL,
6806 );
6807 utils::result(
6808 vips_op_response,
6809 VipsImage { ctx: out_out },
6810 Error::MaskButterworthRingError,
6811 )
6812 }
6813}
6814
6815#[derive(Clone, Debug)]
6817pub struct MaskButterworthRingOptions {
6818 pub uchar: bool,
6821 pub nodc: bool,
6824 pub reject: bool,
6827 pub optical: bool,
6830}
6831
6832impl std::default::Default for MaskButterworthRingOptions {
6833 fn default() -> Self {
6834 MaskButterworthRingOptions {
6835 uchar: false,
6836 nodc: false,
6837 reject: false,
6838 optical: false,
6839 }
6840 }
6841}
6842
6843pub fn mask_butterworth_ring_with_opts(
6859 width: i32,
6860 height: i32,
6861 order: f64,
6862 frequency_cutoff: f64,
6863 amplitude_cutoff: f64,
6864 ringwidth: f64,
6865 mask_butterworth_ring_options: &MaskButterworthRingOptions,
6866) -> Result<VipsImage> {
6867 unsafe {
6868 let width_in: i32 = width;
6869 let height_in: i32 = height;
6870 let order_in: f64 = order;
6871 let frequency_cutoff_in: f64 = frequency_cutoff;
6872 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6873 let ringwidth_in: f64 = ringwidth;
6874 let mut out_out: *mut bindings::VipsImage = null_mut();
6875
6876 let uchar_in: i32 = if mask_butterworth_ring_options.uchar {
6877 1
6878 } else {
6879 0
6880 };
6881 let uchar_in_name = utils::new_c_string("uchar")?;
6882
6883 let nodc_in: i32 = if mask_butterworth_ring_options.nodc {
6884 1
6885 } else {
6886 0
6887 };
6888 let nodc_in_name = utils::new_c_string("nodc")?;
6889
6890 let reject_in: i32 = if mask_butterworth_ring_options.reject {
6891 1
6892 } else {
6893 0
6894 };
6895 let reject_in_name = utils::new_c_string("reject")?;
6896
6897 let optical_in: i32 = if mask_butterworth_ring_options.optical {
6898 1
6899 } else {
6900 0
6901 };
6902 let optical_in_name = utils::new_c_string("optical")?;
6903
6904 let vips_op_response = bindings::vips_mask_butterworth_ring(
6905 &mut out_out,
6906 width_in,
6907 height_in,
6908 order_in,
6909 frequency_cutoff_in,
6910 amplitude_cutoff_in,
6911 ringwidth_in,
6912 uchar_in_name.as_ptr(),
6913 uchar_in,
6914 nodc_in_name.as_ptr(),
6915 nodc_in,
6916 reject_in_name.as_ptr(),
6917 reject_in,
6918 optical_in_name.as_ptr(),
6919 optical_in,
6920 NULL,
6921 );
6922 utils::result(
6923 vips_op_response,
6924 VipsImage { ctx: out_out },
6925 Error::MaskButterworthRingError,
6926 )
6927 }
6928}
6929
6930pub fn mask_butterworth_band(
6947 width: i32,
6948 height: i32,
6949 order: f64,
6950 frequency_cutoff_x: f64,
6951 frequency_cutoff_y: f64,
6952 radius: f64,
6953 amplitude_cutoff: f64,
6954) -> Result<VipsImage> {
6955 unsafe {
6956 let width_in: i32 = width;
6957 let height_in: i32 = height;
6958 let order_in: f64 = order;
6959 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
6960 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
6961 let radius_in: f64 = radius;
6962 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6963 let mut out_out: *mut bindings::VipsImage = null_mut();
6964
6965 let vips_op_response = bindings::vips_mask_butterworth_band(
6966 &mut out_out,
6967 width_in,
6968 height_in,
6969 order_in,
6970 frequency_cutoff_x_in,
6971 frequency_cutoff_y_in,
6972 radius_in,
6973 amplitude_cutoff_in,
6974 NULL,
6975 );
6976 utils::result(
6977 vips_op_response,
6978 VipsImage { ctx: out_out },
6979 Error::MaskButterworthBandError,
6980 )
6981 }
6982}
6983
6984#[derive(Clone, Debug)]
6986pub struct MaskButterworthBandOptions {
6987 pub uchar: bool,
6990 pub nodc: bool,
6993 pub reject: bool,
6996 pub optical: bool,
6999}
7000
7001impl std::default::Default for MaskButterworthBandOptions {
7002 fn default() -> Self {
7003 MaskButterworthBandOptions {
7004 uchar: false,
7005 nodc: false,
7006 reject: false,
7007 optical: false,
7008 }
7009 }
7010}
7011
7012pub fn mask_butterworth_band_with_opts(
7030 width: i32,
7031 height: i32,
7032 order: f64,
7033 frequency_cutoff_x: f64,
7034 frequency_cutoff_y: f64,
7035 radius: f64,
7036 amplitude_cutoff: f64,
7037 mask_butterworth_band_options: &MaskButterworthBandOptions,
7038) -> Result<VipsImage> {
7039 unsafe {
7040 let width_in: i32 = width;
7041 let height_in: i32 = height;
7042 let order_in: f64 = order;
7043 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7044 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7045 let radius_in: f64 = radius;
7046 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7047 let mut out_out: *mut bindings::VipsImage = null_mut();
7048
7049 let uchar_in: i32 = if mask_butterworth_band_options.uchar {
7050 1
7051 } else {
7052 0
7053 };
7054 let uchar_in_name = utils::new_c_string("uchar")?;
7055
7056 let nodc_in: i32 = if mask_butterworth_band_options.nodc {
7057 1
7058 } else {
7059 0
7060 };
7061 let nodc_in_name = utils::new_c_string("nodc")?;
7062
7063 let reject_in: i32 = if mask_butterworth_band_options.reject {
7064 1
7065 } else {
7066 0
7067 };
7068 let reject_in_name = utils::new_c_string("reject")?;
7069
7070 let optical_in: i32 = if mask_butterworth_band_options.optical {
7071 1
7072 } else {
7073 0
7074 };
7075 let optical_in_name = utils::new_c_string("optical")?;
7076
7077 let vips_op_response = bindings::vips_mask_butterworth_band(
7078 &mut out_out,
7079 width_in,
7080 height_in,
7081 order_in,
7082 frequency_cutoff_x_in,
7083 frequency_cutoff_y_in,
7084 radius_in,
7085 amplitude_cutoff_in,
7086 uchar_in_name.as_ptr(),
7087 uchar_in,
7088 nodc_in_name.as_ptr(),
7089 nodc_in,
7090 reject_in_name.as_ptr(),
7091 reject_in,
7092 optical_in_name.as_ptr(),
7093 optical_in,
7094 NULL,
7095 );
7096 utils::result(
7097 vips_op_response,
7098 VipsImage { ctx: out_out },
7099 Error::MaskButterworthBandError,
7100 )
7101 }
7102}
7103
7104pub fn mask_gaussian(
7115 width: i32,
7116 height: i32,
7117 frequency_cutoff: f64,
7118 amplitude_cutoff: f64,
7119) -> Result<VipsImage> {
7120 unsafe {
7121 let width_in: i32 = width;
7122 let height_in: i32 = height;
7123 let frequency_cutoff_in: f64 = frequency_cutoff;
7124 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7125 let mut out_out: *mut bindings::VipsImage = null_mut();
7126
7127 let vips_op_response = bindings::vips_mask_gaussian(
7128 &mut out_out,
7129 width_in,
7130 height_in,
7131 frequency_cutoff_in,
7132 amplitude_cutoff_in,
7133 NULL,
7134 );
7135 utils::result(
7136 vips_op_response,
7137 VipsImage { ctx: out_out },
7138 Error::MaskGaussianError,
7139 )
7140 }
7141}
7142
7143#[derive(Clone, Debug)]
7145pub struct MaskGaussianOptions {
7146 pub uchar: bool,
7149 pub nodc: bool,
7152 pub reject: bool,
7155 pub optical: bool,
7158}
7159
7160impl std::default::Default for MaskGaussianOptions {
7161 fn default() -> Self {
7162 MaskGaussianOptions {
7163 uchar: false,
7164 nodc: false,
7165 reject: false,
7166 optical: false,
7167 }
7168 }
7169}
7170
7171pub fn mask_gaussian_with_opts(
7183 width: i32,
7184 height: i32,
7185 frequency_cutoff: f64,
7186 amplitude_cutoff: f64,
7187 mask_gaussian_options: &MaskGaussianOptions,
7188) -> Result<VipsImage> {
7189 unsafe {
7190 let width_in: i32 = width;
7191 let height_in: i32 = height;
7192 let frequency_cutoff_in: f64 = frequency_cutoff;
7193 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7194 let mut out_out: *mut bindings::VipsImage = null_mut();
7195
7196 let uchar_in: i32 = if mask_gaussian_options.uchar { 1 } else { 0 };
7197 let uchar_in_name = utils::new_c_string("uchar")?;
7198
7199 let nodc_in: i32 = if mask_gaussian_options.nodc { 1 } else { 0 };
7200 let nodc_in_name = utils::new_c_string("nodc")?;
7201
7202 let reject_in: i32 = if mask_gaussian_options.reject { 1 } else { 0 };
7203 let reject_in_name = utils::new_c_string("reject")?;
7204
7205 let optical_in: i32 = if mask_gaussian_options.optical { 1 } else { 0 };
7206 let optical_in_name = utils::new_c_string("optical")?;
7207
7208 let vips_op_response = bindings::vips_mask_gaussian(
7209 &mut out_out,
7210 width_in,
7211 height_in,
7212 frequency_cutoff_in,
7213 amplitude_cutoff_in,
7214 uchar_in_name.as_ptr(),
7215 uchar_in,
7216 nodc_in_name.as_ptr(),
7217 nodc_in,
7218 reject_in_name.as_ptr(),
7219 reject_in,
7220 optical_in_name.as_ptr(),
7221 optical_in,
7222 NULL,
7223 );
7224 utils::result(
7225 vips_op_response,
7226 VipsImage { ctx: out_out },
7227 Error::MaskGaussianError,
7228 )
7229 }
7230}
7231
7232pub fn mask_gaussian_ring(
7245 width: i32,
7246 height: i32,
7247 frequency_cutoff: f64,
7248 amplitude_cutoff: f64,
7249 ringwidth: f64,
7250) -> Result<VipsImage> {
7251 unsafe {
7252 let width_in: i32 = width;
7253 let height_in: i32 = height;
7254 let frequency_cutoff_in: f64 = frequency_cutoff;
7255 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7256 let ringwidth_in: f64 = ringwidth;
7257 let mut out_out: *mut bindings::VipsImage = null_mut();
7258
7259 let vips_op_response = bindings::vips_mask_gaussian_ring(
7260 &mut out_out,
7261 width_in,
7262 height_in,
7263 frequency_cutoff_in,
7264 amplitude_cutoff_in,
7265 ringwidth_in,
7266 NULL,
7267 );
7268 utils::result(
7269 vips_op_response,
7270 VipsImage { ctx: out_out },
7271 Error::MaskGaussianRingError,
7272 )
7273 }
7274}
7275
7276#[derive(Clone, Debug)]
7278pub struct MaskGaussianRingOptions {
7279 pub uchar: bool,
7282 pub nodc: bool,
7285 pub reject: bool,
7288 pub optical: bool,
7291}
7292
7293impl std::default::Default for MaskGaussianRingOptions {
7294 fn default() -> Self {
7295 MaskGaussianRingOptions {
7296 uchar: false,
7297 nodc: false,
7298 reject: false,
7299 optical: false,
7300 }
7301 }
7302}
7303
7304pub fn mask_gaussian_ring_with_opts(
7318 width: i32,
7319 height: i32,
7320 frequency_cutoff: f64,
7321 amplitude_cutoff: f64,
7322 ringwidth: f64,
7323 mask_gaussian_ring_options: &MaskGaussianRingOptions,
7324) -> Result<VipsImage> {
7325 unsafe {
7326 let width_in: i32 = width;
7327 let height_in: i32 = height;
7328 let frequency_cutoff_in: f64 = frequency_cutoff;
7329 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7330 let ringwidth_in: f64 = ringwidth;
7331 let mut out_out: *mut bindings::VipsImage = null_mut();
7332
7333 let uchar_in: i32 = if mask_gaussian_ring_options.uchar {
7334 1
7335 } else {
7336 0
7337 };
7338 let uchar_in_name = utils::new_c_string("uchar")?;
7339
7340 let nodc_in: i32 = if mask_gaussian_ring_options.nodc {
7341 1
7342 } else {
7343 0
7344 };
7345 let nodc_in_name = utils::new_c_string("nodc")?;
7346
7347 let reject_in: i32 = if mask_gaussian_ring_options.reject {
7348 1
7349 } else {
7350 0
7351 };
7352 let reject_in_name = utils::new_c_string("reject")?;
7353
7354 let optical_in: i32 = if mask_gaussian_ring_options.optical {
7355 1
7356 } else {
7357 0
7358 };
7359 let optical_in_name = utils::new_c_string("optical")?;
7360
7361 let vips_op_response = bindings::vips_mask_gaussian_ring(
7362 &mut out_out,
7363 width_in,
7364 height_in,
7365 frequency_cutoff_in,
7366 amplitude_cutoff_in,
7367 ringwidth_in,
7368 uchar_in_name.as_ptr(),
7369 uchar_in,
7370 nodc_in_name.as_ptr(),
7371 nodc_in,
7372 reject_in_name.as_ptr(),
7373 reject_in,
7374 optical_in_name.as_ptr(),
7375 optical_in,
7376 NULL,
7377 );
7378 utils::result(
7379 vips_op_response,
7380 VipsImage { ctx: out_out },
7381 Error::MaskGaussianRingError,
7382 )
7383 }
7384}
7385
7386pub fn mask_gaussian_band(
7401 width: i32,
7402 height: i32,
7403 frequency_cutoff_x: f64,
7404 frequency_cutoff_y: f64,
7405 radius: f64,
7406 amplitude_cutoff: f64,
7407) -> Result<VipsImage> {
7408 unsafe {
7409 let width_in: i32 = width;
7410 let height_in: i32 = height;
7411 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7412 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7413 let radius_in: f64 = radius;
7414 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7415 let mut out_out: *mut bindings::VipsImage = null_mut();
7416
7417 let vips_op_response = bindings::vips_mask_gaussian_band(
7418 &mut out_out,
7419 width_in,
7420 height_in,
7421 frequency_cutoff_x_in,
7422 frequency_cutoff_y_in,
7423 radius_in,
7424 amplitude_cutoff_in,
7425 NULL,
7426 );
7427 utils::result(
7428 vips_op_response,
7429 VipsImage { ctx: out_out },
7430 Error::MaskGaussianBandError,
7431 )
7432 }
7433}
7434
7435#[derive(Clone, Debug)]
7437pub struct MaskGaussianBandOptions {
7438 pub uchar: bool,
7441 pub nodc: bool,
7444 pub reject: bool,
7447 pub optical: bool,
7450}
7451
7452impl std::default::Default for MaskGaussianBandOptions {
7453 fn default() -> Self {
7454 MaskGaussianBandOptions {
7455 uchar: false,
7456 nodc: false,
7457 reject: false,
7458 optical: false,
7459 }
7460 }
7461}
7462
7463pub fn mask_gaussian_band_with_opts(
7479 width: i32,
7480 height: i32,
7481 frequency_cutoff_x: f64,
7482 frequency_cutoff_y: f64,
7483 radius: f64,
7484 amplitude_cutoff: f64,
7485 mask_gaussian_band_options: &MaskGaussianBandOptions,
7486) -> Result<VipsImage> {
7487 unsafe {
7488 let width_in: i32 = width;
7489 let height_in: i32 = height;
7490 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7491 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7492 let radius_in: f64 = radius;
7493 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7494 let mut out_out: *mut bindings::VipsImage = null_mut();
7495
7496 let uchar_in: i32 = if mask_gaussian_band_options.uchar {
7497 1
7498 } else {
7499 0
7500 };
7501 let uchar_in_name = utils::new_c_string("uchar")?;
7502
7503 let nodc_in: i32 = if mask_gaussian_band_options.nodc {
7504 1
7505 } else {
7506 0
7507 };
7508 let nodc_in_name = utils::new_c_string("nodc")?;
7509
7510 let reject_in: i32 = if mask_gaussian_band_options.reject {
7511 1
7512 } else {
7513 0
7514 };
7515 let reject_in_name = utils::new_c_string("reject")?;
7516
7517 let optical_in: i32 = if mask_gaussian_band_options.optical {
7518 1
7519 } else {
7520 0
7521 };
7522 let optical_in_name = utils::new_c_string("optical")?;
7523
7524 let vips_op_response = bindings::vips_mask_gaussian_band(
7525 &mut out_out,
7526 width_in,
7527 height_in,
7528 frequency_cutoff_x_in,
7529 frequency_cutoff_y_in,
7530 radius_in,
7531 amplitude_cutoff_in,
7532 uchar_in_name.as_ptr(),
7533 uchar_in,
7534 nodc_in_name.as_ptr(),
7535 nodc_in,
7536 reject_in_name.as_ptr(),
7537 reject_in,
7538 optical_in_name.as_ptr(),
7539 optical_in,
7540 NULL,
7541 );
7542 utils::result(
7543 vips_op_response,
7544 VipsImage { ctx: out_out },
7545 Error::MaskGaussianBandError,
7546 )
7547 }
7548}
7549
7550pub fn mask_fractal(width: i32, height: i32, fractal_dimension: f64) -> Result<VipsImage> {
7559 unsafe {
7560 let width_in: i32 = width;
7561 let height_in: i32 = height;
7562 let fractal_dimension_in: f64 = fractal_dimension;
7563 let mut out_out: *mut bindings::VipsImage = null_mut();
7564
7565 let vips_op_response = bindings::vips_mask_fractal(
7566 &mut out_out,
7567 width_in,
7568 height_in,
7569 fractal_dimension_in,
7570 NULL,
7571 );
7572 utils::result(
7573 vips_op_response,
7574 VipsImage { ctx: out_out },
7575 Error::MaskFractalError,
7576 )
7577 }
7578}
7579
7580#[derive(Clone, Debug)]
7582pub struct MaskFractalOptions {
7583 pub uchar: bool,
7586 pub nodc: bool,
7589 pub reject: bool,
7592 pub optical: bool,
7595}
7596
7597impl std::default::Default for MaskFractalOptions {
7598 fn default() -> Self {
7599 MaskFractalOptions {
7600 uchar: false,
7601 nodc: false,
7602 reject: false,
7603 optical: false,
7604 }
7605 }
7606}
7607
7608pub fn mask_fractal_with_opts(
7618 width: i32,
7619 height: i32,
7620 fractal_dimension: f64,
7621 mask_fractal_options: &MaskFractalOptions,
7622) -> Result<VipsImage> {
7623 unsafe {
7624 let width_in: i32 = width;
7625 let height_in: i32 = height;
7626 let fractal_dimension_in: f64 = fractal_dimension;
7627 let mut out_out: *mut bindings::VipsImage = null_mut();
7628
7629 let uchar_in: i32 = if mask_fractal_options.uchar { 1 } else { 0 };
7630 let uchar_in_name = utils::new_c_string("uchar")?;
7631
7632 let nodc_in: i32 = if mask_fractal_options.nodc { 1 } else { 0 };
7633 let nodc_in_name = utils::new_c_string("nodc")?;
7634
7635 let reject_in: i32 = if mask_fractal_options.reject { 1 } else { 0 };
7636 let reject_in_name = utils::new_c_string("reject")?;
7637
7638 let optical_in: i32 = if mask_fractal_options.optical { 1 } else { 0 };
7639 let optical_in_name = utils::new_c_string("optical")?;
7640
7641 let vips_op_response = bindings::vips_mask_fractal(
7642 &mut out_out,
7643 width_in,
7644 height_in,
7645 fractal_dimension_in,
7646 uchar_in_name.as_ptr(),
7647 uchar_in,
7648 nodc_in_name.as_ptr(),
7649 nodc_in,
7650 reject_in_name.as_ptr(),
7651 reject_in,
7652 optical_in_name.as_ptr(),
7653 optical_in,
7654 NULL,
7655 );
7656 utils::result(
7657 vips_op_response,
7658 VipsImage { ctx: out_out },
7659 Error::MaskFractalError,
7660 )
7661 }
7662}
7663
7664pub fn buildlut(inp: &VipsImage) -> Result<VipsImage> {
7668 unsafe {
7669 let inp_in: *mut bindings::VipsImage = inp.ctx;
7670 let mut out_out: *mut bindings::VipsImage = null_mut();
7671
7672 let vips_op_response = bindings::vips_buildlut(inp_in, &mut out_out, NULL);
7673 utils::result(
7674 vips_op_response,
7675 VipsImage { ctx: out_out },
7676 Error::BuildlutError,
7677 )
7678 }
7679}
7680
7681pub fn invertlut(inp: &VipsImage) -> Result<VipsImage> {
7685 unsafe {
7686 let inp_in: *mut bindings::VipsImage = inp.ctx;
7687 let mut out_out: *mut bindings::VipsImage = null_mut();
7688
7689 let vips_op_response = bindings::vips_invertlut(inp_in, &mut out_out, NULL);
7690 utils::result(
7691 vips_op_response,
7692 VipsImage { ctx: out_out },
7693 Error::InvertlutError,
7694 )
7695 }
7696}
7697
7698#[derive(Clone, Debug)]
7700pub struct InvertlutOptions {
7701 pub size: i32,
7704}
7705
7706impl std::default::Default for InvertlutOptions {
7707 fn default() -> Self {
7708 InvertlutOptions {
7709 size: i32::from(256),
7710 }
7711 }
7712}
7713
7714pub fn invertlut_with_opts(
7719 inp: &VipsImage,
7720 invertlut_options: &InvertlutOptions,
7721) -> Result<VipsImage> {
7722 unsafe {
7723 let inp_in: *mut bindings::VipsImage = inp.ctx;
7724 let mut out_out: *mut bindings::VipsImage = null_mut();
7725
7726 let size_in: i32 = invertlut_options.size;
7727 let size_in_name = utils::new_c_string("size")?;
7728
7729 let vips_op_response =
7730 bindings::vips_invertlut(inp_in, &mut out_out, size_in_name.as_ptr(), size_in, NULL);
7731 utils::result(
7732 vips_op_response,
7733 VipsImage { ctx: out_out },
7734 Error::InvertlutError,
7735 )
7736 }
7737}
7738
7739pub fn tonelut() -> Result<VipsImage> {
7743 unsafe {
7744 let mut out_out: *mut bindings::VipsImage = null_mut();
7745
7746 let vips_op_response = bindings::vips_tonelut(&mut out_out, NULL);
7747 utils::result(
7748 vips_op_response,
7749 VipsImage { ctx: out_out },
7750 Error::TonelutError,
7751 )
7752 }
7753}
7754
7755#[derive(Clone, Debug)]
7757pub struct TonelutOptions {
7758 pub in_max: i32,
7761 pub out_max: i32,
7764 pub lb: f64,
7767 pub lw: f64,
7770 pub ps: f64,
7773 pub pm: f64,
7776 pub ph: f64,
7779 pub s: f64,
7782 pub m: f64,
7785 pub h: f64,
7788}
7789
7790impl std::default::Default for TonelutOptions {
7791 fn default() -> Self {
7792 TonelutOptions {
7793 in_max: i32::from(32767),
7794 out_max: i32::from(32767),
7795 lb: f64::from(0),
7796 lw: f64::from(100),
7797 ps: f64::from(0.2),
7798 pm: f64::from(0.5),
7799 ph: f64::from(0.8),
7800 s: f64::from(0),
7801 m: f64::from(0),
7802 h: f64::from(0),
7803 }
7804 }
7805}
7806
7807pub fn tonelut_with_opts(tonelut_options: &TonelutOptions) -> Result<VipsImage> {
7812 unsafe {
7813 let mut out_out: *mut bindings::VipsImage = null_mut();
7814
7815 let in_max_in: i32 = tonelut_options.in_max;
7816 let in_max_in_name = utils::new_c_string("in-max")?;
7817
7818 let out_max_in: i32 = tonelut_options.out_max;
7819 let out_max_in_name = utils::new_c_string("out-max")?;
7820
7821 let lb_in: f64 = tonelut_options.lb;
7822 let lb_in_name = utils::new_c_string("Lb")?;
7823
7824 let lw_in: f64 = tonelut_options.lw;
7825 let lw_in_name = utils::new_c_string("Lw")?;
7826
7827 let ps_in: f64 = tonelut_options.ps;
7828 let ps_in_name = utils::new_c_string("Ps")?;
7829
7830 let pm_in: f64 = tonelut_options.pm;
7831 let pm_in_name = utils::new_c_string("Pm")?;
7832
7833 let ph_in: f64 = tonelut_options.ph;
7834 let ph_in_name = utils::new_c_string("Ph")?;
7835
7836 let s_in: f64 = tonelut_options.s;
7837 let s_in_name = utils::new_c_string("S")?;
7838
7839 let m_in: f64 = tonelut_options.m;
7840 let m_in_name = utils::new_c_string("M")?;
7841
7842 let h_in: f64 = tonelut_options.h;
7843 let h_in_name = utils::new_c_string("H")?;
7844
7845 let vips_op_response = bindings::vips_tonelut(
7846 &mut out_out,
7847 in_max_in_name.as_ptr(),
7848 in_max_in,
7849 out_max_in_name.as_ptr(),
7850 out_max_in,
7851 lb_in_name.as_ptr(),
7852 lb_in,
7853 lw_in_name.as_ptr(),
7854 lw_in,
7855 ps_in_name.as_ptr(),
7856 ps_in,
7857 pm_in_name.as_ptr(),
7858 pm_in,
7859 ph_in_name.as_ptr(),
7860 ph_in,
7861 s_in_name.as_ptr(),
7862 s_in,
7863 m_in_name.as_ptr(),
7864 m_in,
7865 h_in_name.as_ptr(),
7866 h_in,
7867 NULL,
7868 );
7869 utils::result(
7870 vips_op_response,
7871 VipsImage { ctx: out_out },
7872 Error::TonelutError,
7873 )
7874 }
7875}
7876
7877pub fn identity() -> Result<VipsImage> {
7881 unsafe {
7882 let mut out_out: *mut bindings::VipsImage = null_mut();
7883
7884 let vips_op_response = bindings::vips_identity(&mut out_out, NULL);
7885 utils::result(
7886 vips_op_response,
7887 VipsImage { ctx: out_out },
7888 Error::IdentityError,
7889 )
7890 }
7891}
7892
7893#[derive(Clone, Debug)]
7895pub struct IdentityOptions {
7896 pub bands: i32,
7899 pub ushort: bool,
7902 pub size: i32,
7905}
7906
7907impl std::default::Default for IdentityOptions {
7908 fn default() -> Self {
7909 IdentityOptions {
7910 bands: i32::from(1),
7911 ushort: false,
7912 size: i32::from(65536),
7913 }
7914 }
7915}
7916
7917pub fn identity_with_opts(identity_options: &IdentityOptions) -> Result<VipsImage> {
7922 unsafe {
7923 let mut out_out: *mut bindings::VipsImage = null_mut();
7924
7925 let bands_in: i32 = identity_options.bands;
7926 let bands_in_name = utils::new_c_string("bands")?;
7927
7928 let ushort_in: i32 = if identity_options.ushort { 1 } else { 0 };
7929 let ushort_in_name = utils::new_c_string("ushort")?;
7930
7931 let size_in: i32 = identity_options.size;
7932 let size_in_name = utils::new_c_string("size")?;
7933
7934 let vips_op_response = bindings::vips_identity(
7935 &mut out_out,
7936 bands_in_name.as_ptr(),
7937 bands_in,
7938 ushort_in_name.as_ptr(),
7939 ushort_in,
7940 size_in_name.as_ptr(),
7941 size_in,
7942 NULL,
7943 );
7944 utils::result(
7945 vips_op_response,
7946 VipsImage { ctx: out_out },
7947 Error::IdentityError,
7948 )
7949 }
7950}
7951
7952pub fn fractsurf(width: i32, height: i32, fractal_dimension: f64) -> Result<VipsImage> {
7961 unsafe {
7962 let width_in: i32 = width;
7963 let height_in: i32 = height;
7964 let fractal_dimension_in: f64 = fractal_dimension;
7965 let mut out_out: *mut bindings::VipsImage = null_mut();
7966
7967 let vips_op_response = bindings::vips_fractsurf(
7968 &mut out_out,
7969 width_in,
7970 height_in,
7971 fractal_dimension_in,
7972 NULL,
7973 );
7974 utils::result(
7975 vips_op_response,
7976 VipsImage { ctx: out_out },
7977 Error::FractsurfError,
7978 )
7979 }
7980}
7981
7982pub fn worley(width: i32, height: i32) -> Result<VipsImage> {
7989 unsafe {
7990 let width_in: i32 = width;
7991 let height_in: i32 = height;
7992 let mut out_out: *mut bindings::VipsImage = null_mut();
7993
7994 let vips_op_response = bindings::vips_worley(&mut out_out, width_in, height_in, NULL);
7995 utils::result(
7996 vips_op_response,
7997 VipsImage { ctx: out_out },
7998 Error::WorleyError,
7999 )
8000 }
8001}
8002
8003#[derive(Clone, Debug)]
8005pub struct WorleyOptions {
8006 pub cell_size: i32,
8009 pub seed: i32,
8012}
8013
8014impl std::default::Default for WorleyOptions {
8015 fn default() -> Self {
8016 WorleyOptions {
8017 cell_size: i32::from(256),
8018 seed: i32::from(0),
8019 }
8020 }
8021}
8022
8023pub fn worley_with_opts(
8031 width: i32,
8032 height: i32,
8033 worley_options: &WorleyOptions,
8034) -> Result<VipsImage> {
8035 unsafe {
8036 let width_in: i32 = width;
8037 let height_in: i32 = height;
8038 let mut out_out: *mut bindings::VipsImage = null_mut();
8039
8040 let cell_size_in: i32 = worley_options.cell_size;
8041 let cell_size_in_name = utils::new_c_string("cell-size")?;
8042
8043 let seed_in: i32 = worley_options.seed;
8044 let seed_in_name = utils::new_c_string("seed")?;
8045
8046 let vips_op_response = bindings::vips_worley(
8047 &mut out_out,
8048 width_in,
8049 height_in,
8050 cell_size_in_name.as_ptr(),
8051 cell_size_in,
8052 seed_in_name.as_ptr(),
8053 seed_in,
8054 NULL,
8055 );
8056 utils::result(
8057 vips_op_response,
8058 VipsImage { ctx: out_out },
8059 Error::WorleyError,
8060 )
8061 }
8062}
8063
8064pub fn perlin(width: i32, height: i32) -> Result<VipsImage> {
8071 unsafe {
8072 let width_in: i32 = width;
8073 let height_in: i32 = height;
8074 let mut out_out: *mut bindings::VipsImage = null_mut();
8075
8076 let vips_op_response = bindings::vips_perlin(&mut out_out, width_in, height_in, NULL);
8077 utils::result(
8078 vips_op_response,
8079 VipsImage { ctx: out_out },
8080 Error::PerlinError,
8081 )
8082 }
8083}
8084
8085#[derive(Clone, Debug)]
8087pub struct PerlinOptions {
8088 pub cell_size: i32,
8091 pub uchar: bool,
8094 pub seed: i32,
8097}
8098
8099impl std::default::Default for PerlinOptions {
8100 fn default() -> Self {
8101 PerlinOptions {
8102 cell_size: i32::from(256),
8103 uchar: false,
8104 seed: i32::from(0),
8105 }
8106 }
8107}
8108
8109pub fn perlin_with_opts(
8117 width: i32,
8118 height: i32,
8119 perlin_options: &PerlinOptions,
8120) -> Result<VipsImage> {
8121 unsafe {
8122 let width_in: i32 = width;
8123 let height_in: i32 = height;
8124 let mut out_out: *mut bindings::VipsImage = null_mut();
8125
8126 let cell_size_in: i32 = perlin_options.cell_size;
8127 let cell_size_in_name = utils::new_c_string("cell-size")?;
8128
8129 let uchar_in: i32 = if perlin_options.uchar { 1 } else { 0 };
8130 let uchar_in_name = utils::new_c_string("uchar")?;
8131
8132 let seed_in: i32 = perlin_options.seed;
8133 let seed_in_name = utils::new_c_string("seed")?;
8134
8135 let vips_op_response = bindings::vips_perlin(
8136 &mut out_out,
8137 width_in,
8138 height_in,
8139 cell_size_in_name.as_ptr(),
8140 cell_size_in,
8141 uchar_in_name.as_ptr(),
8142 uchar_in,
8143 seed_in_name.as_ptr(),
8144 seed_in,
8145 NULL,
8146 );
8147 utils::result(
8148 vips_op_response,
8149 VipsImage { ctx: out_out },
8150 Error::PerlinError,
8151 )
8152 }
8153}
8154
8155pub fn switch(tests: &mut [VipsImage]) -> Result<VipsImage> {
8159 unsafe {
8160 let (tests_len, mut tests_in) = {
8161 let len = tests.len();
8162 let mut input = Vec::new();
8163 for img in tests {
8164 input.push(img.ctx)
8165 }
8166 (len as i32, input)
8167 };
8168 let mut out_out: *mut bindings::VipsImage = null_mut();
8169
8170 let vips_op_response =
8171 bindings::vips_switch(tests_in.as_mut_ptr(), &mut out_out, tests_len, NULL);
8172 utils::result(
8173 vips_op_response,
8174 VipsImage { ctx: out_out },
8175 Error::SwitchError,
8176 )
8177 }
8178}
8179
8180pub fn csvload(filename: &str) -> Result<VipsImage> {
8184 unsafe {
8185 let filename_in: CString = utils::new_c_string(filename)?;
8186 let mut out_out: *mut bindings::VipsImage = null_mut();
8187
8188 let vips_op_response = bindings::vips_csvload(filename_in.as_ptr(), &mut out_out, NULL);
8189 utils::result(
8190 vips_op_response,
8191 VipsImage { ctx: out_out },
8192 Error::CsvloadError,
8193 )
8194 }
8195}
8196
8197#[derive(Clone, Debug)]
8199pub struct CsvloadOptions {
8200 pub skip: i32,
8203 pub lines: i32,
8206 pub whitespace: String,
8208 pub separator: String,
8210 pub flags: ForeignFlags,
8217 pub memory: bool,
8220 pub access: Access,
8225 pub fail_on: FailOn,
8231 pub revalidate: bool,
8234}
8235
8236impl std::default::Default for CsvloadOptions {
8237 fn default() -> Self {
8238 CsvloadOptions {
8239 skip: i32::from(0),
8240 lines: i32::from(-1),
8241 whitespace: String::new(),
8242 separator: String::new(),
8243 flags: ForeignFlags::None,
8244 memory: false,
8245 access: Access::Random,
8246 fail_on: FailOn::None,
8247 revalidate: false,
8248 }
8249 }
8250}
8251
8252pub fn csvload_with_opts(filename: &str, csvload_options: &CsvloadOptions) -> Result<VipsImage> {
8257 unsafe {
8258 let filename_in: CString = utils::new_c_string(filename)?;
8259 let mut out_out: *mut bindings::VipsImage = null_mut();
8260
8261 let skip_in: i32 = csvload_options.skip;
8262 let skip_in_name = utils::new_c_string("skip")?;
8263
8264 let lines_in: i32 = csvload_options.lines;
8265 let lines_in_name = utils::new_c_string("lines")?;
8266
8267 let whitespace_in: CString = utils::new_c_string(&csvload_options.whitespace)?;
8268 let whitespace_in_name = utils::new_c_string("whitespace")?;
8269
8270 let separator_in: CString = utils::new_c_string(&csvload_options.separator)?;
8271 let separator_in_name = utils::new_c_string("separator")?;
8272
8273 let flags_in: i32 = csvload_options.flags as i32;
8274 let flags_in_name = utils::new_c_string("flags")?;
8275
8276 let memory_in: i32 = if csvload_options.memory { 1 } else { 0 };
8277 let memory_in_name = utils::new_c_string("memory")?;
8278
8279 let access_in: i32 = csvload_options.access as i32;
8280 let access_in_name = utils::new_c_string("access")?;
8281
8282 let fail_on_in: i32 = csvload_options.fail_on as i32;
8283 let fail_on_in_name = utils::new_c_string("fail-on")?;
8284
8285 let revalidate_in: i32 = if csvload_options.revalidate { 1 } else { 0 };
8286 let revalidate_in_name = utils::new_c_string("revalidate")?;
8287
8288 let vips_op_response = bindings::vips_csvload(
8289 filename_in.as_ptr(),
8290 &mut out_out,
8291 skip_in_name.as_ptr(),
8292 skip_in,
8293 lines_in_name.as_ptr(),
8294 lines_in,
8295 whitespace_in_name.as_ptr(),
8296 whitespace_in.as_ptr(),
8297 separator_in_name.as_ptr(),
8298 separator_in.as_ptr(),
8299 flags_in_name.as_ptr(),
8300 flags_in,
8301 memory_in_name.as_ptr(),
8302 memory_in,
8303 access_in_name.as_ptr(),
8304 access_in,
8305 fail_on_in_name.as_ptr(),
8306 fail_on_in,
8307 revalidate_in_name.as_ptr(),
8308 revalidate_in,
8309 NULL,
8310 );
8311 utils::result(
8312 vips_op_response,
8313 VipsImage { ctx: out_out },
8314 Error::CsvloadError,
8315 )
8316 }
8317}
8318
8319pub fn csvload_source(source: &VipsSource) -> Result<VipsImage> {
8323 unsafe {
8324 let source_in: *mut bindings::VipsSource = source.ctx;
8325 let mut out_out: *mut bindings::VipsImage = null_mut();
8326
8327 let vips_op_response = bindings::vips_csvload_source(source_in, &mut out_out, NULL);
8328 utils::result(
8329 vips_op_response,
8330 VipsImage { ctx: out_out },
8331 Error::CsvloadSourceError,
8332 )
8333 }
8334}
8335
8336#[derive(Clone, Debug)]
8338pub struct CsvloadSourceOptions {
8339 pub skip: i32,
8342 pub lines: i32,
8345 pub whitespace: String,
8347 pub separator: String,
8349 pub flags: ForeignFlags,
8356 pub memory: bool,
8359 pub access: Access,
8364 pub fail_on: FailOn,
8370 pub revalidate: bool,
8373}
8374
8375impl std::default::Default for CsvloadSourceOptions {
8376 fn default() -> Self {
8377 CsvloadSourceOptions {
8378 skip: i32::from(0),
8379 lines: i32::from(-1),
8380 whitespace: String::new(),
8381 separator: String::new(),
8382 flags: ForeignFlags::None,
8383 memory: false,
8384 access: Access::Random,
8385 fail_on: FailOn::None,
8386 revalidate: false,
8387 }
8388 }
8389}
8390
8391pub fn csvload_source_with_opts(
8396 source: &VipsSource,
8397 csvload_source_options: &CsvloadSourceOptions,
8398) -> Result<VipsImage> {
8399 unsafe {
8400 let source_in: *mut bindings::VipsSource = source.ctx;
8401 let mut out_out: *mut bindings::VipsImage = null_mut();
8402
8403 let skip_in: i32 = csvload_source_options.skip;
8404 let skip_in_name = utils::new_c_string("skip")?;
8405
8406 let lines_in: i32 = csvload_source_options.lines;
8407 let lines_in_name = utils::new_c_string("lines")?;
8408
8409 let whitespace_in: CString = utils::new_c_string(&csvload_source_options.whitespace)?;
8410 let whitespace_in_name = utils::new_c_string("whitespace")?;
8411
8412 let separator_in: CString = utils::new_c_string(&csvload_source_options.separator)?;
8413 let separator_in_name = utils::new_c_string("separator")?;
8414
8415 let flags_in: i32 = csvload_source_options.flags as i32;
8416 let flags_in_name = utils::new_c_string("flags")?;
8417
8418 let memory_in: i32 = if csvload_source_options.memory { 1 } else { 0 };
8419 let memory_in_name = utils::new_c_string("memory")?;
8420
8421 let access_in: i32 = csvload_source_options.access as i32;
8422 let access_in_name = utils::new_c_string("access")?;
8423
8424 let fail_on_in: i32 = csvload_source_options.fail_on as i32;
8425 let fail_on_in_name = utils::new_c_string("fail-on")?;
8426
8427 let revalidate_in: i32 = if csvload_source_options.revalidate {
8428 1
8429 } else {
8430 0
8431 };
8432 let revalidate_in_name = utils::new_c_string("revalidate")?;
8433
8434 let vips_op_response = bindings::vips_csvload_source(
8435 source_in,
8436 &mut out_out,
8437 skip_in_name.as_ptr(),
8438 skip_in,
8439 lines_in_name.as_ptr(),
8440 lines_in,
8441 whitespace_in_name.as_ptr(),
8442 whitespace_in.as_ptr(),
8443 separator_in_name.as_ptr(),
8444 separator_in.as_ptr(),
8445 flags_in_name.as_ptr(),
8446 flags_in,
8447 memory_in_name.as_ptr(),
8448 memory_in,
8449 access_in_name.as_ptr(),
8450 access_in,
8451 fail_on_in_name.as_ptr(),
8452 fail_on_in,
8453 revalidate_in_name.as_ptr(),
8454 revalidate_in,
8455 NULL,
8456 );
8457 utils::result(
8458 vips_op_response,
8459 VipsImage { ctx: out_out },
8460 Error::CsvloadSourceError,
8461 )
8462 }
8463}
8464
8465pub fn matrixload(filename: &str) -> Result<VipsImage> {
8469 unsafe {
8470 let filename_in: CString = utils::new_c_string(filename)?;
8471 let mut out_out: *mut bindings::VipsImage = null_mut();
8472
8473 let vips_op_response = bindings::vips_matrixload(filename_in.as_ptr(), &mut out_out, NULL);
8474 utils::result(
8475 vips_op_response,
8476 VipsImage { ctx: out_out },
8477 Error::MatrixloadError,
8478 )
8479 }
8480}
8481
8482#[derive(Clone, Debug)]
8484pub struct MatrixloadOptions {
8485 pub flags: ForeignFlags,
8492 pub memory: bool,
8495 pub access: Access,
8500 pub fail_on: FailOn,
8506 pub revalidate: bool,
8509}
8510
8511impl std::default::Default for MatrixloadOptions {
8512 fn default() -> Self {
8513 MatrixloadOptions {
8514 flags: ForeignFlags::None,
8515 memory: false,
8516 access: Access::Random,
8517 fail_on: FailOn::None,
8518 revalidate: false,
8519 }
8520 }
8521}
8522
8523pub fn matrixload_with_opts(
8528 filename: &str,
8529 matrixload_options: &MatrixloadOptions,
8530) -> Result<VipsImage> {
8531 unsafe {
8532 let filename_in: CString = utils::new_c_string(filename)?;
8533 let mut out_out: *mut bindings::VipsImage = null_mut();
8534
8535 let flags_in: i32 = matrixload_options.flags as i32;
8536 let flags_in_name = utils::new_c_string("flags")?;
8537
8538 let memory_in: i32 = if matrixload_options.memory { 1 } else { 0 };
8539 let memory_in_name = utils::new_c_string("memory")?;
8540
8541 let access_in: i32 = matrixload_options.access as i32;
8542 let access_in_name = utils::new_c_string("access")?;
8543
8544 let fail_on_in: i32 = matrixload_options.fail_on as i32;
8545 let fail_on_in_name = utils::new_c_string("fail-on")?;
8546
8547 let revalidate_in: i32 = if matrixload_options.revalidate { 1 } else { 0 };
8548 let revalidate_in_name = utils::new_c_string("revalidate")?;
8549
8550 let vips_op_response = bindings::vips_matrixload(
8551 filename_in.as_ptr(),
8552 &mut out_out,
8553 flags_in_name.as_ptr(),
8554 flags_in,
8555 memory_in_name.as_ptr(),
8556 memory_in,
8557 access_in_name.as_ptr(),
8558 access_in,
8559 fail_on_in_name.as_ptr(),
8560 fail_on_in,
8561 revalidate_in_name.as_ptr(),
8562 revalidate_in,
8563 NULL,
8564 );
8565 utils::result(
8566 vips_op_response,
8567 VipsImage { ctx: out_out },
8568 Error::MatrixloadError,
8569 )
8570 }
8571}
8572
8573pub fn matrixload_source(source: &VipsSource) -> Result<VipsImage> {
8577 unsafe {
8578 let source_in: *mut bindings::VipsSource = source.ctx;
8579 let mut out_out: *mut bindings::VipsImage = null_mut();
8580
8581 let vips_op_response = bindings::vips_matrixload_source(source_in, &mut out_out, NULL);
8582 utils::result(
8583 vips_op_response,
8584 VipsImage { ctx: out_out },
8585 Error::MatrixloadSourceError,
8586 )
8587 }
8588}
8589
8590#[derive(Clone, Debug)]
8592pub struct MatrixloadSourceOptions {
8593 pub flags: ForeignFlags,
8600 pub memory: bool,
8603 pub access: Access,
8608 pub fail_on: FailOn,
8614 pub revalidate: bool,
8617}
8618
8619impl std::default::Default for MatrixloadSourceOptions {
8620 fn default() -> Self {
8621 MatrixloadSourceOptions {
8622 flags: ForeignFlags::None,
8623 memory: false,
8624 access: Access::Random,
8625 fail_on: FailOn::None,
8626 revalidate: false,
8627 }
8628 }
8629}
8630
8631pub fn matrixload_source_with_opts(
8636 source: &VipsSource,
8637 matrixload_source_options: &MatrixloadSourceOptions,
8638) -> Result<VipsImage> {
8639 unsafe {
8640 let source_in: *mut bindings::VipsSource = source.ctx;
8641 let mut out_out: *mut bindings::VipsImage = null_mut();
8642
8643 let flags_in: i32 = matrixload_source_options.flags as i32;
8644 let flags_in_name = utils::new_c_string("flags")?;
8645
8646 let memory_in: i32 = if matrixload_source_options.memory {
8647 1
8648 } else {
8649 0
8650 };
8651 let memory_in_name = utils::new_c_string("memory")?;
8652
8653 let access_in: i32 = matrixload_source_options.access as i32;
8654 let access_in_name = utils::new_c_string("access")?;
8655
8656 let fail_on_in: i32 = matrixload_source_options.fail_on as i32;
8657 let fail_on_in_name = utils::new_c_string("fail-on")?;
8658
8659 let revalidate_in: i32 = if matrixload_source_options.revalidate {
8660 1
8661 } else {
8662 0
8663 };
8664 let revalidate_in_name = utils::new_c_string("revalidate")?;
8665
8666 let vips_op_response = bindings::vips_matrixload_source(
8667 source_in,
8668 &mut out_out,
8669 flags_in_name.as_ptr(),
8670 flags_in,
8671 memory_in_name.as_ptr(),
8672 memory_in,
8673 access_in_name.as_ptr(),
8674 access_in,
8675 fail_on_in_name.as_ptr(),
8676 fail_on_in,
8677 revalidate_in_name.as_ptr(),
8678 revalidate_in,
8679 NULL,
8680 );
8681 utils::result(
8682 vips_op_response,
8683 VipsImage { ctx: out_out },
8684 Error::MatrixloadSourceError,
8685 )
8686 }
8687}
8688
8689pub fn rawload(filename: &str, width: i32, height: i32, bands: i32) -> Result<VipsImage> {
8699 unsafe {
8700 let filename_in: CString = utils::new_c_string(filename)?;
8701 let width_in: i32 = width;
8702 let height_in: i32 = height;
8703 let bands_in: i32 = bands;
8704 let mut out_out: *mut bindings::VipsImage = null_mut();
8705
8706 let vips_op_response = bindings::vips_rawload(
8707 filename_in.as_ptr(),
8708 &mut out_out,
8709 width_in,
8710 height_in,
8711 bands_in,
8712 NULL,
8713 );
8714 utils::result(
8715 vips_op_response,
8716 VipsImage { ctx: out_out },
8717 Error::RawloadError,
8718 )
8719 }
8720}
8721
8722#[derive(Clone, Debug)]
8724pub struct RawloadOptions {
8725 pub offset: u64,
8728 pub format: BandFormat,
8741 pub interpretation: Interpretation,
8765 pub flags: ForeignFlags,
8772 pub memory: bool,
8775 pub access: Access,
8780 pub fail_on: FailOn,
8786 pub revalidate: bool,
8789}
8790
8791impl std::default::Default for RawloadOptions {
8792 fn default() -> Self {
8793 RawloadOptions {
8794 offset: 0,
8795 format: BandFormat::Uchar,
8796 interpretation: Interpretation::Multiband,
8797 flags: ForeignFlags::None,
8798 memory: false,
8799 access: Access::Random,
8800 fail_on: FailOn::None,
8801 revalidate: false,
8802 }
8803 }
8804}
8805
8806pub fn rawload_with_opts(
8817 filename: &str,
8818 width: i32,
8819 height: i32,
8820 bands: i32,
8821 rawload_options: &RawloadOptions,
8822) -> Result<VipsImage> {
8823 unsafe {
8824 let filename_in: CString = utils::new_c_string(filename)?;
8825 let width_in: i32 = width;
8826 let height_in: i32 = height;
8827 let bands_in: i32 = bands;
8828 let mut out_out: *mut bindings::VipsImage = null_mut();
8829
8830 let offset_in: u64 = rawload_options.offset;
8831 let offset_in_name = utils::new_c_string("offset")?;
8832
8833 let format_in: i32 = rawload_options.format as i32;
8834 let format_in_name = utils::new_c_string("format")?;
8835
8836 let interpretation_in: i32 = rawload_options.interpretation as i32;
8837 let interpretation_in_name = utils::new_c_string("interpretation")?;
8838
8839 let flags_in: i32 = rawload_options.flags as i32;
8840 let flags_in_name = utils::new_c_string("flags")?;
8841
8842 let memory_in: i32 = if rawload_options.memory { 1 } else { 0 };
8843 let memory_in_name = utils::new_c_string("memory")?;
8844
8845 let access_in: i32 = rawload_options.access as i32;
8846 let access_in_name = utils::new_c_string("access")?;
8847
8848 let fail_on_in: i32 = rawload_options.fail_on as i32;
8849 let fail_on_in_name = utils::new_c_string("fail-on")?;
8850
8851 let revalidate_in: i32 = if rawload_options.revalidate { 1 } else { 0 };
8852 let revalidate_in_name = utils::new_c_string("revalidate")?;
8853
8854 let vips_op_response = bindings::vips_rawload(
8855 filename_in.as_ptr(),
8856 &mut out_out,
8857 width_in,
8858 height_in,
8859 bands_in,
8860 offset_in_name.as_ptr(),
8861 offset_in,
8862 format_in_name.as_ptr(),
8863 format_in,
8864 interpretation_in_name.as_ptr(),
8865 interpretation_in,
8866 flags_in_name.as_ptr(),
8867 flags_in,
8868 memory_in_name.as_ptr(),
8869 memory_in,
8870 access_in_name.as_ptr(),
8871 access_in,
8872 fail_on_in_name.as_ptr(),
8873 fail_on_in,
8874 revalidate_in_name.as_ptr(),
8875 revalidate_in,
8876 NULL,
8877 );
8878 utils::result(
8879 vips_op_response,
8880 VipsImage { ctx: out_out },
8881 Error::RawloadError,
8882 )
8883 }
8884}
8885
8886pub fn vipsload(filename: &str) -> Result<VipsImage> {
8890 unsafe {
8891 let filename_in: CString = utils::new_c_string(filename)?;
8892 let mut out_out: *mut bindings::VipsImage = null_mut();
8893
8894 let vips_op_response = bindings::vips_vipsload(filename_in.as_ptr(), &mut out_out, NULL);
8895 utils::result(
8896 vips_op_response,
8897 VipsImage { ctx: out_out },
8898 Error::VipsloadError,
8899 )
8900 }
8901}
8902
8903#[derive(Clone, Debug)]
8905pub struct VipsloadOptions {
8906 pub flags: ForeignFlags,
8913 pub memory: bool,
8916 pub access: Access,
8921 pub fail_on: FailOn,
8927 pub revalidate: bool,
8930}
8931
8932impl std::default::Default for VipsloadOptions {
8933 fn default() -> Self {
8934 VipsloadOptions {
8935 flags: ForeignFlags::None,
8936 memory: false,
8937 access: Access::Random,
8938 fail_on: FailOn::None,
8939 revalidate: false,
8940 }
8941 }
8942}
8943
8944pub fn vipsload_with_opts(filename: &str, vipsload_options: &VipsloadOptions) -> Result<VipsImage> {
8949 unsafe {
8950 let filename_in: CString = utils::new_c_string(filename)?;
8951 let mut out_out: *mut bindings::VipsImage = null_mut();
8952
8953 let flags_in: i32 = vipsload_options.flags as i32;
8954 let flags_in_name = utils::new_c_string("flags")?;
8955
8956 let memory_in: i32 = if vipsload_options.memory { 1 } else { 0 };
8957 let memory_in_name = utils::new_c_string("memory")?;
8958
8959 let access_in: i32 = vipsload_options.access as i32;
8960 let access_in_name = utils::new_c_string("access")?;
8961
8962 let fail_on_in: i32 = vipsload_options.fail_on as i32;
8963 let fail_on_in_name = utils::new_c_string("fail-on")?;
8964
8965 let revalidate_in: i32 = if vipsload_options.revalidate { 1 } else { 0 };
8966 let revalidate_in_name = utils::new_c_string("revalidate")?;
8967
8968 let vips_op_response = bindings::vips_vipsload(
8969 filename_in.as_ptr(),
8970 &mut out_out,
8971 flags_in_name.as_ptr(),
8972 flags_in,
8973 memory_in_name.as_ptr(),
8974 memory_in,
8975 access_in_name.as_ptr(),
8976 access_in,
8977 fail_on_in_name.as_ptr(),
8978 fail_on_in,
8979 revalidate_in_name.as_ptr(),
8980 revalidate_in,
8981 NULL,
8982 );
8983 utils::result(
8984 vips_op_response,
8985 VipsImage { ctx: out_out },
8986 Error::VipsloadError,
8987 )
8988 }
8989}
8990
8991pub fn vipsload_source(source: &VipsSource) -> Result<VipsImage> {
8995 unsafe {
8996 let source_in: *mut bindings::VipsSource = source.ctx;
8997 let mut out_out: *mut bindings::VipsImage = null_mut();
8998
8999 let vips_op_response = bindings::vips_vipsload_source(source_in, &mut out_out, NULL);
9000 utils::result(
9001 vips_op_response,
9002 VipsImage { ctx: out_out },
9003 Error::VipsloadSourceError,
9004 )
9005 }
9006}
9007
9008#[derive(Clone, Debug)]
9010pub struct VipsloadSourceOptions {
9011 pub flags: ForeignFlags,
9018 pub memory: bool,
9021 pub access: Access,
9026 pub fail_on: FailOn,
9032 pub revalidate: bool,
9035}
9036
9037impl std::default::Default for VipsloadSourceOptions {
9038 fn default() -> Self {
9039 VipsloadSourceOptions {
9040 flags: ForeignFlags::None,
9041 memory: false,
9042 access: Access::Random,
9043 fail_on: FailOn::None,
9044 revalidate: false,
9045 }
9046 }
9047}
9048
9049pub fn vipsload_source_with_opts(
9054 source: &VipsSource,
9055 vipsload_source_options: &VipsloadSourceOptions,
9056) -> Result<VipsImage> {
9057 unsafe {
9058 let source_in: *mut bindings::VipsSource = source.ctx;
9059 let mut out_out: *mut bindings::VipsImage = null_mut();
9060
9061 let flags_in: i32 = vipsload_source_options.flags as i32;
9062 let flags_in_name = utils::new_c_string("flags")?;
9063
9064 let memory_in: i32 = if vipsload_source_options.memory { 1 } else { 0 };
9065 let memory_in_name = utils::new_c_string("memory")?;
9066
9067 let access_in: i32 = vipsload_source_options.access as i32;
9068 let access_in_name = utils::new_c_string("access")?;
9069
9070 let fail_on_in: i32 = vipsload_source_options.fail_on as i32;
9071 let fail_on_in_name = utils::new_c_string("fail-on")?;
9072
9073 let revalidate_in: i32 = if vipsload_source_options.revalidate {
9074 1
9075 } else {
9076 0
9077 };
9078 let revalidate_in_name = utils::new_c_string("revalidate")?;
9079
9080 let vips_op_response = bindings::vips_vipsload_source(
9081 source_in,
9082 &mut out_out,
9083 flags_in_name.as_ptr(),
9084 flags_in,
9085 memory_in_name.as_ptr(),
9086 memory_in,
9087 access_in_name.as_ptr(),
9088 access_in,
9089 fail_on_in_name.as_ptr(),
9090 fail_on_in,
9091 revalidate_in_name.as_ptr(),
9092 revalidate_in,
9093 NULL,
9094 );
9095 utils::result(
9096 vips_op_response,
9097 VipsImage { ctx: out_out },
9098 Error::VipsloadSourceError,
9099 )
9100 }
9101}
9102
9103pub fn analyzeload(filename: &str) -> Result<VipsImage> {
9107 unsafe {
9108 let filename_in: CString = utils::new_c_string(filename)?;
9109 let mut out_out: *mut bindings::VipsImage = null_mut();
9110
9111 let vips_op_response = bindings::vips_analyzeload(filename_in.as_ptr(), &mut out_out, NULL);
9112 utils::result(
9113 vips_op_response,
9114 VipsImage { ctx: out_out },
9115 Error::AnalyzeloadError,
9116 )
9117 }
9118}
9119
9120#[derive(Clone, Debug)]
9122pub struct AnalyzeloadOptions {
9123 pub flags: ForeignFlags,
9130 pub memory: bool,
9133 pub access: Access,
9138 pub fail_on: FailOn,
9144 pub revalidate: bool,
9147}
9148
9149impl std::default::Default for AnalyzeloadOptions {
9150 fn default() -> Self {
9151 AnalyzeloadOptions {
9152 flags: ForeignFlags::None,
9153 memory: false,
9154 access: Access::Random,
9155 fail_on: FailOn::None,
9156 revalidate: false,
9157 }
9158 }
9159}
9160
9161pub fn analyzeload_with_opts(
9166 filename: &str,
9167 analyzeload_options: &AnalyzeloadOptions,
9168) -> Result<VipsImage> {
9169 unsafe {
9170 let filename_in: CString = utils::new_c_string(filename)?;
9171 let mut out_out: *mut bindings::VipsImage = null_mut();
9172
9173 let flags_in: i32 = analyzeload_options.flags as i32;
9174 let flags_in_name = utils::new_c_string("flags")?;
9175
9176 let memory_in: i32 = if analyzeload_options.memory { 1 } else { 0 };
9177 let memory_in_name = utils::new_c_string("memory")?;
9178
9179 let access_in: i32 = analyzeload_options.access as i32;
9180 let access_in_name = utils::new_c_string("access")?;
9181
9182 let fail_on_in: i32 = analyzeload_options.fail_on as i32;
9183 let fail_on_in_name = utils::new_c_string("fail-on")?;
9184
9185 let revalidate_in: i32 = if analyzeload_options.revalidate { 1 } else { 0 };
9186 let revalidate_in_name = utils::new_c_string("revalidate")?;
9187
9188 let vips_op_response = bindings::vips_analyzeload(
9189 filename_in.as_ptr(),
9190 &mut out_out,
9191 flags_in_name.as_ptr(),
9192 flags_in,
9193 memory_in_name.as_ptr(),
9194 memory_in,
9195 access_in_name.as_ptr(),
9196 access_in,
9197 fail_on_in_name.as_ptr(),
9198 fail_on_in,
9199 revalidate_in_name.as_ptr(),
9200 revalidate_in,
9201 NULL,
9202 );
9203 utils::result(
9204 vips_op_response,
9205 VipsImage { ctx: out_out },
9206 Error::AnalyzeloadError,
9207 )
9208 }
9209}
9210
9211pub fn ppmload(filename: &str) -> Result<VipsImage> {
9215 unsafe {
9216 let filename_in: CString = utils::new_c_string(filename)?;
9217 let mut out_out: *mut bindings::VipsImage = null_mut();
9218
9219 let vips_op_response = bindings::vips_ppmload(filename_in.as_ptr(), &mut out_out, NULL);
9220 utils::result(
9221 vips_op_response,
9222 VipsImage { ctx: out_out },
9223 Error::PpmloadError,
9224 )
9225 }
9226}
9227
9228#[derive(Clone, Debug)]
9230pub struct PpmloadOptions {
9231 pub flags: ForeignFlags,
9238 pub memory: bool,
9241 pub access: Access,
9246 pub fail_on: FailOn,
9252 pub revalidate: bool,
9255}
9256
9257impl std::default::Default for PpmloadOptions {
9258 fn default() -> Self {
9259 PpmloadOptions {
9260 flags: ForeignFlags::None,
9261 memory: false,
9262 access: Access::Random,
9263 fail_on: FailOn::None,
9264 revalidate: false,
9265 }
9266 }
9267}
9268
9269pub fn ppmload_with_opts(filename: &str, ppmload_options: &PpmloadOptions) -> Result<VipsImage> {
9274 unsafe {
9275 let filename_in: CString = utils::new_c_string(filename)?;
9276 let mut out_out: *mut bindings::VipsImage = null_mut();
9277
9278 let flags_in: i32 = ppmload_options.flags as i32;
9279 let flags_in_name = utils::new_c_string("flags")?;
9280
9281 let memory_in: i32 = if ppmload_options.memory { 1 } else { 0 };
9282 let memory_in_name = utils::new_c_string("memory")?;
9283
9284 let access_in: i32 = ppmload_options.access as i32;
9285 let access_in_name = utils::new_c_string("access")?;
9286
9287 let fail_on_in: i32 = ppmload_options.fail_on as i32;
9288 let fail_on_in_name = utils::new_c_string("fail-on")?;
9289
9290 let revalidate_in: i32 = if ppmload_options.revalidate { 1 } else { 0 };
9291 let revalidate_in_name = utils::new_c_string("revalidate")?;
9292
9293 let vips_op_response = bindings::vips_ppmload(
9294 filename_in.as_ptr(),
9295 &mut out_out,
9296 flags_in_name.as_ptr(),
9297 flags_in,
9298 memory_in_name.as_ptr(),
9299 memory_in,
9300 access_in_name.as_ptr(),
9301 access_in,
9302 fail_on_in_name.as_ptr(),
9303 fail_on_in,
9304 revalidate_in_name.as_ptr(),
9305 revalidate_in,
9306 NULL,
9307 );
9308 utils::result(
9309 vips_op_response,
9310 VipsImage { ctx: out_out },
9311 Error::PpmloadError,
9312 )
9313 }
9314}
9315
9316pub fn ppmload_buffer(buffer: &[u8]) -> Result<VipsImage> {
9320 unsafe {
9321 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
9322 let mut out_out: *mut bindings::VipsImage = null_mut();
9323
9324 let vips_op_response =
9325 bindings::vips_ppmload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
9326 utils::result(
9327 vips_op_response,
9328 VipsImage { ctx: out_out },
9329 Error::PpmloadBufferError,
9330 )
9331 }
9332}
9333
9334#[derive(Clone, Debug)]
9336pub struct PpmloadBufferOptions {
9337 pub flags: ForeignFlags,
9344 pub memory: bool,
9347 pub access: Access,
9352 pub fail_on: FailOn,
9358 pub revalidate: bool,
9361}
9362
9363impl std::default::Default for PpmloadBufferOptions {
9364 fn default() -> Self {
9365 PpmloadBufferOptions {
9366 flags: ForeignFlags::None,
9367 memory: false,
9368 access: Access::Random,
9369 fail_on: FailOn::None,
9370 revalidate: false,
9371 }
9372 }
9373}
9374
9375pub fn ppmload_buffer_with_opts(
9380 buffer: &[u8],
9381 ppmload_buffer_options: &PpmloadBufferOptions,
9382) -> Result<VipsImage> {
9383 unsafe {
9384 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
9385 let mut out_out: *mut bindings::VipsImage = null_mut();
9386
9387 let flags_in: i32 = ppmload_buffer_options.flags as i32;
9388 let flags_in_name = utils::new_c_string("flags")?;
9389
9390 let memory_in: i32 = if ppmload_buffer_options.memory { 1 } else { 0 };
9391 let memory_in_name = utils::new_c_string("memory")?;
9392
9393 let access_in: i32 = ppmload_buffer_options.access as i32;
9394 let access_in_name = utils::new_c_string("access")?;
9395
9396 let fail_on_in: i32 = ppmload_buffer_options.fail_on as i32;
9397 let fail_on_in_name = utils::new_c_string("fail-on")?;
9398
9399 let revalidate_in: i32 = if ppmload_buffer_options.revalidate {
9400 1
9401 } else {
9402 0
9403 };
9404 let revalidate_in_name = utils::new_c_string("revalidate")?;
9405
9406 let vips_op_response = bindings::vips_ppmload_buffer(
9407 buffer_in,
9408 buffer.len() as u64,
9409 &mut out_out,
9410 flags_in_name.as_ptr(),
9411 flags_in,
9412 memory_in_name.as_ptr(),
9413 memory_in,
9414 access_in_name.as_ptr(),
9415 access_in,
9416 fail_on_in_name.as_ptr(),
9417 fail_on_in,
9418 revalidate_in_name.as_ptr(),
9419 revalidate_in,
9420 NULL,
9421 );
9422 utils::result(
9423 vips_op_response,
9424 VipsImage { ctx: out_out },
9425 Error::PpmloadBufferError,
9426 )
9427 }
9428}
9429
9430pub fn ppmload_source(source: &VipsSource) -> Result<VipsImage> {
9434 unsafe {
9435 let source_in: *mut bindings::VipsSource = source.ctx;
9436 let mut out_out: *mut bindings::VipsImage = null_mut();
9437
9438 let vips_op_response = bindings::vips_ppmload_source(source_in, &mut out_out, NULL);
9439 utils::result(
9440 vips_op_response,
9441 VipsImage { ctx: out_out },
9442 Error::PpmloadSourceError,
9443 )
9444 }
9445}
9446
9447#[derive(Clone, Debug)]
9449pub struct PpmloadSourceOptions {
9450 pub flags: ForeignFlags,
9457 pub memory: bool,
9460 pub access: Access,
9465 pub fail_on: FailOn,
9471 pub revalidate: bool,
9474}
9475
9476impl std::default::Default for PpmloadSourceOptions {
9477 fn default() -> Self {
9478 PpmloadSourceOptions {
9479 flags: ForeignFlags::None,
9480 memory: false,
9481 access: Access::Random,
9482 fail_on: FailOn::None,
9483 revalidate: false,
9484 }
9485 }
9486}
9487
9488pub fn ppmload_source_with_opts(
9493 source: &VipsSource,
9494 ppmload_source_options: &PpmloadSourceOptions,
9495) -> Result<VipsImage> {
9496 unsafe {
9497 let source_in: *mut bindings::VipsSource = source.ctx;
9498 let mut out_out: *mut bindings::VipsImage = null_mut();
9499
9500 let flags_in: i32 = ppmload_source_options.flags as i32;
9501 let flags_in_name = utils::new_c_string("flags")?;
9502
9503 let memory_in: i32 = if ppmload_source_options.memory { 1 } else { 0 };
9504 let memory_in_name = utils::new_c_string("memory")?;
9505
9506 let access_in: i32 = ppmload_source_options.access as i32;
9507 let access_in_name = utils::new_c_string("access")?;
9508
9509 let fail_on_in: i32 = ppmload_source_options.fail_on as i32;
9510 let fail_on_in_name = utils::new_c_string("fail-on")?;
9511
9512 let revalidate_in: i32 = if ppmload_source_options.revalidate {
9513 1
9514 } else {
9515 0
9516 };
9517 let revalidate_in_name = utils::new_c_string("revalidate")?;
9518
9519 let vips_op_response = bindings::vips_ppmload_source(
9520 source_in,
9521 &mut out_out,
9522 flags_in_name.as_ptr(),
9523 flags_in,
9524 memory_in_name.as_ptr(),
9525 memory_in,
9526 access_in_name.as_ptr(),
9527 access_in,
9528 fail_on_in_name.as_ptr(),
9529 fail_on_in,
9530 revalidate_in_name.as_ptr(),
9531 revalidate_in,
9532 NULL,
9533 );
9534 utils::result(
9535 vips_op_response,
9536 VipsImage { ctx: out_out },
9537 Error::PpmloadSourceError,
9538 )
9539 }
9540}
9541
9542pub fn radload(filename: &str) -> Result<VipsImage> {
9546 unsafe {
9547 let filename_in: CString = utils::new_c_string(filename)?;
9548 let mut out_out: *mut bindings::VipsImage = null_mut();
9549
9550 let vips_op_response = bindings::vips_radload(filename_in.as_ptr(), &mut out_out, NULL);
9551 utils::result(
9552 vips_op_response,
9553 VipsImage { ctx: out_out },
9554 Error::RadloadError,
9555 )
9556 }
9557}
9558
9559#[derive(Clone, Debug)]
9561pub struct RadloadOptions {
9562 pub flags: ForeignFlags,
9569 pub memory: bool,
9572 pub access: Access,
9577 pub fail_on: FailOn,
9583 pub revalidate: bool,
9586}
9587
9588impl std::default::Default for RadloadOptions {
9589 fn default() -> Self {
9590 RadloadOptions {
9591 flags: ForeignFlags::None,
9592 memory: false,
9593 access: Access::Random,
9594 fail_on: FailOn::None,
9595 revalidate: false,
9596 }
9597 }
9598}
9599
9600pub fn radload_with_opts(filename: &str, radload_options: &RadloadOptions) -> Result<VipsImage> {
9605 unsafe {
9606 let filename_in: CString = utils::new_c_string(filename)?;
9607 let mut out_out: *mut bindings::VipsImage = null_mut();
9608
9609 let flags_in: i32 = radload_options.flags as i32;
9610 let flags_in_name = utils::new_c_string("flags")?;
9611
9612 let memory_in: i32 = if radload_options.memory { 1 } else { 0 };
9613 let memory_in_name = utils::new_c_string("memory")?;
9614
9615 let access_in: i32 = radload_options.access as i32;
9616 let access_in_name = utils::new_c_string("access")?;
9617
9618 let fail_on_in: i32 = radload_options.fail_on as i32;
9619 let fail_on_in_name = utils::new_c_string("fail-on")?;
9620
9621 let revalidate_in: i32 = if radload_options.revalidate { 1 } else { 0 };
9622 let revalidate_in_name = utils::new_c_string("revalidate")?;
9623
9624 let vips_op_response = bindings::vips_radload(
9625 filename_in.as_ptr(),
9626 &mut out_out,
9627 flags_in_name.as_ptr(),
9628 flags_in,
9629 memory_in_name.as_ptr(),
9630 memory_in,
9631 access_in_name.as_ptr(),
9632 access_in,
9633 fail_on_in_name.as_ptr(),
9634 fail_on_in,
9635 revalidate_in_name.as_ptr(),
9636 revalidate_in,
9637 NULL,
9638 );
9639 utils::result(
9640 vips_op_response,
9641 VipsImage { ctx: out_out },
9642 Error::RadloadError,
9643 )
9644 }
9645}
9646
9647pub fn radload_buffer(buffer: &[u8]) -> Result<VipsImage> {
9651 unsafe {
9652 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
9653 let mut out_out: *mut bindings::VipsImage = null_mut();
9654
9655 let vips_op_response =
9656 bindings::vips_radload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
9657 utils::result(
9658 vips_op_response,
9659 VipsImage { ctx: out_out },
9660 Error::RadloadBufferError,
9661 )
9662 }
9663}
9664
9665#[derive(Clone, Debug)]
9667pub struct RadloadBufferOptions {
9668 pub flags: ForeignFlags,
9675 pub memory: bool,
9678 pub access: Access,
9683 pub fail_on: FailOn,
9689 pub revalidate: bool,
9692}
9693
9694impl std::default::Default for RadloadBufferOptions {
9695 fn default() -> Self {
9696 RadloadBufferOptions {
9697 flags: ForeignFlags::None,
9698 memory: false,
9699 access: Access::Random,
9700 fail_on: FailOn::None,
9701 revalidate: false,
9702 }
9703 }
9704}
9705
9706pub fn radload_buffer_with_opts(
9711 buffer: &[u8],
9712 radload_buffer_options: &RadloadBufferOptions,
9713) -> Result<VipsImage> {
9714 unsafe {
9715 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
9716 let mut out_out: *mut bindings::VipsImage = null_mut();
9717
9718 let flags_in: i32 = radload_buffer_options.flags as i32;
9719 let flags_in_name = utils::new_c_string("flags")?;
9720
9721 let memory_in: i32 = if radload_buffer_options.memory { 1 } else { 0 };
9722 let memory_in_name = utils::new_c_string("memory")?;
9723
9724 let access_in: i32 = radload_buffer_options.access as i32;
9725 let access_in_name = utils::new_c_string("access")?;
9726
9727 let fail_on_in: i32 = radload_buffer_options.fail_on as i32;
9728 let fail_on_in_name = utils::new_c_string("fail-on")?;
9729
9730 let revalidate_in: i32 = if radload_buffer_options.revalidate {
9731 1
9732 } else {
9733 0
9734 };
9735 let revalidate_in_name = utils::new_c_string("revalidate")?;
9736
9737 let vips_op_response = bindings::vips_radload_buffer(
9738 buffer_in,
9739 buffer.len() as u64,
9740 &mut out_out,
9741 flags_in_name.as_ptr(),
9742 flags_in,
9743 memory_in_name.as_ptr(),
9744 memory_in,
9745 access_in_name.as_ptr(),
9746 access_in,
9747 fail_on_in_name.as_ptr(),
9748 fail_on_in,
9749 revalidate_in_name.as_ptr(),
9750 revalidate_in,
9751 NULL,
9752 );
9753 utils::result(
9754 vips_op_response,
9755 VipsImage { ctx: out_out },
9756 Error::RadloadBufferError,
9757 )
9758 }
9759}
9760
9761pub fn radload_source(source: &VipsSource) -> Result<VipsImage> {
9765 unsafe {
9766 let source_in: *mut bindings::VipsSource = source.ctx;
9767 let mut out_out: *mut bindings::VipsImage = null_mut();
9768
9769 let vips_op_response = bindings::vips_radload_source(source_in, &mut out_out, NULL);
9770 utils::result(
9771 vips_op_response,
9772 VipsImage { ctx: out_out },
9773 Error::RadloadSourceError,
9774 )
9775 }
9776}
9777
9778#[derive(Clone, Debug)]
9780pub struct RadloadSourceOptions {
9781 pub flags: ForeignFlags,
9788 pub memory: bool,
9791 pub access: Access,
9796 pub fail_on: FailOn,
9802 pub revalidate: bool,
9805}
9806
9807impl std::default::Default for RadloadSourceOptions {
9808 fn default() -> Self {
9809 RadloadSourceOptions {
9810 flags: ForeignFlags::None,
9811 memory: false,
9812 access: Access::Random,
9813 fail_on: FailOn::None,
9814 revalidate: false,
9815 }
9816 }
9817}
9818
9819pub fn radload_source_with_opts(
9824 source: &VipsSource,
9825 radload_source_options: &RadloadSourceOptions,
9826) -> Result<VipsImage> {
9827 unsafe {
9828 let source_in: *mut bindings::VipsSource = source.ctx;
9829 let mut out_out: *mut bindings::VipsImage = null_mut();
9830
9831 let flags_in: i32 = radload_source_options.flags as i32;
9832 let flags_in_name = utils::new_c_string("flags")?;
9833
9834 let memory_in: i32 = if radload_source_options.memory { 1 } else { 0 };
9835 let memory_in_name = utils::new_c_string("memory")?;
9836
9837 let access_in: i32 = radload_source_options.access as i32;
9838 let access_in_name = utils::new_c_string("access")?;
9839
9840 let fail_on_in: i32 = radload_source_options.fail_on as i32;
9841 let fail_on_in_name = utils::new_c_string("fail-on")?;
9842
9843 let revalidate_in: i32 = if radload_source_options.revalidate {
9844 1
9845 } else {
9846 0
9847 };
9848 let revalidate_in_name = utils::new_c_string("revalidate")?;
9849
9850 let vips_op_response = bindings::vips_radload_source(
9851 source_in,
9852 &mut out_out,
9853 flags_in_name.as_ptr(),
9854 flags_in,
9855 memory_in_name.as_ptr(),
9856 memory_in,
9857 access_in_name.as_ptr(),
9858 access_in,
9859 fail_on_in_name.as_ptr(),
9860 fail_on_in,
9861 revalidate_in_name.as_ptr(),
9862 revalidate_in,
9863 NULL,
9864 );
9865 utils::result(
9866 vips_op_response,
9867 VipsImage { ctx: out_out },
9868 Error::RadloadSourceError,
9869 )
9870 }
9871}
9872
9873pub fn svgload(filename: &str) -> Result<VipsImage> {
9877 unsafe {
9878 let filename_in: CString = utils::new_c_string(filename)?;
9879 let mut out_out: *mut bindings::VipsImage = null_mut();
9880
9881 let vips_op_response = bindings::vips_svgload(filename_in.as_ptr(), &mut out_out, NULL);
9882 utils::result(
9883 vips_op_response,
9884 VipsImage { ctx: out_out },
9885 Error::SvgloadError,
9886 )
9887 }
9888}
9889
9890#[derive(Clone, Debug)]
9892pub struct SvgloadOptions {
9893 pub dpi: f64,
9896 pub scale: f64,
9899 pub unlimited: bool,
9902 pub stylesheet: String,
9904 pub high_bitdepth: bool,
9907 pub flags: ForeignFlags,
9914 pub memory: bool,
9917 pub access: Access,
9922 pub fail_on: FailOn,
9928 pub revalidate: bool,
9931}
9932
9933impl std::default::Default for SvgloadOptions {
9934 fn default() -> Self {
9935 SvgloadOptions {
9936 dpi: f64::from(72),
9937 scale: f64::from(1),
9938 unlimited: false,
9939 stylesheet: String::new(),
9940 high_bitdepth: false,
9941 flags: ForeignFlags::None,
9942 memory: false,
9943 access: Access::Random,
9944 fail_on: FailOn::None,
9945 revalidate: false,
9946 }
9947 }
9948}
9949
9950pub fn svgload_with_opts(filename: &str, svgload_options: &SvgloadOptions) -> Result<VipsImage> {
9955 unsafe {
9956 let filename_in: CString = utils::new_c_string(filename)?;
9957 let mut out_out: *mut bindings::VipsImage = null_mut();
9958
9959 let dpi_in: f64 = svgload_options.dpi;
9960 let dpi_in_name = utils::new_c_string("dpi")?;
9961
9962 let scale_in: f64 = svgload_options.scale;
9963 let scale_in_name = utils::new_c_string("scale")?;
9964
9965 let unlimited_in: i32 = if svgload_options.unlimited { 1 } else { 0 };
9966 let unlimited_in_name = utils::new_c_string("unlimited")?;
9967
9968 let stylesheet_in: CString = utils::new_c_string(&svgload_options.stylesheet)?;
9969 let stylesheet_in_name = utils::new_c_string("stylesheet")?;
9970
9971 let high_bitdepth_in: i32 = if svgload_options.high_bitdepth { 1 } else { 0 };
9972 let high_bitdepth_in_name = utils::new_c_string("high-bitdepth")?;
9973
9974 let flags_in: i32 = svgload_options.flags as i32;
9975 let flags_in_name = utils::new_c_string("flags")?;
9976
9977 let memory_in: i32 = if svgload_options.memory { 1 } else { 0 };
9978 let memory_in_name = utils::new_c_string("memory")?;
9979
9980 let access_in: i32 = svgload_options.access as i32;
9981 let access_in_name = utils::new_c_string("access")?;
9982
9983 let fail_on_in: i32 = svgload_options.fail_on as i32;
9984 let fail_on_in_name = utils::new_c_string("fail-on")?;
9985
9986 let revalidate_in: i32 = if svgload_options.revalidate { 1 } else { 0 };
9987 let revalidate_in_name = utils::new_c_string("revalidate")?;
9988
9989 let vips_op_response = bindings::vips_svgload(
9990 filename_in.as_ptr(),
9991 &mut out_out,
9992 dpi_in_name.as_ptr(),
9993 dpi_in,
9994 scale_in_name.as_ptr(),
9995 scale_in,
9996 unlimited_in_name.as_ptr(),
9997 unlimited_in,
9998 stylesheet_in_name.as_ptr(),
9999 stylesheet_in.as_ptr(),
10000 high_bitdepth_in_name.as_ptr(),
10001 high_bitdepth_in,
10002 flags_in_name.as_ptr(),
10003 flags_in,
10004 memory_in_name.as_ptr(),
10005 memory_in,
10006 access_in_name.as_ptr(),
10007 access_in,
10008 fail_on_in_name.as_ptr(),
10009 fail_on_in,
10010 revalidate_in_name.as_ptr(),
10011 revalidate_in,
10012 NULL,
10013 );
10014 utils::result(
10015 vips_op_response,
10016 VipsImage { ctx: out_out },
10017 Error::SvgloadError,
10018 )
10019 }
10020}
10021
10022pub fn svgload_buffer(buffer: &[u8]) -> Result<VipsImage> {
10026 unsafe {
10027 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10028 let mut out_out: *mut bindings::VipsImage = null_mut();
10029
10030 let vips_op_response =
10031 bindings::vips_svgload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
10032 utils::result(
10033 vips_op_response,
10034 VipsImage { ctx: out_out },
10035 Error::SvgloadBufferError,
10036 )
10037 }
10038}
10039
10040#[derive(Clone, Debug)]
10042pub struct SvgloadBufferOptions {
10043 pub dpi: f64,
10046 pub scale: f64,
10049 pub unlimited: bool,
10052 pub stylesheet: String,
10054 pub high_bitdepth: bool,
10057 pub flags: ForeignFlags,
10064 pub memory: bool,
10067 pub access: Access,
10072 pub fail_on: FailOn,
10078 pub revalidate: bool,
10081}
10082
10083impl std::default::Default for SvgloadBufferOptions {
10084 fn default() -> Self {
10085 SvgloadBufferOptions {
10086 dpi: f64::from(72),
10087 scale: f64::from(1),
10088 unlimited: false,
10089 stylesheet: String::new(),
10090 high_bitdepth: false,
10091 flags: ForeignFlags::None,
10092 memory: false,
10093 access: Access::Random,
10094 fail_on: FailOn::None,
10095 revalidate: false,
10096 }
10097 }
10098}
10099
10100pub fn svgload_buffer_with_opts(
10105 buffer: &[u8],
10106 svgload_buffer_options: &SvgloadBufferOptions,
10107) -> Result<VipsImage> {
10108 unsafe {
10109 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10110 let mut out_out: *mut bindings::VipsImage = null_mut();
10111
10112 let dpi_in: f64 = svgload_buffer_options.dpi;
10113 let dpi_in_name = utils::new_c_string("dpi")?;
10114
10115 let scale_in: f64 = svgload_buffer_options.scale;
10116 let scale_in_name = utils::new_c_string("scale")?;
10117
10118 let unlimited_in: i32 = if svgload_buffer_options.unlimited {
10119 1
10120 } else {
10121 0
10122 };
10123 let unlimited_in_name = utils::new_c_string("unlimited")?;
10124
10125 let stylesheet_in: CString = utils::new_c_string(&svgload_buffer_options.stylesheet)?;
10126 let stylesheet_in_name = utils::new_c_string("stylesheet")?;
10127
10128 let high_bitdepth_in: i32 = if svgload_buffer_options.high_bitdepth {
10129 1
10130 } else {
10131 0
10132 };
10133 let high_bitdepth_in_name = utils::new_c_string("high-bitdepth")?;
10134
10135 let flags_in: i32 = svgload_buffer_options.flags as i32;
10136 let flags_in_name = utils::new_c_string("flags")?;
10137
10138 let memory_in: i32 = if svgload_buffer_options.memory { 1 } else { 0 };
10139 let memory_in_name = utils::new_c_string("memory")?;
10140
10141 let access_in: i32 = svgload_buffer_options.access as i32;
10142 let access_in_name = utils::new_c_string("access")?;
10143
10144 let fail_on_in: i32 = svgload_buffer_options.fail_on as i32;
10145 let fail_on_in_name = utils::new_c_string("fail-on")?;
10146
10147 let revalidate_in: i32 = if svgload_buffer_options.revalidate {
10148 1
10149 } else {
10150 0
10151 };
10152 let revalidate_in_name = utils::new_c_string("revalidate")?;
10153
10154 let vips_op_response = bindings::vips_svgload_buffer(
10155 buffer_in,
10156 buffer.len() as u64,
10157 &mut out_out,
10158 dpi_in_name.as_ptr(),
10159 dpi_in,
10160 scale_in_name.as_ptr(),
10161 scale_in,
10162 unlimited_in_name.as_ptr(),
10163 unlimited_in,
10164 stylesheet_in_name.as_ptr(),
10165 stylesheet_in.as_ptr(),
10166 high_bitdepth_in_name.as_ptr(),
10167 high_bitdepth_in,
10168 flags_in_name.as_ptr(),
10169 flags_in,
10170 memory_in_name.as_ptr(),
10171 memory_in,
10172 access_in_name.as_ptr(),
10173 access_in,
10174 fail_on_in_name.as_ptr(),
10175 fail_on_in,
10176 revalidate_in_name.as_ptr(),
10177 revalidate_in,
10178 NULL,
10179 );
10180 utils::result(
10181 vips_op_response,
10182 VipsImage { ctx: out_out },
10183 Error::SvgloadBufferError,
10184 )
10185 }
10186}
10187
10188pub fn gifload(filename: &str) -> Result<VipsImage> {
10192 unsafe {
10193 let filename_in: CString = utils::new_c_string(filename)?;
10194 let mut out_out: *mut bindings::VipsImage = null_mut();
10195
10196 let vips_op_response = bindings::vips_gifload(filename_in.as_ptr(), &mut out_out, NULL);
10197 utils::result(
10198 vips_op_response,
10199 VipsImage { ctx: out_out },
10200 Error::GifloadError,
10201 )
10202 }
10203}
10204
10205#[derive(Clone, Debug)]
10207pub struct GifloadOptions {
10208 pub n: i32,
10211 pub page: i32,
10214 pub flags: ForeignFlags,
10221 pub memory: bool,
10224 pub access: Access,
10229 pub fail_on: FailOn,
10235 pub revalidate: bool,
10238}
10239
10240impl std::default::Default for GifloadOptions {
10241 fn default() -> Self {
10242 GifloadOptions {
10243 n: i32::from(1),
10244 page: i32::from(0),
10245 flags: ForeignFlags::None,
10246 memory: false,
10247 access: Access::Random,
10248 fail_on: FailOn::None,
10249 revalidate: false,
10250 }
10251 }
10252}
10253
10254pub fn gifload_with_opts(filename: &str, gifload_options: &GifloadOptions) -> Result<VipsImage> {
10259 unsafe {
10260 let filename_in: CString = utils::new_c_string(filename)?;
10261 let mut out_out: *mut bindings::VipsImage = null_mut();
10262
10263 let n_in: i32 = gifload_options.n;
10264 let n_in_name = utils::new_c_string("n")?;
10265
10266 let page_in: i32 = gifload_options.page;
10267 let page_in_name = utils::new_c_string("page")?;
10268
10269 let flags_in: i32 = gifload_options.flags as i32;
10270 let flags_in_name = utils::new_c_string("flags")?;
10271
10272 let memory_in: i32 = if gifload_options.memory { 1 } else { 0 };
10273 let memory_in_name = utils::new_c_string("memory")?;
10274
10275 let access_in: i32 = gifload_options.access as i32;
10276 let access_in_name = utils::new_c_string("access")?;
10277
10278 let fail_on_in: i32 = gifload_options.fail_on as i32;
10279 let fail_on_in_name = utils::new_c_string("fail-on")?;
10280
10281 let revalidate_in: i32 = if gifload_options.revalidate { 1 } else { 0 };
10282 let revalidate_in_name = utils::new_c_string("revalidate")?;
10283
10284 let vips_op_response = bindings::vips_gifload(
10285 filename_in.as_ptr(),
10286 &mut out_out,
10287 n_in_name.as_ptr(),
10288 n_in,
10289 page_in_name.as_ptr(),
10290 page_in,
10291 flags_in_name.as_ptr(),
10292 flags_in,
10293 memory_in_name.as_ptr(),
10294 memory_in,
10295 access_in_name.as_ptr(),
10296 access_in,
10297 fail_on_in_name.as_ptr(),
10298 fail_on_in,
10299 revalidate_in_name.as_ptr(),
10300 revalidate_in,
10301 NULL,
10302 );
10303 utils::result(
10304 vips_op_response,
10305 VipsImage { ctx: out_out },
10306 Error::GifloadError,
10307 )
10308 }
10309}
10310
10311pub fn gifload_buffer(buffer: &[u8]) -> Result<VipsImage> {
10315 unsafe {
10316 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10317 let mut out_out: *mut bindings::VipsImage = null_mut();
10318
10319 let vips_op_response =
10320 bindings::vips_gifload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
10321 utils::result(
10322 vips_op_response,
10323 VipsImage { ctx: out_out },
10324 Error::GifloadBufferError,
10325 )
10326 }
10327}
10328
10329#[derive(Clone, Debug)]
10331pub struct GifloadBufferOptions {
10332 pub n: i32,
10335 pub page: i32,
10338 pub flags: ForeignFlags,
10345 pub memory: bool,
10348 pub access: Access,
10353 pub fail_on: FailOn,
10359 pub revalidate: bool,
10362}
10363
10364impl std::default::Default for GifloadBufferOptions {
10365 fn default() -> Self {
10366 GifloadBufferOptions {
10367 n: i32::from(1),
10368 page: i32::from(0),
10369 flags: ForeignFlags::None,
10370 memory: false,
10371 access: Access::Random,
10372 fail_on: FailOn::None,
10373 revalidate: false,
10374 }
10375 }
10376}
10377
10378pub fn gifload_buffer_with_opts(
10383 buffer: &[u8],
10384 gifload_buffer_options: &GifloadBufferOptions,
10385) -> Result<VipsImage> {
10386 unsafe {
10387 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10388 let mut out_out: *mut bindings::VipsImage = null_mut();
10389
10390 let n_in: i32 = gifload_buffer_options.n;
10391 let n_in_name = utils::new_c_string("n")?;
10392
10393 let page_in: i32 = gifload_buffer_options.page;
10394 let page_in_name = utils::new_c_string("page")?;
10395
10396 let flags_in: i32 = gifload_buffer_options.flags as i32;
10397 let flags_in_name = utils::new_c_string("flags")?;
10398
10399 let memory_in: i32 = if gifload_buffer_options.memory { 1 } else { 0 };
10400 let memory_in_name = utils::new_c_string("memory")?;
10401
10402 let access_in: i32 = gifload_buffer_options.access as i32;
10403 let access_in_name = utils::new_c_string("access")?;
10404
10405 let fail_on_in: i32 = gifload_buffer_options.fail_on as i32;
10406 let fail_on_in_name = utils::new_c_string("fail-on")?;
10407
10408 let revalidate_in: i32 = if gifload_buffer_options.revalidate {
10409 1
10410 } else {
10411 0
10412 };
10413 let revalidate_in_name = utils::new_c_string("revalidate")?;
10414
10415 let vips_op_response = bindings::vips_gifload_buffer(
10416 buffer_in,
10417 buffer.len() as u64,
10418 &mut out_out,
10419 n_in_name.as_ptr(),
10420 n_in,
10421 page_in_name.as_ptr(),
10422 page_in,
10423 flags_in_name.as_ptr(),
10424 flags_in,
10425 memory_in_name.as_ptr(),
10426 memory_in,
10427 access_in_name.as_ptr(),
10428 access_in,
10429 fail_on_in_name.as_ptr(),
10430 fail_on_in,
10431 revalidate_in_name.as_ptr(),
10432 revalidate_in,
10433 NULL,
10434 );
10435 utils::result(
10436 vips_op_response,
10437 VipsImage { ctx: out_out },
10438 Error::GifloadBufferError,
10439 )
10440 }
10441}
10442
10443pub fn gifload_source(source: &VipsSource) -> Result<VipsImage> {
10447 unsafe {
10448 let source_in: *mut bindings::VipsSource = source.ctx;
10449 let mut out_out: *mut bindings::VipsImage = null_mut();
10450
10451 let vips_op_response = bindings::vips_gifload_source(source_in, &mut out_out, NULL);
10452 utils::result(
10453 vips_op_response,
10454 VipsImage { ctx: out_out },
10455 Error::GifloadSourceError,
10456 )
10457 }
10458}
10459
10460#[derive(Clone, Debug)]
10462pub struct GifloadSourceOptions {
10463 pub n: i32,
10466 pub page: i32,
10469 pub flags: ForeignFlags,
10476 pub memory: bool,
10479 pub access: Access,
10484 pub fail_on: FailOn,
10490 pub revalidate: bool,
10493}
10494
10495impl std::default::Default for GifloadSourceOptions {
10496 fn default() -> Self {
10497 GifloadSourceOptions {
10498 n: i32::from(1),
10499 page: i32::from(0),
10500 flags: ForeignFlags::None,
10501 memory: false,
10502 access: Access::Random,
10503 fail_on: FailOn::None,
10504 revalidate: false,
10505 }
10506 }
10507}
10508
10509pub fn gifload_source_with_opts(
10514 source: &VipsSource,
10515 gifload_source_options: &GifloadSourceOptions,
10516) -> Result<VipsImage> {
10517 unsafe {
10518 let source_in: *mut bindings::VipsSource = source.ctx;
10519 let mut out_out: *mut bindings::VipsImage = null_mut();
10520
10521 let n_in: i32 = gifload_source_options.n;
10522 let n_in_name = utils::new_c_string("n")?;
10523
10524 let page_in: i32 = gifload_source_options.page;
10525 let page_in_name = utils::new_c_string("page")?;
10526
10527 let flags_in: i32 = gifload_source_options.flags as i32;
10528 let flags_in_name = utils::new_c_string("flags")?;
10529
10530 let memory_in: i32 = if gifload_source_options.memory { 1 } else { 0 };
10531 let memory_in_name = utils::new_c_string("memory")?;
10532
10533 let access_in: i32 = gifload_source_options.access as i32;
10534 let access_in_name = utils::new_c_string("access")?;
10535
10536 let fail_on_in: i32 = gifload_source_options.fail_on as i32;
10537 let fail_on_in_name = utils::new_c_string("fail-on")?;
10538
10539 let revalidate_in: i32 = if gifload_source_options.revalidate {
10540 1
10541 } else {
10542 0
10543 };
10544 let revalidate_in_name = utils::new_c_string("revalidate")?;
10545
10546 let vips_op_response = bindings::vips_gifload_source(
10547 source_in,
10548 &mut out_out,
10549 n_in_name.as_ptr(),
10550 n_in,
10551 page_in_name.as_ptr(),
10552 page_in,
10553 flags_in_name.as_ptr(),
10554 flags_in,
10555 memory_in_name.as_ptr(),
10556 memory_in,
10557 access_in_name.as_ptr(),
10558 access_in,
10559 fail_on_in_name.as_ptr(),
10560 fail_on_in,
10561 revalidate_in_name.as_ptr(),
10562 revalidate_in,
10563 NULL,
10564 );
10565 utils::result(
10566 vips_op_response,
10567 VipsImage { ctx: out_out },
10568 Error::GifloadSourceError,
10569 )
10570 }
10571}
10572
10573pub fn pngload(filename: &str) -> Result<VipsImage> {
10577 unsafe {
10578 let filename_in: CString = utils::new_c_string(filename)?;
10579 let mut out_out: *mut bindings::VipsImage = null_mut();
10580
10581 let vips_op_response = bindings::vips_pngload(filename_in.as_ptr(), &mut out_out, NULL);
10582 utils::result(
10583 vips_op_response,
10584 VipsImage { ctx: out_out },
10585 Error::PngloadError,
10586 )
10587 }
10588}
10589
10590#[derive(Clone, Debug)]
10592pub struct PngloadOptions {
10593 pub unlimited: bool,
10596 pub flags: ForeignFlags,
10603 pub memory: bool,
10606 pub access: Access,
10611 pub fail_on: FailOn,
10617 pub revalidate: bool,
10620}
10621
10622impl std::default::Default for PngloadOptions {
10623 fn default() -> Self {
10624 PngloadOptions {
10625 unlimited: false,
10626 flags: ForeignFlags::None,
10627 memory: false,
10628 access: Access::Random,
10629 fail_on: FailOn::None,
10630 revalidate: false,
10631 }
10632 }
10633}
10634
10635pub fn pngload_with_opts(filename: &str, pngload_options: &PngloadOptions) -> Result<VipsImage> {
10640 unsafe {
10641 let filename_in: CString = utils::new_c_string(filename)?;
10642 let mut out_out: *mut bindings::VipsImage = null_mut();
10643
10644 let unlimited_in: i32 = if pngload_options.unlimited { 1 } else { 0 };
10645 let unlimited_in_name = utils::new_c_string("unlimited")?;
10646
10647 let flags_in: i32 = pngload_options.flags as i32;
10648 let flags_in_name = utils::new_c_string("flags")?;
10649
10650 let memory_in: i32 = if pngload_options.memory { 1 } else { 0 };
10651 let memory_in_name = utils::new_c_string("memory")?;
10652
10653 let access_in: i32 = pngload_options.access as i32;
10654 let access_in_name = utils::new_c_string("access")?;
10655
10656 let fail_on_in: i32 = pngload_options.fail_on as i32;
10657 let fail_on_in_name = utils::new_c_string("fail-on")?;
10658
10659 let revalidate_in: i32 = if pngload_options.revalidate { 1 } else { 0 };
10660 let revalidate_in_name = utils::new_c_string("revalidate")?;
10661
10662 let vips_op_response = bindings::vips_pngload(
10663 filename_in.as_ptr(),
10664 &mut out_out,
10665 unlimited_in_name.as_ptr(),
10666 unlimited_in,
10667 flags_in_name.as_ptr(),
10668 flags_in,
10669 memory_in_name.as_ptr(),
10670 memory_in,
10671 access_in_name.as_ptr(),
10672 access_in,
10673 fail_on_in_name.as_ptr(),
10674 fail_on_in,
10675 revalidate_in_name.as_ptr(),
10676 revalidate_in,
10677 NULL,
10678 );
10679 utils::result(
10680 vips_op_response,
10681 VipsImage { ctx: out_out },
10682 Error::PngloadError,
10683 )
10684 }
10685}
10686
10687pub fn pngload_buffer(buffer: &[u8]) -> Result<VipsImage> {
10691 unsafe {
10692 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10693 let mut out_out: *mut bindings::VipsImage = null_mut();
10694
10695 let vips_op_response =
10696 bindings::vips_pngload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
10697 utils::result(
10698 vips_op_response,
10699 VipsImage { ctx: out_out },
10700 Error::PngloadBufferError,
10701 )
10702 }
10703}
10704
10705#[derive(Clone, Debug)]
10707pub struct PngloadBufferOptions {
10708 pub unlimited: bool,
10711 pub flags: ForeignFlags,
10718 pub memory: bool,
10721 pub access: Access,
10726 pub fail_on: FailOn,
10732 pub revalidate: bool,
10735}
10736
10737impl std::default::Default for PngloadBufferOptions {
10738 fn default() -> Self {
10739 PngloadBufferOptions {
10740 unlimited: false,
10741 flags: ForeignFlags::None,
10742 memory: false,
10743 access: Access::Random,
10744 fail_on: FailOn::None,
10745 revalidate: false,
10746 }
10747 }
10748}
10749
10750pub fn pngload_buffer_with_opts(
10755 buffer: &[u8],
10756 pngload_buffer_options: &PngloadBufferOptions,
10757) -> Result<VipsImage> {
10758 unsafe {
10759 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10760 let mut out_out: *mut bindings::VipsImage = null_mut();
10761
10762 let unlimited_in: i32 = if pngload_buffer_options.unlimited {
10763 1
10764 } else {
10765 0
10766 };
10767 let unlimited_in_name = utils::new_c_string("unlimited")?;
10768
10769 let flags_in: i32 = pngload_buffer_options.flags as i32;
10770 let flags_in_name = utils::new_c_string("flags")?;
10771
10772 let memory_in: i32 = if pngload_buffer_options.memory { 1 } else { 0 };
10773 let memory_in_name = utils::new_c_string("memory")?;
10774
10775 let access_in: i32 = pngload_buffer_options.access as i32;
10776 let access_in_name = utils::new_c_string("access")?;
10777
10778 let fail_on_in: i32 = pngload_buffer_options.fail_on as i32;
10779 let fail_on_in_name = utils::new_c_string("fail-on")?;
10780
10781 let revalidate_in: i32 = if pngload_buffer_options.revalidate {
10782 1
10783 } else {
10784 0
10785 };
10786 let revalidate_in_name = utils::new_c_string("revalidate")?;
10787
10788 let vips_op_response = bindings::vips_pngload_buffer(
10789 buffer_in,
10790 buffer.len() as u64,
10791 &mut out_out,
10792 unlimited_in_name.as_ptr(),
10793 unlimited_in,
10794 flags_in_name.as_ptr(),
10795 flags_in,
10796 memory_in_name.as_ptr(),
10797 memory_in,
10798 access_in_name.as_ptr(),
10799 access_in,
10800 fail_on_in_name.as_ptr(),
10801 fail_on_in,
10802 revalidate_in_name.as_ptr(),
10803 revalidate_in,
10804 NULL,
10805 );
10806 utils::result(
10807 vips_op_response,
10808 VipsImage { ctx: out_out },
10809 Error::PngloadBufferError,
10810 )
10811 }
10812}
10813
10814pub fn pngload_source(source: &VipsSource) -> Result<VipsImage> {
10818 unsafe {
10819 let source_in: *mut bindings::VipsSource = source.ctx;
10820 let mut out_out: *mut bindings::VipsImage = null_mut();
10821
10822 let vips_op_response = bindings::vips_pngload_source(source_in, &mut out_out, NULL);
10823 utils::result(
10824 vips_op_response,
10825 VipsImage { ctx: out_out },
10826 Error::PngloadSourceError,
10827 )
10828 }
10829}
10830
10831#[derive(Clone, Debug)]
10833pub struct PngloadSourceOptions {
10834 pub unlimited: bool,
10837 pub flags: ForeignFlags,
10844 pub memory: bool,
10847 pub access: Access,
10852 pub fail_on: FailOn,
10858 pub revalidate: bool,
10861}
10862
10863impl std::default::Default for PngloadSourceOptions {
10864 fn default() -> Self {
10865 PngloadSourceOptions {
10866 unlimited: false,
10867 flags: ForeignFlags::None,
10868 memory: false,
10869 access: Access::Random,
10870 fail_on: FailOn::None,
10871 revalidate: false,
10872 }
10873 }
10874}
10875
10876pub fn pngload_source_with_opts(
10881 source: &VipsSource,
10882 pngload_source_options: &PngloadSourceOptions,
10883) -> Result<VipsImage> {
10884 unsafe {
10885 let source_in: *mut bindings::VipsSource = source.ctx;
10886 let mut out_out: *mut bindings::VipsImage = null_mut();
10887
10888 let unlimited_in: i32 = if pngload_source_options.unlimited {
10889 1
10890 } else {
10891 0
10892 };
10893 let unlimited_in_name = utils::new_c_string("unlimited")?;
10894
10895 let flags_in: i32 = pngload_source_options.flags as i32;
10896 let flags_in_name = utils::new_c_string("flags")?;
10897
10898 let memory_in: i32 = if pngload_source_options.memory { 1 } else { 0 };
10899 let memory_in_name = utils::new_c_string("memory")?;
10900
10901 let access_in: i32 = pngload_source_options.access as i32;
10902 let access_in_name = utils::new_c_string("access")?;
10903
10904 let fail_on_in: i32 = pngload_source_options.fail_on as i32;
10905 let fail_on_in_name = utils::new_c_string("fail-on")?;
10906
10907 let revalidate_in: i32 = if pngload_source_options.revalidate {
10908 1
10909 } else {
10910 0
10911 };
10912 let revalidate_in_name = utils::new_c_string("revalidate")?;
10913
10914 let vips_op_response = bindings::vips_pngload_source(
10915 source_in,
10916 &mut out_out,
10917 unlimited_in_name.as_ptr(),
10918 unlimited_in,
10919 flags_in_name.as_ptr(),
10920 flags_in,
10921 memory_in_name.as_ptr(),
10922 memory_in,
10923 access_in_name.as_ptr(),
10924 access_in,
10925 fail_on_in_name.as_ptr(),
10926 fail_on_in,
10927 revalidate_in_name.as_ptr(),
10928 revalidate_in,
10929 NULL,
10930 );
10931 utils::result(
10932 vips_op_response,
10933 VipsImage { ctx: out_out },
10934 Error::PngloadSourceError,
10935 )
10936 }
10937}
10938
10939pub fn jpegload(filename: &str) -> Result<VipsImage> {
10943 unsafe {
10944 let filename_in: CString = utils::new_c_string(filename)?;
10945 let mut out_out: *mut bindings::VipsImage = null_mut();
10946
10947 let vips_op_response = bindings::vips_jpegload(filename_in.as_ptr(), &mut out_out, NULL);
10948 utils::result(
10949 vips_op_response,
10950 VipsImage { ctx: out_out },
10951 Error::JpegloadError,
10952 )
10953 }
10954}
10955
10956#[derive(Clone, Debug)]
10958pub struct JpegloadOptions {
10959 pub shrink: i32,
10962 pub autorotate: bool,
10965 pub unlimited: bool,
10968 pub flags: ForeignFlags,
10975 pub memory: bool,
10978 pub access: Access,
10983 pub fail_on: FailOn,
10989 pub revalidate: bool,
10992}
10993
10994impl std::default::Default for JpegloadOptions {
10995 fn default() -> Self {
10996 JpegloadOptions {
10997 shrink: i32::from(1),
10998 autorotate: false,
10999 unlimited: false,
11000 flags: ForeignFlags::None,
11001 memory: false,
11002 access: Access::Random,
11003 fail_on: FailOn::None,
11004 revalidate: false,
11005 }
11006 }
11007}
11008
11009pub fn jpegload_with_opts(filename: &str, jpegload_options: &JpegloadOptions) -> Result<VipsImage> {
11014 unsafe {
11015 let filename_in: CString = utils::new_c_string(filename)?;
11016 let mut out_out: *mut bindings::VipsImage = null_mut();
11017
11018 let shrink_in: i32 = jpegload_options.shrink;
11019 let shrink_in_name = utils::new_c_string("shrink")?;
11020
11021 let autorotate_in: i32 = if jpegload_options.autorotate { 1 } else { 0 };
11022 let autorotate_in_name = utils::new_c_string("autorotate")?;
11023
11024 let unlimited_in: i32 = if jpegload_options.unlimited { 1 } else { 0 };
11025 let unlimited_in_name = utils::new_c_string("unlimited")?;
11026
11027 let flags_in: i32 = jpegload_options.flags as i32;
11028 let flags_in_name = utils::new_c_string("flags")?;
11029
11030 let memory_in: i32 = if jpegload_options.memory { 1 } else { 0 };
11031 let memory_in_name = utils::new_c_string("memory")?;
11032
11033 let access_in: i32 = jpegload_options.access as i32;
11034 let access_in_name = utils::new_c_string("access")?;
11035
11036 let fail_on_in: i32 = jpegload_options.fail_on as i32;
11037 let fail_on_in_name = utils::new_c_string("fail-on")?;
11038
11039 let revalidate_in: i32 = if jpegload_options.revalidate { 1 } else { 0 };
11040 let revalidate_in_name = utils::new_c_string("revalidate")?;
11041
11042 let vips_op_response = bindings::vips_jpegload(
11043 filename_in.as_ptr(),
11044 &mut out_out,
11045 shrink_in_name.as_ptr(),
11046 shrink_in,
11047 autorotate_in_name.as_ptr(),
11048 autorotate_in,
11049 unlimited_in_name.as_ptr(),
11050 unlimited_in,
11051 flags_in_name.as_ptr(),
11052 flags_in,
11053 memory_in_name.as_ptr(),
11054 memory_in,
11055 access_in_name.as_ptr(),
11056 access_in,
11057 fail_on_in_name.as_ptr(),
11058 fail_on_in,
11059 revalidate_in_name.as_ptr(),
11060 revalidate_in,
11061 NULL,
11062 );
11063 utils::result(
11064 vips_op_response,
11065 VipsImage { ctx: out_out },
11066 Error::JpegloadError,
11067 )
11068 }
11069}
11070
11071pub fn jpegload_buffer(buffer: &[u8]) -> Result<VipsImage> {
11075 unsafe {
11076 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11077 let mut out_out: *mut bindings::VipsImage = null_mut();
11078
11079 let vips_op_response =
11080 bindings::vips_jpegload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
11081 utils::result(
11082 vips_op_response,
11083 VipsImage { ctx: out_out },
11084 Error::JpegloadBufferError,
11085 )
11086 }
11087}
11088
11089#[derive(Clone, Debug)]
11091pub struct JpegloadBufferOptions {
11092 pub shrink: i32,
11095 pub autorotate: bool,
11098 pub unlimited: bool,
11101 pub flags: ForeignFlags,
11108 pub memory: bool,
11111 pub access: Access,
11116 pub fail_on: FailOn,
11122 pub revalidate: bool,
11125}
11126
11127impl std::default::Default for JpegloadBufferOptions {
11128 fn default() -> Self {
11129 JpegloadBufferOptions {
11130 shrink: i32::from(1),
11131 autorotate: false,
11132 unlimited: false,
11133 flags: ForeignFlags::None,
11134 memory: false,
11135 access: Access::Random,
11136 fail_on: FailOn::None,
11137 revalidate: false,
11138 }
11139 }
11140}
11141
11142pub fn jpegload_buffer_with_opts(
11147 buffer: &[u8],
11148 jpegload_buffer_options: &JpegloadBufferOptions,
11149) -> Result<VipsImage> {
11150 unsafe {
11151 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11152 let mut out_out: *mut bindings::VipsImage = null_mut();
11153
11154 let shrink_in: i32 = jpegload_buffer_options.shrink;
11155 let shrink_in_name = utils::new_c_string("shrink")?;
11156
11157 let autorotate_in: i32 = if jpegload_buffer_options.autorotate {
11158 1
11159 } else {
11160 0
11161 };
11162 let autorotate_in_name = utils::new_c_string("autorotate")?;
11163
11164 let unlimited_in: i32 = if jpegload_buffer_options.unlimited {
11165 1
11166 } else {
11167 0
11168 };
11169 let unlimited_in_name = utils::new_c_string("unlimited")?;
11170
11171 let flags_in: i32 = jpegload_buffer_options.flags as i32;
11172 let flags_in_name = utils::new_c_string("flags")?;
11173
11174 let memory_in: i32 = if jpegload_buffer_options.memory { 1 } else { 0 };
11175 let memory_in_name = utils::new_c_string("memory")?;
11176
11177 let access_in: i32 = jpegload_buffer_options.access as i32;
11178 let access_in_name = utils::new_c_string("access")?;
11179
11180 let fail_on_in: i32 = jpegload_buffer_options.fail_on as i32;
11181 let fail_on_in_name = utils::new_c_string("fail-on")?;
11182
11183 let revalidate_in: i32 = if jpegload_buffer_options.revalidate {
11184 1
11185 } else {
11186 0
11187 };
11188 let revalidate_in_name = utils::new_c_string("revalidate")?;
11189
11190 let vips_op_response = bindings::vips_jpegload_buffer(
11191 buffer_in,
11192 buffer.len() as u64,
11193 &mut out_out,
11194 shrink_in_name.as_ptr(),
11195 shrink_in,
11196 autorotate_in_name.as_ptr(),
11197 autorotate_in,
11198 unlimited_in_name.as_ptr(),
11199 unlimited_in,
11200 flags_in_name.as_ptr(),
11201 flags_in,
11202 memory_in_name.as_ptr(),
11203 memory_in,
11204 access_in_name.as_ptr(),
11205 access_in,
11206 fail_on_in_name.as_ptr(),
11207 fail_on_in,
11208 revalidate_in_name.as_ptr(),
11209 revalidate_in,
11210 NULL,
11211 );
11212 utils::result(
11213 vips_op_response,
11214 VipsImage { ctx: out_out },
11215 Error::JpegloadBufferError,
11216 )
11217 }
11218}
11219
11220pub fn webpload(filename: &str) -> Result<VipsImage> {
11224 unsafe {
11225 let filename_in: CString = utils::new_c_string(filename)?;
11226 let mut out_out: *mut bindings::VipsImage = null_mut();
11227
11228 let vips_op_response = bindings::vips_webpload(filename_in.as_ptr(), &mut out_out, NULL);
11229 utils::result(
11230 vips_op_response,
11231 VipsImage { ctx: out_out },
11232 Error::WebploadError,
11233 )
11234 }
11235}
11236
11237#[derive(Clone, Debug)]
11239pub struct WebploadOptions {
11240 pub page: i32,
11243 pub n: i32,
11246 pub scale: f64,
11249 pub flags: ForeignFlags,
11256 pub memory: bool,
11259 pub access: Access,
11264 pub fail_on: FailOn,
11270 pub revalidate: bool,
11273}
11274
11275impl std::default::Default for WebploadOptions {
11276 fn default() -> Self {
11277 WebploadOptions {
11278 page: i32::from(0),
11279 n: i32::from(1),
11280 scale: f64::from(1),
11281 flags: ForeignFlags::None,
11282 memory: false,
11283 access: Access::Random,
11284 fail_on: FailOn::None,
11285 revalidate: false,
11286 }
11287 }
11288}
11289
11290pub fn webpload_with_opts(filename: &str, webpload_options: &WebploadOptions) -> Result<VipsImage> {
11295 unsafe {
11296 let filename_in: CString = utils::new_c_string(filename)?;
11297 let mut out_out: *mut bindings::VipsImage = null_mut();
11298
11299 let page_in: i32 = webpload_options.page;
11300 let page_in_name = utils::new_c_string("page")?;
11301
11302 let n_in: i32 = webpload_options.n;
11303 let n_in_name = utils::new_c_string("n")?;
11304
11305 let scale_in: f64 = webpload_options.scale;
11306 let scale_in_name = utils::new_c_string("scale")?;
11307
11308 let flags_in: i32 = webpload_options.flags as i32;
11309 let flags_in_name = utils::new_c_string("flags")?;
11310
11311 let memory_in: i32 = if webpload_options.memory { 1 } else { 0 };
11312 let memory_in_name = utils::new_c_string("memory")?;
11313
11314 let access_in: i32 = webpload_options.access as i32;
11315 let access_in_name = utils::new_c_string("access")?;
11316
11317 let fail_on_in: i32 = webpload_options.fail_on as i32;
11318 let fail_on_in_name = utils::new_c_string("fail-on")?;
11319
11320 let revalidate_in: i32 = if webpload_options.revalidate { 1 } else { 0 };
11321 let revalidate_in_name = utils::new_c_string("revalidate")?;
11322
11323 let vips_op_response = bindings::vips_webpload(
11324 filename_in.as_ptr(),
11325 &mut out_out,
11326 page_in_name.as_ptr(),
11327 page_in,
11328 n_in_name.as_ptr(),
11329 n_in,
11330 scale_in_name.as_ptr(),
11331 scale_in,
11332 flags_in_name.as_ptr(),
11333 flags_in,
11334 memory_in_name.as_ptr(),
11335 memory_in,
11336 access_in_name.as_ptr(),
11337 access_in,
11338 fail_on_in_name.as_ptr(),
11339 fail_on_in,
11340 revalidate_in_name.as_ptr(),
11341 revalidate_in,
11342 NULL,
11343 );
11344 utils::result(
11345 vips_op_response,
11346 VipsImage { ctx: out_out },
11347 Error::WebploadError,
11348 )
11349 }
11350}
11351
11352pub fn webpload_buffer(buffer: &[u8]) -> Result<VipsImage> {
11356 unsafe {
11357 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11358 let mut out_out: *mut bindings::VipsImage = null_mut();
11359
11360 let vips_op_response =
11361 bindings::vips_webpload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
11362 utils::result(
11363 vips_op_response,
11364 VipsImage { ctx: out_out },
11365 Error::WebploadBufferError,
11366 )
11367 }
11368}
11369
11370#[derive(Clone, Debug)]
11372pub struct WebploadBufferOptions {
11373 pub page: i32,
11376 pub n: i32,
11379 pub scale: f64,
11382 pub flags: ForeignFlags,
11389 pub memory: bool,
11392 pub access: Access,
11397 pub fail_on: FailOn,
11403 pub revalidate: bool,
11406}
11407
11408impl std::default::Default for WebploadBufferOptions {
11409 fn default() -> Self {
11410 WebploadBufferOptions {
11411 page: i32::from(0),
11412 n: i32::from(1),
11413 scale: f64::from(1),
11414 flags: ForeignFlags::None,
11415 memory: false,
11416 access: Access::Random,
11417 fail_on: FailOn::None,
11418 revalidate: false,
11419 }
11420 }
11421}
11422
11423pub fn webpload_buffer_with_opts(
11428 buffer: &[u8],
11429 webpload_buffer_options: &WebploadBufferOptions,
11430) -> Result<VipsImage> {
11431 unsafe {
11432 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11433 let mut out_out: *mut bindings::VipsImage = null_mut();
11434
11435 let page_in: i32 = webpload_buffer_options.page;
11436 let page_in_name = utils::new_c_string("page")?;
11437
11438 let n_in: i32 = webpload_buffer_options.n;
11439 let n_in_name = utils::new_c_string("n")?;
11440
11441 let scale_in: f64 = webpload_buffer_options.scale;
11442 let scale_in_name = utils::new_c_string("scale")?;
11443
11444 let flags_in: i32 = webpload_buffer_options.flags as i32;
11445 let flags_in_name = utils::new_c_string("flags")?;
11446
11447 let memory_in: i32 = if webpload_buffer_options.memory { 1 } else { 0 };
11448 let memory_in_name = utils::new_c_string("memory")?;
11449
11450 let access_in: i32 = webpload_buffer_options.access as i32;
11451 let access_in_name = utils::new_c_string("access")?;
11452
11453 let fail_on_in: i32 = webpload_buffer_options.fail_on as i32;
11454 let fail_on_in_name = utils::new_c_string("fail-on")?;
11455
11456 let revalidate_in: i32 = if webpload_buffer_options.revalidate {
11457 1
11458 } else {
11459 0
11460 };
11461 let revalidate_in_name = utils::new_c_string("revalidate")?;
11462
11463 let vips_op_response = bindings::vips_webpload_buffer(
11464 buffer_in,
11465 buffer.len() as u64,
11466 &mut out_out,
11467 page_in_name.as_ptr(),
11468 page_in,
11469 n_in_name.as_ptr(),
11470 n_in,
11471 scale_in_name.as_ptr(),
11472 scale_in,
11473 flags_in_name.as_ptr(),
11474 flags_in,
11475 memory_in_name.as_ptr(),
11476 memory_in,
11477 access_in_name.as_ptr(),
11478 access_in,
11479 fail_on_in_name.as_ptr(),
11480 fail_on_in,
11481 revalidate_in_name.as_ptr(),
11482 revalidate_in,
11483 NULL,
11484 );
11485 utils::result(
11486 vips_op_response,
11487 VipsImage { ctx: out_out },
11488 Error::WebploadBufferError,
11489 )
11490 }
11491}
11492
11493pub fn webpload_source(source: &VipsSource) -> Result<VipsImage> {
11497 unsafe {
11498 let source_in: *mut bindings::VipsSource = source.ctx;
11499 let mut out_out: *mut bindings::VipsImage = null_mut();
11500
11501 let vips_op_response = bindings::vips_webpload_source(source_in, &mut out_out, NULL);
11502 utils::result(
11503 vips_op_response,
11504 VipsImage { ctx: out_out },
11505 Error::WebploadSourceError,
11506 )
11507 }
11508}
11509
11510#[derive(Clone, Debug)]
11512pub struct WebploadSourceOptions {
11513 pub page: i32,
11516 pub n: i32,
11519 pub scale: f64,
11522 pub flags: ForeignFlags,
11529 pub memory: bool,
11532 pub access: Access,
11537 pub fail_on: FailOn,
11543 pub revalidate: bool,
11546}
11547
11548impl std::default::Default for WebploadSourceOptions {
11549 fn default() -> Self {
11550 WebploadSourceOptions {
11551 page: i32::from(0),
11552 n: i32::from(1),
11553 scale: f64::from(1),
11554 flags: ForeignFlags::None,
11555 memory: false,
11556 access: Access::Random,
11557 fail_on: FailOn::None,
11558 revalidate: false,
11559 }
11560 }
11561}
11562
11563pub fn webpload_source_with_opts(
11568 source: &VipsSource,
11569 webpload_source_options: &WebploadSourceOptions,
11570) -> Result<VipsImage> {
11571 unsafe {
11572 let source_in: *mut bindings::VipsSource = source.ctx;
11573 let mut out_out: *mut bindings::VipsImage = null_mut();
11574
11575 let page_in: i32 = webpload_source_options.page;
11576 let page_in_name = utils::new_c_string("page")?;
11577
11578 let n_in: i32 = webpload_source_options.n;
11579 let n_in_name = utils::new_c_string("n")?;
11580
11581 let scale_in: f64 = webpload_source_options.scale;
11582 let scale_in_name = utils::new_c_string("scale")?;
11583
11584 let flags_in: i32 = webpload_source_options.flags as i32;
11585 let flags_in_name = utils::new_c_string("flags")?;
11586
11587 let memory_in: i32 = if webpload_source_options.memory { 1 } else { 0 };
11588 let memory_in_name = utils::new_c_string("memory")?;
11589
11590 let access_in: i32 = webpload_source_options.access as i32;
11591 let access_in_name = utils::new_c_string("access")?;
11592
11593 let fail_on_in: i32 = webpload_source_options.fail_on as i32;
11594 let fail_on_in_name = utils::new_c_string("fail-on")?;
11595
11596 let revalidate_in: i32 = if webpload_source_options.revalidate {
11597 1
11598 } else {
11599 0
11600 };
11601 let revalidate_in_name = utils::new_c_string("revalidate")?;
11602
11603 let vips_op_response = bindings::vips_webpload_source(
11604 source_in,
11605 &mut out_out,
11606 page_in_name.as_ptr(),
11607 page_in,
11608 n_in_name.as_ptr(),
11609 n_in,
11610 scale_in_name.as_ptr(),
11611 scale_in,
11612 flags_in_name.as_ptr(),
11613 flags_in,
11614 memory_in_name.as_ptr(),
11615 memory_in,
11616 access_in_name.as_ptr(),
11617 access_in,
11618 fail_on_in_name.as_ptr(),
11619 fail_on_in,
11620 revalidate_in_name.as_ptr(),
11621 revalidate_in,
11622 NULL,
11623 );
11624 utils::result(
11625 vips_op_response,
11626 VipsImage { ctx: out_out },
11627 Error::WebploadSourceError,
11628 )
11629 }
11630}
11631
11632pub fn tiffload(filename: &str) -> Result<VipsImage> {
11636 unsafe {
11637 let filename_in: CString = utils::new_c_string(filename)?;
11638 let mut out_out: *mut bindings::VipsImage = null_mut();
11639
11640 let vips_op_response = bindings::vips_tiffload(filename_in.as_ptr(), &mut out_out, NULL);
11641 utils::result(
11642 vips_op_response,
11643 VipsImage { ctx: out_out },
11644 Error::TiffloadError,
11645 )
11646 }
11647}
11648
11649#[derive(Clone, Debug)]
11651pub struct TiffloadOptions {
11652 pub page: i32,
11655 pub n: i32,
11658 pub autorotate: bool,
11661 pub subifd: i32,
11664 pub unlimited: bool,
11667 pub flags: ForeignFlags,
11674 pub memory: bool,
11677 pub access: Access,
11682 pub fail_on: FailOn,
11688 pub revalidate: bool,
11691}
11692
11693impl std::default::Default for TiffloadOptions {
11694 fn default() -> Self {
11695 TiffloadOptions {
11696 page: i32::from(0),
11697 n: i32::from(1),
11698 autorotate: false,
11699 subifd: i32::from(-1),
11700 unlimited: false,
11701 flags: ForeignFlags::None,
11702 memory: false,
11703 access: Access::Random,
11704 fail_on: FailOn::None,
11705 revalidate: false,
11706 }
11707 }
11708}
11709
11710pub fn tiffload_with_opts(filename: &str, tiffload_options: &TiffloadOptions) -> Result<VipsImage> {
11715 unsafe {
11716 let filename_in: CString = utils::new_c_string(filename)?;
11717 let mut out_out: *mut bindings::VipsImage = null_mut();
11718
11719 let page_in: i32 = tiffload_options.page;
11720 let page_in_name = utils::new_c_string("page")?;
11721
11722 let n_in: i32 = tiffload_options.n;
11723 let n_in_name = utils::new_c_string("n")?;
11724
11725 let autorotate_in: i32 = if tiffload_options.autorotate { 1 } else { 0 };
11726 let autorotate_in_name = utils::new_c_string("autorotate")?;
11727
11728 let subifd_in: i32 = tiffload_options.subifd;
11729 let subifd_in_name = utils::new_c_string("subifd")?;
11730
11731 let unlimited_in: i32 = if tiffload_options.unlimited { 1 } else { 0 };
11732 let unlimited_in_name = utils::new_c_string("unlimited")?;
11733
11734 let flags_in: i32 = tiffload_options.flags as i32;
11735 let flags_in_name = utils::new_c_string("flags")?;
11736
11737 let memory_in: i32 = if tiffload_options.memory { 1 } else { 0 };
11738 let memory_in_name = utils::new_c_string("memory")?;
11739
11740 let access_in: i32 = tiffload_options.access as i32;
11741 let access_in_name = utils::new_c_string("access")?;
11742
11743 let fail_on_in: i32 = tiffload_options.fail_on as i32;
11744 let fail_on_in_name = utils::new_c_string("fail-on")?;
11745
11746 let revalidate_in: i32 = if tiffload_options.revalidate { 1 } else { 0 };
11747 let revalidate_in_name = utils::new_c_string("revalidate")?;
11748
11749 let vips_op_response = bindings::vips_tiffload(
11750 filename_in.as_ptr(),
11751 &mut out_out,
11752 page_in_name.as_ptr(),
11753 page_in,
11754 n_in_name.as_ptr(),
11755 n_in,
11756 autorotate_in_name.as_ptr(),
11757 autorotate_in,
11758 subifd_in_name.as_ptr(),
11759 subifd_in,
11760 unlimited_in_name.as_ptr(),
11761 unlimited_in,
11762 flags_in_name.as_ptr(),
11763 flags_in,
11764 memory_in_name.as_ptr(),
11765 memory_in,
11766 access_in_name.as_ptr(),
11767 access_in,
11768 fail_on_in_name.as_ptr(),
11769 fail_on_in,
11770 revalidate_in_name.as_ptr(),
11771 revalidate_in,
11772 NULL,
11773 );
11774 utils::result(
11775 vips_op_response,
11776 VipsImage { ctx: out_out },
11777 Error::TiffloadError,
11778 )
11779 }
11780}
11781
11782pub fn tiffload_buffer(buffer: &[u8]) -> Result<VipsImage> {
11786 unsafe {
11787 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11788 let mut out_out: *mut bindings::VipsImage = null_mut();
11789
11790 let vips_op_response =
11791 bindings::vips_tiffload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
11792 utils::result(
11793 vips_op_response,
11794 VipsImage { ctx: out_out },
11795 Error::TiffloadBufferError,
11796 )
11797 }
11798}
11799
11800#[derive(Clone, Debug)]
11802pub struct TiffloadBufferOptions {
11803 pub page: i32,
11806 pub n: i32,
11809 pub autorotate: bool,
11812 pub subifd: i32,
11815 pub unlimited: bool,
11818 pub flags: ForeignFlags,
11825 pub memory: bool,
11828 pub access: Access,
11833 pub fail_on: FailOn,
11839 pub revalidate: bool,
11842}
11843
11844impl std::default::Default for TiffloadBufferOptions {
11845 fn default() -> Self {
11846 TiffloadBufferOptions {
11847 page: i32::from(0),
11848 n: i32::from(1),
11849 autorotate: false,
11850 subifd: i32::from(-1),
11851 unlimited: false,
11852 flags: ForeignFlags::None,
11853 memory: false,
11854 access: Access::Random,
11855 fail_on: FailOn::None,
11856 revalidate: false,
11857 }
11858 }
11859}
11860
11861pub fn tiffload_buffer_with_opts(
11866 buffer: &[u8],
11867 tiffload_buffer_options: &TiffloadBufferOptions,
11868) -> Result<VipsImage> {
11869 unsafe {
11870 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11871 let mut out_out: *mut bindings::VipsImage = null_mut();
11872
11873 let page_in: i32 = tiffload_buffer_options.page;
11874 let page_in_name = utils::new_c_string("page")?;
11875
11876 let n_in: i32 = tiffload_buffer_options.n;
11877 let n_in_name = utils::new_c_string("n")?;
11878
11879 let autorotate_in: i32 = if tiffload_buffer_options.autorotate {
11880 1
11881 } else {
11882 0
11883 };
11884 let autorotate_in_name = utils::new_c_string("autorotate")?;
11885
11886 let subifd_in: i32 = tiffload_buffer_options.subifd;
11887 let subifd_in_name = utils::new_c_string("subifd")?;
11888
11889 let unlimited_in: i32 = if tiffload_buffer_options.unlimited {
11890 1
11891 } else {
11892 0
11893 };
11894 let unlimited_in_name = utils::new_c_string("unlimited")?;
11895
11896 let flags_in: i32 = tiffload_buffer_options.flags as i32;
11897 let flags_in_name = utils::new_c_string("flags")?;
11898
11899 let memory_in: i32 = if tiffload_buffer_options.memory { 1 } else { 0 };
11900 let memory_in_name = utils::new_c_string("memory")?;
11901
11902 let access_in: i32 = tiffload_buffer_options.access as i32;
11903 let access_in_name = utils::new_c_string("access")?;
11904
11905 let fail_on_in: i32 = tiffload_buffer_options.fail_on as i32;
11906 let fail_on_in_name = utils::new_c_string("fail-on")?;
11907
11908 let revalidate_in: i32 = if tiffload_buffer_options.revalidate {
11909 1
11910 } else {
11911 0
11912 };
11913 let revalidate_in_name = utils::new_c_string("revalidate")?;
11914
11915 let vips_op_response = bindings::vips_tiffload_buffer(
11916 buffer_in,
11917 buffer.len() as u64,
11918 &mut out_out,
11919 page_in_name.as_ptr(),
11920 page_in,
11921 n_in_name.as_ptr(),
11922 n_in,
11923 autorotate_in_name.as_ptr(),
11924 autorotate_in,
11925 subifd_in_name.as_ptr(),
11926 subifd_in,
11927 unlimited_in_name.as_ptr(),
11928 unlimited_in,
11929 flags_in_name.as_ptr(),
11930 flags_in,
11931 memory_in_name.as_ptr(),
11932 memory_in,
11933 access_in_name.as_ptr(),
11934 access_in,
11935 fail_on_in_name.as_ptr(),
11936 fail_on_in,
11937 revalidate_in_name.as_ptr(),
11938 revalidate_in,
11939 NULL,
11940 );
11941 utils::result(
11942 vips_op_response,
11943 VipsImage { ctx: out_out },
11944 Error::TiffloadBufferError,
11945 )
11946 }
11947}
11948
11949pub fn tiffload_source(source: &VipsSource) -> Result<VipsImage> {
11953 unsafe {
11954 let source_in: *mut bindings::VipsSource = source.ctx;
11955 let mut out_out: *mut bindings::VipsImage = null_mut();
11956
11957 let vips_op_response = bindings::vips_tiffload_source(source_in, &mut out_out, NULL);
11958 utils::result(
11959 vips_op_response,
11960 VipsImage { ctx: out_out },
11961 Error::TiffloadSourceError,
11962 )
11963 }
11964}
11965
11966#[derive(Clone, Debug)]
11968pub struct TiffloadSourceOptions {
11969 pub page: i32,
11972 pub n: i32,
11975 pub autorotate: bool,
11978 pub subifd: i32,
11981 pub unlimited: bool,
11984 pub flags: ForeignFlags,
11991 pub memory: bool,
11994 pub access: Access,
11999 pub fail_on: FailOn,
12005 pub revalidate: bool,
12008}
12009
12010impl std::default::Default for TiffloadSourceOptions {
12011 fn default() -> Self {
12012 TiffloadSourceOptions {
12013 page: i32::from(0),
12014 n: i32::from(1),
12015 autorotate: false,
12016 subifd: i32::from(-1),
12017 unlimited: false,
12018 flags: ForeignFlags::None,
12019 memory: false,
12020 access: Access::Random,
12021 fail_on: FailOn::None,
12022 revalidate: false,
12023 }
12024 }
12025}
12026
12027pub fn tiffload_source_with_opts(
12032 source: &VipsSource,
12033 tiffload_source_options: &TiffloadSourceOptions,
12034) -> Result<VipsImage> {
12035 unsafe {
12036 let source_in: *mut bindings::VipsSource = source.ctx;
12037 let mut out_out: *mut bindings::VipsImage = null_mut();
12038
12039 let page_in: i32 = tiffload_source_options.page;
12040 let page_in_name = utils::new_c_string("page")?;
12041
12042 let n_in: i32 = tiffload_source_options.n;
12043 let n_in_name = utils::new_c_string("n")?;
12044
12045 let autorotate_in: i32 = if tiffload_source_options.autorotate {
12046 1
12047 } else {
12048 0
12049 };
12050 let autorotate_in_name = utils::new_c_string("autorotate")?;
12051
12052 let subifd_in: i32 = tiffload_source_options.subifd;
12053 let subifd_in_name = utils::new_c_string("subifd")?;
12054
12055 let unlimited_in: i32 = if tiffload_source_options.unlimited {
12056 1
12057 } else {
12058 0
12059 };
12060 let unlimited_in_name = utils::new_c_string("unlimited")?;
12061
12062 let flags_in: i32 = tiffload_source_options.flags as i32;
12063 let flags_in_name = utils::new_c_string("flags")?;
12064
12065 let memory_in: i32 = if tiffload_source_options.memory { 1 } else { 0 };
12066 let memory_in_name = utils::new_c_string("memory")?;
12067
12068 let access_in: i32 = tiffload_source_options.access as i32;
12069 let access_in_name = utils::new_c_string("access")?;
12070
12071 let fail_on_in: i32 = tiffload_source_options.fail_on as i32;
12072 let fail_on_in_name = utils::new_c_string("fail-on")?;
12073
12074 let revalidate_in: i32 = if tiffload_source_options.revalidate {
12075 1
12076 } else {
12077 0
12078 };
12079 let revalidate_in_name = utils::new_c_string("revalidate")?;
12080
12081 let vips_op_response = bindings::vips_tiffload_source(
12082 source_in,
12083 &mut out_out,
12084 page_in_name.as_ptr(),
12085 page_in,
12086 n_in_name.as_ptr(),
12087 n_in,
12088 autorotate_in_name.as_ptr(),
12089 autorotate_in,
12090 subifd_in_name.as_ptr(),
12091 subifd_in,
12092 unlimited_in_name.as_ptr(),
12093 unlimited_in,
12094 flags_in_name.as_ptr(),
12095 flags_in,
12096 memory_in_name.as_ptr(),
12097 memory_in,
12098 access_in_name.as_ptr(),
12099 access_in,
12100 fail_on_in_name.as_ptr(),
12101 fail_on_in,
12102 revalidate_in_name.as_ptr(),
12103 revalidate_in,
12104 NULL,
12105 );
12106 utils::result(
12107 vips_op_response,
12108 VipsImage { ctx: out_out },
12109 Error::TiffloadSourceError,
12110 )
12111 }
12112}
12113
12114pub fn heifload(filename: &str) -> Result<VipsImage> {
12118 unsafe {
12119 let filename_in: CString = utils::new_c_string(filename)?;
12120 let mut out_out: *mut bindings::VipsImage = null_mut();
12121
12122 let vips_op_response = bindings::vips_heifload(filename_in.as_ptr(), &mut out_out, NULL);
12123 utils::result(
12124 vips_op_response,
12125 VipsImage { ctx: out_out },
12126 Error::HeifloadError,
12127 )
12128 }
12129}
12130
12131#[derive(Clone, Debug)]
12133pub struct HeifloadOptions {
12134 pub page: i32,
12137 pub n: i32,
12140 pub thumbnail: bool,
12143 pub unlimited: bool,
12146 pub flags: ForeignFlags,
12153 pub memory: bool,
12156 pub access: Access,
12161 pub fail_on: FailOn,
12167 pub revalidate: bool,
12170}
12171
12172impl std::default::Default for HeifloadOptions {
12173 fn default() -> Self {
12174 HeifloadOptions {
12175 page: i32::from(0),
12176 n: i32::from(1),
12177 thumbnail: false,
12178 unlimited: false,
12179 flags: ForeignFlags::None,
12180 memory: false,
12181 access: Access::Random,
12182 fail_on: FailOn::None,
12183 revalidate: false,
12184 }
12185 }
12186}
12187
12188pub fn heifload_with_opts(filename: &str, heifload_options: &HeifloadOptions) -> Result<VipsImage> {
12193 unsafe {
12194 let filename_in: CString = utils::new_c_string(filename)?;
12195 let mut out_out: *mut bindings::VipsImage = null_mut();
12196
12197 let page_in: i32 = heifload_options.page;
12198 let page_in_name = utils::new_c_string("page")?;
12199
12200 let n_in: i32 = heifload_options.n;
12201 let n_in_name = utils::new_c_string("n")?;
12202
12203 let thumbnail_in: i32 = if heifload_options.thumbnail { 1 } else { 0 };
12204 let thumbnail_in_name = utils::new_c_string("thumbnail")?;
12205
12206 let unlimited_in: i32 = if heifload_options.unlimited { 1 } else { 0 };
12207 let unlimited_in_name = utils::new_c_string("unlimited")?;
12208
12209 let flags_in: i32 = heifload_options.flags as i32;
12210 let flags_in_name = utils::new_c_string("flags")?;
12211
12212 let memory_in: i32 = if heifload_options.memory { 1 } else { 0 };
12213 let memory_in_name = utils::new_c_string("memory")?;
12214
12215 let access_in: i32 = heifload_options.access as i32;
12216 let access_in_name = utils::new_c_string("access")?;
12217
12218 let fail_on_in: i32 = heifload_options.fail_on as i32;
12219 let fail_on_in_name = utils::new_c_string("fail-on")?;
12220
12221 let revalidate_in: i32 = if heifload_options.revalidate { 1 } else { 0 };
12222 let revalidate_in_name = utils::new_c_string("revalidate")?;
12223
12224 let vips_op_response = bindings::vips_heifload(
12225 filename_in.as_ptr(),
12226 &mut out_out,
12227 page_in_name.as_ptr(),
12228 page_in,
12229 n_in_name.as_ptr(),
12230 n_in,
12231 thumbnail_in_name.as_ptr(),
12232 thumbnail_in,
12233 unlimited_in_name.as_ptr(),
12234 unlimited_in,
12235 flags_in_name.as_ptr(),
12236 flags_in,
12237 memory_in_name.as_ptr(),
12238 memory_in,
12239 access_in_name.as_ptr(),
12240 access_in,
12241 fail_on_in_name.as_ptr(),
12242 fail_on_in,
12243 revalidate_in_name.as_ptr(),
12244 revalidate_in,
12245 NULL,
12246 );
12247 utils::result(
12248 vips_op_response,
12249 VipsImage { ctx: out_out },
12250 Error::HeifloadError,
12251 )
12252 }
12253}
12254
12255pub fn heifload_buffer(buffer: &[u8]) -> Result<VipsImage> {
12259 unsafe {
12260 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
12261 let mut out_out: *mut bindings::VipsImage = null_mut();
12262
12263 let vips_op_response =
12264 bindings::vips_heifload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
12265 utils::result(
12266 vips_op_response,
12267 VipsImage { ctx: out_out },
12268 Error::HeifloadBufferError,
12269 )
12270 }
12271}
12272
12273#[derive(Clone, Debug)]
12275pub struct HeifloadBufferOptions {
12276 pub page: i32,
12279 pub n: i32,
12282 pub thumbnail: bool,
12285 pub unlimited: bool,
12288 pub flags: ForeignFlags,
12295 pub memory: bool,
12298 pub access: Access,
12303 pub fail_on: FailOn,
12309 pub revalidate: bool,
12312}
12313
12314impl std::default::Default for HeifloadBufferOptions {
12315 fn default() -> Self {
12316 HeifloadBufferOptions {
12317 page: i32::from(0),
12318 n: i32::from(1),
12319 thumbnail: false,
12320 unlimited: false,
12321 flags: ForeignFlags::None,
12322 memory: false,
12323 access: Access::Random,
12324 fail_on: FailOn::None,
12325 revalidate: false,
12326 }
12327 }
12328}
12329
12330pub fn heifload_buffer_with_opts(
12335 buffer: &[u8],
12336 heifload_buffer_options: &HeifloadBufferOptions,
12337) -> Result<VipsImage> {
12338 unsafe {
12339 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
12340 let mut out_out: *mut bindings::VipsImage = null_mut();
12341
12342 let page_in: i32 = heifload_buffer_options.page;
12343 let page_in_name = utils::new_c_string("page")?;
12344
12345 let n_in: i32 = heifload_buffer_options.n;
12346 let n_in_name = utils::new_c_string("n")?;
12347
12348 let thumbnail_in: i32 = if heifload_buffer_options.thumbnail {
12349 1
12350 } else {
12351 0
12352 };
12353 let thumbnail_in_name = utils::new_c_string("thumbnail")?;
12354
12355 let unlimited_in: i32 = if heifload_buffer_options.unlimited {
12356 1
12357 } else {
12358 0
12359 };
12360 let unlimited_in_name = utils::new_c_string("unlimited")?;
12361
12362 let flags_in: i32 = heifload_buffer_options.flags as i32;
12363 let flags_in_name = utils::new_c_string("flags")?;
12364
12365 let memory_in: i32 = if heifload_buffer_options.memory { 1 } else { 0 };
12366 let memory_in_name = utils::new_c_string("memory")?;
12367
12368 let access_in: i32 = heifload_buffer_options.access as i32;
12369 let access_in_name = utils::new_c_string("access")?;
12370
12371 let fail_on_in: i32 = heifload_buffer_options.fail_on as i32;
12372 let fail_on_in_name = utils::new_c_string("fail-on")?;
12373
12374 let revalidate_in: i32 = if heifload_buffer_options.revalidate {
12375 1
12376 } else {
12377 0
12378 };
12379 let revalidate_in_name = utils::new_c_string("revalidate")?;
12380
12381 let vips_op_response = bindings::vips_heifload_buffer(
12382 buffer_in,
12383 buffer.len() as u64,
12384 &mut out_out,
12385 page_in_name.as_ptr(),
12386 page_in,
12387 n_in_name.as_ptr(),
12388 n_in,
12389 thumbnail_in_name.as_ptr(),
12390 thumbnail_in,
12391 unlimited_in_name.as_ptr(),
12392 unlimited_in,
12393 flags_in_name.as_ptr(),
12394 flags_in,
12395 memory_in_name.as_ptr(),
12396 memory_in,
12397 access_in_name.as_ptr(),
12398 access_in,
12399 fail_on_in_name.as_ptr(),
12400 fail_on_in,
12401 revalidate_in_name.as_ptr(),
12402 revalidate_in,
12403 NULL,
12404 );
12405 utils::result(
12406 vips_op_response,
12407 VipsImage { ctx: out_out },
12408 Error::HeifloadBufferError,
12409 )
12410 }
12411}
12412
12413pub fn heifload_source(source: &VipsSource) -> Result<VipsImage> {
12417 unsafe {
12418 let source_in: *mut bindings::VipsSource = source.ctx;
12419 let mut out_out: *mut bindings::VipsImage = null_mut();
12420
12421 let vips_op_response = bindings::vips_heifload_source(source_in, &mut out_out, NULL);
12422 utils::result(
12423 vips_op_response,
12424 VipsImage { ctx: out_out },
12425 Error::HeifloadSourceError,
12426 )
12427 }
12428}
12429
12430#[derive(Clone, Debug)]
12432pub struct HeifloadSourceOptions {
12433 pub page: i32,
12436 pub n: i32,
12439 pub thumbnail: bool,
12442 pub unlimited: bool,
12445 pub flags: ForeignFlags,
12452 pub memory: bool,
12455 pub access: Access,
12460 pub fail_on: FailOn,
12466 pub revalidate: bool,
12469}
12470
12471impl std::default::Default for HeifloadSourceOptions {
12472 fn default() -> Self {
12473 HeifloadSourceOptions {
12474 page: i32::from(0),
12475 n: i32::from(1),
12476 thumbnail: false,
12477 unlimited: false,
12478 flags: ForeignFlags::None,
12479 memory: false,
12480 access: Access::Random,
12481 fail_on: FailOn::None,
12482 revalidate: false,
12483 }
12484 }
12485}
12486
12487pub fn heifload_source_with_opts(
12492 source: &VipsSource,
12493 heifload_source_options: &HeifloadSourceOptions,
12494) -> Result<VipsImage> {
12495 unsafe {
12496 let source_in: *mut bindings::VipsSource = source.ctx;
12497 let mut out_out: *mut bindings::VipsImage = null_mut();
12498
12499 let page_in: i32 = heifload_source_options.page;
12500 let page_in_name = utils::new_c_string("page")?;
12501
12502 let n_in: i32 = heifload_source_options.n;
12503 let n_in_name = utils::new_c_string("n")?;
12504
12505 let thumbnail_in: i32 = if heifload_source_options.thumbnail {
12506 1
12507 } else {
12508 0
12509 };
12510 let thumbnail_in_name = utils::new_c_string("thumbnail")?;
12511
12512 let unlimited_in: i32 = if heifload_source_options.unlimited {
12513 1
12514 } else {
12515 0
12516 };
12517 let unlimited_in_name = utils::new_c_string("unlimited")?;
12518
12519 let flags_in: i32 = heifload_source_options.flags as i32;
12520 let flags_in_name = utils::new_c_string("flags")?;
12521
12522 let memory_in: i32 = if heifload_source_options.memory { 1 } else { 0 };
12523 let memory_in_name = utils::new_c_string("memory")?;
12524
12525 let access_in: i32 = heifload_source_options.access as i32;
12526 let access_in_name = utils::new_c_string("access")?;
12527
12528 let fail_on_in: i32 = heifload_source_options.fail_on as i32;
12529 let fail_on_in_name = utils::new_c_string("fail-on")?;
12530
12531 let revalidate_in: i32 = if heifload_source_options.revalidate {
12532 1
12533 } else {
12534 0
12535 };
12536 let revalidate_in_name = utils::new_c_string("revalidate")?;
12537
12538 let vips_op_response = bindings::vips_heifload_source(
12539 source_in,
12540 &mut out_out,
12541 page_in_name.as_ptr(),
12542 page_in,
12543 n_in_name.as_ptr(),
12544 n_in,
12545 thumbnail_in_name.as_ptr(),
12546 thumbnail_in,
12547 unlimited_in_name.as_ptr(),
12548 unlimited_in,
12549 flags_in_name.as_ptr(),
12550 flags_in,
12551 memory_in_name.as_ptr(),
12552 memory_in,
12553 access_in_name.as_ptr(),
12554 access_in,
12555 fail_on_in_name.as_ptr(),
12556 fail_on_in,
12557 revalidate_in_name.as_ptr(),
12558 revalidate_in,
12559 NULL,
12560 );
12561 utils::result(
12562 vips_op_response,
12563 VipsImage { ctx: out_out },
12564 Error::HeifloadSourceError,
12565 )
12566 }
12567}
12568
12569pub fn csvsave(inp: &VipsImage, filename: &str) -> Result<()> {
12574 unsafe {
12575 let inp_in: *mut bindings::VipsImage = inp.ctx;
12576 let filename_in: CString = utils::new_c_string(filename)?;
12577
12578 let vips_op_response = bindings::vips_csvsave(inp_in, filename_in.as_ptr(), NULL);
12579 utils::result(vips_op_response, (), Error::CsvsaveError)
12580 }
12581}
12582
12583#[derive(Clone, Debug)]
12585pub struct CsvsaveOptions {
12586 pub separator: String,
12588 pub keep: ForeignKeep,
12598 pub background: Vec<f64>,
12600 pub page_height: i32,
12603 pub profile: String,
12605}
12606
12607impl std::default::Default for CsvsaveOptions {
12608 fn default() -> Self {
12609 CsvsaveOptions {
12610 separator: String::new(),
12611 keep: ForeignKeep::All,
12612 background: Vec::new(),
12613 page_height: i32::from(0),
12614 profile: String::from("sRGB"),
12615 }
12616 }
12617}
12618
12619pub fn csvsave_with_opts(
12625 inp: &VipsImage,
12626 filename: &str,
12627 csvsave_options: &CsvsaveOptions,
12628) -> Result<()> {
12629 unsafe {
12630 let inp_in: *mut bindings::VipsImage = inp.ctx;
12631 let filename_in: CString = utils::new_c_string(filename)?;
12632
12633 let separator_in: CString = utils::new_c_string(&csvsave_options.separator)?;
12634 let separator_in_name = utils::new_c_string("separator")?;
12635
12636 let keep_in: i32 = csvsave_options.keep as i32;
12637 let keep_in_name = utils::new_c_string("keep")?;
12638
12639 let background_wrapper =
12640 utils::VipsArrayDoubleWrapper::from(&csvsave_options.background[..]);
12641 let background_in = background_wrapper.ctx;
12642 let background_in_name = utils::new_c_string("background")?;
12643
12644 let page_height_in: i32 = csvsave_options.page_height;
12645 let page_height_in_name = utils::new_c_string("page-height")?;
12646
12647 let profile_in: CString = utils::new_c_string(&csvsave_options.profile)?;
12648 let profile_in_name = utils::new_c_string("profile")?;
12649
12650 let vips_op_response = bindings::vips_csvsave(
12651 inp_in,
12652 filename_in.as_ptr(),
12653 separator_in_name.as_ptr(),
12654 separator_in.as_ptr(),
12655 keep_in_name.as_ptr(),
12656 keep_in,
12657 background_in_name.as_ptr(),
12658 background_in,
12659 page_height_in_name.as_ptr(),
12660 page_height_in,
12661 profile_in_name.as_ptr(),
12662 profile_in.as_ptr(),
12663 NULL,
12664 );
12665 utils::result(vips_op_response, (), Error::CsvsaveError)
12666 }
12667}
12668
12669pub fn csvsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
12674 unsafe {
12675 let inp_in: *mut bindings::VipsImage = inp.ctx;
12676 let target_in: *mut bindings::VipsTarget = target.ctx;
12677
12678 let vips_op_response = bindings::vips_csvsave_target(inp_in, target_in, NULL);
12679 utils::result(vips_op_response, (), Error::CsvsaveTargetError)
12680 }
12681}
12682
12683#[derive(Clone, Debug)]
12685pub struct CsvsaveTargetOptions {
12686 pub separator: String,
12688 pub keep: ForeignKeep,
12698 pub background: Vec<f64>,
12700 pub page_height: i32,
12703 pub profile: String,
12705}
12706
12707impl std::default::Default for CsvsaveTargetOptions {
12708 fn default() -> Self {
12709 CsvsaveTargetOptions {
12710 separator: String::new(),
12711 keep: ForeignKeep::All,
12712 background: Vec::new(),
12713 page_height: i32::from(0),
12714 profile: String::from("sRGB"),
12715 }
12716 }
12717}
12718
12719pub fn csvsave_target_with_opts(
12725 inp: &VipsImage,
12726 target: &VipsTarget,
12727 csvsave_target_options: &CsvsaveTargetOptions,
12728) -> Result<()> {
12729 unsafe {
12730 let inp_in: *mut bindings::VipsImage = inp.ctx;
12731 let target_in: *mut bindings::VipsTarget = target.ctx;
12732
12733 let separator_in: CString = utils::new_c_string(&csvsave_target_options.separator)?;
12734 let separator_in_name = utils::new_c_string("separator")?;
12735
12736 let keep_in: i32 = csvsave_target_options.keep as i32;
12737 let keep_in_name = utils::new_c_string("keep")?;
12738
12739 let background_wrapper =
12740 utils::VipsArrayDoubleWrapper::from(&csvsave_target_options.background[..]);
12741 let background_in = background_wrapper.ctx;
12742 let background_in_name = utils::new_c_string("background")?;
12743
12744 let page_height_in: i32 = csvsave_target_options.page_height;
12745 let page_height_in_name = utils::new_c_string("page-height")?;
12746
12747 let profile_in: CString = utils::new_c_string(&csvsave_target_options.profile)?;
12748 let profile_in_name = utils::new_c_string("profile")?;
12749
12750 let vips_op_response = bindings::vips_csvsave_target(
12751 inp_in,
12752 target_in,
12753 separator_in_name.as_ptr(),
12754 separator_in.as_ptr(),
12755 keep_in_name.as_ptr(),
12756 keep_in,
12757 background_in_name.as_ptr(),
12758 background_in,
12759 page_height_in_name.as_ptr(),
12760 page_height_in,
12761 profile_in_name.as_ptr(),
12762 profile_in.as_ptr(),
12763 NULL,
12764 );
12765 utils::result(vips_op_response, (), Error::CsvsaveTargetError)
12766 }
12767}
12768
12769pub fn matrixsave(inp: &VipsImage, filename: &str) -> Result<()> {
12774 unsafe {
12775 let inp_in: *mut bindings::VipsImage = inp.ctx;
12776 let filename_in: CString = utils::new_c_string(filename)?;
12777
12778 let vips_op_response = bindings::vips_matrixsave(inp_in, filename_in.as_ptr(), NULL);
12779 utils::result(vips_op_response, (), Error::MatrixsaveError)
12780 }
12781}
12782
12783#[derive(Clone, Debug)]
12785pub struct MatrixsaveOptions {
12786 pub keep: ForeignKeep,
12796 pub background: Vec<f64>,
12798 pub page_height: i32,
12801 pub profile: String,
12803}
12804
12805impl std::default::Default for MatrixsaveOptions {
12806 fn default() -> Self {
12807 MatrixsaveOptions {
12808 keep: ForeignKeep::All,
12809 background: Vec::new(),
12810 page_height: i32::from(0),
12811 profile: String::from("sRGB"),
12812 }
12813 }
12814}
12815
12816pub fn matrixsave_with_opts(
12822 inp: &VipsImage,
12823 filename: &str,
12824 matrixsave_options: &MatrixsaveOptions,
12825) -> Result<()> {
12826 unsafe {
12827 let inp_in: *mut bindings::VipsImage = inp.ctx;
12828 let filename_in: CString = utils::new_c_string(filename)?;
12829
12830 let keep_in: i32 = matrixsave_options.keep as i32;
12831 let keep_in_name = utils::new_c_string("keep")?;
12832
12833 let background_wrapper =
12834 utils::VipsArrayDoubleWrapper::from(&matrixsave_options.background[..]);
12835 let background_in = background_wrapper.ctx;
12836 let background_in_name = utils::new_c_string("background")?;
12837
12838 let page_height_in: i32 = matrixsave_options.page_height;
12839 let page_height_in_name = utils::new_c_string("page-height")?;
12840
12841 let profile_in: CString = utils::new_c_string(&matrixsave_options.profile)?;
12842 let profile_in_name = utils::new_c_string("profile")?;
12843
12844 let vips_op_response = bindings::vips_matrixsave(
12845 inp_in,
12846 filename_in.as_ptr(),
12847 keep_in_name.as_ptr(),
12848 keep_in,
12849 background_in_name.as_ptr(),
12850 background_in,
12851 page_height_in_name.as_ptr(),
12852 page_height_in,
12853 profile_in_name.as_ptr(),
12854 profile_in.as_ptr(),
12855 NULL,
12856 );
12857 utils::result(vips_op_response, (), Error::MatrixsaveError)
12858 }
12859}
12860
12861pub fn matrixsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
12866 unsafe {
12867 let inp_in: *mut bindings::VipsImage = inp.ctx;
12868 let target_in: *mut bindings::VipsTarget = target.ctx;
12869
12870 let vips_op_response = bindings::vips_matrixsave_target(inp_in, target_in, NULL);
12871 utils::result(vips_op_response, (), Error::MatrixsaveTargetError)
12872 }
12873}
12874
12875#[derive(Clone, Debug)]
12877pub struct MatrixsaveTargetOptions {
12878 pub keep: ForeignKeep,
12888 pub background: Vec<f64>,
12890 pub page_height: i32,
12893 pub profile: String,
12895}
12896
12897impl std::default::Default for MatrixsaveTargetOptions {
12898 fn default() -> Self {
12899 MatrixsaveTargetOptions {
12900 keep: ForeignKeep::All,
12901 background: Vec::new(),
12902 page_height: i32::from(0),
12903 profile: String::from("sRGB"),
12904 }
12905 }
12906}
12907
12908pub fn matrixsave_target_with_opts(
12914 inp: &VipsImage,
12915 target: &VipsTarget,
12916 matrixsave_target_options: &MatrixsaveTargetOptions,
12917) -> Result<()> {
12918 unsafe {
12919 let inp_in: *mut bindings::VipsImage = inp.ctx;
12920 let target_in: *mut bindings::VipsTarget = target.ctx;
12921
12922 let keep_in: i32 = matrixsave_target_options.keep as i32;
12923 let keep_in_name = utils::new_c_string("keep")?;
12924
12925 let background_wrapper =
12926 utils::VipsArrayDoubleWrapper::from(&matrixsave_target_options.background[..]);
12927 let background_in = background_wrapper.ctx;
12928 let background_in_name = utils::new_c_string("background")?;
12929
12930 let page_height_in: i32 = matrixsave_target_options.page_height;
12931 let page_height_in_name = utils::new_c_string("page-height")?;
12932
12933 let profile_in: CString = utils::new_c_string(&matrixsave_target_options.profile)?;
12934 let profile_in_name = utils::new_c_string("profile")?;
12935
12936 let vips_op_response = bindings::vips_matrixsave_target(
12937 inp_in,
12938 target_in,
12939 keep_in_name.as_ptr(),
12940 keep_in,
12941 background_in_name.as_ptr(),
12942 background_in,
12943 page_height_in_name.as_ptr(),
12944 page_height_in,
12945 profile_in_name.as_ptr(),
12946 profile_in.as_ptr(),
12947 NULL,
12948 );
12949 utils::result(vips_op_response, (), Error::MatrixsaveTargetError)
12950 }
12951}
12952
12953pub fn matrixprint(inp: &VipsImage) -> Result<()> {
12957 unsafe {
12958 let inp_in: *mut bindings::VipsImage = inp.ctx;
12959
12960 let vips_op_response = bindings::vips_matrixprint(inp_in, NULL);
12961 utils::result(vips_op_response, (), Error::MatrixprintError)
12962 }
12963}
12964
12965#[derive(Clone, Debug)]
12967pub struct MatrixprintOptions {
12968 pub keep: ForeignKeep,
12978 pub background: Vec<f64>,
12980 pub page_height: i32,
12983 pub profile: String,
12985}
12986
12987impl std::default::Default for MatrixprintOptions {
12988 fn default() -> Self {
12989 MatrixprintOptions {
12990 keep: ForeignKeep::All,
12991 background: Vec::new(),
12992 page_height: i32::from(0),
12993 profile: String::from("sRGB"),
12994 }
12995 }
12996}
12997
12998pub fn matrixprint_with_opts(
13003 inp: &VipsImage,
13004 matrixprint_options: &MatrixprintOptions,
13005) -> Result<()> {
13006 unsafe {
13007 let inp_in: *mut bindings::VipsImage = inp.ctx;
13008
13009 let keep_in: i32 = matrixprint_options.keep as i32;
13010 let keep_in_name = utils::new_c_string("keep")?;
13011
13012 let background_wrapper =
13013 utils::VipsArrayDoubleWrapper::from(&matrixprint_options.background[..]);
13014 let background_in = background_wrapper.ctx;
13015 let background_in_name = utils::new_c_string("background")?;
13016
13017 let page_height_in: i32 = matrixprint_options.page_height;
13018 let page_height_in_name = utils::new_c_string("page-height")?;
13019
13020 let profile_in: CString = utils::new_c_string(&matrixprint_options.profile)?;
13021 let profile_in_name = utils::new_c_string("profile")?;
13022
13023 let vips_op_response = bindings::vips_matrixprint(
13024 inp_in,
13025 keep_in_name.as_ptr(),
13026 keep_in,
13027 background_in_name.as_ptr(),
13028 background_in,
13029 page_height_in_name.as_ptr(),
13030 page_height_in,
13031 profile_in_name.as_ptr(),
13032 profile_in.as_ptr(),
13033 NULL,
13034 );
13035 utils::result(vips_op_response, (), Error::MatrixprintError)
13036 }
13037}
13038
13039pub fn rawsave(inp: &VipsImage, filename: &str) -> Result<()> {
13044 unsafe {
13045 let inp_in: *mut bindings::VipsImage = inp.ctx;
13046 let filename_in: CString = utils::new_c_string(filename)?;
13047
13048 let vips_op_response = bindings::vips_rawsave(inp_in, filename_in.as_ptr(), NULL);
13049 utils::result(vips_op_response, (), Error::RawsaveError)
13050 }
13051}
13052
13053#[derive(Clone, Debug)]
13055pub struct RawsaveOptions {
13056 pub keep: ForeignKeep,
13066 pub background: Vec<f64>,
13068 pub page_height: i32,
13071 pub profile: String,
13073}
13074
13075impl std::default::Default for RawsaveOptions {
13076 fn default() -> Self {
13077 RawsaveOptions {
13078 keep: ForeignKeep::All,
13079 background: Vec::new(),
13080 page_height: i32::from(0),
13081 profile: String::from("sRGB"),
13082 }
13083 }
13084}
13085
13086pub fn rawsave_with_opts(
13092 inp: &VipsImage,
13093 filename: &str,
13094 rawsave_options: &RawsaveOptions,
13095) -> Result<()> {
13096 unsafe {
13097 let inp_in: *mut bindings::VipsImage = inp.ctx;
13098 let filename_in: CString = utils::new_c_string(filename)?;
13099
13100 let keep_in: i32 = rawsave_options.keep as i32;
13101 let keep_in_name = utils::new_c_string("keep")?;
13102
13103 let background_wrapper =
13104 utils::VipsArrayDoubleWrapper::from(&rawsave_options.background[..]);
13105 let background_in = background_wrapper.ctx;
13106 let background_in_name = utils::new_c_string("background")?;
13107
13108 let page_height_in: i32 = rawsave_options.page_height;
13109 let page_height_in_name = utils::new_c_string("page-height")?;
13110
13111 let profile_in: CString = utils::new_c_string(&rawsave_options.profile)?;
13112 let profile_in_name = utils::new_c_string("profile")?;
13113
13114 let vips_op_response = bindings::vips_rawsave(
13115 inp_in,
13116 filename_in.as_ptr(),
13117 keep_in_name.as_ptr(),
13118 keep_in,
13119 background_in_name.as_ptr(),
13120 background_in,
13121 page_height_in_name.as_ptr(),
13122 page_height_in,
13123 profile_in_name.as_ptr(),
13124 profile_in.as_ptr(),
13125 NULL,
13126 );
13127 utils::result(vips_op_response, (), Error::RawsaveError)
13128 }
13129}
13130
13131pub fn rawsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
13135 unsafe {
13136 let inp_in: *mut bindings::VipsImage = inp.ctx;
13137 let mut buffer_buf_size: u64 = 0;
13138 let mut buffer_out: *mut c_void = null_mut();
13139
13140 let vips_op_response =
13141 bindings::vips_rawsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
13142 utils::result(
13143 vips_op_response,
13144 utils::new_byte_array(buffer_out, buffer_buf_size),
13145 Error::RawsaveBufferError,
13146 )
13147 }
13148}
13149
13150#[derive(Clone, Debug)]
13152pub struct RawsaveBufferOptions {
13153 pub keep: ForeignKeep,
13163 pub background: Vec<f64>,
13165 pub page_height: i32,
13168 pub profile: String,
13170}
13171
13172impl std::default::Default for RawsaveBufferOptions {
13173 fn default() -> Self {
13174 RawsaveBufferOptions {
13175 keep: ForeignKeep::All,
13176 background: Vec::new(),
13177 page_height: i32::from(0),
13178 profile: String::from("sRGB"),
13179 }
13180 }
13181}
13182
13183pub fn rawsave_buffer_with_opts(
13188 inp: &VipsImage,
13189 rawsave_buffer_options: &RawsaveBufferOptions,
13190) -> Result<Vec<u8>> {
13191 unsafe {
13192 let inp_in: *mut bindings::VipsImage = inp.ctx;
13193 let mut buffer_buf_size: u64 = 0;
13194 let mut buffer_out: *mut c_void = null_mut();
13195
13196 let keep_in: i32 = rawsave_buffer_options.keep as i32;
13197 let keep_in_name = utils::new_c_string("keep")?;
13198
13199 let background_wrapper =
13200 utils::VipsArrayDoubleWrapper::from(&rawsave_buffer_options.background[..]);
13201 let background_in = background_wrapper.ctx;
13202 let background_in_name = utils::new_c_string("background")?;
13203
13204 let page_height_in: i32 = rawsave_buffer_options.page_height;
13205 let page_height_in_name = utils::new_c_string("page-height")?;
13206
13207 let profile_in: CString = utils::new_c_string(&rawsave_buffer_options.profile)?;
13208 let profile_in_name = utils::new_c_string("profile")?;
13209
13210 let vips_op_response = bindings::vips_rawsave_buffer(
13211 inp_in,
13212 &mut buffer_out,
13213 &mut buffer_buf_size,
13214 keep_in_name.as_ptr(),
13215 keep_in,
13216 background_in_name.as_ptr(),
13217 background_in,
13218 page_height_in_name.as_ptr(),
13219 page_height_in,
13220 profile_in_name.as_ptr(),
13221 profile_in.as_ptr(),
13222 NULL,
13223 );
13224 utils::result(
13225 vips_op_response,
13226 utils::new_byte_array(buffer_out, buffer_buf_size),
13227 Error::RawsaveBufferError,
13228 )
13229 }
13230}
13231
13232pub fn rawsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13237 unsafe {
13238 let inp_in: *mut bindings::VipsImage = inp.ctx;
13239 let target_in: *mut bindings::VipsTarget = target.ctx;
13240
13241 let vips_op_response = bindings::vips_rawsave_target(inp_in, target_in, NULL);
13242 utils::result(vips_op_response, (), Error::RawsaveTargetError)
13243 }
13244}
13245
13246#[derive(Clone, Debug)]
13248pub struct RawsaveTargetOptions {
13249 pub keep: ForeignKeep,
13259 pub background: Vec<f64>,
13261 pub page_height: i32,
13264 pub profile: String,
13266}
13267
13268impl std::default::Default for RawsaveTargetOptions {
13269 fn default() -> Self {
13270 RawsaveTargetOptions {
13271 keep: ForeignKeep::All,
13272 background: Vec::new(),
13273 page_height: i32::from(0),
13274 profile: String::from("sRGB"),
13275 }
13276 }
13277}
13278
13279pub fn rawsave_target_with_opts(
13285 inp: &VipsImage,
13286 target: &VipsTarget,
13287 rawsave_target_options: &RawsaveTargetOptions,
13288) -> Result<()> {
13289 unsafe {
13290 let inp_in: *mut bindings::VipsImage = inp.ctx;
13291 let target_in: *mut bindings::VipsTarget = target.ctx;
13292
13293 let keep_in: i32 = rawsave_target_options.keep as i32;
13294 let keep_in_name = utils::new_c_string("keep")?;
13295
13296 let background_wrapper =
13297 utils::VipsArrayDoubleWrapper::from(&rawsave_target_options.background[..]);
13298 let background_in = background_wrapper.ctx;
13299 let background_in_name = utils::new_c_string("background")?;
13300
13301 let page_height_in: i32 = rawsave_target_options.page_height;
13302 let page_height_in_name = utils::new_c_string("page-height")?;
13303
13304 let profile_in: CString = utils::new_c_string(&rawsave_target_options.profile)?;
13305 let profile_in_name = utils::new_c_string("profile")?;
13306
13307 let vips_op_response = bindings::vips_rawsave_target(
13308 inp_in,
13309 target_in,
13310 keep_in_name.as_ptr(),
13311 keep_in,
13312 background_in_name.as_ptr(),
13313 background_in,
13314 page_height_in_name.as_ptr(),
13315 page_height_in,
13316 profile_in_name.as_ptr(),
13317 profile_in.as_ptr(),
13318 NULL,
13319 );
13320 utils::result(vips_op_response, (), Error::RawsaveTargetError)
13321 }
13322}
13323
13324pub fn vipssave(inp: &VipsImage, filename: &str) -> Result<()> {
13329 unsafe {
13330 let inp_in: *mut bindings::VipsImage = inp.ctx;
13331 let filename_in: CString = utils::new_c_string(filename)?;
13332
13333 let vips_op_response = bindings::vips_vipssave(inp_in, filename_in.as_ptr(), NULL);
13334 utils::result(vips_op_response, (), Error::VipssaveError)
13335 }
13336}
13337
13338#[derive(Clone, Debug)]
13340pub struct VipssaveOptions {
13341 pub keep: ForeignKeep,
13351 pub background: Vec<f64>,
13353 pub page_height: i32,
13356 pub profile: String,
13358}
13359
13360impl std::default::Default for VipssaveOptions {
13361 fn default() -> Self {
13362 VipssaveOptions {
13363 keep: ForeignKeep::All,
13364 background: Vec::new(),
13365 page_height: i32::from(0),
13366 profile: String::from("sRGB"),
13367 }
13368 }
13369}
13370
13371pub fn vipssave_with_opts(
13377 inp: &VipsImage,
13378 filename: &str,
13379 vipssave_options: &VipssaveOptions,
13380) -> Result<()> {
13381 unsafe {
13382 let inp_in: *mut bindings::VipsImage = inp.ctx;
13383 let filename_in: CString = utils::new_c_string(filename)?;
13384
13385 let keep_in: i32 = vipssave_options.keep as i32;
13386 let keep_in_name = utils::new_c_string("keep")?;
13387
13388 let background_wrapper =
13389 utils::VipsArrayDoubleWrapper::from(&vipssave_options.background[..]);
13390 let background_in = background_wrapper.ctx;
13391 let background_in_name = utils::new_c_string("background")?;
13392
13393 let page_height_in: i32 = vipssave_options.page_height;
13394 let page_height_in_name = utils::new_c_string("page-height")?;
13395
13396 let profile_in: CString = utils::new_c_string(&vipssave_options.profile)?;
13397 let profile_in_name = utils::new_c_string("profile")?;
13398
13399 let vips_op_response = bindings::vips_vipssave(
13400 inp_in,
13401 filename_in.as_ptr(),
13402 keep_in_name.as_ptr(),
13403 keep_in,
13404 background_in_name.as_ptr(),
13405 background_in,
13406 page_height_in_name.as_ptr(),
13407 page_height_in,
13408 profile_in_name.as_ptr(),
13409 profile_in.as_ptr(),
13410 NULL,
13411 );
13412 utils::result(vips_op_response, (), Error::VipssaveError)
13413 }
13414}
13415
13416pub fn vipssave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13421 unsafe {
13422 let inp_in: *mut bindings::VipsImage = inp.ctx;
13423 let target_in: *mut bindings::VipsTarget = target.ctx;
13424
13425 let vips_op_response = bindings::vips_vipssave_target(inp_in, target_in, NULL);
13426 utils::result(vips_op_response, (), Error::VipssaveTargetError)
13427 }
13428}
13429
13430#[derive(Clone, Debug)]
13432pub struct VipssaveTargetOptions {
13433 pub keep: ForeignKeep,
13443 pub background: Vec<f64>,
13445 pub page_height: i32,
13448 pub profile: String,
13450}
13451
13452impl std::default::Default for VipssaveTargetOptions {
13453 fn default() -> Self {
13454 VipssaveTargetOptions {
13455 keep: ForeignKeep::All,
13456 background: Vec::new(),
13457 page_height: i32::from(0),
13458 profile: String::from("sRGB"),
13459 }
13460 }
13461}
13462
13463pub fn vipssave_target_with_opts(
13469 inp: &VipsImage,
13470 target: &VipsTarget,
13471 vipssave_target_options: &VipssaveTargetOptions,
13472) -> Result<()> {
13473 unsafe {
13474 let inp_in: *mut bindings::VipsImage = inp.ctx;
13475 let target_in: *mut bindings::VipsTarget = target.ctx;
13476
13477 let keep_in: i32 = vipssave_target_options.keep as i32;
13478 let keep_in_name = utils::new_c_string("keep")?;
13479
13480 let background_wrapper =
13481 utils::VipsArrayDoubleWrapper::from(&vipssave_target_options.background[..]);
13482 let background_in = background_wrapper.ctx;
13483 let background_in_name = utils::new_c_string("background")?;
13484
13485 let page_height_in: i32 = vipssave_target_options.page_height;
13486 let page_height_in_name = utils::new_c_string("page-height")?;
13487
13488 let profile_in: CString = utils::new_c_string(&vipssave_target_options.profile)?;
13489 let profile_in_name = utils::new_c_string("profile")?;
13490
13491 let vips_op_response = bindings::vips_vipssave_target(
13492 inp_in,
13493 target_in,
13494 keep_in_name.as_ptr(),
13495 keep_in,
13496 background_in_name.as_ptr(),
13497 background_in,
13498 page_height_in_name.as_ptr(),
13499 page_height_in,
13500 profile_in_name.as_ptr(),
13501 profile_in.as_ptr(),
13502 NULL,
13503 );
13504 utils::result(vips_op_response, (), Error::VipssaveTargetError)
13505 }
13506}
13507
13508pub fn ppmsave(inp: &VipsImage, filename: &str) -> Result<()> {
13513 unsafe {
13514 let inp_in: *mut bindings::VipsImage = inp.ctx;
13515 let filename_in: CString = utils::new_c_string(filename)?;
13516
13517 let vips_op_response = bindings::vips_ppmsave(inp_in, filename_in.as_ptr(), NULL);
13518 utils::result(vips_op_response, (), Error::PpmsaveError)
13519 }
13520}
13521
13522#[derive(Clone, Debug)]
13524pub struct PpmsaveOptions {
13525 pub format: ForeignPpmFormat,
13532 pub ascii: bool,
13535 pub bitdepth: i32,
13538 pub keep: ForeignKeep,
13548 pub background: Vec<f64>,
13550 pub page_height: i32,
13553 pub profile: String,
13555}
13556
13557impl std::default::Default for PpmsaveOptions {
13558 fn default() -> Self {
13559 PpmsaveOptions {
13560 format: ForeignPpmFormat::Ppm,
13561 ascii: false,
13562 bitdepth: i32::from(0),
13563 keep: ForeignKeep::All,
13564 background: Vec::new(),
13565 page_height: i32::from(0),
13566 profile: String::from("sRGB"),
13567 }
13568 }
13569}
13570
13571pub fn ppmsave_with_opts(
13577 inp: &VipsImage,
13578 filename: &str,
13579 ppmsave_options: &PpmsaveOptions,
13580) -> Result<()> {
13581 unsafe {
13582 let inp_in: *mut bindings::VipsImage = inp.ctx;
13583 let filename_in: CString = utils::new_c_string(filename)?;
13584
13585 let format_in: i32 = ppmsave_options.format as i32;
13586 let format_in_name = utils::new_c_string("format")?;
13587
13588 let ascii_in: i32 = if ppmsave_options.ascii { 1 } else { 0 };
13589 let ascii_in_name = utils::new_c_string("ascii")?;
13590
13591 let bitdepth_in: i32 = ppmsave_options.bitdepth;
13592 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
13593
13594 let keep_in: i32 = ppmsave_options.keep as i32;
13595 let keep_in_name = utils::new_c_string("keep")?;
13596
13597 let background_wrapper =
13598 utils::VipsArrayDoubleWrapper::from(&ppmsave_options.background[..]);
13599 let background_in = background_wrapper.ctx;
13600 let background_in_name = utils::new_c_string("background")?;
13601
13602 let page_height_in: i32 = ppmsave_options.page_height;
13603 let page_height_in_name = utils::new_c_string("page-height")?;
13604
13605 let profile_in: CString = utils::new_c_string(&ppmsave_options.profile)?;
13606 let profile_in_name = utils::new_c_string("profile")?;
13607
13608 let vips_op_response = bindings::vips_ppmsave(
13609 inp_in,
13610 filename_in.as_ptr(),
13611 format_in_name.as_ptr(),
13612 format_in,
13613 ascii_in_name.as_ptr(),
13614 ascii_in,
13615 bitdepth_in_name.as_ptr(),
13616 bitdepth_in,
13617 keep_in_name.as_ptr(),
13618 keep_in,
13619 background_in_name.as_ptr(),
13620 background_in,
13621 page_height_in_name.as_ptr(),
13622 page_height_in,
13623 profile_in_name.as_ptr(),
13624 profile_in.as_ptr(),
13625 NULL,
13626 );
13627 utils::result(vips_op_response, (), Error::PpmsaveError)
13628 }
13629}
13630
13631pub fn ppmsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13636 unsafe {
13637 let inp_in: *mut bindings::VipsImage = inp.ctx;
13638 let target_in: *mut bindings::VipsTarget = target.ctx;
13639
13640 let vips_op_response = bindings::vips_ppmsave_target(inp_in, target_in, NULL);
13641 utils::result(vips_op_response, (), Error::PpmsaveTargetError)
13642 }
13643}
13644
13645#[derive(Clone, Debug)]
13647pub struct PpmsaveTargetOptions {
13648 pub format: ForeignPpmFormat,
13655 pub ascii: bool,
13658 pub bitdepth: i32,
13661 pub keep: ForeignKeep,
13671 pub background: Vec<f64>,
13673 pub page_height: i32,
13676 pub profile: String,
13678}
13679
13680impl std::default::Default for PpmsaveTargetOptions {
13681 fn default() -> Self {
13682 PpmsaveTargetOptions {
13683 format: ForeignPpmFormat::Ppm,
13684 ascii: false,
13685 bitdepth: i32::from(0),
13686 keep: ForeignKeep::All,
13687 background: Vec::new(),
13688 page_height: i32::from(0),
13689 profile: String::from("sRGB"),
13690 }
13691 }
13692}
13693
13694pub fn ppmsave_target_with_opts(
13700 inp: &VipsImage,
13701 target: &VipsTarget,
13702 ppmsave_target_options: &PpmsaveTargetOptions,
13703) -> Result<()> {
13704 unsafe {
13705 let inp_in: *mut bindings::VipsImage = inp.ctx;
13706 let target_in: *mut bindings::VipsTarget = target.ctx;
13707
13708 let format_in: i32 = ppmsave_target_options.format as i32;
13709 let format_in_name = utils::new_c_string("format")?;
13710
13711 let ascii_in: i32 = if ppmsave_target_options.ascii { 1 } else { 0 };
13712 let ascii_in_name = utils::new_c_string("ascii")?;
13713
13714 let bitdepth_in: i32 = ppmsave_target_options.bitdepth;
13715 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
13716
13717 let keep_in: i32 = ppmsave_target_options.keep as i32;
13718 let keep_in_name = utils::new_c_string("keep")?;
13719
13720 let background_wrapper =
13721 utils::VipsArrayDoubleWrapper::from(&ppmsave_target_options.background[..]);
13722 let background_in = background_wrapper.ctx;
13723 let background_in_name = utils::new_c_string("background")?;
13724
13725 let page_height_in: i32 = ppmsave_target_options.page_height;
13726 let page_height_in_name = utils::new_c_string("page-height")?;
13727
13728 let profile_in: CString = utils::new_c_string(&ppmsave_target_options.profile)?;
13729 let profile_in_name = utils::new_c_string("profile")?;
13730
13731 let vips_op_response = bindings::vips_ppmsave_target(
13732 inp_in,
13733 target_in,
13734 format_in_name.as_ptr(),
13735 format_in,
13736 ascii_in_name.as_ptr(),
13737 ascii_in,
13738 bitdepth_in_name.as_ptr(),
13739 bitdepth_in,
13740 keep_in_name.as_ptr(),
13741 keep_in,
13742 background_in_name.as_ptr(),
13743 background_in,
13744 page_height_in_name.as_ptr(),
13745 page_height_in,
13746 profile_in_name.as_ptr(),
13747 profile_in.as_ptr(),
13748 NULL,
13749 );
13750 utils::result(vips_op_response, (), Error::PpmsaveTargetError)
13751 }
13752}
13753
13754pub fn radsave(inp: &VipsImage, filename: &str) -> Result<()> {
13759 unsafe {
13760 let inp_in: *mut bindings::VipsImage = inp.ctx;
13761 let filename_in: CString = utils::new_c_string(filename)?;
13762
13763 let vips_op_response = bindings::vips_radsave(inp_in, filename_in.as_ptr(), NULL);
13764 utils::result(vips_op_response, (), Error::RadsaveError)
13765 }
13766}
13767
13768#[derive(Clone, Debug)]
13770pub struct RadsaveOptions {
13771 pub keep: ForeignKeep,
13781 pub background: Vec<f64>,
13783 pub page_height: i32,
13786 pub profile: String,
13788}
13789
13790impl std::default::Default for RadsaveOptions {
13791 fn default() -> Self {
13792 RadsaveOptions {
13793 keep: ForeignKeep::All,
13794 background: Vec::new(),
13795 page_height: i32::from(0),
13796 profile: String::from("sRGB"),
13797 }
13798 }
13799}
13800
13801pub fn radsave_with_opts(
13807 inp: &VipsImage,
13808 filename: &str,
13809 radsave_options: &RadsaveOptions,
13810) -> Result<()> {
13811 unsafe {
13812 let inp_in: *mut bindings::VipsImage = inp.ctx;
13813 let filename_in: CString = utils::new_c_string(filename)?;
13814
13815 let keep_in: i32 = radsave_options.keep as i32;
13816 let keep_in_name = utils::new_c_string("keep")?;
13817
13818 let background_wrapper =
13819 utils::VipsArrayDoubleWrapper::from(&radsave_options.background[..]);
13820 let background_in = background_wrapper.ctx;
13821 let background_in_name = utils::new_c_string("background")?;
13822
13823 let page_height_in: i32 = radsave_options.page_height;
13824 let page_height_in_name = utils::new_c_string("page-height")?;
13825
13826 let profile_in: CString = utils::new_c_string(&radsave_options.profile)?;
13827 let profile_in_name = utils::new_c_string("profile")?;
13828
13829 let vips_op_response = bindings::vips_radsave(
13830 inp_in,
13831 filename_in.as_ptr(),
13832 keep_in_name.as_ptr(),
13833 keep_in,
13834 background_in_name.as_ptr(),
13835 background_in,
13836 page_height_in_name.as_ptr(),
13837 page_height_in,
13838 profile_in_name.as_ptr(),
13839 profile_in.as_ptr(),
13840 NULL,
13841 );
13842 utils::result(vips_op_response, (), Error::RadsaveError)
13843 }
13844}
13845
13846pub fn radsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
13850 unsafe {
13851 let inp_in: *mut bindings::VipsImage = inp.ctx;
13852 let mut buffer_buf_size: u64 = 0;
13853 let mut buffer_out: *mut c_void = null_mut();
13854
13855 let vips_op_response =
13856 bindings::vips_radsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
13857 utils::result(
13858 vips_op_response,
13859 utils::new_byte_array(buffer_out, buffer_buf_size),
13860 Error::RadsaveBufferError,
13861 )
13862 }
13863}
13864
13865#[derive(Clone, Debug)]
13867pub struct RadsaveBufferOptions {
13868 pub keep: ForeignKeep,
13878 pub background: Vec<f64>,
13880 pub page_height: i32,
13883 pub profile: String,
13885}
13886
13887impl std::default::Default for RadsaveBufferOptions {
13888 fn default() -> Self {
13889 RadsaveBufferOptions {
13890 keep: ForeignKeep::All,
13891 background: Vec::new(),
13892 page_height: i32::from(0),
13893 profile: String::from("sRGB"),
13894 }
13895 }
13896}
13897
13898pub fn radsave_buffer_with_opts(
13903 inp: &VipsImage,
13904 radsave_buffer_options: &RadsaveBufferOptions,
13905) -> Result<Vec<u8>> {
13906 unsafe {
13907 let inp_in: *mut bindings::VipsImage = inp.ctx;
13908 let mut buffer_buf_size: u64 = 0;
13909 let mut buffer_out: *mut c_void = null_mut();
13910
13911 let keep_in: i32 = radsave_buffer_options.keep as i32;
13912 let keep_in_name = utils::new_c_string("keep")?;
13913
13914 let background_wrapper =
13915 utils::VipsArrayDoubleWrapper::from(&radsave_buffer_options.background[..]);
13916 let background_in = background_wrapper.ctx;
13917 let background_in_name = utils::new_c_string("background")?;
13918
13919 let page_height_in: i32 = radsave_buffer_options.page_height;
13920 let page_height_in_name = utils::new_c_string("page-height")?;
13921
13922 let profile_in: CString = utils::new_c_string(&radsave_buffer_options.profile)?;
13923 let profile_in_name = utils::new_c_string("profile")?;
13924
13925 let vips_op_response = bindings::vips_radsave_buffer(
13926 inp_in,
13927 &mut buffer_out,
13928 &mut buffer_buf_size,
13929 keep_in_name.as_ptr(),
13930 keep_in,
13931 background_in_name.as_ptr(),
13932 background_in,
13933 page_height_in_name.as_ptr(),
13934 page_height_in,
13935 profile_in_name.as_ptr(),
13936 profile_in.as_ptr(),
13937 NULL,
13938 );
13939 utils::result(
13940 vips_op_response,
13941 utils::new_byte_array(buffer_out, buffer_buf_size),
13942 Error::RadsaveBufferError,
13943 )
13944 }
13945}
13946
13947pub fn radsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13952 unsafe {
13953 let inp_in: *mut bindings::VipsImage = inp.ctx;
13954 let target_in: *mut bindings::VipsTarget = target.ctx;
13955
13956 let vips_op_response = bindings::vips_radsave_target(inp_in, target_in, NULL);
13957 utils::result(vips_op_response, (), Error::RadsaveTargetError)
13958 }
13959}
13960
13961#[derive(Clone, Debug)]
13963pub struct RadsaveTargetOptions {
13964 pub keep: ForeignKeep,
13974 pub background: Vec<f64>,
13976 pub page_height: i32,
13979 pub profile: String,
13981}
13982
13983impl std::default::Default for RadsaveTargetOptions {
13984 fn default() -> Self {
13985 RadsaveTargetOptions {
13986 keep: ForeignKeep::All,
13987 background: Vec::new(),
13988 page_height: i32::from(0),
13989 profile: String::from("sRGB"),
13990 }
13991 }
13992}
13993
13994pub fn radsave_target_with_opts(
14000 inp: &VipsImage,
14001 target: &VipsTarget,
14002 radsave_target_options: &RadsaveTargetOptions,
14003) -> Result<()> {
14004 unsafe {
14005 let inp_in: *mut bindings::VipsImage = inp.ctx;
14006 let target_in: *mut bindings::VipsTarget = target.ctx;
14007
14008 let keep_in: i32 = radsave_target_options.keep as i32;
14009 let keep_in_name = utils::new_c_string("keep")?;
14010
14011 let background_wrapper =
14012 utils::VipsArrayDoubleWrapper::from(&radsave_target_options.background[..]);
14013 let background_in = background_wrapper.ctx;
14014 let background_in_name = utils::new_c_string("background")?;
14015
14016 let page_height_in: i32 = radsave_target_options.page_height;
14017 let page_height_in_name = utils::new_c_string("page-height")?;
14018
14019 let profile_in: CString = utils::new_c_string(&radsave_target_options.profile)?;
14020 let profile_in_name = utils::new_c_string("profile")?;
14021
14022 let vips_op_response = bindings::vips_radsave_target(
14023 inp_in,
14024 target_in,
14025 keep_in_name.as_ptr(),
14026 keep_in,
14027 background_in_name.as_ptr(),
14028 background_in,
14029 page_height_in_name.as_ptr(),
14030 page_height_in,
14031 profile_in_name.as_ptr(),
14032 profile_in.as_ptr(),
14033 NULL,
14034 );
14035 utils::result(vips_op_response, (), Error::RadsaveTargetError)
14036 }
14037}
14038
14039pub fn gifsave(inp: &VipsImage, filename: &str) -> Result<()> {
14044 unsafe {
14045 let inp_in: *mut bindings::VipsImage = inp.ctx;
14046 let filename_in: CString = utils::new_c_string(filename)?;
14047
14048 let vips_op_response = bindings::vips_gifsave(inp_in, filename_in.as_ptr(), NULL);
14049 utils::result(vips_op_response, (), Error::GifsaveError)
14050 }
14051}
14052
14053#[derive(Clone, Debug)]
14055pub struct GifsaveOptions {
14056 pub dither: f64,
14059 pub effort: i32,
14062 pub bitdepth: i32,
14065 pub interframe_maxerror: f64,
14068 pub reuse: bool,
14071 pub interpalette_maxerror: f64,
14074 pub interlace: bool,
14077 pub keep_duplicate_frames: bool,
14080 pub keep: ForeignKeep,
14090 pub background: Vec<f64>,
14092 pub page_height: i32,
14095 pub profile: String,
14097}
14098
14099impl std::default::Default for GifsaveOptions {
14100 fn default() -> Self {
14101 GifsaveOptions {
14102 dither: f64::from(1),
14103 effort: i32::from(7),
14104 bitdepth: i32::from(8),
14105 interframe_maxerror: f64::from(0),
14106 reuse: false,
14107 interpalette_maxerror: f64::from(3),
14108 interlace: false,
14109 keep_duplicate_frames: false,
14110 keep: ForeignKeep::All,
14111 background: Vec::new(),
14112 page_height: i32::from(0),
14113 profile: String::from("sRGB"),
14114 }
14115 }
14116}
14117
14118pub fn gifsave_with_opts(
14124 inp: &VipsImage,
14125 filename: &str,
14126 gifsave_options: &GifsaveOptions,
14127) -> Result<()> {
14128 unsafe {
14129 let inp_in: *mut bindings::VipsImage = inp.ctx;
14130 let filename_in: CString = utils::new_c_string(filename)?;
14131
14132 let dither_in: f64 = gifsave_options.dither;
14133 let dither_in_name = utils::new_c_string("dither")?;
14134
14135 let effort_in: i32 = gifsave_options.effort;
14136 let effort_in_name = utils::new_c_string("effort")?;
14137
14138 let bitdepth_in: i32 = gifsave_options.bitdepth;
14139 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14140
14141 let interframe_maxerror_in: f64 = gifsave_options.interframe_maxerror;
14142 let interframe_maxerror_in_name = utils::new_c_string("interframe-maxerror")?;
14143
14144 let reuse_in: i32 = if gifsave_options.reuse { 1 } else { 0 };
14145 let reuse_in_name = utils::new_c_string("reuse")?;
14146
14147 let interpalette_maxerror_in: f64 = gifsave_options.interpalette_maxerror;
14148 let interpalette_maxerror_in_name = utils::new_c_string("interpalette-maxerror")?;
14149
14150 let interlace_in: i32 = if gifsave_options.interlace { 1 } else { 0 };
14151 let interlace_in_name = utils::new_c_string("interlace")?;
14152
14153 let keep_duplicate_frames_in: i32 = if gifsave_options.keep_duplicate_frames {
14154 1
14155 } else {
14156 0
14157 };
14158 let keep_duplicate_frames_in_name = utils::new_c_string("keep-duplicate-frames")?;
14159
14160 let keep_in: i32 = gifsave_options.keep as i32;
14161 let keep_in_name = utils::new_c_string("keep")?;
14162
14163 let background_wrapper =
14164 utils::VipsArrayDoubleWrapper::from(&gifsave_options.background[..]);
14165 let background_in = background_wrapper.ctx;
14166 let background_in_name = utils::new_c_string("background")?;
14167
14168 let page_height_in: i32 = gifsave_options.page_height;
14169 let page_height_in_name = utils::new_c_string("page-height")?;
14170
14171 let profile_in: CString = utils::new_c_string(&gifsave_options.profile)?;
14172 let profile_in_name = utils::new_c_string("profile")?;
14173
14174 let vips_op_response = bindings::vips_gifsave(
14175 inp_in,
14176 filename_in.as_ptr(),
14177 dither_in_name.as_ptr(),
14178 dither_in,
14179 effort_in_name.as_ptr(),
14180 effort_in,
14181 bitdepth_in_name.as_ptr(),
14182 bitdepth_in,
14183 interframe_maxerror_in_name.as_ptr(),
14184 interframe_maxerror_in,
14185 reuse_in_name.as_ptr(),
14186 reuse_in,
14187 interpalette_maxerror_in_name.as_ptr(),
14188 interpalette_maxerror_in,
14189 interlace_in_name.as_ptr(),
14190 interlace_in,
14191 keep_duplicate_frames_in_name.as_ptr(),
14192 keep_duplicate_frames_in,
14193 keep_in_name.as_ptr(),
14194 keep_in,
14195 background_in_name.as_ptr(),
14196 background_in,
14197 page_height_in_name.as_ptr(),
14198 page_height_in,
14199 profile_in_name.as_ptr(),
14200 profile_in.as_ptr(),
14201 NULL,
14202 );
14203 utils::result(vips_op_response, (), Error::GifsaveError)
14204 }
14205}
14206
14207pub fn gifsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
14211 unsafe {
14212 let inp_in: *mut bindings::VipsImage = inp.ctx;
14213 let mut buffer_buf_size: u64 = 0;
14214 let mut buffer_out: *mut c_void = null_mut();
14215
14216 let vips_op_response =
14217 bindings::vips_gifsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
14218 utils::result(
14219 vips_op_response,
14220 utils::new_byte_array(buffer_out, buffer_buf_size),
14221 Error::GifsaveBufferError,
14222 )
14223 }
14224}
14225
14226#[derive(Clone, Debug)]
14228pub struct GifsaveBufferOptions {
14229 pub dither: f64,
14232 pub effort: i32,
14235 pub bitdepth: i32,
14238 pub interframe_maxerror: f64,
14241 pub reuse: bool,
14244 pub interpalette_maxerror: f64,
14247 pub interlace: bool,
14250 pub keep_duplicate_frames: bool,
14253 pub keep: ForeignKeep,
14263 pub background: Vec<f64>,
14265 pub page_height: i32,
14268 pub profile: String,
14270}
14271
14272impl std::default::Default for GifsaveBufferOptions {
14273 fn default() -> Self {
14274 GifsaveBufferOptions {
14275 dither: f64::from(1),
14276 effort: i32::from(7),
14277 bitdepth: i32::from(8),
14278 interframe_maxerror: f64::from(0),
14279 reuse: false,
14280 interpalette_maxerror: f64::from(3),
14281 interlace: false,
14282 keep_duplicate_frames: false,
14283 keep: ForeignKeep::All,
14284 background: Vec::new(),
14285 page_height: i32::from(0),
14286 profile: String::from("sRGB"),
14287 }
14288 }
14289}
14290
14291pub fn gifsave_buffer_with_opts(
14296 inp: &VipsImage,
14297 gifsave_buffer_options: &GifsaveBufferOptions,
14298) -> Result<Vec<u8>> {
14299 unsafe {
14300 let inp_in: *mut bindings::VipsImage = inp.ctx;
14301 let mut buffer_buf_size: u64 = 0;
14302 let mut buffer_out: *mut c_void = null_mut();
14303
14304 let dither_in: f64 = gifsave_buffer_options.dither;
14305 let dither_in_name = utils::new_c_string("dither")?;
14306
14307 let effort_in: i32 = gifsave_buffer_options.effort;
14308 let effort_in_name = utils::new_c_string("effort")?;
14309
14310 let bitdepth_in: i32 = gifsave_buffer_options.bitdepth;
14311 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14312
14313 let interframe_maxerror_in: f64 = gifsave_buffer_options.interframe_maxerror;
14314 let interframe_maxerror_in_name = utils::new_c_string("interframe-maxerror")?;
14315
14316 let reuse_in: i32 = if gifsave_buffer_options.reuse { 1 } else { 0 };
14317 let reuse_in_name = utils::new_c_string("reuse")?;
14318
14319 let interpalette_maxerror_in: f64 = gifsave_buffer_options.interpalette_maxerror;
14320 let interpalette_maxerror_in_name = utils::new_c_string("interpalette-maxerror")?;
14321
14322 let interlace_in: i32 = if gifsave_buffer_options.interlace {
14323 1
14324 } else {
14325 0
14326 };
14327 let interlace_in_name = utils::new_c_string("interlace")?;
14328
14329 let keep_duplicate_frames_in: i32 = if gifsave_buffer_options.keep_duplicate_frames {
14330 1
14331 } else {
14332 0
14333 };
14334 let keep_duplicate_frames_in_name = utils::new_c_string("keep-duplicate-frames")?;
14335
14336 let keep_in: i32 = gifsave_buffer_options.keep as i32;
14337 let keep_in_name = utils::new_c_string("keep")?;
14338
14339 let background_wrapper =
14340 utils::VipsArrayDoubleWrapper::from(&gifsave_buffer_options.background[..]);
14341 let background_in = background_wrapper.ctx;
14342 let background_in_name = utils::new_c_string("background")?;
14343
14344 let page_height_in: i32 = gifsave_buffer_options.page_height;
14345 let page_height_in_name = utils::new_c_string("page-height")?;
14346
14347 let profile_in: CString = utils::new_c_string(&gifsave_buffer_options.profile)?;
14348 let profile_in_name = utils::new_c_string("profile")?;
14349
14350 let vips_op_response = bindings::vips_gifsave_buffer(
14351 inp_in,
14352 &mut buffer_out,
14353 &mut buffer_buf_size,
14354 dither_in_name.as_ptr(),
14355 dither_in,
14356 effort_in_name.as_ptr(),
14357 effort_in,
14358 bitdepth_in_name.as_ptr(),
14359 bitdepth_in,
14360 interframe_maxerror_in_name.as_ptr(),
14361 interframe_maxerror_in,
14362 reuse_in_name.as_ptr(),
14363 reuse_in,
14364 interpalette_maxerror_in_name.as_ptr(),
14365 interpalette_maxerror_in,
14366 interlace_in_name.as_ptr(),
14367 interlace_in,
14368 keep_duplicate_frames_in_name.as_ptr(),
14369 keep_duplicate_frames_in,
14370 keep_in_name.as_ptr(),
14371 keep_in,
14372 background_in_name.as_ptr(),
14373 background_in,
14374 page_height_in_name.as_ptr(),
14375 page_height_in,
14376 profile_in_name.as_ptr(),
14377 profile_in.as_ptr(),
14378 NULL,
14379 );
14380 utils::result(
14381 vips_op_response,
14382 utils::new_byte_array(buffer_out, buffer_buf_size),
14383 Error::GifsaveBufferError,
14384 )
14385 }
14386}
14387
14388pub fn gifsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
14393 unsafe {
14394 let inp_in: *mut bindings::VipsImage = inp.ctx;
14395 let target_in: *mut bindings::VipsTarget = target.ctx;
14396
14397 let vips_op_response = bindings::vips_gifsave_target(inp_in, target_in, NULL);
14398 utils::result(vips_op_response, (), Error::GifsaveTargetError)
14399 }
14400}
14401
14402#[derive(Clone, Debug)]
14404pub struct GifsaveTargetOptions {
14405 pub dither: f64,
14408 pub effort: i32,
14411 pub bitdepth: i32,
14414 pub interframe_maxerror: f64,
14417 pub reuse: bool,
14420 pub interpalette_maxerror: f64,
14423 pub interlace: bool,
14426 pub keep_duplicate_frames: bool,
14429 pub keep: ForeignKeep,
14439 pub background: Vec<f64>,
14441 pub page_height: i32,
14444 pub profile: String,
14446}
14447
14448impl std::default::Default for GifsaveTargetOptions {
14449 fn default() -> Self {
14450 GifsaveTargetOptions {
14451 dither: f64::from(1),
14452 effort: i32::from(7),
14453 bitdepth: i32::from(8),
14454 interframe_maxerror: f64::from(0),
14455 reuse: false,
14456 interpalette_maxerror: f64::from(3),
14457 interlace: false,
14458 keep_duplicate_frames: false,
14459 keep: ForeignKeep::All,
14460 background: Vec::new(),
14461 page_height: i32::from(0),
14462 profile: String::from("sRGB"),
14463 }
14464 }
14465}
14466
14467pub fn gifsave_target_with_opts(
14473 inp: &VipsImage,
14474 target: &VipsTarget,
14475 gifsave_target_options: &GifsaveTargetOptions,
14476) -> Result<()> {
14477 unsafe {
14478 let inp_in: *mut bindings::VipsImage = inp.ctx;
14479 let target_in: *mut bindings::VipsTarget = target.ctx;
14480
14481 let dither_in: f64 = gifsave_target_options.dither;
14482 let dither_in_name = utils::new_c_string("dither")?;
14483
14484 let effort_in: i32 = gifsave_target_options.effort;
14485 let effort_in_name = utils::new_c_string("effort")?;
14486
14487 let bitdepth_in: i32 = gifsave_target_options.bitdepth;
14488 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14489
14490 let interframe_maxerror_in: f64 = gifsave_target_options.interframe_maxerror;
14491 let interframe_maxerror_in_name = utils::new_c_string("interframe-maxerror")?;
14492
14493 let reuse_in: i32 = if gifsave_target_options.reuse { 1 } else { 0 };
14494 let reuse_in_name = utils::new_c_string("reuse")?;
14495
14496 let interpalette_maxerror_in: f64 = gifsave_target_options.interpalette_maxerror;
14497 let interpalette_maxerror_in_name = utils::new_c_string("interpalette-maxerror")?;
14498
14499 let interlace_in: i32 = if gifsave_target_options.interlace {
14500 1
14501 } else {
14502 0
14503 };
14504 let interlace_in_name = utils::new_c_string("interlace")?;
14505
14506 let keep_duplicate_frames_in: i32 = if gifsave_target_options.keep_duplicate_frames {
14507 1
14508 } else {
14509 0
14510 };
14511 let keep_duplicate_frames_in_name = utils::new_c_string("keep-duplicate-frames")?;
14512
14513 let keep_in: i32 = gifsave_target_options.keep as i32;
14514 let keep_in_name = utils::new_c_string("keep")?;
14515
14516 let background_wrapper =
14517 utils::VipsArrayDoubleWrapper::from(&gifsave_target_options.background[..]);
14518 let background_in = background_wrapper.ctx;
14519 let background_in_name = utils::new_c_string("background")?;
14520
14521 let page_height_in: i32 = gifsave_target_options.page_height;
14522 let page_height_in_name = utils::new_c_string("page-height")?;
14523
14524 let profile_in: CString = utils::new_c_string(&gifsave_target_options.profile)?;
14525 let profile_in_name = utils::new_c_string("profile")?;
14526
14527 let vips_op_response = bindings::vips_gifsave_target(
14528 inp_in,
14529 target_in,
14530 dither_in_name.as_ptr(),
14531 dither_in,
14532 effort_in_name.as_ptr(),
14533 effort_in,
14534 bitdepth_in_name.as_ptr(),
14535 bitdepth_in,
14536 interframe_maxerror_in_name.as_ptr(),
14537 interframe_maxerror_in,
14538 reuse_in_name.as_ptr(),
14539 reuse_in,
14540 interpalette_maxerror_in_name.as_ptr(),
14541 interpalette_maxerror_in,
14542 interlace_in_name.as_ptr(),
14543 interlace_in,
14544 keep_duplicate_frames_in_name.as_ptr(),
14545 keep_duplicate_frames_in,
14546 keep_in_name.as_ptr(),
14547 keep_in,
14548 background_in_name.as_ptr(),
14549 background_in,
14550 page_height_in_name.as_ptr(),
14551 page_height_in,
14552 profile_in_name.as_ptr(),
14553 profile_in.as_ptr(),
14554 NULL,
14555 );
14556 utils::result(vips_op_response, (), Error::GifsaveTargetError)
14557 }
14558}
14559
14560pub fn pngsave(inp: &VipsImage, filename: &str) -> Result<()> {
14565 unsafe {
14566 let inp_in: *mut bindings::VipsImage = inp.ctx;
14567 let filename_in: CString = utils::new_c_string(filename)?;
14568
14569 let vips_op_response = bindings::vips_pngsave(inp_in, filename_in.as_ptr(), NULL);
14570 utils::result(vips_op_response, (), Error::PngsaveError)
14571 }
14572}
14573
14574#[derive(Clone, Debug)]
14576pub struct PngsaveOptions {
14577 pub compression: i32,
14580 pub interlace: bool,
14583 pub filter: ForeignPngFilter,
14591 pub palette: bool,
14594 pub q: i32,
14597 pub dither: f64,
14600 pub bitdepth: i32,
14603 pub effort: i32,
14606 pub keep: ForeignKeep,
14616 pub background: Vec<f64>,
14618 pub page_height: i32,
14621 pub profile: String,
14623}
14624
14625impl std::default::Default for PngsaveOptions {
14626 fn default() -> Self {
14627 PngsaveOptions {
14628 compression: i32::from(6),
14629 interlace: false,
14630 filter: ForeignPngFilter::None,
14631 palette: false,
14632 q: i32::from(100),
14633 dither: f64::from(1),
14634 bitdepth: i32::from(8),
14635 effort: i32::from(7),
14636 keep: ForeignKeep::All,
14637 background: Vec::new(),
14638 page_height: i32::from(0),
14639 profile: String::from("sRGB"),
14640 }
14641 }
14642}
14643
14644pub fn pngsave_with_opts(
14650 inp: &VipsImage,
14651 filename: &str,
14652 pngsave_options: &PngsaveOptions,
14653) -> Result<()> {
14654 unsafe {
14655 let inp_in: *mut bindings::VipsImage = inp.ctx;
14656 let filename_in: CString = utils::new_c_string(filename)?;
14657
14658 let compression_in: i32 = pngsave_options.compression;
14659 let compression_in_name = utils::new_c_string("compression")?;
14660
14661 let interlace_in: i32 = if pngsave_options.interlace { 1 } else { 0 };
14662 let interlace_in_name = utils::new_c_string("interlace")?;
14663
14664 let filter_in: i32 = pngsave_options.filter as i32;
14665 let filter_in_name = utils::new_c_string("filter")?;
14666
14667 let palette_in: i32 = if pngsave_options.palette { 1 } else { 0 };
14668 let palette_in_name = utils::new_c_string("palette")?;
14669
14670 let q_in: i32 = pngsave_options.q;
14671 let q_in_name = utils::new_c_string("Q")?;
14672
14673 let dither_in: f64 = pngsave_options.dither;
14674 let dither_in_name = utils::new_c_string("dither")?;
14675
14676 let bitdepth_in: i32 = pngsave_options.bitdepth;
14677 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14678
14679 let effort_in: i32 = pngsave_options.effort;
14680 let effort_in_name = utils::new_c_string("effort")?;
14681
14682 let keep_in: i32 = pngsave_options.keep as i32;
14683 let keep_in_name = utils::new_c_string("keep")?;
14684
14685 let background_wrapper =
14686 utils::VipsArrayDoubleWrapper::from(&pngsave_options.background[..]);
14687 let background_in = background_wrapper.ctx;
14688 let background_in_name = utils::new_c_string("background")?;
14689
14690 let page_height_in: i32 = pngsave_options.page_height;
14691 let page_height_in_name = utils::new_c_string("page-height")?;
14692
14693 let profile_in: CString = utils::new_c_string(&pngsave_options.profile)?;
14694 let profile_in_name = utils::new_c_string("profile")?;
14695
14696 let vips_op_response = bindings::vips_pngsave(
14697 inp_in,
14698 filename_in.as_ptr(),
14699 compression_in_name.as_ptr(),
14700 compression_in,
14701 interlace_in_name.as_ptr(),
14702 interlace_in,
14703 filter_in_name.as_ptr(),
14704 filter_in,
14705 palette_in_name.as_ptr(),
14706 palette_in,
14707 q_in_name.as_ptr(),
14708 q_in,
14709 dither_in_name.as_ptr(),
14710 dither_in,
14711 bitdepth_in_name.as_ptr(),
14712 bitdepth_in,
14713 effort_in_name.as_ptr(),
14714 effort_in,
14715 keep_in_name.as_ptr(),
14716 keep_in,
14717 background_in_name.as_ptr(),
14718 background_in,
14719 page_height_in_name.as_ptr(),
14720 page_height_in,
14721 profile_in_name.as_ptr(),
14722 profile_in.as_ptr(),
14723 NULL,
14724 );
14725 utils::result(vips_op_response, (), Error::PngsaveError)
14726 }
14727}
14728
14729pub fn pngsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
14733 unsafe {
14734 let inp_in: *mut bindings::VipsImage = inp.ctx;
14735 let mut buffer_buf_size: u64 = 0;
14736 let mut buffer_out: *mut c_void = null_mut();
14737
14738 let vips_op_response =
14739 bindings::vips_pngsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
14740 utils::result(
14741 vips_op_response,
14742 utils::new_byte_array(buffer_out, buffer_buf_size),
14743 Error::PngsaveBufferError,
14744 )
14745 }
14746}
14747
14748#[derive(Clone, Debug)]
14750pub struct PngsaveBufferOptions {
14751 pub compression: i32,
14754 pub interlace: bool,
14757 pub filter: ForeignPngFilter,
14765 pub palette: bool,
14768 pub q: i32,
14771 pub dither: f64,
14774 pub bitdepth: i32,
14777 pub effort: i32,
14780 pub keep: ForeignKeep,
14790 pub background: Vec<f64>,
14792 pub page_height: i32,
14795 pub profile: String,
14797}
14798
14799impl std::default::Default for PngsaveBufferOptions {
14800 fn default() -> Self {
14801 PngsaveBufferOptions {
14802 compression: i32::from(6),
14803 interlace: false,
14804 filter: ForeignPngFilter::None,
14805 palette: false,
14806 q: i32::from(100),
14807 dither: f64::from(1),
14808 bitdepth: i32::from(8),
14809 effort: i32::from(7),
14810 keep: ForeignKeep::All,
14811 background: Vec::new(),
14812 page_height: i32::from(0),
14813 profile: String::from("sRGB"),
14814 }
14815 }
14816}
14817
14818pub fn pngsave_buffer_with_opts(
14823 inp: &VipsImage,
14824 pngsave_buffer_options: &PngsaveBufferOptions,
14825) -> Result<Vec<u8>> {
14826 unsafe {
14827 let inp_in: *mut bindings::VipsImage = inp.ctx;
14828 let mut buffer_buf_size: u64 = 0;
14829 let mut buffer_out: *mut c_void = null_mut();
14830
14831 let compression_in: i32 = pngsave_buffer_options.compression;
14832 let compression_in_name = utils::new_c_string("compression")?;
14833
14834 let interlace_in: i32 = if pngsave_buffer_options.interlace {
14835 1
14836 } else {
14837 0
14838 };
14839 let interlace_in_name = utils::new_c_string("interlace")?;
14840
14841 let filter_in: i32 = pngsave_buffer_options.filter as i32;
14842 let filter_in_name = utils::new_c_string("filter")?;
14843
14844 let palette_in: i32 = if pngsave_buffer_options.palette { 1 } else { 0 };
14845 let palette_in_name = utils::new_c_string("palette")?;
14846
14847 let q_in: i32 = pngsave_buffer_options.q;
14848 let q_in_name = utils::new_c_string("Q")?;
14849
14850 let dither_in: f64 = pngsave_buffer_options.dither;
14851 let dither_in_name = utils::new_c_string("dither")?;
14852
14853 let bitdepth_in: i32 = pngsave_buffer_options.bitdepth;
14854 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14855
14856 let effort_in: i32 = pngsave_buffer_options.effort;
14857 let effort_in_name = utils::new_c_string("effort")?;
14858
14859 let keep_in: i32 = pngsave_buffer_options.keep as i32;
14860 let keep_in_name = utils::new_c_string("keep")?;
14861
14862 let background_wrapper =
14863 utils::VipsArrayDoubleWrapper::from(&pngsave_buffer_options.background[..]);
14864 let background_in = background_wrapper.ctx;
14865 let background_in_name = utils::new_c_string("background")?;
14866
14867 let page_height_in: i32 = pngsave_buffer_options.page_height;
14868 let page_height_in_name = utils::new_c_string("page-height")?;
14869
14870 let profile_in: CString = utils::new_c_string(&pngsave_buffer_options.profile)?;
14871 let profile_in_name = utils::new_c_string("profile")?;
14872
14873 let vips_op_response = bindings::vips_pngsave_buffer(
14874 inp_in,
14875 &mut buffer_out,
14876 &mut buffer_buf_size,
14877 compression_in_name.as_ptr(),
14878 compression_in,
14879 interlace_in_name.as_ptr(),
14880 interlace_in,
14881 filter_in_name.as_ptr(),
14882 filter_in,
14883 palette_in_name.as_ptr(),
14884 palette_in,
14885 q_in_name.as_ptr(),
14886 q_in,
14887 dither_in_name.as_ptr(),
14888 dither_in,
14889 bitdepth_in_name.as_ptr(),
14890 bitdepth_in,
14891 effort_in_name.as_ptr(),
14892 effort_in,
14893 keep_in_name.as_ptr(),
14894 keep_in,
14895 background_in_name.as_ptr(),
14896 background_in,
14897 page_height_in_name.as_ptr(),
14898 page_height_in,
14899 profile_in_name.as_ptr(),
14900 profile_in.as_ptr(),
14901 NULL,
14902 );
14903 utils::result(
14904 vips_op_response,
14905 utils::new_byte_array(buffer_out, buffer_buf_size),
14906 Error::PngsaveBufferError,
14907 )
14908 }
14909}
14910
14911pub fn pngsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
14916 unsafe {
14917 let inp_in: *mut bindings::VipsImage = inp.ctx;
14918 let target_in: *mut bindings::VipsTarget = target.ctx;
14919
14920 let vips_op_response = bindings::vips_pngsave_target(inp_in, target_in, NULL);
14921 utils::result(vips_op_response, (), Error::PngsaveTargetError)
14922 }
14923}
14924
14925#[derive(Clone, Debug)]
14927pub struct PngsaveTargetOptions {
14928 pub compression: i32,
14931 pub interlace: bool,
14934 pub filter: ForeignPngFilter,
14942 pub palette: bool,
14945 pub q: i32,
14948 pub dither: f64,
14951 pub bitdepth: i32,
14954 pub effort: i32,
14957 pub keep: ForeignKeep,
14967 pub background: Vec<f64>,
14969 pub page_height: i32,
14972 pub profile: String,
14974}
14975
14976impl std::default::Default for PngsaveTargetOptions {
14977 fn default() -> Self {
14978 PngsaveTargetOptions {
14979 compression: i32::from(6),
14980 interlace: false,
14981 filter: ForeignPngFilter::None,
14982 palette: false,
14983 q: i32::from(100),
14984 dither: f64::from(1),
14985 bitdepth: i32::from(8),
14986 effort: i32::from(7),
14987 keep: ForeignKeep::All,
14988 background: Vec::new(),
14989 page_height: i32::from(0),
14990 profile: String::from("sRGB"),
14991 }
14992 }
14993}
14994
14995pub fn pngsave_target_with_opts(
15001 inp: &VipsImage,
15002 target: &VipsTarget,
15003 pngsave_target_options: &PngsaveTargetOptions,
15004) -> Result<()> {
15005 unsafe {
15006 let inp_in: *mut bindings::VipsImage = inp.ctx;
15007 let target_in: *mut bindings::VipsTarget = target.ctx;
15008
15009 let compression_in: i32 = pngsave_target_options.compression;
15010 let compression_in_name = utils::new_c_string("compression")?;
15011
15012 let interlace_in: i32 = if pngsave_target_options.interlace {
15013 1
15014 } else {
15015 0
15016 };
15017 let interlace_in_name = utils::new_c_string("interlace")?;
15018
15019 let filter_in: i32 = pngsave_target_options.filter as i32;
15020 let filter_in_name = utils::new_c_string("filter")?;
15021
15022 let palette_in: i32 = if pngsave_target_options.palette { 1 } else { 0 };
15023 let palette_in_name = utils::new_c_string("palette")?;
15024
15025 let q_in: i32 = pngsave_target_options.q;
15026 let q_in_name = utils::new_c_string("Q")?;
15027
15028 let dither_in: f64 = pngsave_target_options.dither;
15029 let dither_in_name = utils::new_c_string("dither")?;
15030
15031 let bitdepth_in: i32 = pngsave_target_options.bitdepth;
15032 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
15033
15034 let effort_in: i32 = pngsave_target_options.effort;
15035 let effort_in_name = utils::new_c_string("effort")?;
15036
15037 let keep_in: i32 = pngsave_target_options.keep as i32;
15038 let keep_in_name = utils::new_c_string("keep")?;
15039
15040 let background_wrapper =
15041 utils::VipsArrayDoubleWrapper::from(&pngsave_target_options.background[..]);
15042 let background_in = background_wrapper.ctx;
15043 let background_in_name = utils::new_c_string("background")?;
15044
15045 let page_height_in: i32 = pngsave_target_options.page_height;
15046 let page_height_in_name = utils::new_c_string("page-height")?;
15047
15048 let profile_in: CString = utils::new_c_string(&pngsave_target_options.profile)?;
15049 let profile_in_name = utils::new_c_string("profile")?;
15050
15051 let vips_op_response = bindings::vips_pngsave_target(
15052 inp_in,
15053 target_in,
15054 compression_in_name.as_ptr(),
15055 compression_in,
15056 interlace_in_name.as_ptr(),
15057 interlace_in,
15058 filter_in_name.as_ptr(),
15059 filter_in,
15060 palette_in_name.as_ptr(),
15061 palette_in,
15062 q_in_name.as_ptr(),
15063 q_in,
15064 dither_in_name.as_ptr(),
15065 dither_in,
15066 bitdepth_in_name.as_ptr(),
15067 bitdepth_in,
15068 effort_in_name.as_ptr(),
15069 effort_in,
15070 keep_in_name.as_ptr(),
15071 keep_in,
15072 background_in_name.as_ptr(),
15073 background_in,
15074 page_height_in_name.as_ptr(),
15075 page_height_in,
15076 profile_in_name.as_ptr(),
15077 profile_in.as_ptr(),
15078 NULL,
15079 );
15080 utils::result(vips_op_response, (), Error::PngsaveTargetError)
15081 }
15082}
15083
15084pub fn jpegsave(inp: &VipsImage, filename: &str) -> Result<()> {
15089 unsafe {
15090 let inp_in: *mut bindings::VipsImage = inp.ctx;
15091 let filename_in: CString = utils::new_c_string(filename)?;
15092
15093 let vips_op_response = bindings::vips_jpegsave(inp_in, filename_in.as_ptr(), NULL);
15094 utils::result(vips_op_response, (), Error::JpegsaveError)
15095 }
15096}
15097
15098#[derive(Clone, Debug)]
15100pub struct JpegsaveOptions {
15101 pub q: i32,
15104 pub optimize_coding: bool,
15107 pub interlace: bool,
15110 pub trellis_quant: bool,
15113 pub overshoot_deringing: bool,
15116 pub optimize_scans: bool,
15119 pub quant_table: i32,
15122 pub subsample_mode: ForeignSubsample,
15127 pub restart_interval: i32,
15130 pub keep: ForeignKeep,
15140 pub background: Vec<f64>,
15142 pub page_height: i32,
15145 pub profile: String,
15147}
15148
15149impl std::default::Default for JpegsaveOptions {
15150 fn default() -> Self {
15151 JpegsaveOptions {
15152 q: i32::from(75),
15153 optimize_coding: false,
15154 interlace: false,
15155 trellis_quant: false,
15156 overshoot_deringing: false,
15157 optimize_scans: false,
15158 quant_table: i32::from(0),
15159 subsample_mode: ForeignSubsample::Auto,
15160 restart_interval: i32::from(0),
15161 keep: ForeignKeep::All,
15162 background: Vec::new(),
15163 page_height: i32::from(0),
15164 profile: String::from("sRGB"),
15165 }
15166 }
15167}
15168
15169pub fn jpegsave_with_opts(
15175 inp: &VipsImage,
15176 filename: &str,
15177 jpegsave_options: &JpegsaveOptions,
15178) -> Result<()> {
15179 unsafe {
15180 let inp_in: *mut bindings::VipsImage = inp.ctx;
15181 let filename_in: CString = utils::new_c_string(filename)?;
15182
15183 let q_in: i32 = jpegsave_options.q;
15184 let q_in_name = utils::new_c_string("Q")?;
15185
15186 let optimize_coding_in: i32 = if jpegsave_options.optimize_coding {
15187 1
15188 } else {
15189 0
15190 };
15191 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15192
15193 let interlace_in: i32 = if jpegsave_options.interlace { 1 } else { 0 };
15194 let interlace_in_name = utils::new_c_string("interlace")?;
15195
15196 let trellis_quant_in: i32 = if jpegsave_options.trellis_quant { 1 } else { 0 };
15197 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15198
15199 let overshoot_deringing_in: i32 = if jpegsave_options.overshoot_deringing {
15200 1
15201 } else {
15202 0
15203 };
15204 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15205
15206 let optimize_scans_in: i32 = if jpegsave_options.optimize_scans {
15207 1
15208 } else {
15209 0
15210 };
15211 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15212
15213 let quant_table_in: i32 = jpegsave_options.quant_table;
15214 let quant_table_in_name = utils::new_c_string("quant-table")?;
15215
15216 let subsample_mode_in: i32 = jpegsave_options.subsample_mode as i32;
15217 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15218
15219 let restart_interval_in: i32 = jpegsave_options.restart_interval;
15220 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15221
15222 let keep_in: i32 = jpegsave_options.keep as i32;
15223 let keep_in_name = utils::new_c_string("keep")?;
15224
15225 let background_wrapper =
15226 utils::VipsArrayDoubleWrapper::from(&jpegsave_options.background[..]);
15227 let background_in = background_wrapper.ctx;
15228 let background_in_name = utils::new_c_string("background")?;
15229
15230 let page_height_in: i32 = jpegsave_options.page_height;
15231 let page_height_in_name = utils::new_c_string("page-height")?;
15232
15233 let profile_in: CString = utils::new_c_string(&jpegsave_options.profile)?;
15234 let profile_in_name = utils::new_c_string("profile")?;
15235
15236 let vips_op_response = bindings::vips_jpegsave(
15237 inp_in,
15238 filename_in.as_ptr(),
15239 q_in_name.as_ptr(),
15240 q_in,
15241 optimize_coding_in_name.as_ptr(),
15242 optimize_coding_in,
15243 interlace_in_name.as_ptr(),
15244 interlace_in,
15245 trellis_quant_in_name.as_ptr(),
15246 trellis_quant_in,
15247 overshoot_deringing_in_name.as_ptr(),
15248 overshoot_deringing_in,
15249 optimize_scans_in_name.as_ptr(),
15250 optimize_scans_in,
15251 quant_table_in_name.as_ptr(),
15252 quant_table_in,
15253 subsample_mode_in_name.as_ptr(),
15254 subsample_mode_in,
15255 restart_interval_in_name.as_ptr(),
15256 restart_interval_in,
15257 keep_in_name.as_ptr(),
15258 keep_in,
15259 background_in_name.as_ptr(),
15260 background_in,
15261 page_height_in_name.as_ptr(),
15262 page_height_in,
15263 profile_in_name.as_ptr(),
15264 profile_in.as_ptr(),
15265 NULL,
15266 );
15267 utils::result(vips_op_response, (), Error::JpegsaveError)
15268 }
15269}
15270
15271pub fn jpegsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
15275 unsafe {
15276 let inp_in: *mut bindings::VipsImage = inp.ctx;
15277 let mut buffer_buf_size: u64 = 0;
15278 let mut buffer_out: *mut c_void = null_mut();
15279
15280 let vips_op_response =
15281 bindings::vips_jpegsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
15282 utils::result(
15283 vips_op_response,
15284 utils::new_byte_array(buffer_out, buffer_buf_size),
15285 Error::JpegsaveBufferError,
15286 )
15287 }
15288}
15289
15290#[derive(Clone, Debug)]
15292pub struct JpegsaveBufferOptions {
15293 pub q: i32,
15296 pub optimize_coding: bool,
15299 pub interlace: bool,
15302 pub trellis_quant: bool,
15305 pub overshoot_deringing: bool,
15308 pub optimize_scans: bool,
15311 pub quant_table: i32,
15314 pub subsample_mode: ForeignSubsample,
15319 pub restart_interval: i32,
15322 pub keep: ForeignKeep,
15332 pub background: Vec<f64>,
15334 pub page_height: i32,
15337 pub profile: String,
15339}
15340
15341impl std::default::Default for JpegsaveBufferOptions {
15342 fn default() -> Self {
15343 JpegsaveBufferOptions {
15344 q: i32::from(75),
15345 optimize_coding: false,
15346 interlace: false,
15347 trellis_quant: false,
15348 overshoot_deringing: false,
15349 optimize_scans: false,
15350 quant_table: i32::from(0),
15351 subsample_mode: ForeignSubsample::Auto,
15352 restart_interval: i32::from(0),
15353 keep: ForeignKeep::All,
15354 background: Vec::new(),
15355 page_height: i32::from(0),
15356 profile: String::from("sRGB"),
15357 }
15358 }
15359}
15360
15361pub fn jpegsave_buffer_with_opts(
15366 inp: &VipsImage,
15367 jpegsave_buffer_options: &JpegsaveBufferOptions,
15368) -> Result<Vec<u8>> {
15369 unsafe {
15370 let inp_in: *mut bindings::VipsImage = inp.ctx;
15371 let mut buffer_buf_size: u64 = 0;
15372 let mut buffer_out: *mut c_void = null_mut();
15373
15374 let q_in: i32 = jpegsave_buffer_options.q;
15375 let q_in_name = utils::new_c_string("Q")?;
15376
15377 let optimize_coding_in: i32 = if jpegsave_buffer_options.optimize_coding {
15378 1
15379 } else {
15380 0
15381 };
15382 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15383
15384 let interlace_in: i32 = if jpegsave_buffer_options.interlace {
15385 1
15386 } else {
15387 0
15388 };
15389 let interlace_in_name = utils::new_c_string("interlace")?;
15390
15391 let trellis_quant_in: i32 = if jpegsave_buffer_options.trellis_quant {
15392 1
15393 } else {
15394 0
15395 };
15396 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15397
15398 let overshoot_deringing_in: i32 = if jpegsave_buffer_options.overshoot_deringing {
15399 1
15400 } else {
15401 0
15402 };
15403 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15404
15405 let optimize_scans_in: i32 = if jpegsave_buffer_options.optimize_scans {
15406 1
15407 } else {
15408 0
15409 };
15410 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15411
15412 let quant_table_in: i32 = jpegsave_buffer_options.quant_table;
15413 let quant_table_in_name = utils::new_c_string("quant-table")?;
15414
15415 let subsample_mode_in: i32 = jpegsave_buffer_options.subsample_mode as i32;
15416 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15417
15418 let restart_interval_in: i32 = jpegsave_buffer_options.restart_interval;
15419 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15420
15421 let keep_in: i32 = jpegsave_buffer_options.keep as i32;
15422 let keep_in_name = utils::new_c_string("keep")?;
15423
15424 let background_wrapper =
15425 utils::VipsArrayDoubleWrapper::from(&jpegsave_buffer_options.background[..]);
15426 let background_in = background_wrapper.ctx;
15427 let background_in_name = utils::new_c_string("background")?;
15428
15429 let page_height_in: i32 = jpegsave_buffer_options.page_height;
15430 let page_height_in_name = utils::new_c_string("page-height")?;
15431
15432 let profile_in: CString = utils::new_c_string(&jpegsave_buffer_options.profile)?;
15433 let profile_in_name = utils::new_c_string("profile")?;
15434
15435 let vips_op_response = bindings::vips_jpegsave_buffer(
15436 inp_in,
15437 &mut buffer_out,
15438 &mut buffer_buf_size,
15439 q_in_name.as_ptr(),
15440 q_in,
15441 optimize_coding_in_name.as_ptr(),
15442 optimize_coding_in,
15443 interlace_in_name.as_ptr(),
15444 interlace_in,
15445 trellis_quant_in_name.as_ptr(),
15446 trellis_quant_in,
15447 overshoot_deringing_in_name.as_ptr(),
15448 overshoot_deringing_in,
15449 optimize_scans_in_name.as_ptr(),
15450 optimize_scans_in,
15451 quant_table_in_name.as_ptr(),
15452 quant_table_in,
15453 subsample_mode_in_name.as_ptr(),
15454 subsample_mode_in,
15455 restart_interval_in_name.as_ptr(),
15456 restart_interval_in,
15457 keep_in_name.as_ptr(),
15458 keep_in,
15459 background_in_name.as_ptr(),
15460 background_in,
15461 page_height_in_name.as_ptr(),
15462 page_height_in,
15463 profile_in_name.as_ptr(),
15464 profile_in.as_ptr(),
15465 NULL,
15466 );
15467 utils::result(
15468 vips_op_response,
15469 utils::new_byte_array(buffer_out, buffer_buf_size),
15470 Error::JpegsaveBufferError,
15471 )
15472 }
15473}
15474
15475pub fn jpegsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
15480 unsafe {
15481 let inp_in: *mut bindings::VipsImage = inp.ctx;
15482 let target_in: *mut bindings::VipsTarget = target.ctx;
15483
15484 let vips_op_response = bindings::vips_jpegsave_target(inp_in, target_in, NULL);
15485 utils::result(vips_op_response, (), Error::JpegsaveTargetError)
15486 }
15487}
15488
15489#[derive(Clone, Debug)]
15491pub struct JpegsaveTargetOptions {
15492 pub q: i32,
15495 pub optimize_coding: bool,
15498 pub interlace: bool,
15501 pub trellis_quant: bool,
15504 pub overshoot_deringing: bool,
15507 pub optimize_scans: bool,
15510 pub quant_table: i32,
15513 pub subsample_mode: ForeignSubsample,
15518 pub restart_interval: i32,
15521 pub keep: ForeignKeep,
15531 pub background: Vec<f64>,
15533 pub page_height: i32,
15536 pub profile: String,
15538}
15539
15540impl std::default::Default for JpegsaveTargetOptions {
15541 fn default() -> Self {
15542 JpegsaveTargetOptions {
15543 q: i32::from(75),
15544 optimize_coding: false,
15545 interlace: false,
15546 trellis_quant: false,
15547 overshoot_deringing: false,
15548 optimize_scans: false,
15549 quant_table: i32::from(0),
15550 subsample_mode: ForeignSubsample::Auto,
15551 restart_interval: i32::from(0),
15552 keep: ForeignKeep::All,
15553 background: Vec::new(),
15554 page_height: i32::from(0),
15555 profile: String::from("sRGB"),
15556 }
15557 }
15558}
15559
15560pub fn jpegsave_target_with_opts(
15566 inp: &VipsImage,
15567 target: &VipsTarget,
15568 jpegsave_target_options: &JpegsaveTargetOptions,
15569) -> Result<()> {
15570 unsafe {
15571 let inp_in: *mut bindings::VipsImage = inp.ctx;
15572 let target_in: *mut bindings::VipsTarget = target.ctx;
15573
15574 let q_in: i32 = jpegsave_target_options.q;
15575 let q_in_name = utils::new_c_string("Q")?;
15576
15577 let optimize_coding_in: i32 = if jpegsave_target_options.optimize_coding {
15578 1
15579 } else {
15580 0
15581 };
15582 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15583
15584 let interlace_in: i32 = if jpegsave_target_options.interlace {
15585 1
15586 } else {
15587 0
15588 };
15589 let interlace_in_name = utils::new_c_string("interlace")?;
15590
15591 let trellis_quant_in: i32 = if jpegsave_target_options.trellis_quant {
15592 1
15593 } else {
15594 0
15595 };
15596 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15597
15598 let overshoot_deringing_in: i32 = if jpegsave_target_options.overshoot_deringing {
15599 1
15600 } else {
15601 0
15602 };
15603 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15604
15605 let optimize_scans_in: i32 = if jpegsave_target_options.optimize_scans {
15606 1
15607 } else {
15608 0
15609 };
15610 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15611
15612 let quant_table_in: i32 = jpegsave_target_options.quant_table;
15613 let quant_table_in_name = utils::new_c_string("quant-table")?;
15614
15615 let subsample_mode_in: i32 = jpegsave_target_options.subsample_mode as i32;
15616 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15617
15618 let restart_interval_in: i32 = jpegsave_target_options.restart_interval;
15619 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15620
15621 let keep_in: i32 = jpegsave_target_options.keep as i32;
15622 let keep_in_name = utils::new_c_string("keep")?;
15623
15624 let background_wrapper =
15625 utils::VipsArrayDoubleWrapper::from(&jpegsave_target_options.background[..]);
15626 let background_in = background_wrapper.ctx;
15627 let background_in_name = utils::new_c_string("background")?;
15628
15629 let page_height_in: i32 = jpegsave_target_options.page_height;
15630 let page_height_in_name = utils::new_c_string("page-height")?;
15631
15632 let profile_in: CString = utils::new_c_string(&jpegsave_target_options.profile)?;
15633 let profile_in_name = utils::new_c_string("profile")?;
15634
15635 let vips_op_response = bindings::vips_jpegsave_target(
15636 inp_in,
15637 target_in,
15638 q_in_name.as_ptr(),
15639 q_in,
15640 optimize_coding_in_name.as_ptr(),
15641 optimize_coding_in,
15642 interlace_in_name.as_ptr(),
15643 interlace_in,
15644 trellis_quant_in_name.as_ptr(),
15645 trellis_quant_in,
15646 overshoot_deringing_in_name.as_ptr(),
15647 overshoot_deringing_in,
15648 optimize_scans_in_name.as_ptr(),
15649 optimize_scans_in,
15650 quant_table_in_name.as_ptr(),
15651 quant_table_in,
15652 subsample_mode_in_name.as_ptr(),
15653 subsample_mode_in,
15654 restart_interval_in_name.as_ptr(),
15655 restart_interval_in,
15656 keep_in_name.as_ptr(),
15657 keep_in,
15658 background_in_name.as_ptr(),
15659 background_in,
15660 page_height_in_name.as_ptr(),
15661 page_height_in,
15662 profile_in_name.as_ptr(),
15663 profile_in.as_ptr(),
15664 NULL,
15665 );
15666 utils::result(vips_op_response, (), Error::JpegsaveTargetError)
15667 }
15668}
15669
15670pub fn jpegsave_mime(inp: &VipsImage) -> Result<()> {
15674 unsafe {
15675 let inp_in: *mut bindings::VipsImage = inp.ctx;
15676
15677 let vips_op_response = bindings::vips_jpegsave_mime(inp_in, NULL);
15678 utils::result(vips_op_response, (), Error::JpegsaveMimeError)
15679 }
15680}
15681
15682#[derive(Clone, Debug)]
15684pub struct JpegsaveMimeOptions {
15685 pub q: i32,
15688 pub optimize_coding: bool,
15691 pub interlace: bool,
15694 pub trellis_quant: bool,
15697 pub overshoot_deringing: bool,
15700 pub optimize_scans: bool,
15703 pub quant_table: i32,
15706 pub subsample_mode: ForeignSubsample,
15711 pub restart_interval: i32,
15714 pub keep: ForeignKeep,
15724 pub background: Vec<f64>,
15726 pub page_height: i32,
15729 pub profile: String,
15731}
15732
15733impl std::default::Default for JpegsaveMimeOptions {
15734 fn default() -> Self {
15735 JpegsaveMimeOptions {
15736 q: i32::from(75),
15737 optimize_coding: false,
15738 interlace: false,
15739 trellis_quant: false,
15740 overshoot_deringing: false,
15741 optimize_scans: false,
15742 quant_table: i32::from(0),
15743 subsample_mode: ForeignSubsample::Auto,
15744 restart_interval: i32::from(0),
15745 keep: ForeignKeep::All,
15746 background: Vec::new(),
15747 page_height: i32::from(0),
15748 profile: String::from("sRGB"),
15749 }
15750 }
15751}
15752
15753pub fn jpegsave_mime_with_opts(
15758 inp: &VipsImage,
15759 jpegsave_mime_options: &JpegsaveMimeOptions,
15760) -> Result<()> {
15761 unsafe {
15762 let inp_in: *mut bindings::VipsImage = inp.ctx;
15763
15764 let q_in: i32 = jpegsave_mime_options.q;
15765 let q_in_name = utils::new_c_string("Q")?;
15766
15767 let optimize_coding_in: i32 = if jpegsave_mime_options.optimize_coding {
15768 1
15769 } else {
15770 0
15771 };
15772 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15773
15774 let interlace_in: i32 = if jpegsave_mime_options.interlace {
15775 1
15776 } else {
15777 0
15778 };
15779 let interlace_in_name = utils::new_c_string("interlace")?;
15780
15781 let trellis_quant_in: i32 = if jpegsave_mime_options.trellis_quant {
15782 1
15783 } else {
15784 0
15785 };
15786 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15787
15788 let overshoot_deringing_in: i32 = if jpegsave_mime_options.overshoot_deringing {
15789 1
15790 } else {
15791 0
15792 };
15793 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15794
15795 let optimize_scans_in: i32 = if jpegsave_mime_options.optimize_scans {
15796 1
15797 } else {
15798 0
15799 };
15800 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15801
15802 let quant_table_in: i32 = jpegsave_mime_options.quant_table;
15803 let quant_table_in_name = utils::new_c_string("quant-table")?;
15804
15805 let subsample_mode_in: i32 = jpegsave_mime_options.subsample_mode as i32;
15806 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15807
15808 let restart_interval_in: i32 = jpegsave_mime_options.restart_interval;
15809 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15810
15811 let keep_in: i32 = jpegsave_mime_options.keep as i32;
15812 let keep_in_name = utils::new_c_string("keep")?;
15813
15814 let background_wrapper =
15815 utils::VipsArrayDoubleWrapper::from(&jpegsave_mime_options.background[..]);
15816 let background_in = background_wrapper.ctx;
15817 let background_in_name = utils::new_c_string("background")?;
15818
15819 let page_height_in: i32 = jpegsave_mime_options.page_height;
15820 let page_height_in_name = utils::new_c_string("page-height")?;
15821
15822 let profile_in: CString = utils::new_c_string(&jpegsave_mime_options.profile)?;
15823 let profile_in_name = utils::new_c_string("profile")?;
15824
15825 let vips_op_response = bindings::vips_jpegsave_mime(
15826 inp_in,
15827 q_in_name.as_ptr(),
15828 q_in,
15829 optimize_coding_in_name.as_ptr(),
15830 optimize_coding_in,
15831 interlace_in_name.as_ptr(),
15832 interlace_in,
15833 trellis_quant_in_name.as_ptr(),
15834 trellis_quant_in,
15835 overshoot_deringing_in_name.as_ptr(),
15836 overshoot_deringing_in,
15837 optimize_scans_in_name.as_ptr(),
15838 optimize_scans_in,
15839 quant_table_in_name.as_ptr(),
15840 quant_table_in,
15841 subsample_mode_in_name.as_ptr(),
15842 subsample_mode_in,
15843 restart_interval_in_name.as_ptr(),
15844 restart_interval_in,
15845 keep_in_name.as_ptr(),
15846 keep_in,
15847 background_in_name.as_ptr(),
15848 background_in,
15849 page_height_in_name.as_ptr(),
15850 page_height_in,
15851 profile_in_name.as_ptr(),
15852 profile_in.as_ptr(),
15853 NULL,
15854 );
15855 utils::result(vips_op_response, (), Error::JpegsaveMimeError)
15856 }
15857}
15858
15859pub fn webpsave(inp: &VipsImage, filename: &str) -> Result<()> {
15864 unsafe {
15865 let inp_in: *mut bindings::VipsImage = inp.ctx;
15866 let filename_in: CString = utils::new_c_string(filename)?;
15867
15868 let vips_op_response = bindings::vips_webpsave(inp_in, filename_in.as_ptr(), NULL);
15869 utils::result(vips_op_response, (), Error::WebpsaveError)
15870 }
15871}
15872
15873#[derive(Clone, Debug)]
15875pub struct WebpsaveOptions {
15876 pub q: i32,
15879 pub lossless: bool,
15882 pub exact: bool,
15885 pub preset: ForeignWebpPreset,
15893 pub smart_subsample: bool,
15896 pub near_lossless: bool,
15899 pub alpha_q: i32,
15902 pub min_size: bool,
15905 pub kmin: i32,
15908 pub kmax: i32,
15911 pub effort: i32,
15914 pub target_size: i32,
15917 pub mixed: bool,
15920 pub smart_deblock: bool,
15923 pub passes: i32,
15926 pub keep: ForeignKeep,
15936 pub background: Vec<f64>,
15938 pub page_height: i32,
15941 pub profile: String,
15943}
15944
15945impl std::default::Default for WebpsaveOptions {
15946 fn default() -> Self {
15947 WebpsaveOptions {
15948 q: i32::from(75),
15949 lossless: false,
15950 exact: false,
15951 preset: ForeignWebpPreset::Default,
15952 smart_subsample: false,
15953 near_lossless: false,
15954 alpha_q: i32::from(100),
15955 min_size: false,
15956 kmin: i32::from(2147483646),
15957 kmax: i32::from(2147483647),
15958 effort: i32::from(4),
15959 target_size: i32::from(0),
15960 mixed: false,
15961 smart_deblock: false,
15962 passes: i32::from(1),
15963 keep: ForeignKeep::All,
15964 background: Vec::new(),
15965 page_height: i32::from(0),
15966 profile: String::from("sRGB"),
15967 }
15968 }
15969}
15970
15971pub fn webpsave_with_opts(
15977 inp: &VipsImage,
15978 filename: &str,
15979 webpsave_options: &WebpsaveOptions,
15980) -> Result<()> {
15981 unsafe {
15982 let inp_in: *mut bindings::VipsImage = inp.ctx;
15983 let filename_in: CString = utils::new_c_string(filename)?;
15984
15985 let q_in: i32 = webpsave_options.q;
15986 let q_in_name = utils::new_c_string("Q")?;
15987
15988 let lossless_in: i32 = if webpsave_options.lossless { 1 } else { 0 };
15989 let lossless_in_name = utils::new_c_string("lossless")?;
15990
15991 let exact_in: i32 = if webpsave_options.exact { 1 } else { 0 };
15992 let exact_in_name = utils::new_c_string("exact")?;
15993
15994 let preset_in: i32 = webpsave_options.preset as i32;
15995 let preset_in_name = utils::new_c_string("preset")?;
15996
15997 let smart_subsample_in: i32 = if webpsave_options.smart_subsample {
15998 1
15999 } else {
16000 0
16001 };
16002 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16003
16004 let near_lossless_in: i32 = if webpsave_options.near_lossless { 1 } else { 0 };
16005 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16006
16007 let alpha_q_in: i32 = webpsave_options.alpha_q;
16008 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16009
16010 let min_size_in: i32 = if webpsave_options.min_size { 1 } else { 0 };
16011 let min_size_in_name = utils::new_c_string("min-size")?;
16012
16013 let kmin_in: i32 = webpsave_options.kmin;
16014 let kmin_in_name = utils::new_c_string("kmin")?;
16015
16016 let kmax_in: i32 = webpsave_options.kmax;
16017 let kmax_in_name = utils::new_c_string("kmax")?;
16018
16019 let effort_in: i32 = webpsave_options.effort;
16020 let effort_in_name = utils::new_c_string("effort")?;
16021
16022 let target_size_in: i32 = webpsave_options.target_size;
16023 let target_size_in_name = utils::new_c_string("target-size")?;
16024
16025 let mixed_in: i32 = if webpsave_options.mixed { 1 } else { 0 };
16026 let mixed_in_name = utils::new_c_string("mixed")?;
16027
16028 let smart_deblock_in: i32 = if webpsave_options.smart_deblock { 1 } else { 0 };
16029 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16030
16031 let passes_in: i32 = webpsave_options.passes;
16032 let passes_in_name = utils::new_c_string("passes")?;
16033
16034 let keep_in: i32 = webpsave_options.keep as i32;
16035 let keep_in_name = utils::new_c_string("keep")?;
16036
16037 let background_wrapper =
16038 utils::VipsArrayDoubleWrapper::from(&webpsave_options.background[..]);
16039 let background_in = background_wrapper.ctx;
16040 let background_in_name = utils::new_c_string("background")?;
16041
16042 let page_height_in: i32 = webpsave_options.page_height;
16043 let page_height_in_name = utils::new_c_string("page-height")?;
16044
16045 let profile_in: CString = utils::new_c_string(&webpsave_options.profile)?;
16046 let profile_in_name = utils::new_c_string("profile")?;
16047
16048 let vips_op_response = bindings::vips_webpsave(
16049 inp_in,
16050 filename_in.as_ptr(),
16051 q_in_name.as_ptr(),
16052 q_in,
16053 lossless_in_name.as_ptr(),
16054 lossless_in,
16055 exact_in_name.as_ptr(),
16056 exact_in,
16057 preset_in_name.as_ptr(),
16058 preset_in,
16059 smart_subsample_in_name.as_ptr(),
16060 smart_subsample_in,
16061 near_lossless_in_name.as_ptr(),
16062 near_lossless_in,
16063 alpha_q_in_name.as_ptr(),
16064 alpha_q_in,
16065 min_size_in_name.as_ptr(),
16066 min_size_in,
16067 kmin_in_name.as_ptr(),
16068 kmin_in,
16069 kmax_in_name.as_ptr(),
16070 kmax_in,
16071 effort_in_name.as_ptr(),
16072 effort_in,
16073 target_size_in_name.as_ptr(),
16074 target_size_in,
16075 mixed_in_name.as_ptr(),
16076 mixed_in,
16077 smart_deblock_in_name.as_ptr(),
16078 smart_deblock_in,
16079 passes_in_name.as_ptr(),
16080 passes_in,
16081 keep_in_name.as_ptr(),
16082 keep_in,
16083 background_in_name.as_ptr(),
16084 background_in,
16085 page_height_in_name.as_ptr(),
16086 page_height_in,
16087 profile_in_name.as_ptr(),
16088 profile_in.as_ptr(),
16089 NULL,
16090 );
16091 utils::result(vips_op_response, (), Error::WebpsaveError)
16092 }
16093}
16094
16095pub fn webpsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
16099 unsafe {
16100 let inp_in: *mut bindings::VipsImage = inp.ctx;
16101 let mut buffer_buf_size: u64 = 0;
16102 let mut buffer_out: *mut c_void = null_mut();
16103
16104 let vips_op_response =
16105 bindings::vips_webpsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
16106 utils::result(
16107 vips_op_response,
16108 utils::new_byte_array(buffer_out, buffer_buf_size),
16109 Error::WebpsaveBufferError,
16110 )
16111 }
16112}
16113
16114#[derive(Clone, Debug)]
16116pub struct WebpsaveBufferOptions {
16117 pub q: i32,
16120 pub lossless: bool,
16123 pub exact: bool,
16126 pub preset: ForeignWebpPreset,
16134 pub smart_subsample: bool,
16137 pub near_lossless: bool,
16140 pub alpha_q: i32,
16143 pub min_size: bool,
16146 pub kmin: i32,
16149 pub kmax: i32,
16152 pub effort: i32,
16155 pub target_size: i32,
16158 pub mixed: bool,
16161 pub smart_deblock: bool,
16164 pub passes: i32,
16167 pub keep: ForeignKeep,
16177 pub background: Vec<f64>,
16179 pub page_height: i32,
16182 pub profile: String,
16184}
16185
16186impl std::default::Default for WebpsaveBufferOptions {
16187 fn default() -> Self {
16188 WebpsaveBufferOptions {
16189 q: i32::from(75),
16190 lossless: false,
16191 exact: false,
16192 preset: ForeignWebpPreset::Default,
16193 smart_subsample: false,
16194 near_lossless: false,
16195 alpha_q: i32::from(100),
16196 min_size: false,
16197 kmin: i32::from(2147483646),
16198 kmax: i32::from(2147483647),
16199 effort: i32::from(4),
16200 target_size: i32::from(0),
16201 mixed: false,
16202 smart_deblock: false,
16203 passes: i32::from(1),
16204 keep: ForeignKeep::All,
16205 background: Vec::new(),
16206 page_height: i32::from(0),
16207 profile: String::from("sRGB"),
16208 }
16209 }
16210}
16211
16212pub fn webpsave_buffer_with_opts(
16217 inp: &VipsImage,
16218 webpsave_buffer_options: &WebpsaveBufferOptions,
16219) -> Result<Vec<u8>> {
16220 unsafe {
16221 let inp_in: *mut bindings::VipsImage = inp.ctx;
16222 let mut buffer_buf_size: u64 = 0;
16223 let mut buffer_out: *mut c_void = null_mut();
16224
16225 let q_in: i32 = webpsave_buffer_options.q;
16226 let q_in_name = utils::new_c_string("Q")?;
16227
16228 let lossless_in: i32 = if webpsave_buffer_options.lossless {
16229 1
16230 } else {
16231 0
16232 };
16233 let lossless_in_name = utils::new_c_string("lossless")?;
16234
16235 let exact_in: i32 = if webpsave_buffer_options.exact { 1 } else { 0 };
16236 let exact_in_name = utils::new_c_string("exact")?;
16237
16238 let preset_in: i32 = webpsave_buffer_options.preset as i32;
16239 let preset_in_name = utils::new_c_string("preset")?;
16240
16241 let smart_subsample_in: i32 = if webpsave_buffer_options.smart_subsample {
16242 1
16243 } else {
16244 0
16245 };
16246 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16247
16248 let near_lossless_in: i32 = if webpsave_buffer_options.near_lossless {
16249 1
16250 } else {
16251 0
16252 };
16253 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16254
16255 let alpha_q_in: i32 = webpsave_buffer_options.alpha_q;
16256 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16257
16258 let min_size_in: i32 = if webpsave_buffer_options.min_size {
16259 1
16260 } else {
16261 0
16262 };
16263 let min_size_in_name = utils::new_c_string("min-size")?;
16264
16265 let kmin_in: i32 = webpsave_buffer_options.kmin;
16266 let kmin_in_name = utils::new_c_string("kmin")?;
16267
16268 let kmax_in: i32 = webpsave_buffer_options.kmax;
16269 let kmax_in_name = utils::new_c_string("kmax")?;
16270
16271 let effort_in: i32 = webpsave_buffer_options.effort;
16272 let effort_in_name = utils::new_c_string("effort")?;
16273
16274 let target_size_in: i32 = webpsave_buffer_options.target_size;
16275 let target_size_in_name = utils::new_c_string("target-size")?;
16276
16277 let mixed_in: i32 = if webpsave_buffer_options.mixed { 1 } else { 0 };
16278 let mixed_in_name = utils::new_c_string("mixed")?;
16279
16280 let smart_deblock_in: i32 = if webpsave_buffer_options.smart_deblock {
16281 1
16282 } else {
16283 0
16284 };
16285 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16286
16287 let passes_in: i32 = webpsave_buffer_options.passes;
16288 let passes_in_name = utils::new_c_string("passes")?;
16289
16290 let keep_in: i32 = webpsave_buffer_options.keep as i32;
16291 let keep_in_name = utils::new_c_string("keep")?;
16292
16293 let background_wrapper =
16294 utils::VipsArrayDoubleWrapper::from(&webpsave_buffer_options.background[..]);
16295 let background_in = background_wrapper.ctx;
16296 let background_in_name = utils::new_c_string("background")?;
16297
16298 let page_height_in: i32 = webpsave_buffer_options.page_height;
16299 let page_height_in_name = utils::new_c_string("page-height")?;
16300
16301 let profile_in: CString = utils::new_c_string(&webpsave_buffer_options.profile)?;
16302 let profile_in_name = utils::new_c_string("profile")?;
16303
16304 let vips_op_response = bindings::vips_webpsave_buffer(
16305 inp_in,
16306 &mut buffer_out,
16307 &mut buffer_buf_size,
16308 q_in_name.as_ptr(),
16309 q_in,
16310 lossless_in_name.as_ptr(),
16311 lossless_in,
16312 exact_in_name.as_ptr(),
16313 exact_in,
16314 preset_in_name.as_ptr(),
16315 preset_in,
16316 smart_subsample_in_name.as_ptr(),
16317 smart_subsample_in,
16318 near_lossless_in_name.as_ptr(),
16319 near_lossless_in,
16320 alpha_q_in_name.as_ptr(),
16321 alpha_q_in,
16322 min_size_in_name.as_ptr(),
16323 min_size_in,
16324 kmin_in_name.as_ptr(),
16325 kmin_in,
16326 kmax_in_name.as_ptr(),
16327 kmax_in,
16328 effort_in_name.as_ptr(),
16329 effort_in,
16330 target_size_in_name.as_ptr(),
16331 target_size_in,
16332 mixed_in_name.as_ptr(),
16333 mixed_in,
16334 smart_deblock_in_name.as_ptr(),
16335 smart_deblock_in,
16336 passes_in_name.as_ptr(),
16337 passes_in,
16338 keep_in_name.as_ptr(),
16339 keep_in,
16340 background_in_name.as_ptr(),
16341 background_in,
16342 page_height_in_name.as_ptr(),
16343 page_height_in,
16344 profile_in_name.as_ptr(),
16345 profile_in.as_ptr(),
16346 NULL,
16347 );
16348 utils::result(
16349 vips_op_response,
16350 utils::new_byte_array(buffer_out, buffer_buf_size),
16351 Error::WebpsaveBufferError,
16352 )
16353 }
16354}
16355
16356pub fn webpsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
16361 unsafe {
16362 let inp_in: *mut bindings::VipsImage = inp.ctx;
16363 let target_in: *mut bindings::VipsTarget = target.ctx;
16364
16365 let vips_op_response = bindings::vips_webpsave_target(inp_in, target_in, NULL);
16366 utils::result(vips_op_response, (), Error::WebpsaveTargetError)
16367 }
16368}
16369
16370#[derive(Clone, Debug)]
16372pub struct WebpsaveTargetOptions {
16373 pub q: i32,
16376 pub lossless: bool,
16379 pub exact: bool,
16382 pub preset: ForeignWebpPreset,
16390 pub smart_subsample: bool,
16393 pub near_lossless: bool,
16396 pub alpha_q: i32,
16399 pub min_size: bool,
16402 pub kmin: i32,
16405 pub kmax: i32,
16408 pub effort: i32,
16411 pub target_size: i32,
16414 pub mixed: bool,
16417 pub smart_deblock: bool,
16420 pub passes: i32,
16423 pub keep: ForeignKeep,
16433 pub background: Vec<f64>,
16435 pub page_height: i32,
16438 pub profile: String,
16440}
16441
16442impl std::default::Default for WebpsaveTargetOptions {
16443 fn default() -> Self {
16444 WebpsaveTargetOptions {
16445 q: i32::from(75),
16446 lossless: false,
16447 exact: false,
16448 preset: ForeignWebpPreset::Default,
16449 smart_subsample: false,
16450 near_lossless: false,
16451 alpha_q: i32::from(100),
16452 min_size: false,
16453 kmin: i32::from(2147483646),
16454 kmax: i32::from(2147483647),
16455 effort: i32::from(4),
16456 target_size: i32::from(0),
16457 mixed: false,
16458 smart_deblock: false,
16459 passes: i32::from(1),
16460 keep: ForeignKeep::All,
16461 background: Vec::new(),
16462 page_height: i32::from(0),
16463 profile: String::from("sRGB"),
16464 }
16465 }
16466}
16467
16468pub fn webpsave_target_with_opts(
16474 inp: &VipsImage,
16475 target: &VipsTarget,
16476 webpsave_target_options: &WebpsaveTargetOptions,
16477) -> Result<()> {
16478 unsafe {
16479 let inp_in: *mut bindings::VipsImage = inp.ctx;
16480 let target_in: *mut bindings::VipsTarget = target.ctx;
16481
16482 let q_in: i32 = webpsave_target_options.q;
16483 let q_in_name = utils::new_c_string("Q")?;
16484
16485 let lossless_in: i32 = if webpsave_target_options.lossless {
16486 1
16487 } else {
16488 0
16489 };
16490 let lossless_in_name = utils::new_c_string("lossless")?;
16491
16492 let exact_in: i32 = if webpsave_target_options.exact { 1 } else { 0 };
16493 let exact_in_name = utils::new_c_string("exact")?;
16494
16495 let preset_in: i32 = webpsave_target_options.preset as i32;
16496 let preset_in_name = utils::new_c_string("preset")?;
16497
16498 let smart_subsample_in: i32 = if webpsave_target_options.smart_subsample {
16499 1
16500 } else {
16501 0
16502 };
16503 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16504
16505 let near_lossless_in: i32 = if webpsave_target_options.near_lossless {
16506 1
16507 } else {
16508 0
16509 };
16510 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16511
16512 let alpha_q_in: i32 = webpsave_target_options.alpha_q;
16513 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16514
16515 let min_size_in: i32 = if webpsave_target_options.min_size {
16516 1
16517 } else {
16518 0
16519 };
16520 let min_size_in_name = utils::new_c_string("min-size")?;
16521
16522 let kmin_in: i32 = webpsave_target_options.kmin;
16523 let kmin_in_name = utils::new_c_string("kmin")?;
16524
16525 let kmax_in: i32 = webpsave_target_options.kmax;
16526 let kmax_in_name = utils::new_c_string("kmax")?;
16527
16528 let effort_in: i32 = webpsave_target_options.effort;
16529 let effort_in_name = utils::new_c_string("effort")?;
16530
16531 let target_size_in: i32 = webpsave_target_options.target_size;
16532 let target_size_in_name = utils::new_c_string("target-size")?;
16533
16534 let mixed_in: i32 = if webpsave_target_options.mixed { 1 } else { 0 };
16535 let mixed_in_name = utils::new_c_string("mixed")?;
16536
16537 let smart_deblock_in: i32 = if webpsave_target_options.smart_deblock {
16538 1
16539 } else {
16540 0
16541 };
16542 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16543
16544 let passes_in: i32 = webpsave_target_options.passes;
16545 let passes_in_name = utils::new_c_string("passes")?;
16546
16547 let keep_in: i32 = webpsave_target_options.keep as i32;
16548 let keep_in_name = utils::new_c_string("keep")?;
16549
16550 let background_wrapper =
16551 utils::VipsArrayDoubleWrapper::from(&webpsave_target_options.background[..]);
16552 let background_in = background_wrapper.ctx;
16553 let background_in_name = utils::new_c_string("background")?;
16554
16555 let page_height_in: i32 = webpsave_target_options.page_height;
16556 let page_height_in_name = utils::new_c_string("page-height")?;
16557
16558 let profile_in: CString = utils::new_c_string(&webpsave_target_options.profile)?;
16559 let profile_in_name = utils::new_c_string("profile")?;
16560
16561 let vips_op_response = bindings::vips_webpsave_target(
16562 inp_in,
16563 target_in,
16564 q_in_name.as_ptr(),
16565 q_in,
16566 lossless_in_name.as_ptr(),
16567 lossless_in,
16568 exact_in_name.as_ptr(),
16569 exact_in,
16570 preset_in_name.as_ptr(),
16571 preset_in,
16572 smart_subsample_in_name.as_ptr(),
16573 smart_subsample_in,
16574 near_lossless_in_name.as_ptr(),
16575 near_lossless_in,
16576 alpha_q_in_name.as_ptr(),
16577 alpha_q_in,
16578 min_size_in_name.as_ptr(),
16579 min_size_in,
16580 kmin_in_name.as_ptr(),
16581 kmin_in,
16582 kmax_in_name.as_ptr(),
16583 kmax_in,
16584 effort_in_name.as_ptr(),
16585 effort_in,
16586 target_size_in_name.as_ptr(),
16587 target_size_in,
16588 mixed_in_name.as_ptr(),
16589 mixed_in,
16590 smart_deblock_in_name.as_ptr(),
16591 smart_deblock_in,
16592 passes_in_name.as_ptr(),
16593 passes_in,
16594 keep_in_name.as_ptr(),
16595 keep_in,
16596 background_in_name.as_ptr(),
16597 background_in,
16598 page_height_in_name.as_ptr(),
16599 page_height_in,
16600 profile_in_name.as_ptr(),
16601 profile_in.as_ptr(),
16602 NULL,
16603 );
16604 utils::result(vips_op_response, (), Error::WebpsaveTargetError)
16605 }
16606}
16607
16608pub fn webpsave_mime(inp: &VipsImage) -> Result<()> {
16612 unsafe {
16613 let inp_in: *mut bindings::VipsImage = inp.ctx;
16614
16615 let vips_op_response = bindings::vips_webpsave_mime(inp_in, NULL);
16616 utils::result(vips_op_response, (), Error::WebpsaveMimeError)
16617 }
16618}
16619
16620#[derive(Clone, Debug)]
16622pub struct WebpsaveMimeOptions {
16623 pub q: i32,
16626 pub lossless: bool,
16629 pub exact: bool,
16632 pub preset: ForeignWebpPreset,
16640 pub smart_subsample: bool,
16643 pub near_lossless: bool,
16646 pub alpha_q: i32,
16649 pub min_size: bool,
16652 pub kmin: i32,
16655 pub kmax: i32,
16658 pub effort: i32,
16661 pub target_size: i32,
16664 pub mixed: bool,
16667 pub smart_deblock: bool,
16670 pub passes: i32,
16673 pub keep: ForeignKeep,
16683 pub background: Vec<f64>,
16685 pub page_height: i32,
16688 pub profile: String,
16690}
16691
16692impl std::default::Default for WebpsaveMimeOptions {
16693 fn default() -> Self {
16694 WebpsaveMimeOptions {
16695 q: i32::from(75),
16696 lossless: false,
16697 exact: false,
16698 preset: ForeignWebpPreset::Default,
16699 smart_subsample: false,
16700 near_lossless: false,
16701 alpha_q: i32::from(100),
16702 min_size: false,
16703 kmin: i32::from(2147483646),
16704 kmax: i32::from(2147483647),
16705 effort: i32::from(4),
16706 target_size: i32::from(0),
16707 mixed: false,
16708 smart_deblock: false,
16709 passes: i32::from(1),
16710 keep: ForeignKeep::All,
16711 background: Vec::new(),
16712 page_height: i32::from(0),
16713 profile: String::from("sRGB"),
16714 }
16715 }
16716}
16717
16718pub fn webpsave_mime_with_opts(
16723 inp: &VipsImage,
16724 webpsave_mime_options: &WebpsaveMimeOptions,
16725) -> Result<()> {
16726 unsafe {
16727 let inp_in: *mut bindings::VipsImage = inp.ctx;
16728
16729 let q_in: i32 = webpsave_mime_options.q;
16730 let q_in_name = utils::new_c_string("Q")?;
16731
16732 let lossless_in: i32 = if webpsave_mime_options.lossless { 1 } else { 0 };
16733 let lossless_in_name = utils::new_c_string("lossless")?;
16734
16735 let exact_in: i32 = if webpsave_mime_options.exact { 1 } else { 0 };
16736 let exact_in_name = utils::new_c_string("exact")?;
16737
16738 let preset_in: i32 = webpsave_mime_options.preset as i32;
16739 let preset_in_name = utils::new_c_string("preset")?;
16740
16741 let smart_subsample_in: i32 = if webpsave_mime_options.smart_subsample {
16742 1
16743 } else {
16744 0
16745 };
16746 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16747
16748 let near_lossless_in: i32 = if webpsave_mime_options.near_lossless {
16749 1
16750 } else {
16751 0
16752 };
16753 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16754
16755 let alpha_q_in: i32 = webpsave_mime_options.alpha_q;
16756 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16757
16758 let min_size_in: i32 = if webpsave_mime_options.min_size { 1 } else { 0 };
16759 let min_size_in_name = utils::new_c_string("min-size")?;
16760
16761 let kmin_in: i32 = webpsave_mime_options.kmin;
16762 let kmin_in_name = utils::new_c_string("kmin")?;
16763
16764 let kmax_in: i32 = webpsave_mime_options.kmax;
16765 let kmax_in_name = utils::new_c_string("kmax")?;
16766
16767 let effort_in: i32 = webpsave_mime_options.effort;
16768 let effort_in_name = utils::new_c_string("effort")?;
16769
16770 let target_size_in: i32 = webpsave_mime_options.target_size;
16771 let target_size_in_name = utils::new_c_string("target-size")?;
16772
16773 let mixed_in: i32 = if webpsave_mime_options.mixed { 1 } else { 0 };
16774 let mixed_in_name = utils::new_c_string("mixed")?;
16775
16776 let smart_deblock_in: i32 = if webpsave_mime_options.smart_deblock {
16777 1
16778 } else {
16779 0
16780 };
16781 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16782
16783 let passes_in: i32 = webpsave_mime_options.passes;
16784 let passes_in_name = utils::new_c_string("passes")?;
16785
16786 let keep_in: i32 = webpsave_mime_options.keep as i32;
16787 let keep_in_name = utils::new_c_string("keep")?;
16788
16789 let background_wrapper =
16790 utils::VipsArrayDoubleWrapper::from(&webpsave_mime_options.background[..]);
16791 let background_in = background_wrapper.ctx;
16792 let background_in_name = utils::new_c_string("background")?;
16793
16794 let page_height_in: i32 = webpsave_mime_options.page_height;
16795 let page_height_in_name = utils::new_c_string("page-height")?;
16796
16797 let profile_in: CString = utils::new_c_string(&webpsave_mime_options.profile)?;
16798 let profile_in_name = utils::new_c_string("profile")?;
16799
16800 let vips_op_response = bindings::vips_webpsave_mime(
16801 inp_in,
16802 q_in_name.as_ptr(),
16803 q_in,
16804 lossless_in_name.as_ptr(),
16805 lossless_in,
16806 exact_in_name.as_ptr(),
16807 exact_in,
16808 preset_in_name.as_ptr(),
16809 preset_in,
16810 smart_subsample_in_name.as_ptr(),
16811 smart_subsample_in,
16812 near_lossless_in_name.as_ptr(),
16813 near_lossless_in,
16814 alpha_q_in_name.as_ptr(),
16815 alpha_q_in,
16816 min_size_in_name.as_ptr(),
16817 min_size_in,
16818 kmin_in_name.as_ptr(),
16819 kmin_in,
16820 kmax_in_name.as_ptr(),
16821 kmax_in,
16822 effort_in_name.as_ptr(),
16823 effort_in,
16824 target_size_in_name.as_ptr(),
16825 target_size_in,
16826 mixed_in_name.as_ptr(),
16827 mixed_in,
16828 smart_deblock_in_name.as_ptr(),
16829 smart_deblock_in,
16830 passes_in_name.as_ptr(),
16831 passes_in,
16832 keep_in_name.as_ptr(),
16833 keep_in,
16834 background_in_name.as_ptr(),
16835 background_in,
16836 page_height_in_name.as_ptr(),
16837 page_height_in,
16838 profile_in_name.as_ptr(),
16839 profile_in.as_ptr(),
16840 NULL,
16841 );
16842 utils::result(vips_op_response, (), Error::WebpsaveMimeError)
16843 }
16844}
16845
16846pub fn tiffsave(inp: &VipsImage, filename: &str) -> Result<()> {
16851 unsafe {
16852 let inp_in: *mut bindings::VipsImage = inp.ctx;
16853 let filename_in: CString = utils::new_c_string(filename)?;
16854
16855 let vips_op_response = bindings::vips_tiffsave(inp_in, filename_in.as_ptr(), NULL);
16856 utils::result(vips_op_response, (), Error::TiffsaveError)
16857 }
16858}
16859
16860#[derive(Clone, Debug)]
16862pub struct TiffsaveOptions {
16863 pub compression: ForeignTiffCompression,
16874 pub q: i32,
16877 pub predictor: ForeignTiffPredictor,
16882 pub tile: bool,
16885 pub tile_width: i32,
16888 pub tile_height: i32,
16891 pub pyramid: bool,
16894 pub miniswhite: bool,
16897 pub bitdepth: i32,
16900 pub resunit: ForeignTiffResunit,
16904 pub xres: f64,
16907 pub yres: f64,
16910 pub bigtiff: bool,
16913 pub properties: bool,
16916 pub region_shrink: RegionShrink,
16924 pub level: i32,
16927 pub lossless: bool,
16930 pub depth: ForeignDzDepth,
16935 pub subifd: bool,
16938 pub premultiply: bool,
16941 pub keep: ForeignKeep,
16951 pub background: Vec<f64>,
16953 pub page_height: i32,
16956 pub profile: String,
16958}
16959
16960impl std::default::Default for TiffsaveOptions {
16961 fn default() -> Self {
16962 TiffsaveOptions {
16963 compression: ForeignTiffCompression::None,
16964 q: i32::from(75),
16965 predictor: ForeignTiffPredictor::Horizontal,
16966 tile: false,
16967 tile_width: i32::from(128),
16968 tile_height: i32::from(128),
16969 pyramid: false,
16970 miniswhite: false,
16971 bitdepth: i32::from(0),
16972 resunit: ForeignTiffResunit::Cm,
16973 xres: f64::from(1),
16974 yres: f64::from(1),
16975 bigtiff: false,
16976 properties: false,
16977 region_shrink: RegionShrink::Mean,
16978 level: i32::from(0),
16979 lossless: false,
16980 depth: ForeignDzDepth::Onetile,
16981 subifd: false,
16982 premultiply: false,
16983 keep: ForeignKeep::All,
16984 background: Vec::new(),
16985 page_height: i32::from(0),
16986 profile: String::from("sRGB"),
16987 }
16988 }
16989}
16990
16991pub fn tiffsave_with_opts(
16997 inp: &VipsImage,
16998 filename: &str,
16999 tiffsave_options: &TiffsaveOptions,
17000) -> Result<()> {
17001 unsafe {
17002 let inp_in: *mut bindings::VipsImage = inp.ctx;
17003 let filename_in: CString = utils::new_c_string(filename)?;
17004
17005 let compression_in: i32 = tiffsave_options.compression as i32;
17006 let compression_in_name = utils::new_c_string("compression")?;
17007
17008 let q_in: i32 = tiffsave_options.q;
17009 let q_in_name = utils::new_c_string("Q")?;
17010
17011 let predictor_in: i32 = tiffsave_options.predictor as i32;
17012 let predictor_in_name = utils::new_c_string("predictor")?;
17013
17014 let tile_in: i32 = if tiffsave_options.tile { 1 } else { 0 };
17015 let tile_in_name = utils::new_c_string("tile")?;
17016
17017 let tile_width_in: i32 = tiffsave_options.tile_width;
17018 let tile_width_in_name = utils::new_c_string("tile-width")?;
17019
17020 let tile_height_in: i32 = tiffsave_options.tile_height;
17021 let tile_height_in_name = utils::new_c_string("tile-height")?;
17022
17023 let pyramid_in: i32 = if tiffsave_options.pyramid { 1 } else { 0 };
17024 let pyramid_in_name = utils::new_c_string("pyramid")?;
17025
17026 let miniswhite_in: i32 = if tiffsave_options.miniswhite { 1 } else { 0 };
17027 let miniswhite_in_name = utils::new_c_string("miniswhite")?;
17028
17029 let bitdepth_in: i32 = tiffsave_options.bitdepth;
17030 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17031
17032 let resunit_in: i32 = tiffsave_options.resunit as i32;
17033 let resunit_in_name = utils::new_c_string("resunit")?;
17034
17035 let xres_in: f64 = tiffsave_options.xres;
17036 let xres_in_name = utils::new_c_string("xres")?;
17037
17038 let yres_in: f64 = tiffsave_options.yres;
17039 let yres_in_name = utils::new_c_string("yres")?;
17040
17041 let bigtiff_in: i32 = if tiffsave_options.bigtiff { 1 } else { 0 };
17042 let bigtiff_in_name = utils::new_c_string("bigtiff")?;
17043
17044 let properties_in: i32 = if tiffsave_options.properties { 1 } else { 0 };
17045 let properties_in_name = utils::new_c_string("properties")?;
17046
17047 let region_shrink_in: i32 = tiffsave_options.region_shrink as i32;
17048 let region_shrink_in_name = utils::new_c_string("region-shrink")?;
17049
17050 let level_in: i32 = tiffsave_options.level;
17051 let level_in_name = utils::new_c_string("level")?;
17052
17053 let lossless_in: i32 = if tiffsave_options.lossless { 1 } else { 0 };
17054 let lossless_in_name = utils::new_c_string("lossless")?;
17055
17056 let depth_in: i32 = tiffsave_options.depth as i32;
17057 let depth_in_name = utils::new_c_string("depth")?;
17058
17059 let subifd_in: i32 = if tiffsave_options.subifd { 1 } else { 0 };
17060 let subifd_in_name = utils::new_c_string("subifd")?;
17061
17062 let premultiply_in: i32 = if tiffsave_options.premultiply { 1 } else { 0 };
17063 let premultiply_in_name = utils::new_c_string("premultiply")?;
17064
17065 let keep_in: i32 = tiffsave_options.keep as i32;
17066 let keep_in_name = utils::new_c_string("keep")?;
17067
17068 let background_wrapper =
17069 utils::VipsArrayDoubleWrapper::from(&tiffsave_options.background[..]);
17070 let background_in = background_wrapper.ctx;
17071 let background_in_name = utils::new_c_string("background")?;
17072
17073 let page_height_in: i32 = tiffsave_options.page_height;
17074 let page_height_in_name = utils::new_c_string("page-height")?;
17075
17076 let profile_in: CString = utils::new_c_string(&tiffsave_options.profile)?;
17077 let profile_in_name = utils::new_c_string("profile")?;
17078
17079 let vips_op_response = bindings::vips_tiffsave(
17080 inp_in,
17081 filename_in.as_ptr(),
17082 compression_in_name.as_ptr(),
17083 compression_in,
17084 q_in_name.as_ptr(),
17085 q_in,
17086 predictor_in_name.as_ptr(),
17087 predictor_in,
17088 tile_in_name.as_ptr(),
17089 tile_in,
17090 tile_width_in_name.as_ptr(),
17091 tile_width_in,
17092 tile_height_in_name.as_ptr(),
17093 tile_height_in,
17094 pyramid_in_name.as_ptr(),
17095 pyramid_in,
17096 miniswhite_in_name.as_ptr(),
17097 miniswhite_in,
17098 bitdepth_in_name.as_ptr(),
17099 bitdepth_in,
17100 resunit_in_name.as_ptr(),
17101 resunit_in,
17102 xres_in_name.as_ptr(),
17103 xres_in,
17104 yres_in_name.as_ptr(),
17105 yres_in,
17106 bigtiff_in_name.as_ptr(),
17107 bigtiff_in,
17108 properties_in_name.as_ptr(),
17109 properties_in,
17110 region_shrink_in_name.as_ptr(),
17111 region_shrink_in,
17112 level_in_name.as_ptr(),
17113 level_in,
17114 lossless_in_name.as_ptr(),
17115 lossless_in,
17116 depth_in_name.as_ptr(),
17117 depth_in,
17118 subifd_in_name.as_ptr(),
17119 subifd_in,
17120 premultiply_in_name.as_ptr(),
17121 premultiply_in,
17122 keep_in_name.as_ptr(),
17123 keep_in,
17124 background_in_name.as_ptr(),
17125 background_in,
17126 page_height_in_name.as_ptr(),
17127 page_height_in,
17128 profile_in_name.as_ptr(),
17129 profile_in.as_ptr(),
17130 NULL,
17131 );
17132 utils::result(vips_op_response, (), Error::TiffsaveError)
17133 }
17134}
17135
17136pub fn tiffsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
17140 unsafe {
17141 let inp_in: *mut bindings::VipsImage = inp.ctx;
17142 let mut buffer_buf_size: u64 = 0;
17143 let mut buffer_out: *mut c_void = null_mut();
17144
17145 let vips_op_response =
17146 bindings::vips_tiffsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
17147 utils::result(
17148 vips_op_response,
17149 utils::new_byte_array(buffer_out, buffer_buf_size),
17150 Error::TiffsaveBufferError,
17151 )
17152 }
17153}
17154
17155#[derive(Clone, Debug)]
17157pub struct TiffsaveBufferOptions {
17158 pub compression: ForeignTiffCompression,
17169 pub q: i32,
17172 pub predictor: ForeignTiffPredictor,
17177 pub tile: bool,
17180 pub tile_width: i32,
17183 pub tile_height: i32,
17186 pub pyramid: bool,
17189 pub miniswhite: bool,
17192 pub bitdepth: i32,
17195 pub resunit: ForeignTiffResunit,
17199 pub xres: f64,
17202 pub yres: f64,
17205 pub bigtiff: bool,
17208 pub properties: bool,
17211 pub region_shrink: RegionShrink,
17219 pub level: i32,
17222 pub lossless: bool,
17225 pub depth: ForeignDzDepth,
17230 pub subifd: bool,
17233 pub premultiply: bool,
17236 pub keep: ForeignKeep,
17246 pub background: Vec<f64>,
17248 pub page_height: i32,
17251 pub profile: String,
17253}
17254
17255impl std::default::Default for TiffsaveBufferOptions {
17256 fn default() -> Self {
17257 TiffsaveBufferOptions {
17258 compression: ForeignTiffCompression::None,
17259 q: i32::from(75),
17260 predictor: ForeignTiffPredictor::Horizontal,
17261 tile: false,
17262 tile_width: i32::from(128),
17263 tile_height: i32::from(128),
17264 pyramid: false,
17265 miniswhite: false,
17266 bitdepth: i32::from(0),
17267 resunit: ForeignTiffResunit::Cm,
17268 xres: f64::from(1),
17269 yres: f64::from(1),
17270 bigtiff: false,
17271 properties: false,
17272 region_shrink: RegionShrink::Mean,
17273 level: i32::from(0),
17274 lossless: false,
17275 depth: ForeignDzDepth::Onetile,
17276 subifd: false,
17277 premultiply: false,
17278 keep: ForeignKeep::All,
17279 background: Vec::new(),
17280 page_height: i32::from(0),
17281 profile: String::from("sRGB"),
17282 }
17283 }
17284}
17285
17286pub fn tiffsave_buffer_with_opts(
17291 inp: &VipsImage,
17292 tiffsave_buffer_options: &TiffsaveBufferOptions,
17293) -> Result<Vec<u8>> {
17294 unsafe {
17295 let inp_in: *mut bindings::VipsImage = inp.ctx;
17296 let mut buffer_buf_size: u64 = 0;
17297 let mut buffer_out: *mut c_void = null_mut();
17298
17299 let compression_in: i32 = tiffsave_buffer_options.compression as i32;
17300 let compression_in_name = utils::new_c_string("compression")?;
17301
17302 let q_in: i32 = tiffsave_buffer_options.q;
17303 let q_in_name = utils::new_c_string("Q")?;
17304
17305 let predictor_in: i32 = tiffsave_buffer_options.predictor as i32;
17306 let predictor_in_name = utils::new_c_string("predictor")?;
17307
17308 let tile_in: i32 = if tiffsave_buffer_options.tile { 1 } else { 0 };
17309 let tile_in_name = utils::new_c_string("tile")?;
17310
17311 let tile_width_in: i32 = tiffsave_buffer_options.tile_width;
17312 let tile_width_in_name = utils::new_c_string("tile-width")?;
17313
17314 let tile_height_in: i32 = tiffsave_buffer_options.tile_height;
17315 let tile_height_in_name = utils::new_c_string("tile-height")?;
17316
17317 let pyramid_in: i32 = if tiffsave_buffer_options.pyramid {
17318 1
17319 } else {
17320 0
17321 };
17322 let pyramid_in_name = utils::new_c_string("pyramid")?;
17323
17324 let miniswhite_in: i32 = if tiffsave_buffer_options.miniswhite {
17325 1
17326 } else {
17327 0
17328 };
17329 let miniswhite_in_name = utils::new_c_string("miniswhite")?;
17330
17331 let bitdepth_in: i32 = tiffsave_buffer_options.bitdepth;
17332 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17333
17334 let resunit_in: i32 = tiffsave_buffer_options.resunit as i32;
17335 let resunit_in_name = utils::new_c_string("resunit")?;
17336
17337 let xres_in: f64 = tiffsave_buffer_options.xres;
17338 let xres_in_name = utils::new_c_string("xres")?;
17339
17340 let yres_in: f64 = tiffsave_buffer_options.yres;
17341 let yres_in_name = utils::new_c_string("yres")?;
17342
17343 let bigtiff_in: i32 = if tiffsave_buffer_options.bigtiff {
17344 1
17345 } else {
17346 0
17347 };
17348 let bigtiff_in_name = utils::new_c_string("bigtiff")?;
17349
17350 let properties_in: i32 = if tiffsave_buffer_options.properties {
17351 1
17352 } else {
17353 0
17354 };
17355 let properties_in_name = utils::new_c_string("properties")?;
17356
17357 let region_shrink_in: i32 = tiffsave_buffer_options.region_shrink as i32;
17358 let region_shrink_in_name = utils::new_c_string("region-shrink")?;
17359
17360 let level_in: i32 = tiffsave_buffer_options.level;
17361 let level_in_name = utils::new_c_string("level")?;
17362
17363 let lossless_in: i32 = if tiffsave_buffer_options.lossless {
17364 1
17365 } else {
17366 0
17367 };
17368 let lossless_in_name = utils::new_c_string("lossless")?;
17369
17370 let depth_in: i32 = tiffsave_buffer_options.depth as i32;
17371 let depth_in_name = utils::new_c_string("depth")?;
17372
17373 let subifd_in: i32 = if tiffsave_buffer_options.subifd { 1 } else { 0 };
17374 let subifd_in_name = utils::new_c_string("subifd")?;
17375
17376 let premultiply_in: i32 = if tiffsave_buffer_options.premultiply {
17377 1
17378 } else {
17379 0
17380 };
17381 let premultiply_in_name = utils::new_c_string("premultiply")?;
17382
17383 let keep_in: i32 = tiffsave_buffer_options.keep as i32;
17384 let keep_in_name = utils::new_c_string("keep")?;
17385
17386 let background_wrapper =
17387 utils::VipsArrayDoubleWrapper::from(&tiffsave_buffer_options.background[..]);
17388 let background_in = background_wrapper.ctx;
17389 let background_in_name = utils::new_c_string("background")?;
17390
17391 let page_height_in: i32 = tiffsave_buffer_options.page_height;
17392 let page_height_in_name = utils::new_c_string("page-height")?;
17393
17394 let profile_in: CString = utils::new_c_string(&tiffsave_buffer_options.profile)?;
17395 let profile_in_name = utils::new_c_string("profile")?;
17396
17397 let vips_op_response = bindings::vips_tiffsave_buffer(
17398 inp_in,
17399 &mut buffer_out,
17400 &mut buffer_buf_size,
17401 compression_in_name.as_ptr(),
17402 compression_in,
17403 q_in_name.as_ptr(),
17404 q_in,
17405 predictor_in_name.as_ptr(),
17406 predictor_in,
17407 tile_in_name.as_ptr(),
17408 tile_in,
17409 tile_width_in_name.as_ptr(),
17410 tile_width_in,
17411 tile_height_in_name.as_ptr(),
17412 tile_height_in,
17413 pyramid_in_name.as_ptr(),
17414 pyramid_in,
17415 miniswhite_in_name.as_ptr(),
17416 miniswhite_in,
17417 bitdepth_in_name.as_ptr(),
17418 bitdepth_in,
17419 resunit_in_name.as_ptr(),
17420 resunit_in,
17421 xres_in_name.as_ptr(),
17422 xres_in,
17423 yres_in_name.as_ptr(),
17424 yres_in,
17425 bigtiff_in_name.as_ptr(),
17426 bigtiff_in,
17427 properties_in_name.as_ptr(),
17428 properties_in,
17429 region_shrink_in_name.as_ptr(),
17430 region_shrink_in,
17431 level_in_name.as_ptr(),
17432 level_in,
17433 lossless_in_name.as_ptr(),
17434 lossless_in,
17435 depth_in_name.as_ptr(),
17436 depth_in,
17437 subifd_in_name.as_ptr(),
17438 subifd_in,
17439 premultiply_in_name.as_ptr(),
17440 premultiply_in,
17441 keep_in_name.as_ptr(),
17442 keep_in,
17443 background_in_name.as_ptr(),
17444 background_in,
17445 page_height_in_name.as_ptr(),
17446 page_height_in,
17447 profile_in_name.as_ptr(),
17448 profile_in.as_ptr(),
17449 NULL,
17450 );
17451 utils::result(
17452 vips_op_response,
17453 utils::new_byte_array(buffer_out, buffer_buf_size),
17454 Error::TiffsaveBufferError,
17455 )
17456 }
17457}
17458
17459pub fn tiffsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
17464 unsafe {
17465 let inp_in: *mut bindings::VipsImage = inp.ctx;
17466 let target_in: *mut bindings::VipsTarget = target.ctx;
17467
17468 let vips_op_response = bindings::vips_tiffsave_target(inp_in, target_in, NULL);
17469 utils::result(vips_op_response, (), Error::TiffsaveTargetError)
17470 }
17471}
17472
17473#[derive(Clone, Debug)]
17475pub struct TiffsaveTargetOptions {
17476 pub compression: ForeignTiffCompression,
17487 pub q: i32,
17490 pub predictor: ForeignTiffPredictor,
17495 pub tile: bool,
17498 pub tile_width: i32,
17501 pub tile_height: i32,
17504 pub pyramid: bool,
17507 pub miniswhite: bool,
17510 pub bitdepth: i32,
17513 pub resunit: ForeignTiffResunit,
17517 pub xres: f64,
17520 pub yres: f64,
17523 pub bigtiff: bool,
17526 pub properties: bool,
17529 pub region_shrink: RegionShrink,
17537 pub level: i32,
17540 pub lossless: bool,
17543 pub depth: ForeignDzDepth,
17548 pub subifd: bool,
17551 pub premultiply: bool,
17554 pub keep: ForeignKeep,
17564 pub background: Vec<f64>,
17566 pub page_height: i32,
17569 pub profile: String,
17571}
17572
17573impl std::default::Default for TiffsaveTargetOptions {
17574 fn default() -> Self {
17575 TiffsaveTargetOptions {
17576 compression: ForeignTiffCompression::None,
17577 q: i32::from(75),
17578 predictor: ForeignTiffPredictor::Horizontal,
17579 tile: false,
17580 tile_width: i32::from(128),
17581 tile_height: i32::from(128),
17582 pyramid: false,
17583 miniswhite: false,
17584 bitdepth: i32::from(0),
17585 resunit: ForeignTiffResunit::Cm,
17586 xres: f64::from(1),
17587 yres: f64::from(1),
17588 bigtiff: false,
17589 properties: false,
17590 region_shrink: RegionShrink::Mean,
17591 level: i32::from(0),
17592 lossless: false,
17593 depth: ForeignDzDepth::Onetile,
17594 subifd: false,
17595 premultiply: false,
17596 keep: ForeignKeep::All,
17597 background: Vec::new(),
17598 page_height: i32::from(0),
17599 profile: String::from("sRGB"),
17600 }
17601 }
17602}
17603
17604pub fn tiffsave_target_with_opts(
17610 inp: &VipsImage,
17611 target: &VipsTarget,
17612 tiffsave_target_options: &TiffsaveTargetOptions,
17613) -> Result<()> {
17614 unsafe {
17615 let inp_in: *mut bindings::VipsImage = inp.ctx;
17616 let target_in: *mut bindings::VipsTarget = target.ctx;
17617
17618 let compression_in: i32 = tiffsave_target_options.compression as i32;
17619 let compression_in_name = utils::new_c_string("compression")?;
17620
17621 let q_in: i32 = tiffsave_target_options.q;
17622 let q_in_name = utils::new_c_string("Q")?;
17623
17624 let predictor_in: i32 = tiffsave_target_options.predictor as i32;
17625 let predictor_in_name = utils::new_c_string("predictor")?;
17626
17627 let tile_in: i32 = if tiffsave_target_options.tile { 1 } else { 0 };
17628 let tile_in_name = utils::new_c_string("tile")?;
17629
17630 let tile_width_in: i32 = tiffsave_target_options.tile_width;
17631 let tile_width_in_name = utils::new_c_string("tile-width")?;
17632
17633 let tile_height_in: i32 = tiffsave_target_options.tile_height;
17634 let tile_height_in_name = utils::new_c_string("tile-height")?;
17635
17636 let pyramid_in: i32 = if tiffsave_target_options.pyramid {
17637 1
17638 } else {
17639 0
17640 };
17641 let pyramid_in_name = utils::new_c_string("pyramid")?;
17642
17643 let miniswhite_in: i32 = if tiffsave_target_options.miniswhite {
17644 1
17645 } else {
17646 0
17647 };
17648 let miniswhite_in_name = utils::new_c_string("miniswhite")?;
17649
17650 let bitdepth_in: i32 = tiffsave_target_options.bitdepth;
17651 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17652
17653 let resunit_in: i32 = tiffsave_target_options.resunit as i32;
17654 let resunit_in_name = utils::new_c_string("resunit")?;
17655
17656 let xres_in: f64 = tiffsave_target_options.xres;
17657 let xres_in_name = utils::new_c_string("xres")?;
17658
17659 let yres_in: f64 = tiffsave_target_options.yres;
17660 let yres_in_name = utils::new_c_string("yres")?;
17661
17662 let bigtiff_in: i32 = if tiffsave_target_options.bigtiff {
17663 1
17664 } else {
17665 0
17666 };
17667 let bigtiff_in_name = utils::new_c_string("bigtiff")?;
17668
17669 let properties_in: i32 = if tiffsave_target_options.properties {
17670 1
17671 } else {
17672 0
17673 };
17674 let properties_in_name = utils::new_c_string("properties")?;
17675
17676 let region_shrink_in: i32 = tiffsave_target_options.region_shrink as i32;
17677 let region_shrink_in_name = utils::new_c_string("region-shrink")?;
17678
17679 let level_in: i32 = tiffsave_target_options.level;
17680 let level_in_name = utils::new_c_string("level")?;
17681
17682 let lossless_in: i32 = if tiffsave_target_options.lossless {
17683 1
17684 } else {
17685 0
17686 };
17687 let lossless_in_name = utils::new_c_string("lossless")?;
17688
17689 let depth_in: i32 = tiffsave_target_options.depth as i32;
17690 let depth_in_name = utils::new_c_string("depth")?;
17691
17692 let subifd_in: i32 = if tiffsave_target_options.subifd { 1 } else { 0 };
17693 let subifd_in_name = utils::new_c_string("subifd")?;
17694
17695 let premultiply_in: i32 = if tiffsave_target_options.premultiply {
17696 1
17697 } else {
17698 0
17699 };
17700 let premultiply_in_name = utils::new_c_string("premultiply")?;
17701
17702 let keep_in: i32 = tiffsave_target_options.keep as i32;
17703 let keep_in_name = utils::new_c_string("keep")?;
17704
17705 let background_wrapper =
17706 utils::VipsArrayDoubleWrapper::from(&tiffsave_target_options.background[..]);
17707 let background_in = background_wrapper.ctx;
17708 let background_in_name = utils::new_c_string("background")?;
17709
17710 let page_height_in: i32 = tiffsave_target_options.page_height;
17711 let page_height_in_name = utils::new_c_string("page-height")?;
17712
17713 let profile_in: CString = utils::new_c_string(&tiffsave_target_options.profile)?;
17714 let profile_in_name = utils::new_c_string("profile")?;
17715
17716 let vips_op_response = bindings::vips_tiffsave_target(
17717 inp_in,
17718 target_in,
17719 compression_in_name.as_ptr(),
17720 compression_in,
17721 q_in_name.as_ptr(),
17722 q_in,
17723 predictor_in_name.as_ptr(),
17724 predictor_in,
17725 tile_in_name.as_ptr(),
17726 tile_in,
17727 tile_width_in_name.as_ptr(),
17728 tile_width_in,
17729 tile_height_in_name.as_ptr(),
17730 tile_height_in,
17731 pyramid_in_name.as_ptr(),
17732 pyramid_in,
17733 miniswhite_in_name.as_ptr(),
17734 miniswhite_in,
17735 bitdepth_in_name.as_ptr(),
17736 bitdepth_in,
17737 resunit_in_name.as_ptr(),
17738 resunit_in,
17739 xres_in_name.as_ptr(),
17740 xres_in,
17741 yres_in_name.as_ptr(),
17742 yres_in,
17743 bigtiff_in_name.as_ptr(),
17744 bigtiff_in,
17745 properties_in_name.as_ptr(),
17746 properties_in,
17747 region_shrink_in_name.as_ptr(),
17748 region_shrink_in,
17749 level_in_name.as_ptr(),
17750 level_in,
17751 lossless_in_name.as_ptr(),
17752 lossless_in,
17753 depth_in_name.as_ptr(),
17754 depth_in,
17755 subifd_in_name.as_ptr(),
17756 subifd_in,
17757 premultiply_in_name.as_ptr(),
17758 premultiply_in,
17759 keep_in_name.as_ptr(),
17760 keep_in,
17761 background_in_name.as_ptr(),
17762 background_in,
17763 page_height_in_name.as_ptr(),
17764 page_height_in,
17765 profile_in_name.as_ptr(),
17766 profile_in.as_ptr(),
17767 NULL,
17768 );
17769 utils::result(vips_op_response, (), Error::TiffsaveTargetError)
17770 }
17771}
17772
17773pub fn heifsave(inp: &VipsImage, filename: &str) -> Result<()> {
17778 unsafe {
17779 let inp_in: *mut bindings::VipsImage = inp.ctx;
17780 let filename_in: CString = utils::new_c_string(filename)?;
17781
17782 let vips_op_response = bindings::vips_heifsave(inp_in, filename_in.as_ptr(), NULL);
17783 utils::result(vips_op_response, (), Error::HeifsaveError)
17784 }
17785}
17786
17787#[derive(Clone, Debug)]
17789pub struct HeifsaveOptions {
17790 pub q: i32,
17793 pub bitdepth: i32,
17796 pub lossless: bool,
17799 pub compression: ForeignHeifCompression,
17805 pub effort: i32,
17808 pub subsample_mode: ForeignSubsample,
17813 pub encoder: ForeignHeifEncoder,
17820 pub tune: String,
17822 pub keep: ForeignKeep,
17832 pub background: Vec<f64>,
17834 pub page_height: i32,
17837 pub profile: String,
17839}
17840
17841impl std::default::Default for HeifsaveOptions {
17842 fn default() -> Self {
17843 HeifsaveOptions {
17844 q: i32::from(50),
17845 bitdepth: i32::from(12),
17846 lossless: false,
17847 compression: ForeignHeifCompression::Hevc,
17848 effort: i32::from(4),
17849 subsample_mode: ForeignSubsample::Auto,
17850 encoder: ForeignHeifEncoder::Auto,
17851 tune: String::new(),
17852 keep: ForeignKeep::All,
17853 background: Vec::new(),
17854 page_height: i32::from(0),
17855 profile: String::from("sRGB"),
17856 }
17857 }
17858}
17859
17860pub fn heifsave_with_opts(
17866 inp: &VipsImage,
17867 filename: &str,
17868 heifsave_options: &HeifsaveOptions,
17869) -> Result<()> {
17870 unsafe {
17871 let inp_in: *mut bindings::VipsImage = inp.ctx;
17872 let filename_in: CString = utils::new_c_string(filename)?;
17873
17874 let q_in: i32 = heifsave_options.q;
17875 let q_in_name = utils::new_c_string("Q")?;
17876
17877 let bitdepth_in: i32 = heifsave_options.bitdepth;
17878 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17879
17880 let lossless_in: i32 = if heifsave_options.lossless { 1 } else { 0 };
17881 let lossless_in_name = utils::new_c_string("lossless")?;
17882
17883 let compression_in: i32 = heifsave_options.compression as i32;
17884 let compression_in_name = utils::new_c_string("compression")?;
17885
17886 let effort_in: i32 = heifsave_options.effort;
17887 let effort_in_name = utils::new_c_string("effort")?;
17888
17889 let subsample_mode_in: i32 = heifsave_options.subsample_mode as i32;
17890 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
17891
17892 let encoder_in: i32 = heifsave_options.encoder as i32;
17893 let encoder_in_name = utils::new_c_string("encoder")?;
17894
17895 let tune_in: CString = utils::new_c_string(&heifsave_options.tune)?;
17896 let tune_in_name = utils::new_c_string("tune")?;
17897
17898 let keep_in: i32 = heifsave_options.keep as i32;
17899 let keep_in_name = utils::new_c_string("keep")?;
17900
17901 let background_wrapper =
17902 utils::VipsArrayDoubleWrapper::from(&heifsave_options.background[..]);
17903 let background_in = background_wrapper.ctx;
17904 let background_in_name = utils::new_c_string("background")?;
17905
17906 let page_height_in: i32 = heifsave_options.page_height;
17907 let page_height_in_name = utils::new_c_string("page-height")?;
17908
17909 let profile_in: CString = utils::new_c_string(&heifsave_options.profile)?;
17910 let profile_in_name = utils::new_c_string("profile")?;
17911
17912 let vips_op_response = bindings::vips_heifsave(
17913 inp_in,
17914 filename_in.as_ptr(),
17915 q_in_name.as_ptr(),
17916 q_in,
17917 bitdepth_in_name.as_ptr(),
17918 bitdepth_in,
17919 lossless_in_name.as_ptr(),
17920 lossless_in,
17921 compression_in_name.as_ptr(),
17922 compression_in,
17923 effort_in_name.as_ptr(),
17924 effort_in,
17925 subsample_mode_in_name.as_ptr(),
17926 subsample_mode_in,
17927 encoder_in_name.as_ptr(),
17928 encoder_in,
17929 tune_in_name.as_ptr(),
17930 tune_in.as_ptr(),
17931 keep_in_name.as_ptr(),
17932 keep_in,
17933 background_in_name.as_ptr(),
17934 background_in,
17935 page_height_in_name.as_ptr(),
17936 page_height_in,
17937 profile_in_name.as_ptr(),
17938 profile_in.as_ptr(),
17939 NULL,
17940 );
17941 utils::result(vips_op_response, (), Error::HeifsaveError)
17942 }
17943}
17944
17945pub fn heifsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
17949 unsafe {
17950 let inp_in: *mut bindings::VipsImage = inp.ctx;
17951 let mut buffer_buf_size: u64 = 0;
17952 let mut buffer_out: *mut c_void = null_mut();
17953
17954 let vips_op_response =
17955 bindings::vips_heifsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
17956 utils::result(
17957 vips_op_response,
17958 utils::new_byte_array(buffer_out, buffer_buf_size),
17959 Error::HeifsaveBufferError,
17960 )
17961 }
17962}
17963
17964#[derive(Clone, Debug)]
17966pub struct HeifsaveBufferOptions {
17967 pub q: i32,
17970 pub bitdepth: i32,
17973 pub lossless: bool,
17976 pub compression: ForeignHeifCompression,
17982 pub effort: i32,
17985 pub subsample_mode: ForeignSubsample,
17990 pub encoder: ForeignHeifEncoder,
17997 pub tune: String,
17999 pub keep: ForeignKeep,
18009 pub background: Vec<f64>,
18011 pub page_height: i32,
18014 pub profile: String,
18016}
18017
18018impl std::default::Default for HeifsaveBufferOptions {
18019 fn default() -> Self {
18020 HeifsaveBufferOptions {
18021 q: i32::from(50),
18022 bitdepth: i32::from(12),
18023 lossless: false,
18024 compression: ForeignHeifCompression::Hevc,
18025 effort: i32::from(4),
18026 subsample_mode: ForeignSubsample::Auto,
18027 encoder: ForeignHeifEncoder::Auto,
18028 tune: String::new(),
18029 keep: ForeignKeep::All,
18030 background: Vec::new(),
18031 page_height: i32::from(0),
18032 profile: String::from("sRGB"),
18033 }
18034 }
18035}
18036
18037pub fn heifsave_buffer_with_opts(
18042 inp: &VipsImage,
18043 heifsave_buffer_options: &HeifsaveBufferOptions,
18044) -> Result<Vec<u8>> {
18045 unsafe {
18046 let inp_in: *mut bindings::VipsImage = inp.ctx;
18047 let mut buffer_buf_size: u64 = 0;
18048 let mut buffer_out: *mut c_void = null_mut();
18049
18050 let q_in: i32 = heifsave_buffer_options.q;
18051 let q_in_name = utils::new_c_string("Q")?;
18052
18053 let bitdepth_in: i32 = heifsave_buffer_options.bitdepth;
18054 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
18055
18056 let lossless_in: i32 = if heifsave_buffer_options.lossless {
18057 1
18058 } else {
18059 0
18060 };
18061 let lossless_in_name = utils::new_c_string("lossless")?;
18062
18063 let compression_in: i32 = heifsave_buffer_options.compression as i32;
18064 let compression_in_name = utils::new_c_string("compression")?;
18065
18066 let effort_in: i32 = heifsave_buffer_options.effort;
18067 let effort_in_name = utils::new_c_string("effort")?;
18068
18069 let subsample_mode_in: i32 = heifsave_buffer_options.subsample_mode as i32;
18070 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
18071
18072 let encoder_in: i32 = heifsave_buffer_options.encoder as i32;
18073 let encoder_in_name = utils::new_c_string("encoder")?;
18074
18075 let tune_in: CString = utils::new_c_string(&heifsave_buffer_options.tune)?;
18076 let tune_in_name = utils::new_c_string("tune")?;
18077
18078 let keep_in: i32 = heifsave_buffer_options.keep as i32;
18079 let keep_in_name = utils::new_c_string("keep")?;
18080
18081 let background_wrapper =
18082 utils::VipsArrayDoubleWrapper::from(&heifsave_buffer_options.background[..]);
18083 let background_in = background_wrapper.ctx;
18084 let background_in_name = utils::new_c_string("background")?;
18085
18086 let page_height_in: i32 = heifsave_buffer_options.page_height;
18087 let page_height_in_name = utils::new_c_string("page-height")?;
18088
18089 let profile_in: CString = utils::new_c_string(&heifsave_buffer_options.profile)?;
18090 let profile_in_name = utils::new_c_string("profile")?;
18091
18092 let vips_op_response = bindings::vips_heifsave_buffer(
18093 inp_in,
18094 &mut buffer_out,
18095 &mut buffer_buf_size,
18096 q_in_name.as_ptr(),
18097 q_in,
18098 bitdepth_in_name.as_ptr(),
18099 bitdepth_in,
18100 lossless_in_name.as_ptr(),
18101 lossless_in,
18102 compression_in_name.as_ptr(),
18103 compression_in,
18104 effort_in_name.as_ptr(),
18105 effort_in,
18106 subsample_mode_in_name.as_ptr(),
18107 subsample_mode_in,
18108 encoder_in_name.as_ptr(),
18109 encoder_in,
18110 tune_in_name.as_ptr(),
18111 tune_in.as_ptr(),
18112 keep_in_name.as_ptr(),
18113 keep_in,
18114 background_in_name.as_ptr(),
18115 background_in,
18116 page_height_in_name.as_ptr(),
18117 page_height_in,
18118 profile_in_name.as_ptr(),
18119 profile_in.as_ptr(),
18120 NULL,
18121 );
18122 utils::result(
18123 vips_op_response,
18124 utils::new_byte_array(buffer_out, buffer_buf_size),
18125 Error::HeifsaveBufferError,
18126 )
18127 }
18128}
18129
18130pub fn heifsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
18135 unsafe {
18136 let inp_in: *mut bindings::VipsImage = inp.ctx;
18137 let target_in: *mut bindings::VipsTarget = target.ctx;
18138
18139 let vips_op_response = bindings::vips_heifsave_target(inp_in, target_in, NULL);
18140 utils::result(vips_op_response, (), Error::HeifsaveTargetError)
18141 }
18142}
18143
18144#[derive(Clone, Debug)]
18146pub struct HeifsaveTargetOptions {
18147 pub q: i32,
18150 pub bitdepth: i32,
18153 pub lossless: bool,
18156 pub compression: ForeignHeifCompression,
18162 pub effort: i32,
18165 pub subsample_mode: ForeignSubsample,
18170 pub encoder: ForeignHeifEncoder,
18177 pub tune: String,
18179 pub keep: ForeignKeep,
18189 pub background: Vec<f64>,
18191 pub page_height: i32,
18194 pub profile: String,
18196}
18197
18198impl std::default::Default for HeifsaveTargetOptions {
18199 fn default() -> Self {
18200 HeifsaveTargetOptions {
18201 q: i32::from(50),
18202 bitdepth: i32::from(12),
18203 lossless: false,
18204 compression: ForeignHeifCompression::Hevc,
18205 effort: i32::from(4),
18206 subsample_mode: ForeignSubsample::Auto,
18207 encoder: ForeignHeifEncoder::Auto,
18208 tune: String::new(),
18209 keep: ForeignKeep::All,
18210 background: Vec::new(),
18211 page_height: i32::from(0),
18212 profile: String::from("sRGB"),
18213 }
18214 }
18215}
18216
18217pub fn heifsave_target_with_opts(
18223 inp: &VipsImage,
18224 target: &VipsTarget,
18225 heifsave_target_options: &HeifsaveTargetOptions,
18226) -> Result<()> {
18227 unsafe {
18228 let inp_in: *mut bindings::VipsImage = inp.ctx;
18229 let target_in: *mut bindings::VipsTarget = target.ctx;
18230
18231 let q_in: i32 = heifsave_target_options.q;
18232 let q_in_name = utils::new_c_string("Q")?;
18233
18234 let bitdepth_in: i32 = heifsave_target_options.bitdepth;
18235 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
18236
18237 let lossless_in: i32 = if heifsave_target_options.lossless {
18238 1
18239 } else {
18240 0
18241 };
18242 let lossless_in_name = utils::new_c_string("lossless")?;
18243
18244 let compression_in: i32 = heifsave_target_options.compression as i32;
18245 let compression_in_name = utils::new_c_string("compression")?;
18246
18247 let effort_in: i32 = heifsave_target_options.effort;
18248 let effort_in_name = utils::new_c_string("effort")?;
18249
18250 let subsample_mode_in: i32 = heifsave_target_options.subsample_mode as i32;
18251 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
18252
18253 let encoder_in: i32 = heifsave_target_options.encoder as i32;
18254 let encoder_in_name = utils::new_c_string("encoder")?;
18255
18256 let tune_in: CString = utils::new_c_string(&heifsave_target_options.tune)?;
18257 let tune_in_name = utils::new_c_string("tune")?;
18258
18259 let keep_in: i32 = heifsave_target_options.keep as i32;
18260 let keep_in_name = utils::new_c_string("keep")?;
18261
18262 let background_wrapper =
18263 utils::VipsArrayDoubleWrapper::from(&heifsave_target_options.background[..]);
18264 let background_in = background_wrapper.ctx;
18265 let background_in_name = utils::new_c_string("background")?;
18266
18267 let page_height_in: i32 = heifsave_target_options.page_height;
18268 let page_height_in_name = utils::new_c_string("page-height")?;
18269
18270 let profile_in: CString = utils::new_c_string(&heifsave_target_options.profile)?;
18271 let profile_in_name = utils::new_c_string("profile")?;
18272
18273 let vips_op_response = bindings::vips_heifsave_target(
18274 inp_in,
18275 target_in,
18276 q_in_name.as_ptr(),
18277 q_in,
18278 bitdepth_in_name.as_ptr(),
18279 bitdepth_in,
18280 lossless_in_name.as_ptr(),
18281 lossless_in,
18282 compression_in_name.as_ptr(),
18283 compression_in,
18284 effort_in_name.as_ptr(),
18285 effort_in,
18286 subsample_mode_in_name.as_ptr(),
18287 subsample_mode_in,
18288 encoder_in_name.as_ptr(),
18289 encoder_in,
18290 tune_in_name.as_ptr(),
18291 tune_in.as_ptr(),
18292 keep_in_name.as_ptr(),
18293 keep_in,
18294 background_in_name.as_ptr(),
18295 background_in,
18296 page_height_in_name.as_ptr(),
18297 page_height_in,
18298 profile_in_name.as_ptr(),
18299 profile_in.as_ptr(),
18300 NULL,
18301 );
18302 utils::result(vips_op_response, (), Error::HeifsaveTargetError)
18303 }
18304}
18305
18306pub fn thumbnail(filename: &str, width: i32) -> Result<VipsImage> {
18312 unsafe {
18313 let filename_in: CString = utils::new_c_string(filename)?;
18314 let width_in: i32 = width;
18315 let mut out_out: *mut bindings::VipsImage = null_mut();
18316
18317 let vips_op_response =
18318 bindings::vips_thumbnail(filename_in.as_ptr(), &mut out_out, width_in, NULL);
18319 utils::result(
18320 vips_op_response,
18321 VipsImage { ctx: out_out },
18322 Error::ThumbnailError,
18323 )
18324 }
18325}
18326
18327#[derive(Clone, Debug)]
18329pub struct ThumbnailOptions {
18330 pub height: i32,
18333 pub size: Size,
18339 pub no_rotate: bool,
18342 pub crop: Interesting,
18351 pub linear: bool,
18354 pub input_profile: String,
18356 pub output_profile: String,
18358 pub intent: Intent,
18365 pub fail_on: FailOn,
18371}
18372
18373impl std::default::Default for ThumbnailOptions {
18374 fn default() -> Self {
18375 ThumbnailOptions {
18376 height: i32::from(1),
18377 size: Size::Both,
18378 no_rotate: false,
18379 crop: Interesting::None,
18380 linear: false,
18381 input_profile: String::new(),
18382 output_profile: String::new(),
18383 intent: Intent::Relative,
18384 fail_on: FailOn::None,
18385 }
18386 }
18387}
18388
18389pub fn thumbnail_with_opts(
18396 filename: &str,
18397 width: i32,
18398 thumbnail_options: &ThumbnailOptions,
18399) -> Result<VipsImage> {
18400 unsafe {
18401 let filename_in: CString = utils::new_c_string(filename)?;
18402 let width_in: i32 = width;
18403 let mut out_out: *mut bindings::VipsImage = null_mut();
18404
18405 let height_in: i32 = thumbnail_options.height;
18406 let height_in_name = utils::new_c_string("height")?;
18407
18408 let size_in: i32 = thumbnail_options.size as i32;
18409 let size_in_name = utils::new_c_string("size")?;
18410
18411 let no_rotate_in: i32 = if thumbnail_options.no_rotate { 1 } else { 0 };
18412 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18413
18414 let crop_in: i32 = thumbnail_options.crop as i32;
18415 let crop_in_name = utils::new_c_string("crop")?;
18416
18417 let linear_in: i32 = if thumbnail_options.linear { 1 } else { 0 };
18418 let linear_in_name = utils::new_c_string("linear")?;
18419
18420 let input_profile_in: CString = utils::new_c_string(&thumbnail_options.input_profile)?;
18421 let input_profile_in_name = utils::new_c_string("input-profile")?;
18422
18423 let output_profile_in: CString = utils::new_c_string(&thumbnail_options.output_profile)?;
18424 let output_profile_in_name = utils::new_c_string("output-profile")?;
18425
18426 let intent_in: i32 = thumbnail_options.intent as i32;
18427 let intent_in_name = utils::new_c_string("intent")?;
18428
18429 let fail_on_in: i32 = thumbnail_options.fail_on as i32;
18430 let fail_on_in_name = utils::new_c_string("fail-on")?;
18431
18432 let vips_op_response = bindings::vips_thumbnail(
18433 filename_in.as_ptr(),
18434 &mut out_out,
18435 width_in,
18436 height_in_name.as_ptr(),
18437 height_in,
18438 size_in_name.as_ptr(),
18439 size_in,
18440 no_rotate_in_name.as_ptr(),
18441 no_rotate_in,
18442 crop_in_name.as_ptr(),
18443 crop_in,
18444 linear_in_name.as_ptr(),
18445 linear_in,
18446 input_profile_in_name.as_ptr(),
18447 input_profile_in.as_ptr(),
18448 output_profile_in_name.as_ptr(),
18449 output_profile_in.as_ptr(),
18450 intent_in_name.as_ptr(),
18451 intent_in,
18452 fail_on_in_name.as_ptr(),
18453 fail_on_in,
18454 NULL,
18455 );
18456 utils::result(
18457 vips_op_response,
18458 VipsImage { ctx: out_out },
18459 Error::ThumbnailError,
18460 )
18461 }
18462}
18463
18464pub fn thumbnail_buffer(buffer: &[u8], width: i32) -> Result<VipsImage> {
18470 unsafe {
18471 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
18472 let width_in: i32 = width;
18473 let mut out_out: *mut bindings::VipsImage = null_mut();
18474
18475 let vips_op_response = bindings::vips_thumbnail_buffer(
18476 buffer_in,
18477 buffer.len() as u64,
18478 &mut out_out,
18479 width_in,
18480 NULL,
18481 );
18482 utils::result(
18483 vips_op_response,
18484 VipsImage { ctx: out_out },
18485 Error::ThumbnailBufferError,
18486 )
18487 }
18488}
18489
18490#[derive(Clone, Debug)]
18492pub struct ThumbnailBufferOptions {
18493 pub option_string: String,
18495 pub height: i32,
18498 pub size: Size,
18504 pub no_rotate: bool,
18507 pub crop: Interesting,
18516 pub linear: bool,
18519 pub input_profile: String,
18521 pub output_profile: String,
18523 pub intent: Intent,
18530 pub fail_on: FailOn,
18536}
18537
18538impl std::default::Default for ThumbnailBufferOptions {
18539 fn default() -> Self {
18540 ThumbnailBufferOptions {
18541 option_string: String::new(),
18542 height: i32::from(1),
18543 size: Size::Both,
18544 no_rotate: false,
18545 crop: Interesting::None,
18546 linear: false,
18547 input_profile: String::new(),
18548 output_profile: String::new(),
18549 intent: Intent::Relative,
18550 fail_on: FailOn::None,
18551 }
18552 }
18553}
18554
18555pub fn thumbnail_buffer_with_opts(
18562 buffer: &[u8],
18563 width: i32,
18564 thumbnail_buffer_options: &ThumbnailBufferOptions,
18565) -> Result<VipsImage> {
18566 unsafe {
18567 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
18568 let width_in: i32 = width;
18569 let mut out_out: *mut bindings::VipsImage = null_mut();
18570
18571 let option_string_in: CString =
18572 utils::new_c_string(&thumbnail_buffer_options.option_string)?;
18573 let option_string_in_name = utils::new_c_string("option-string")?;
18574
18575 let height_in: i32 = thumbnail_buffer_options.height;
18576 let height_in_name = utils::new_c_string("height")?;
18577
18578 let size_in: i32 = thumbnail_buffer_options.size as i32;
18579 let size_in_name = utils::new_c_string("size")?;
18580
18581 let no_rotate_in: i32 = if thumbnail_buffer_options.no_rotate {
18582 1
18583 } else {
18584 0
18585 };
18586 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18587
18588 let crop_in: i32 = thumbnail_buffer_options.crop as i32;
18589 let crop_in_name = utils::new_c_string("crop")?;
18590
18591 let linear_in: i32 = if thumbnail_buffer_options.linear {
18592 1
18593 } else {
18594 0
18595 };
18596 let linear_in_name = utils::new_c_string("linear")?;
18597
18598 let input_profile_in: CString =
18599 utils::new_c_string(&thumbnail_buffer_options.input_profile)?;
18600 let input_profile_in_name = utils::new_c_string("input-profile")?;
18601
18602 let output_profile_in: CString =
18603 utils::new_c_string(&thumbnail_buffer_options.output_profile)?;
18604 let output_profile_in_name = utils::new_c_string("output-profile")?;
18605
18606 let intent_in: i32 = thumbnail_buffer_options.intent as i32;
18607 let intent_in_name = utils::new_c_string("intent")?;
18608
18609 let fail_on_in: i32 = thumbnail_buffer_options.fail_on as i32;
18610 let fail_on_in_name = utils::new_c_string("fail-on")?;
18611
18612 let vips_op_response = bindings::vips_thumbnail_buffer(
18613 buffer_in,
18614 buffer.len() as u64,
18615 &mut out_out,
18616 width_in,
18617 option_string_in_name.as_ptr(),
18618 option_string_in.as_ptr(),
18619 height_in_name.as_ptr(),
18620 height_in,
18621 size_in_name.as_ptr(),
18622 size_in,
18623 no_rotate_in_name.as_ptr(),
18624 no_rotate_in,
18625 crop_in_name.as_ptr(),
18626 crop_in,
18627 linear_in_name.as_ptr(),
18628 linear_in,
18629 input_profile_in_name.as_ptr(),
18630 input_profile_in.as_ptr(),
18631 output_profile_in_name.as_ptr(),
18632 output_profile_in.as_ptr(),
18633 intent_in_name.as_ptr(),
18634 intent_in,
18635 fail_on_in_name.as_ptr(),
18636 fail_on_in,
18637 NULL,
18638 );
18639 utils::result(
18640 vips_op_response,
18641 VipsImage { ctx: out_out },
18642 Error::ThumbnailBufferError,
18643 )
18644 }
18645}
18646
18647pub fn thumbnail_image(inp: &VipsImage, width: i32) -> Result<VipsImage> {
18653 unsafe {
18654 let inp_in: *mut bindings::VipsImage = inp.ctx;
18655 let width_in: i32 = width;
18656 let mut out_out: *mut bindings::VipsImage = null_mut();
18657
18658 let vips_op_response = bindings::vips_thumbnail_image(inp_in, &mut out_out, width_in, NULL);
18659 utils::result(
18660 vips_op_response,
18661 VipsImage { ctx: out_out },
18662 Error::ThumbnailImageError,
18663 )
18664 }
18665}
18666
18667#[derive(Clone, Debug)]
18669pub struct ThumbnailImageOptions {
18670 pub height: i32,
18673 pub size: Size,
18679 pub no_rotate: bool,
18682 pub crop: Interesting,
18691 pub linear: bool,
18694 pub input_profile: String,
18696 pub output_profile: String,
18698 pub intent: Intent,
18705 pub fail_on: FailOn,
18711}
18712
18713impl std::default::Default for ThumbnailImageOptions {
18714 fn default() -> Self {
18715 ThumbnailImageOptions {
18716 height: i32::from(1),
18717 size: Size::Both,
18718 no_rotate: false,
18719 crop: Interesting::None,
18720 linear: false,
18721 input_profile: String::new(),
18722 output_profile: String::new(),
18723 intent: Intent::Relative,
18724 fail_on: FailOn::None,
18725 }
18726 }
18727}
18728
18729pub fn thumbnail_image_with_opts(
18736 inp: &VipsImage,
18737 width: i32,
18738 thumbnail_image_options: &ThumbnailImageOptions,
18739) -> Result<VipsImage> {
18740 unsafe {
18741 let inp_in: *mut bindings::VipsImage = inp.ctx;
18742 let width_in: i32 = width;
18743 let mut out_out: *mut bindings::VipsImage = null_mut();
18744
18745 let height_in: i32 = thumbnail_image_options.height;
18746 let height_in_name = utils::new_c_string("height")?;
18747
18748 let size_in: i32 = thumbnail_image_options.size as i32;
18749 let size_in_name = utils::new_c_string("size")?;
18750
18751 let no_rotate_in: i32 = if thumbnail_image_options.no_rotate {
18752 1
18753 } else {
18754 0
18755 };
18756 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18757
18758 let crop_in: i32 = thumbnail_image_options.crop as i32;
18759 let crop_in_name = utils::new_c_string("crop")?;
18760
18761 let linear_in: i32 = if thumbnail_image_options.linear { 1 } else { 0 };
18762 let linear_in_name = utils::new_c_string("linear")?;
18763
18764 let input_profile_in: CString =
18765 utils::new_c_string(&thumbnail_image_options.input_profile)?;
18766 let input_profile_in_name = utils::new_c_string("input-profile")?;
18767
18768 let output_profile_in: CString =
18769 utils::new_c_string(&thumbnail_image_options.output_profile)?;
18770 let output_profile_in_name = utils::new_c_string("output-profile")?;
18771
18772 let intent_in: i32 = thumbnail_image_options.intent as i32;
18773 let intent_in_name = utils::new_c_string("intent")?;
18774
18775 let fail_on_in: i32 = thumbnail_image_options.fail_on as i32;
18776 let fail_on_in_name = utils::new_c_string("fail-on")?;
18777
18778 let vips_op_response = bindings::vips_thumbnail_image(
18779 inp_in,
18780 &mut out_out,
18781 width_in,
18782 height_in_name.as_ptr(),
18783 height_in,
18784 size_in_name.as_ptr(),
18785 size_in,
18786 no_rotate_in_name.as_ptr(),
18787 no_rotate_in,
18788 crop_in_name.as_ptr(),
18789 crop_in,
18790 linear_in_name.as_ptr(),
18791 linear_in,
18792 input_profile_in_name.as_ptr(),
18793 input_profile_in.as_ptr(),
18794 output_profile_in_name.as_ptr(),
18795 output_profile_in.as_ptr(),
18796 intent_in_name.as_ptr(),
18797 intent_in,
18798 fail_on_in_name.as_ptr(),
18799 fail_on_in,
18800 NULL,
18801 );
18802 utils::result(
18803 vips_op_response,
18804 VipsImage { ctx: out_out },
18805 Error::ThumbnailImageError,
18806 )
18807 }
18808}
18809
18810pub fn thumbnail_source(source: &VipsSource, width: i32) -> Result<VipsImage> {
18816 unsafe {
18817 let source_in: *mut bindings::VipsSource = source.ctx;
18818 let width_in: i32 = width;
18819 let mut out_out: *mut bindings::VipsImage = null_mut();
18820
18821 let vips_op_response =
18822 bindings::vips_thumbnail_source(source_in, &mut out_out, width_in, NULL);
18823 utils::result(
18824 vips_op_response,
18825 VipsImage { ctx: out_out },
18826 Error::ThumbnailSourceError,
18827 )
18828 }
18829}
18830
18831#[derive(Clone, Debug)]
18833pub struct ThumbnailSourceOptions {
18834 pub option_string: String,
18836 pub height: i32,
18839 pub size: Size,
18845 pub no_rotate: bool,
18848 pub crop: Interesting,
18857 pub linear: bool,
18860 pub input_profile: String,
18862 pub output_profile: String,
18864 pub intent: Intent,
18871 pub fail_on: FailOn,
18877}
18878
18879impl std::default::Default for ThumbnailSourceOptions {
18880 fn default() -> Self {
18881 ThumbnailSourceOptions {
18882 option_string: String::new(),
18883 height: i32::from(1),
18884 size: Size::Both,
18885 no_rotate: false,
18886 crop: Interesting::None,
18887 linear: false,
18888 input_profile: String::new(),
18889 output_profile: String::new(),
18890 intent: Intent::Relative,
18891 fail_on: FailOn::None,
18892 }
18893 }
18894}
18895
18896pub fn thumbnail_source_with_opts(
18903 source: &VipsSource,
18904 width: i32,
18905 thumbnail_source_options: &ThumbnailSourceOptions,
18906) -> Result<VipsImage> {
18907 unsafe {
18908 let source_in: *mut bindings::VipsSource = source.ctx;
18909 let width_in: i32 = width;
18910 let mut out_out: *mut bindings::VipsImage = null_mut();
18911
18912 let option_string_in: CString =
18913 utils::new_c_string(&thumbnail_source_options.option_string)?;
18914 let option_string_in_name = utils::new_c_string("option-string")?;
18915
18916 let height_in: i32 = thumbnail_source_options.height;
18917 let height_in_name = utils::new_c_string("height")?;
18918
18919 let size_in: i32 = thumbnail_source_options.size as i32;
18920 let size_in_name = utils::new_c_string("size")?;
18921
18922 let no_rotate_in: i32 = if thumbnail_source_options.no_rotate {
18923 1
18924 } else {
18925 0
18926 };
18927 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18928
18929 let crop_in: i32 = thumbnail_source_options.crop as i32;
18930 let crop_in_name = utils::new_c_string("crop")?;
18931
18932 let linear_in: i32 = if thumbnail_source_options.linear {
18933 1
18934 } else {
18935 0
18936 };
18937 let linear_in_name = utils::new_c_string("linear")?;
18938
18939 let input_profile_in: CString =
18940 utils::new_c_string(&thumbnail_source_options.input_profile)?;
18941 let input_profile_in_name = utils::new_c_string("input-profile")?;
18942
18943 let output_profile_in: CString =
18944 utils::new_c_string(&thumbnail_source_options.output_profile)?;
18945 let output_profile_in_name = utils::new_c_string("output-profile")?;
18946
18947 let intent_in: i32 = thumbnail_source_options.intent as i32;
18948 let intent_in_name = utils::new_c_string("intent")?;
18949
18950 let fail_on_in: i32 = thumbnail_source_options.fail_on as i32;
18951 let fail_on_in_name = utils::new_c_string("fail-on")?;
18952
18953 let vips_op_response = bindings::vips_thumbnail_source(
18954 source_in,
18955 &mut out_out,
18956 width_in,
18957 option_string_in_name.as_ptr(),
18958 option_string_in.as_ptr(),
18959 height_in_name.as_ptr(),
18960 height_in,
18961 size_in_name.as_ptr(),
18962 size_in,
18963 no_rotate_in_name.as_ptr(),
18964 no_rotate_in,
18965 crop_in_name.as_ptr(),
18966 crop_in,
18967 linear_in_name.as_ptr(),
18968 linear_in,
18969 input_profile_in_name.as_ptr(),
18970 input_profile_in.as_ptr(),
18971 output_profile_in_name.as_ptr(),
18972 output_profile_in.as_ptr(),
18973 intent_in_name.as_ptr(),
18974 intent_in,
18975 fail_on_in_name.as_ptr(),
18976 fail_on_in,
18977 NULL,
18978 );
18979 utils::result(
18980 vips_op_response,
18981 VipsImage { ctx: out_out },
18982 Error::ThumbnailSourceError,
18983 )
18984 }
18985}
18986
18987pub fn mapim(inp: &VipsImage, index: &VipsImage) -> Result<VipsImage> {
18992 unsafe {
18993 let inp_in: *mut bindings::VipsImage = inp.ctx;
18994 let index_in: *mut bindings::VipsImage = index.ctx;
18995 let mut out_out: *mut bindings::VipsImage = null_mut();
18996
18997 let vips_op_response = bindings::vips_mapim(inp_in, &mut out_out, index_in, NULL);
18998 utils::result(
18999 vips_op_response,
19000 VipsImage { ctx: out_out },
19001 Error::MapimError,
19002 )
19003 }
19004}
19005
19006#[derive(Clone, Debug)]
19008pub struct MapimOptions {
19009 pub interpolate: VipsInterpolate,
19011 pub background: Vec<f64>,
19013 pub premultiplied: bool,
19016 pub extend: Extend,
19024}
19025
19026impl std::default::Default for MapimOptions {
19027 fn default() -> Self {
19028 MapimOptions {
19029 interpolate: VipsInterpolate::new(),
19030 background: Vec::new(),
19031 premultiplied: false,
19032 extend: Extend::Background,
19033 }
19034 }
19035}
19036
19037pub fn mapim_with_opts(
19043 inp: &VipsImage,
19044 index: &VipsImage,
19045 mapim_options: &MapimOptions,
19046) -> Result<VipsImage> {
19047 unsafe {
19048 let inp_in: *mut bindings::VipsImage = inp.ctx;
19049 let index_in: *mut bindings::VipsImage = index.ctx;
19050 let mut out_out: *mut bindings::VipsImage = null_mut();
19051
19052 let interpolate_in: *mut bindings::VipsInterpolate = mapim_options.interpolate.ctx;
19053 let interpolate_in_name = utils::new_c_string("interpolate")?;
19054
19055 let background_wrapper = utils::VipsArrayDoubleWrapper::from(&mapim_options.background[..]);
19056 let background_in = background_wrapper.ctx;
19057 let background_in_name = utils::new_c_string("background")?;
19058
19059 let premultiplied_in: i32 = if mapim_options.premultiplied { 1 } else { 0 };
19060 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
19061
19062 let extend_in: i32 = mapim_options.extend as i32;
19063 let extend_in_name = utils::new_c_string("extend")?;
19064
19065 let vips_op_response = bindings::vips_mapim(
19066 inp_in,
19067 &mut out_out,
19068 index_in,
19069 interpolate_in_name.as_ptr(),
19070 interpolate_in,
19071 background_in_name.as_ptr(),
19072 background_in,
19073 premultiplied_in_name.as_ptr(),
19074 premultiplied_in,
19075 extend_in_name.as_ptr(),
19076 extend_in,
19077 NULL,
19078 );
19079 utils::result(
19080 vips_op_response,
19081 VipsImage { ctx: out_out },
19082 Error::MapimError,
19083 )
19084 }
19085}
19086
19087pub fn shrink(inp: &VipsImage, hshrink: f64, vshrink: f64) -> Result<VipsImage> {
19095 unsafe {
19096 let inp_in: *mut bindings::VipsImage = inp.ctx;
19097 let hshrink_in: f64 = hshrink;
19098 let vshrink_in: f64 = vshrink;
19099 let mut out_out: *mut bindings::VipsImage = null_mut();
19100
19101 let vips_op_response =
19102 bindings::vips_shrink(inp_in, &mut out_out, hshrink_in, vshrink_in, NULL);
19103 utils::result(
19104 vips_op_response,
19105 VipsImage { ctx: out_out },
19106 Error::ShrinkError,
19107 )
19108 }
19109}
19110
19111#[derive(Clone, Debug)]
19113pub struct ShrinkOptions {
19114 pub ceil: bool,
19117}
19118
19119impl std::default::Default for ShrinkOptions {
19120 fn default() -> Self {
19121 ShrinkOptions { ceil: false }
19122 }
19123}
19124
19125pub fn shrink_with_opts(
19134 inp: &VipsImage,
19135 hshrink: f64,
19136 vshrink: f64,
19137 shrink_options: &ShrinkOptions,
19138) -> Result<VipsImage> {
19139 unsafe {
19140 let inp_in: *mut bindings::VipsImage = inp.ctx;
19141 let hshrink_in: f64 = hshrink;
19142 let vshrink_in: f64 = vshrink;
19143 let mut out_out: *mut bindings::VipsImage = null_mut();
19144
19145 let ceil_in: i32 = if shrink_options.ceil { 1 } else { 0 };
19146 let ceil_in_name = utils::new_c_string("ceil")?;
19147
19148 let vips_op_response = bindings::vips_shrink(
19149 inp_in,
19150 &mut out_out,
19151 hshrink_in,
19152 vshrink_in,
19153 ceil_in_name.as_ptr(),
19154 ceil_in,
19155 NULL,
19156 );
19157 utils::result(
19158 vips_op_response,
19159 VipsImage { ctx: out_out },
19160 Error::ShrinkError,
19161 )
19162 }
19163}
19164
19165pub fn shrinkh(inp: &VipsImage, hshrink: i32) -> Result<VipsImage> {
19171 unsafe {
19172 let inp_in: *mut bindings::VipsImage = inp.ctx;
19173 let hshrink_in: i32 = hshrink;
19174 let mut out_out: *mut bindings::VipsImage = null_mut();
19175
19176 let vips_op_response = bindings::vips_shrinkh(inp_in, &mut out_out, hshrink_in, NULL);
19177 utils::result(
19178 vips_op_response,
19179 VipsImage { ctx: out_out },
19180 Error::ShrinkhError,
19181 )
19182 }
19183}
19184
19185#[derive(Clone, Debug)]
19187pub struct ShrinkhOptions {
19188 pub ceil: bool,
19191}
19192
19193impl std::default::Default for ShrinkhOptions {
19194 fn default() -> Self {
19195 ShrinkhOptions { ceil: false }
19196 }
19197}
19198
19199pub fn shrinkh_with_opts(
19206 inp: &VipsImage,
19207 hshrink: i32,
19208 shrinkh_options: &ShrinkhOptions,
19209) -> Result<VipsImage> {
19210 unsafe {
19211 let inp_in: *mut bindings::VipsImage = inp.ctx;
19212 let hshrink_in: i32 = hshrink;
19213 let mut out_out: *mut bindings::VipsImage = null_mut();
19214
19215 let ceil_in: i32 = if shrinkh_options.ceil { 1 } else { 0 };
19216 let ceil_in_name = utils::new_c_string("ceil")?;
19217
19218 let vips_op_response = bindings::vips_shrinkh(
19219 inp_in,
19220 &mut out_out,
19221 hshrink_in,
19222 ceil_in_name.as_ptr(),
19223 ceil_in,
19224 NULL,
19225 );
19226 utils::result(
19227 vips_op_response,
19228 VipsImage { ctx: out_out },
19229 Error::ShrinkhError,
19230 )
19231 }
19232}
19233
19234pub fn shrinkv(inp: &VipsImage, vshrink: i32) -> Result<VipsImage> {
19240 unsafe {
19241 let inp_in: *mut bindings::VipsImage = inp.ctx;
19242 let vshrink_in: i32 = vshrink;
19243 let mut out_out: *mut bindings::VipsImage = null_mut();
19244
19245 let vips_op_response = bindings::vips_shrinkv(inp_in, &mut out_out, vshrink_in, NULL);
19246 utils::result(
19247 vips_op_response,
19248 VipsImage { ctx: out_out },
19249 Error::ShrinkvError,
19250 )
19251 }
19252}
19253
19254#[derive(Clone, Debug)]
19256pub struct ShrinkvOptions {
19257 pub ceil: bool,
19260}
19261
19262impl std::default::Default for ShrinkvOptions {
19263 fn default() -> Self {
19264 ShrinkvOptions { ceil: false }
19265 }
19266}
19267
19268pub fn shrinkv_with_opts(
19275 inp: &VipsImage,
19276 vshrink: i32,
19277 shrinkv_options: &ShrinkvOptions,
19278) -> Result<VipsImage> {
19279 unsafe {
19280 let inp_in: *mut bindings::VipsImage = inp.ctx;
19281 let vshrink_in: i32 = vshrink;
19282 let mut out_out: *mut bindings::VipsImage = null_mut();
19283
19284 let ceil_in: i32 = if shrinkv_options.ceil { 1 } else { 0 };
19285 let ceil_in_name = utils::new_c_string("ceil")?;
19286
19287 let vips_op_response = bindings::vips_shrinkv(
19288 inp_in,
19289 &mut out_out,
19290 vshrink_in,
19291 ceil_in_name.as_ptr(),
19292 ceil_in,
19293 NULL,
19294 );
19295 utils::result(
19296 vips_op_response,
19297 VipsImage { ctx: out_out },
19298 Error::ShrinkvError,
19299 )
19300 }
19301}
19302
19303pub fn reduceh(inp: &VipsImage, hshrink: f64) -> Result<VipsImage> {
19309 unsafe {
19310 let inp_in: *mut bindings::VipsImage = inp.ctx;
19311 let hshrink_in: f64 = hshrink;
19312 let mut out_out: *mut bindings::VipsImage = null_mut();
19313
19314 let vips_op_response = bindings::vips_reduceh(inp_in, &mut out_out, hshrink_in, NULL);
19315 utils::result(
19316 vips_op_response,
19317 VipsImage { ctx: out_out },
19318 Error::ReducehError,
19319 )
19320 }
19321}
19322
19323#[derive(Clone, Debug)]
19325pub struct ReducehOptions {
19326 pub kernel: Kernel,
19336 pub gap: f64,
19339}
19340
19341impl std::default::Default for ReducehOptions {
19342 fn default() -> Self {
19343 ReducehOptions {
19344 kernel: Kernel::Lanczos3,
19345 gap: f64::from(0),
19346 }
19347 }
19348}
19349
19350pub fn reduceh_with_opts(
19357 inp: &VipsImage,
19358 hshrink: f64,
19359 reduceh_options: &ReducehOptions,
19360) -> Result<VipsImage> {
19361 unsafe {
19362 let inp_in: *mut bindings::VipsImage = inp.ctx;
19363 let hshrink_in: f64 = hshrink;
19364 let mut out_out: *mut bindings::VipsImage = null_mut();
19365
19366 let kernel_in: i32 = reduceh_options.kernel as i32;
19367 let kernel_in_name = utils::new_c_string("kernel")?;
19368
19369 let gap_in: f64 = reduceh_options.gap;
19370 let gap_in_name = utils::new_c_string("gap")?;
19371
19372 let vips_op_response = bindings::vips_reduceh(
19373 inp_in,
19374 &mut out_out,
19375 hshrink_in,
19376 kernel_in_name.as_ptr(),
19377 kernel_in,
19378 gap_in_name.as_ptr(),
19379 gap_in,
19380 NULL,
19381 );
19382 utils::result(
19383 vips_op_response,
19384 VipsImage { ctx: out_out },
19385 Error::ReducehError,
19386 )
19387 }
19388}
19389
19390pub fn reducev(inp: &VipsImage, vshrink: f64) -> Result<VipsImage> {
19396 unsafe {
19397 let inp_in: *mut bindings::VipsImage = inp.ctx;
19398 let vshrink_in: f64 = vshrink;
19399 let mut out_out: *mut bindings::VipsImage = null_mut();
19400
19401 let vips_op_response = bindings::vips_reducev(inp_in, &mut out_out, vshrink_in, NULL);
19402 utils::result(
19403 vips_op_response,
19404 VipsImage { ctx: out_out },
19405 Error::ReducevError,
19406 )
19407 }
19408}
19409
19410#[derive(Clone, Debug)]
19412pub struct ReducevOptions {
19413 pub kernel: Kernel,
19423 pub gap: f64,
19426}
19427
19428impl std::default::Default for ReducevOptions {
19429 fn default() -> Self {
19430 ReducevOptions {
19431 kernel: Kernel::Lanczos3,
19432 gap: f64::from(0),
19433 }
19434 }
19435}
19436
19437pub fn reducev_with_opts(
19444 inp: &VipsImage,
19445 vshrink: f64,
19446 reducev_options: &ReducevOptions,
19447) -> Result<VipsImage> {
19448 unsafe {
19449 let inp_in: *mut bindings::VipsImage = inp.ctx;
19450 let vshrink_in: f64 = vshrink;
19451 let mut out_out: *mut bindings::VipsImage = null_mut();
19452
19453 let kernel_in: i32 = reducev_options.kernel as i32;
19454 let kernel_in_name = utils::new_c_string("kernel")?;
19455
19456 let gap_in: f64 = reducev_options.gap;
19457 let gap_in_name = utils::new_c_string("gap")?;
19458
19459 let vips_op_response = bindings::vips_reducev(
19460 inp_in,
19461 &mut out_out,
19462 vshrink_in,
19463 kernel_in_name.as_ptr(),
19464 kernel_in,
19465 gap_in_name.as_ptr(),
19466 gap_in,
19467 NULL,
19468 );
19469 utils::result(
19470 vips_op_response,
19471 VipsImage { ctx: out_out },
19472 Error::ReducevError,
19473 )
19474 }
19475}
19476
19477pub fn reduce(inp: &VipsImage, hshrink: f64, vshrink: f64) -> Result<VipsImage> {
19485 unsafe {
19486 let inp_in: *mut bindings::VipsImage = inp.ctx;
19487 let hshrink_in: f64 = hshrink;
19488 let vshrink_in: f64 = vshrink;
19489 let mut out_out: *mut bindings::VipsImage = null_mut();
19490
19491 let vips_op_response =
19492 bindings::vips_reduce(inp_in, &mut out_out, hshrink_in, vshrink_in, NULL);
19493 utils::result(
19494 vips_op_response,
19495 VipsImage { ctx: out_out },
19496 Error::ReduceError,
19497 )
19498 }
19499}
19500
19501#[derive(Clone, Debug)]
19503pub struct ReduceOptions {
19504 pub kernel: Kernel,
19514 pub gap: f64,
19517}
19518
19519impl std::default::Default for ReduceOptions {
19520 fn default() -> Self {
19521 ReduceOptions {
19522 kernel: Kernel::Lanczos3,
19523 gap: f64::from(0),
19524 }
19525 }
19526}
19527
19528pub fn reduce_with_opts(
19537 inp: &VipsImage,
19538 hshrink: f64,
19539 vshrink: f64,
19540 reduce_options: &ReduceOptions,
19541) -> Result<VipsImage> {
19542 unsafe {
19543 let inp_in: *mut bindings::VipsImage = inp.ctx;
19544 let hshrink_in: f64 = hshrink;
19545 let vshrink_in: f64 = vshrink;
19546 let mut out_out: *mut bindings::VipsImage = null_mut();
19547
19548 let kernel_in: i32 = reduce_options.kernel as i32;
19549 let kernel_in_name = utils::new_c_string("kernel")?;
19550
19551 let gap_in: f64 = reduce_options.gap;
19552 let gap_in_name = utils::new_c_string("gap")?;
19553
19554 let vips_op_response = bindings::vips_reduce(
19555 inp_in,
19556 &mut out_out,
19557 hshrink_in,
19558 vshrink_in,
19559 kernel_in_name.as_ptr(),
19560 kernel_in,
19561 gap_in_name.as_ptr(),
19562 gap_in,
19563 NULL,
19564 );
19565 utils::result(
19566 vips_op_response,
19567 VipsImage { ctx: out_out },
19568 Error::ReduceError,
19569 )
19570 }
19571}
19572
19573pub fn quadratic(inp: &VipsImage, coeff: &VipsImage) -> Result<VipsImage> {
19578 unsafe {
19579 let inp_in: *mut bindings::VipsImage = inp.ctx;
19580 let coeff_in: *mut bindings::VipsImage = coeff.ctx;
19581 let mut out_out: *mut bindings::VipsImage = null_mut();
19582
19583 let vips_op_response = bindings::vips_quadratic(inp_in, &mut out_out, coeff_in, NULL);
19584 utils::result(
19585 vips_op_response,
19586 VipsImage { ctx: out_out },
19587 Error::QuadraticError,
19588 )
19589 }
19590}
19591
19592#[derive(Clone, Debug)]
19594pub struct QuadraticOptions {
19595 pub interpolate: VipsInterpolate,
19597}
19598
19599impl std::default::Default for QuadraticOptions {
19600 fn default() -> Self {
19601 QuadraticOptions {
19602 interpolate: VipsInterpolate::new(),
19603 }
19604 }
19605}
19606
19607pub fn quadratic_with_opts(
19613 inp: &VipsImage,
19614 coeff: &VipsImage,
19615 quadratic_options: &QuadraticOptions,
19616) -> Result<VipsImage> {
19617 unsafe {
19618 let inp_in: *mut bindings::VipsImage = inp.ctx;
19619 let coeff_in: *mut bindings::VipsImage = coeff.ctx;
19620 let mut out_out: *mut bindings::VipsImage = null_mut();
19621
19622 let interpolate_in: *mut bindings::VipsInterpolate = quadratic_options.interpolate.ctx;
19623 let interpolate_in_name = utils::new_c_string("interpolate")?;
19624
19625 let vips_op_response = bindings::vips_quadratic(
19626 inp_in,
19627 &mut out_out,
19628 coeff_in,
19629 interpolate_in_name.as_ptr(),
19630 interpolate_in,
19631 NULL,
19632 );
19633 utils::result(
19634 vips_op_response,
19635 VipsImage { ctx: out_out },
19636 Error::QuadraticError,
19637 )
19638 }
19639}
19640
19641pub fn affine(inp: &VipsImage, a: f64, b: f64, c: f64, d: f64) -> Result<VipsImage> {
19653 unsafe {
19654 let inp_in: *mut bindings::VipsImage = inp.ctx;
19655 let a_in: f64 = a;
19656 let b_in: f64 = b;
19657 let c_in: f64 = c;
19658 let d_in: f64 = d;
19659 let mut out_out: *mut bindings::VipsImage = null_mut();
19660
19661 let vips_op_response =
19662 bindings::vips_affine(inp_in, &mut out_out, a_in, b_in, c_in, d_in, NULL);
19663 utils::result(
19664 vips_op_response,
19665 VipsImage { ctx: out_out },
19666 Error::AffineError,
19667 )
19668 }
19669}
19670
19671#[derive(Clone, Debug)]
19673pub struct AffineOptions {
19674 pub interpolate: VipsInterpolate,
19676 pub oarea: Vec<i32>,
19678 pub odx: f64,
19681 pub ody: f64,
19684 pub idx: f64,
19687 pub idy: f64,
19690 pub background: Vec<f64>,
19692 pub premultiplied: bool,
19695 pub extend: Extend,
19703}
19704
19705impl std::default::Default for AffineOptions {
19706 fn default() -> Self {
19707 AffineOptions {
19708 interpolate: VipsInterpolate::new(),
19709 oarea: Vec::new(),
19710 odx: f64::from(0),
19711 ody: f64::from(0),
19712 idx: f64::from(0),
19713 idy: f64::from(0),
19714 background: Vec::new(),
19715 premultiplied: false,
19716 extend: Extend::Background,
19717 }
19718 }
19719}
19720
19721pub fn affine_with_opts(
19734 inp: &VipsImage,
19735 a: f64,
19736 b: f64,
19737 c: f64,
19738 d: f64,
19739 affine_options: &AffineOptions,
19740) -> Result<VipsImage> {
19741 unsafe {
19742 let inp_in: *mut bindings::VipsImage = inp.ctx;
19743 let a_in: f64 = a;
19744 let b_in: f64 = b;
19745 let c_in: f64 = c;
19746 let d_in: f64 = d;
19747 let mut out_out: *mut bindings::VipsImage = null_mut();
19748
19749 let interpolate_in: *mut bindings::VipsInterpolate = affine_options.interpolate.ctx;
19750 let interpolate_in_name = utils::new_c_string("interpolate")?;
19751
19752 let oarea_wrapper = utils::VipsArrayIntWrapper::from(&affine_options.oarea[..]);
19753 let oarea_in = oarea_wrapper.ctx;
19754 let oarea_in_name = utils::new_c_string("oarea")?;
19755
19756 let odx_in: f64 = affine_options.odx;
19757 let odx_in_name = utils::new_c_string("odx")?;
19758
19759 let ody_in: f64 = affine_options.ody;
19760 let ody_in_name = utils::new_c_string("ody")?;
19761
19762 let idx_in: f64 = affine_options.idx;
19763 let idx_in_name = utils::new_c_string("idx")?;
19764
19765 let idy_in: f64 = affine_options.idy;
19766 let idy_in_name = utils::new_c_string("idy")?;
19767
19768 let background_wrapper =
19769 utils::VipsArrayDoubleWrapper::from(&affine_options.background[..]);
19770 let background_in = background_wrapper.ctx;
19771 let background_in_name = utils::new_c_string("background")?;
19772
19773 let premultiplied_in: i32 = if affine_options.premultiplied { 1 } else { 0 };
19774 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
19775
19776 let extend_in: i32 = affine_options.extend as i32;
19777 let extend_in_name = utils::new_c_string("extend")?;
19778
19779 let vips_op_response = bindings::vips_affine(
19780 inp_in,
19781 &mut out_out,
19782 a_in,
19783 b_in,
19784 c_in,
19785 d_in,
19786 interpolate_in_name.as_ptr(),
19787 interpolate_in,
19788 oarea_in_name.as_ptr(),
19789 oarea_in,
19790 odx_in_name.as_ptr(),
19791 odx_in,
19792 ody_in_name.as_ptr(),
19793 ody_in,
19794 idx_in_name.as_ptr(),
19795 idx_in,
19796 idy_in_name.as_ptr(),
19797 idy_in,
19798 background_in_name.as_ptr(),
19799 background_in,
19800 premultiplied_in_name.as_ptr(),
19801 premultiplied_in,
19802 extend_in_name.as_ptr(),
19803 extend_in,
19804 NULL,
19805 );
19806 utils::result(
19807 vips_op_response,
19808 VipsImage { ctx: out_out },
19809 Error::AffineError,
19810 )
19811 }
19812}
19813
19814pub fn similarity(inp: &VipsImage) -> Result<VipsImage> {
19818 unsafe {
19819 let inp_in: *mut bindings::VipsImage = inp.ctx;
19820 let mut out_out: *mut bindings::VipsImage = null_mut();
19821
19822 let vips_op_response = bindings::vips_similarity(inp_in, &mut out_out, NULL);
19823 utils::result(
19824 vips_op_response,
19825 VipsImage { ctx: out_out },
19826 Error::SimilarityError,
19827 )
19828 }
19829}
19830
19831#[derive(Clone, Debug)]
19833pub struct SimilarityOptions {
19834 pub scale: f64,
19837 pub angle: f64,
19840 pub interpolate: VipsInterpolate,
19842 pub background: Vec<f64>,
19844 pub odx: f64,
19847 pub ody: f64,
19850 pub idx: f64,
19853 pub idy: f64,
19856}
19857
19858impl std::default::Default for SimilarityOptions {
19859 fn default() -> Self {
19860 SimilarityOptions {
19861 scale: f64::from(1),
19862 angle: f64::from(0),
19863 interpolate: VipsInterpolate::new(),
19864 background: Vec::new(),
19865 odx: f64::from(0),
19866 ody: f64::from(0),
19867 idx: f64::from(0),
19868 idy: f64::from(0),
19869 }
19870 }
19871}
19872
19873pub fn similarity_with_opts(
19878 inp: &VipsImage,
19879 similarity_options: &SimilarityOptions,
19880) -> Result<VipsImage> {
19881 unsafe {
19882 let inp_in: *mut bindings::VipsImage = inp.ctx;
19883 let mut out_out: *mut bindings::VipsImage = null_mut();
19884
19885 let scale_in: f64 = similarity_options.scale;
19886 let scale_in_name = utils::new_c_string("scale")?;
19887
19888 let angle_in: f64 = similarity_options.angle;
19889 let angle_in_name = utils::new_c_string("angle")?;
19890
19891 let interpolate_in: *mut bindings::VipsInterpolate = similarity_options.interpolate.ctx;
19892 let interpolate_in_name = utils::new_c_string("interpolate")?;
19893
19894 let background_wrapper =
19895 utils::VipsArrayDoubleWrapper::from(&similarity_options.background[..]);
19896 let background_in = background_wrapper.ctx;
19897 let background_in_name = utils::new_c_string("background")?;
19898
19899 let odx_in: f64 = similarity_options.odx;
19900 let odx_in_name = utils::new_c_string("odx")?;
19901
19902 let ody_in: f64 = similarity_options.ody;
19903 let ody_in_name = utils::new_c_string("ody")?;
19904
19905 let idx_in: f64 = similarity_options.idx;
19906 let idx_in_name = utils::new_c_string("idx")?;
19907
19908 let idy_in: f64 = similarity_options.idy;
19909 let idy_in_name = utils::new_c_string("idy")?;
19910
19911 let vips_op_response = bindings::vips_similarity(
19912 inp_in,
19913 &mut out_out,
19914 scale_in_name.as_ptr(),
19915 scale_in,
19916 angle_in_name.as_ptr(),
19917 angle_in,
19918 interpolate_in_name.as_ptr(),
19919 interpolate_in,
19920 background_in_name.as_ptr(),
19921 background_in,
19922 odx_in_name.as_ptr(),
19923 odx_in,
19924 ody_in_name.as_ptr(),
19925 ody_in,
19926 idx_in_name.as_ptr(),
19927 idx_in,
19928 idy_in_name.as_ptr(),
19929 idy_in,
19930 NULL,
19931 );
19932 utils::result(
19933 vips_op_response,
19934 VipsImage { ctx: out_out },
19935 Error::SimilarityError,
19936 )
19937 }
19938}
19939
19940pub fn rotate(inp: &VipsImage, angle: f64) -> Result<VipsImage> {
19946 unsafe {
19947 let inp_in: *mut bindings::VipsImage = inp.ctx;
19948 let angle_in: f64 = angle;
19949 let mut out_out: *mut bindings::VipsImage = null_mut();
19950
19951 let vips_op_response = bindings::vips_rotate(inp_in, &mut out_out, angle_in, NULL);
19952 utils::result(
19953 vips_op_response,
19954 VipsImage { ctx: out_out },
19955 Error::RotateError,
19956 )
19957 }
19958}
19959
19960#[derive(Clone, Debug)]
19962pub struct RotateOptions {
19963 pub interpolate: VipsInterpolate,
19965 pub background: Vec<f64>,
19967 pub odx: f64,
19970 pub ody: f64,
19973 pub idx: f64,
19976 pub idy: f64,
19979}
19980
19981impl std::default::Default for RotateOptions {
19982 fn default() -> Self {
19983 RotateOptions {
19984 interpolate: VipsInterpolate::new(),
19985 background: Vec::new(),
19986 odx: f64::from(0),
19987 ody: f64::from(0),
19988 idx: f64::from(0),
19989 idy: f64::from(0),
19990 }
19991 }
19992}
19993
19994pub fn rotate_with_opts(
20001 inp: &VipsImage,
20002 angle: f64,
20003 rotate_options: &RotateOptions,
20004) -> Result<VipsImage> {
20005 unsafe {
20006 let inp_in: *mut bindings::VipsImage = inp.ctx;
20007 let angle_in: f64 = angle;
20008 let mut out_out: *mut bindings::VipsImage = null_mut();
20009
20010 let interpolate_in: *mut bindings::VipsInterpolate = rotate_options.interpolate.ctx;
20011 let interpolate_in_name = utils::new_c_string("interpolate")?;
20012
20013 let background_wrapper =
20014 utils::VipsArrayDoubleWrapper::from(&rotate_options.background[..]);
20015 let background_in = background_wrapper.ctx;
20016 let background_in_name = utils::new_c_string("background")?;
20017
20018 let odx_in: f64 = rotate_options.odx;
20019 let odx_in_name = utils::new_c_string("odx")?;
20020
20021 let ody_in: f64 = rotate_options.ody;
20022 let ody_in_name = utils::new_c_string("ody")?;
20023
20024 let idx_in: f64 = rotate_options.idx;
20025 let idx_in_name = utils::new_c_string("idx")?;
20026
20027 let idy_in: f64 = rotate_options.idy;
20028 let idy_in_name = utils::new_c_string("idy")?;
20029
20030 let vips_op_response = bindings::vips_rotate(
20031 inp_in,
20032 &mut out_out,
20033 angle_in,
20034 interpolate_in_name.as_ptr(),
20035 interpolate_in,
20036 background_in_name.as_ptr(),
20037 background_in,
20038 odx_in_name.as_ptr(),
20039 odx_in,
20040 ody_in_name.as_ptr(),
20041 ody_in,
20042 idx_in_name.as_ptr(),
20043 idx_in,
20044 idy_in_name.as_ptr(),
20045 idy_in,
20046 NULL,
20047 );
20048 utils::result(
20049 vips_op_response,
20050 VipsImage { ctx: out_out },
20051 Error::RotateError,
20052 )
20053 }
20054}
20055
20056pub fn resize(inp: &VipsImage, scale: f64) -> Result<VipsImage> {
20062 unsafe {
20063 let inp_in: *mut bindings::VipsImage = inp.ctx;
20064 let scale_in: f64 = scale;
20065 let mut out_out: *mut bindings::VipsImage = null_mut();
20066
20067 let vips_op_response = bindings::vips_resize(inp_in, &mut out_out, scale_in, NULL);
20068 utils::result(
20069 vips_op_response,
20070 VipsImage { ctx: out_out },
20071 Error::ResizeError,
20072 )
20073 }
20074}
20075
20076#[derive(Clone, Debug)]
20078pub struct ResizeOptions {
20079 pub kernel: Kernel,
20089 pub gap: f64,
20092 pub vscale: f64,
20095}
20096
20097impl std::default::Default for ResizeOptions {
20098 fn default() -> Self {
20099 ResizeOptions {
20100 kernel: Kernel::Lanczos3,
20101 gap: f64::from(2),
20102 vscale: f64::from(0),
20103 }
20104 }
20105}
20106
20107pub fn resize_with_opts(
20114 inp: &VipsImage,
20115 scale: f64,
20116 resize_options: &ResizeOptions,
20117) -> Result<VipsImage> {
20118 unsafe {
20119 let inp_in: *mut bindings::VipsImage = inp.ctx;
20120 let scale_in: f64 = scale;
20121 let mut out_out: *mut bindings::VipsImage = null_mut();
20122
20123 let kernel_in: i32 = resize_options.kernel as i32;
20124 let kernel_in_name = utils::new_c_string("kernel")?;
20125
20126 let gap_in: f64 = resize_options.gap;
20127 let gap_in_name = utils::new_c_string("gap")?;
20128
20129 let vscale_in: f64 = resize_options.vscale;
20130 let vscale_in_name = utils::new_c_string("vscale")?;
20131
20132 let vips_op_response = bindings::vips_resize(
20133 inp_in,
20134 &mut out_out,
20135 scale_in,
20136 kernel_in_name.as_ptr(),
20137 kernel_in,
20138 gap_in_name.as_ptr(),
20139 gap_in,
20140 vscale_in_name.as_ptr(),
20141 vscale_in,
20142 NULL,
20143 );
20144 utils::result(
20145 vips_op_response,
20146 VipsImage { ctx: out_out },
20147 Error::ResizeError,
20148 )
20149 }
20150}
20151
20152pub fn colourspace(inp: &VipsImage, space: Interpretation) -> Result<VipsImage> {
20179 unsafe {
20180 let inp_in: *mut bindings::VipsImage = inp.ctx;
20181 let space_in: i32 = space as i32;
20182 let mut out_out: *mut bindings::VipsImage = null_mut();
20183
20184 let vips_op_response =
20185 bindings::vips_colourspace(inp_in, &mut out_out, space_in.try_into().unwrap(), NULL);
20186 utils::result(
20187 vips_op_response,
20188 VipsImage { ctx: out_out },
20189 Error::ColourspaceError,
20190 )
20191 }
20192}
20193
20194#[derive(Clone, Debug)]
20196pub struct ColourspaceOptions {
20197 pub source_space: Interpretation,
20221}
20222
20223impl std::default::Default for ColourspaceOptions {
20224 fn default() -> Self {
20225 ColourspaceOptions {
20226 source_space: Interpretation::Srgb,
20227 }
20228 }
20229}
20230
20231pub fn colourspace_with_opts(
20259 inp: &VipsImage,
20260 space: Interpretation,
20261 colourspace_options: &ColourspaceOptions,
20262) -> Result<VipsImage> {
20263 unsafe {
20264 let inp_in: *mut bindings::VipsImage = inp.ctx;
20265 let space_in: i32 = space as i32;
20266 let mut out_out: *mut bindings::VipsImage = null_mut();
20267
20268 let source_space_in: i32 = colourspace_options.source_space as i32;
20269 let source_space_in_name = utils::new_c_string("source-space")?;
20270
20271 let vips_op_response = bindings::vips_colourspace(
20272 inp_in,
20273 &mut out_out,
20274 space_in.try_into().unwrap(),
20275 source_space_in_name.as_ptr(),
20276 source_space_in,
20277 NULL,
20278 );
20279 utils::result(
20280 vips_op_response,
20281 VipsImage { ctx: out_out },
20282 Error::ColourspaceError,
20283 )
20284 }
20285}
20286
20287pub fn oklab_2_oklch(inp: &VipsImage) -> Result<VipsImage> {
20291 unsafe {
20292 let inp_in: *mut bindings::VipsImage = inp.ctx;
20293 let mut out_out: *mut bindings::VipsImage = null_mut();
20294
20295 let vips_op_response = bindings::vips_Oklab2Oklch(inp_in, &mut out_out, NULL);
20296 utils::result(
20297 vips_op_response,
20298 VipsImage { ctx: out_out },
20299 Error::Oklab2OklchError,
20300 )
20301 }
20302}
20303
20304pub fn oklch_2_oklab(inp: &VipsImage) -> Result<VipsImage> {
20308 unsafe {
20309 let inp_in: *mut bindings::VipsImage = inp.ctx;
20310 let mut out_out: *mut bindings::VipsImage = null_mut();
20311
20312 let vips_op_response = bindings::vips_Oklch2Oklab(inp_in, &mut out_out, NULL);
20313 utils::result(
20314 vips_op_response,
20315 VipsImage { ctx: out_out },
20316 Error::Oklch2OklabError,
20317 )
20318 }
20319}
20320
20321pub fn oklab_2xyz(inp: &VipsImage) -> Result<VipsImage> {
20325 unsafe {
20326 let inp_in: *mut bindings::VipsImage = inp.ctx;
20327 let mut out_out: *mut bindings::VipsImage = null_mut();
20328
20329 let vips_op_response = bindings::vips_Oklab2XYZ(inp_in, &mut out_out, NULL);
20330 utils::result(
20331 vips_op_response,
20332 VipsImage { ctx: out_out },
20333 Error::Oklab2XyzError,
20334 )
20335 }
20336}
20337
20338pub fn xyz2_oklab(inp: &VipsImage) -> Result<VipsImage> {
20342 unsafe {
20343 let inp_in: *mut bindings::VipsImage = inp.ctx;
20344 let mut out_out: *mut bindings::VipsImage = null_mut();
20345
20346 let vips_op_response = bindings::vips_XYZ2Oklab(inp_in, &mut out_out, NULL);
20347 utils::result(
20348 vips_op_response,
20349 VipsImage { ctx: out_out },
20350 Error::Xyz2OklabError,
20351 )
20352 }
20353}
20354
20355pub fn lab_2xyz(inp: &VipsImage) -> Result<VipsImage> {
20359 unsafe {
20360 let inp_in: *mut bindings::VipsImage = inp.ctx;
20361 let mut out_out: *mut bindings::VipsImage = null_mut();
20362
20363 let vips_op_response = bindings::vips_Lab2XYZ(inp_in, &mut out_out, NULL);
20364 utils::result(
20365 vips_op_response,
20366 VipsImage { ctx: out_out },
20367 Error::Lab2XyzError,
20368 )
20369 }
20370}
20371
20372#[derive(Clone, Debug)]
20374pub struct Lab2XyzOptions {
20375 pub temp: Vec<f64>,
20377}
20378
20379impl std::default::Default for Lab2XyzOptions {
20380 fn default() -> Self {
20381 Lab2XyzOptions { temp: Vec::new() }
20382 }
20383}
20384
20385pub fn lab_2xyz_with_opts(inp: &VipsImage, lab_2xyz_options: &Lab2XyzOptions) -> Result<VipsImage> {
20390 unsafe {
20391 let inp_in: *mut bindings::VipsImage = inp.ctx;
20392 let mut out_out: *mut bindings::VipsImage = null_mut();
20393
20394 let temp_wrapper = utils::VipsArrayDoubleWrapper::from(&lab_2xyz_options.temp[..]);
20395 let temp_in = temp_wrapper.ctx;
20396 let temp_in_name = utils::new_c_string("temp")?;
20397
20398 let vips_op_response =
20399 bindings::vips_Lab2XYZ(inp_in, &mut out_out, temp_in_name.as_ptr(), temp_in, NULL);
20400 utils::result(
20401 vips_op_response,
20402 VipsImage { ctx: out_out },
20403 Error::Lab2XyzError,
20404 )
20405 }
20406}
20407
20408pub fn xyz2_lab(inp: &VipsImage) -> Result<VipsImage> {
20412 unsafe {
20413 let inp_in: *mut bindings::VipsImage = inp.ctx;
20414 let mut out_out: *mut bindings::VipsImage = null_mut();
20415
20416 let vips_op_response = bindings::vips_XYZ2Lab(inp_in, &mut out_out, NULL);
20417 utils::result(
20418 vips_op_response,
20419 VipsImage { ctx: out_out },
20420 Error::Xyz2LabError,
20421 )
20422 }
20423}
20424
20425#[derive(Clone, Debug)]
20427pub struct Xyz2LabOptions {
20428 pub temp: Vec<f64>,
20430}
20431
20432impl std::default::Default for Xyz2LabOptions {
20433 fn default() -> Self {
20434 Xyz2LabOptions { temp: Vec::new() }
20435 }
20436}
20437
20438pub fn xyz2_lab_with_opts(
20443 inp: &VipsImage,
20444 xyz_2_lab_options: &Xyz2LabOptions,
20445) -> Result<VipsImage> {
20446 unsafe {
20447 let inp_in: *mut bindings::VipsImage = inp.ctx;
20448 let mut out_out: *mut bindings::VipsImage = null_mut();
20449
20450 let temp_wrapper = utils::VipsArrayDoubleWrapper::from(&xyz_2_lab_options.temp[..]);
20451 let temp_in = temp_wrapper.ctx;
20452 let temp_in_name = utils::new_c_string("temp")?;
20453
20454 let vips_op_response =
20455 bindings::vips_XYZ2Lab(inp_in, &mut out_out, temp_in_name.as_ptr(), temp_in, NULL);
20456 utils::result(
20457 vips_op_response,
20458 VipsImage { ctx: out_out },
20459 Error::Xyz2LabError,
20460 )
20461 }
20462}
20463
20464pub fn lab_2l_ch(inp: &VipsImage) -> Result<VipsImage> {
20468 unsafe {
20469 let inp_in: *mut bindings::VipsImage = inp.ctx;
20470 let mut out_out: *mut bindings::VipsImage = null_mut();
20471
20472 let vips_op_response = bindings::vips_Lab2LCh(inp_in, &mut out_out, NULL);
20473 utils::result(
20474 vips_op_response,
20475 VipsImage { ctx: out_out },
20476 Error::Lab2LChError,
20477 )
20478 }
20479}
20480
20481pub fn l_ch_2_lab(inp: &VipsImage) -> Result<VipsImage> {
20485 unsafe {
20486 let inp_in: *mut bindings::VipsImage = inp.ctx;
20487 let mut out_out: *mut bindings::VipsImage = null_mut();
20488
20489 let vips_op_response = bindings::vips_LCh2Lab(inp_in, &mut out_out, NULL);
20490 utils::result(
20491 vips_op_response,
20492 VipsImage { ctx: out_out },
20493 Error::LCh2LabError,
20494 )
20495 }
20496}
20497
20498pub fn l_ch_2cmc(inp: &VipsImage) -> Result<VipsImage> {
20502 unsafe {
20503 let inp_in: *mut bindings::VipsImage = inp.ctx;
20504 let mut out_out: *mut bindings::VipsImage = null_mut();
20505
20506 let vips_op_response = bindings::vips_LCh2CMC(inp_in, &mut out_out, NULL);
20507 utils::result(
20508 vips_op_response,
20509 VipsImage { ctx: out_out },
20510 Error::LCh2CmcError,
20511 )
20512 }
20513}
20514
20515pub fn cmc2l_ch(inp: &VipsImage) -> Result<VipsImage> {
20519 unsafe {
20520 let inp_in: *mut bindings::VipsImage = inp.ctx;
20521 let mut out_out: *mut bindings::VipsImage = null_mut();
20522
20523 let vips_op_response = bindings::vips_CMC2LCh(inp_in, &mut out_out, NULL);
20524 utils::result(
20525 vips_op_response,
20526 VipsImage { ctx: out_out },
20527 Error::Cmc2LChError,
20528 )
20529 }
20530}
20531
20532pub fn xyz2_yxy(inp: &VipsImage) -> Result<VipsImage> {
20536 unsafe {
20537 let inp_in: *mut bindings::VipsImage = inp.ctx;
20538 let mut out_out: *mut bindings::VipsImage = null_mut();
20539
20540 let vips_op_response = bindings::vips_XYZ2Yxy(inp_in, &mut out_out, NULL);
20541 utils::result(
20542 vips_op_response,
20543 VipsImage { ctx: out_out },
20544 Error::Xyz2YxyError,
20545 )
20546 }
20547}
20548
20549pub fn yxy_2xyz(inp: &VipsImage) -> Result<VipsImage> {
20553 unsafe {
20554 let inp_in: *mut bindings::VipsImage = inp.ctx;
20555 let mut out_out: *mut bindings::VipsImage = null_mut();
20556
20557 let vips_op_response = bindings::vips_Yxy2XYZ(inp_in, &mut out_out, NULL);
20558 utils::result(
20559 vips_op_response,
20560 VipsImage { ctx: out_out },
20561 Error::Yxy2XyzError,
20562 )
20563 }
20564}
20565
20566pub fn sc_rgb2xyz(inp: &VipsImage) -> Result<VipsImage> {
20570 unsafe {
20571 let inp_in: *mut bindings::VipsImage = inp.ctx;
20572 let mut out_out: *mut bindings::VipsImage = null_mut();
20573
20574 let vips_op_response = bindings::vips_scRGB2XYZ(inp_in, &mut out_out, NULL);
20575 utils::result(
20576 vips_op_response,
20577 VipsImage { ctx: out_out },
20578 Error::ScRgb2XyzError,
20579 )
20580 }
20581}
20582
20583pub fn xyz_2sc_rgb(inp: &VipsImage) -> Result<VipsImage> {
20587 unsafe {
20588 let inp_in: *mut bindings::VipsImage = inp.ctx;
20589 let mut out_out: *mut bindings::VipsImage = null_mut();
20590
20591 let vips_op_response = bindings::vips_XYZ2scRGB(inp_in, &mut out_out, NULL);
20592 utils::result(
20593 vips_op_response,
20594 VipsImage { ctx: out_out },
20595 Error::Xyz2ScRgbError,
20596 )
20597 }
20598}
20599
20600pub fn lab_q2_lab(inp: &VipsImage) -> Result<VipsImage> {
20604 unsafe {
20605 let inp_in: *mut bindings::VipsImage = inp.ctx;
20606 let mut out_out: *mut bindings::VipsImage = null_mut();
20607
20608 let vips_op_response = bindings::vips_LabQ2Lab(inp_in, &mut out_out, NULL);
20609 utils::result(
20610 vips_op_response,
20611 VipsImage { ctx: out_out },
20612 Error::LabQ2LabError,
20613 )
20614 }
20615}
20616
20617pub fn lab_2_lab_q(inp: &VipsImage) -> Result<VipsImage> {
20621 unsafe {
20622 let inp_in: *mut bindings::VipsImage = inp.ctx;
20623 let mut out_out: *mut bindings::VipsImage = null_mut();
20624
20625 let vips_op_response = bindings::vips_Lab2LabQ(inp_in, &mut out_out, NULL);
20626 utils::result(
20627 vips_op_response,
20628 VipsImage { ctx: out_out },
20629 Error::Lab2LabQError,
20630 )
20631 }
20632}
20633
20634pub fn lab_q2_lab_s(inp: &VipsImage) -> Result<VipsImage> {
20638 unsafe {
20639 let inp_in: *mut bindings::VipsImage = inp.ctx;
20640 let mut out_out: *mut bindings::VipsImage = null_mut();
20641
20642 let vips_op_response = bindings::vips_LabQ2LabS(inp_in, &mut out_out, NULL);
20643 utils::result(
20644 vips_op_response,
20645 VipsImage { ctx: out_out },
20646 Error::LabQ2LabSError,
20647 )
20648 }
20649}
20650
20651pub fn lab_s2_lab_q(inp: &VipsImage) -> Result<VipsImage> {
20655 unsafe {
20656 let inp_in: *mut bindings::VipsImage = inp.ctx;
20657 let mut out_out: *mut bindings::VipsImage = null_mut();
20658
20659 let vips_op_response = bindings::vips_LabS2LabQ(inp_in, &mut out_out, NULL);
20660 utils::result(
20661 vips_op_response,
20662 VipsImage { ctx: out_out },
20663 Error::LabS2LabQError,
20664 )
20665 }
20666}
20667
20668pub fn lab_s2_lab(inp: &VipsImage) -> Result<VipsImage> {
20672 unsafe {
20673 let inp_in: *mut bindings::VipsImage = inp.ctx;
20674 let mut out_out: *mut bindings::VipsImage = null_mut();
20675
20676 let vips_op_response = bindings::vips_LabS2Lab(inp_in, &mut out_out, NULL);
20677 utils::result(
20678 vips_op_response,
20679 VipsImage { ctx: out_out },
20680 Error::LabS2LabError,
20681 )
20682 }
20683}
20684
20685pub fn lab_2_lab_s(inp: &VipsImage) -> Result<VipsImage> {
20689 unsafe {
20690 let inp_in: *mut bindings::VipsImage = inp.ctx;
20691 let mut out_out: *mut bindings::VipsImage = null_mut();
20692
20693 let vips_op_response = bindings::vips_Lab2LabS(inp_in, &mut out_out, NULL);
20694 utils::result(
20695 vips_op_response,
20696 VipsImage { ctx: out_out },
20697 Error::Lab2LabSError,
20698 )
20699 }
20700}
20701
20702pub fn rad_2float(inp: &VipsImage) -> Result<VipsImage> {
20706 unsafe {
20707 let inp_in: *mut bindings::VipsImage = inp.ctx;
20708 let mut out_out: *mut bindings::VipsImage = null_mut();
20709
20710 let vips_op_response = bindings::vips_rad2float(inp_in, &mut out_out, NULL);
20711 utils::result(
20712 vips_op_response,
20713 VipsImage { ctx: out_out },
20714 Error::Rad2FloatError,
20715 )
20716 }
20717}
20718
20719pub fn float_2rad(inp: &VipsImage) -> Result<VipsImage> {
20723 unsafe {
20724 let inp_in: *mut bindings::VipsImage = inp.ctx;
20725 let mut out_out: *mut bindings::VipsImage = null_mut();
20726
20727 let vips_op_response = bindings::vips_float2rad(inp_in, &mut out_out, NULL);
20728 utils::result(
20729 vips_op_response,
20730 VipsImage { ctx: out_out },
20731 Error::Float2RadError,
20732 )
20733 }
20734}
20735
20736pub fn lab_q_2s_rgb(inp: &VipsImage) -> Result<VipsImage> {
20740 unsafe {
20741 let inp_in: *mut bindings::VipsImage = inp.ctx;
20742 let mut out_out: *mut bindings::VipsImage = null_mut();
20743
20744 let vips_op_response = bindings::vips_LabQ2sRGB(inp_in, &mut out_out, NULL);
20745 utils::result(
20746 vips_op_response,
20747 VipsImage { ctx: out_out },
20748 Error::LabQ2SRgbError,
20749 )
20750 }
20751}
20752
20753pub fn s_rgb_2sc_rgb(inp: &VipsImage) -> Result<VipsImage> {
20757 unsafe {
20758 let inp_in: *mut bindings::VipsImage = inp.ctx;
20759 let mut out_out: *mut bindings::VipsImage = null_mut();
20760
20761 let vips_op_response = bindings::vips_sRGB2scRGB(inp_in, &mut out_out, NULL);
20762 utils::result(
20763 vips_op_response,
20764 VipsImage { ctx: out_out },
20765 Error::SRgb2ScRgbError,
20766 )
20767 }
20768}
20769
20770pub fn sc_rgb2bw(inp: &VipsImage) -> Result<VipsImage> {
20774 unsafe {
20775 let inp_in: *mut bindings::VipsImage = inp.ctx;
20776 let mut out_out: *mut bindings::VipsImage = null_mut();
20777
20778 let vips_op_response = bindings::vips_scRGB2BW(inp_in, &mut out_out, NULL);
20779 utils::result(
20780 vips_op_response,
20781 VipsImage { ctx: out_out },
20782 Error::ScRgb2BwError,
20783 )
20784 }
20785}
20786
20787#[derive(Clone, Debug)]
20789pub struct ScRgb2BwOptions {
20790 pub depth: i32,
20793}
20794
20795impl std::default::Default for ScRgb2BwOptions {
20796 fn default() -> Self {
20797 ScRgb2BwOptions {
20798 depth: i32::from(8),
20799 }
20800 }
20801}
20802
20803pub fn sc_rgb2bw_with_opts(
20808 inp: &VipsImage,
20809 sc_rgb_2bw_options: &ScRgb2BwOptions,
20810) -> Result<VipsImage> {
20811 unsafe {
20812 let inp_in: *mut bindings::VipsImage = inp.ctx;
20813 let mut out_out: *mut bindings::VipsImage = null_mut();
20814
20815 let depth_in: i32 = sc_rgb_2bw_options.depth;
20816 let depth_in_name = utils::new_c_string("depth")?;
20817
20818 let vips_op_response =
20819 bindings::vips_scRGB2BW(inp_in, &mut out_out, depth_in_name.as_ptr(), depth_in, NULL);
20820 utils::result(
20821 vips_op_response,
20822 VipsImage { ctx: out_out },
20823 Error::ScRgb2BwError,
20824 )
20825 }
20826}
20827
20828pub fn s_rgb2hsv(inp: &VipsImage) -> Result<VipsImage> {
20832 unsafe {
20833 let inp_in: *mut bindings::VipsImage = inp.ctx;
20834 let mut out_out: *mut bindings::VipsImage = null_mut();
20835
20836 let vips_op_response = bindings::vips_sRGB2HSV(inp_in, &mut out_out, NULL);
20837 utils::result(
20838 vips_op_response,
20839 VipsImage { ctx: out_out },
20840 Error::SRgb2HsvError,
20841 )
20842 }
20843}
20844
20845pub fn hsv_2s_rgb(inp: &VipsImage) -> Result<VipsImage> {
20849 unsafe {
20850 let inp_in: *mut bindings::VipsImage = inp.ctx;
20851 let mut out_out: *mut bindings::VipsImage = null_mut();
20852
20853 let vips_op_response = bindings::vips_HSV2sRGB(inp_in, &mut out_out, NULL);
20854 utils::result(
20855 vips_op_response,
20856 VipsImage { ctx: out_out },
20857 Error::Hsv2SRgbError,
20858 )
20859 }
20860}
20861
20862pub fn sc_rgb_2s_rgb(inp: &VipsImage) -> Result<VipsImage> {
20866 unsafe {
20867 let inp_in: *mut bindings::VipsImage = inp.ctx;
20868 let mut out_out: *mut bindings::VipsImage = null_mut();
20869
20870 let vips_op_response = bindings::vips_scRGB2sRGB(inp_in, &mut out_out, NULL);
20871 utils::result(
20872 vips_op_response,
20873 VipsImage { ctx: out_out },
20874 Error::ScRgb2SRgbError,
20875 )
20876 }
20877}
20878
20879#[derive(Clone, Debug)]
20881pub struct ScRgb2SRgbOptions {
20882 pub depth: i32,
20885}
20886
20887impl std::default::Default for ScRgb2SRgbOptions {
20888 fn default() -> Self {
20889 ScRgb2SRgbOptions {
20890 depth: i32::from(8),
20891 }
20892 }
20893}
20894
20895pub fn sc_rgb_2s_rgb_with_opts(
20900 inp: &VipsImage,
20901 sc_rgb_2s_rgb_options: &ScRgb2SRgbOptions,
20902) -> Result<VipsImage> {
20903 unsafe {
20904 let inp_in: *mut bindings::VipsImage = inp.ctx;
20905 let mut out_out: *mut bindings::VipsImage = null_mut();
20906
20907 let depth_in: i32 = sc_rgb_2s_rgb_options.depth;
20908 let depth_in_name = utils::new_c_string("depth")?;
20909
20910 let vips_op_response =
20911 bindings::vips_scRGB2sRGB(inp_in, &mut out_out, depth_in_name.as_ptr(), depth_in, NULL);
20912 utils::result(
20913 vips_op_response,
20914 VipsImage { ctx: out_out },
20915 Error::ScRgb2SRgbError,
20916 )
20917 }
20918}
20919
20920pub fn icc_import(inp: &VipsImage) -> Result<VipsImage> {
20924 unsafe {
20925 let inp_in: *mut bindings::VipsImage = inp.ctx;
20926 let mut out_out: *mut bindings::VipsImage = null_mut();
20927
20928 let vips_op_response = bindings::vips_icc_import(inp_in, &mut out_out, NULL);
20929 utils::result(
20930 vips_op_response,
20931 VipsImage { ctx: out_out },
20932 Error::IccImportError,
20933 )
20934 }
20935}
20936
20937#[derive(Clone, Debug)]
20939pub struct IccImportOptions {
20940 pub pcs: PCS,
20944 pub intent: Intent,
20951 pub black_point_compensation: bool,
20954 pub embedded: bool,
20957 pub input_profile: String,
20959}
20960
20961impl std::default::Default for IccImportOptions {
20962 fn default() -> Self {
20963 IccImportOptions {
20964 pcs: PCS::Lab,
20965 intent: Intent::Relative,
20966 black_point_compensation: false,
20967 embedded: false,
20968 input_profile: String::new(),
20969 }
20970 }
20971}
20972
20973pub fn icc_import_with_opts(
20978 inp: &VipsImage,
20979 icc_import_options: &IccImportOptions,
20980) -> Result<VipsImage> {
20981 unsafe {
20982 let inp_in: *mut bindings::VipsImage = inp.ctx;
20983 let mut out_out: *mut bindings::VipsImage = null_mut();
20984
20985 let pcs_in: i32 = icc_import_options.pcs as i32;
20986 let pcs_in_name = utils::new_c_string("pcs")?;
20987
20988 let intent_in: i32 = icc_import_options.intent as i32;
20989 let intent_in_name = utils::new_c_string("intent")?;
20990
20991 let black_point_compensation_in: i32 = if icc_import_options.black_point_compensation {
20992 1
20993 } else {
20994 0
20995 };
20996 let black_point_compensation_in_name = utils::new_c_string("black-point-compensation")?;
20997
20998 let embedded_in: i32 = if icc_import_options.embedded { 1 } else { 0 };
20999 let embedded_in_name = utils::new_c_string("embedded")?;
21000
21001 let input_profile_in: CString = utils::new_c_string(&icc_import_options.input_profile)?;
21002 let input_profile_in_name = utils::new_c_string("input-profile")?;
21003
21004 let vips_op_response = bindings::vips_icc_import(
21005 inp_in,
21006 &mut out_out,
21007 pcs_in_name.as_ptr(),
21008 pcs_in,
21009 intent_in_name.as_ptr(),
21010 intent_in,
21011 black_point_compensation_in_name.as_ptr(),
21012 black_point_compensation_in,
21013 embedded_in_name.as_ptr(),
21014 embedded_in,
21015 input_profile_in_name.as_ptr(),
21016 input_profile_in.as_ptr(),
21017 NULL,
21018 );
21019 utils::result(
21020 vips_op_response,
21021 VipsImage { ctx: out_out },
21022 Error::IccImportError,
21023 )
21024 }
21025}
21026
21027pub fn icc_export(inp: &VipsImage) -> Result<VipsImage> {
21031 unsafe {
21032 let inp_in: *mut bindings::VipsImage = inp.ctx;
21033 let mut out_out: *mut bindings::VipsImage = null_mut();
21034
21035 let vips_op_response = bindings::vips_icc_export(inp_in, &mut out_out, NULL);
21036 utils::result(
21037 vips_op_response,
21038 VipsImage { ctx: out_out },
21039 Error::IccExportError,
21040 )
21041 }
21042}
21043
21044#[derive(Clone, Debug)]
21046pub struct IccExportOptions {
21047 pub pcs: PCS,
21051 pub intent: Intent,
21058 pub black_point_compensation: bool,
21061 pub output_profile: String,
21063 pub depth: i32,
21066}
21067
21068impl std::default::Default for IccExportOptions {
21069 fn default() -> Self {
21070 IccExportOptions {
21071 pcs: PCS::Lab,
21072 intent: Intent::Relative,
21073 black_point_compensation: false,
21074 output_profile: String::new(),
21075 depth: i32::from(8),
21076 }
21077 }
21078}
21079
21080pub fn icc_export_with_opts(
21085 inp: &VipsImage,
21086 icc_export_options: &IccExportOptions,
21087) -> Result<VipsImage> {
21088 unsafe {
21089 let inp_in: *mut bindings::VipsImage = inp.ctx;
21090 let mut out_out: *mut bindings::VipsImage = null_mut();
21091
21092 let pcs_in: i32 = icc_export_options.pcs as i32;
21093 let pcs_in_name = utils::new_c_string("pcs")?;
21094
21095 let intent_in: i32 = icc_export_options.intent as i32;
21096 let intent_in_name = utils::new_c_string("intent")?;
21097
21098 let black_point_compensation_in: i32 = if icc_export_options.black_point_compensation {
21099 1
21100 } else {
21101 0
21102 };
21103 let black_point_compensation_in_name = utils::new_c_string("black-point-compensation")?;
21104
21105 let output_profile_in: CString = utils::new_c_string(&icc_export_options.output_profile)?;
21106 let output_profile_in_name = utils::new_c_string("output-profile")?;
21107
21108 let depth_in: i32 = icc_export_options.depth;
21109 let depth_in_name = utils::new_c_string("depth")?;
21110
21111 let vips_op_response = bindings::vips_icc_export(
21112 inp_in,
21113 &mut out_out,
21114 pcs_in_name.as_ptr(),
21115 pcs_in,
21116 intent_in_name.as_ptr(),
21117 intent_in,
21118 black_point_compensation_in_name.as_ptr(),
21119 black_point_compensation_in,
21120 output_profile_in_name.as_ptr(),
21121 output_profile_in.as_ptr(),
21122 depth_in_name.as_ptr(),
21123 depth_in,
21124 NULL,
21125 );
21126 utils::result(
21127 vips_op_response,
21128 VipsImage { ctx: out_out },
21129 Error::IccExportError,
21130 )
21131 }
21132}
21133
21134pub fn icc_transform(inp: &VipsImage, output_profile: &str) -> Result<VipsImage> {
21139 unsafe {
21140 let inp_in: *mut bindings::VipsImage = inp.ctx;
21141 let output_profile_in: CString = utils::new_c_string(output_profile)?;
21142 let mut out_out: *mut bindings::VipsImage = null_mut();
21143
21144 let vips_op_response =
21145 bindings::vips_icc_transform(inp_in, &mut out_out, output_profile_in.as_ptr(), NULL);
21146 utils::result(
21147 vips_op_response,
21148 VipsImage { ctx: out_out },
21149 Error::IccTransformError,
21150 )
21151 }
21152}
21153
21154#[derive(Clone, Debug)]
21156pub struct IccTransformOptions {
21157 pub pcs: PCS,
21161 pub intent: Intent,
21168 pub black_point_compensation: bool,
21171 pub embedded: bool,
21174 pub input_profile: String,
21176 pub depth: i32,
21179}
21180
21181impl std::default::Default for IccTransformOptions {
21182 fn default() -> Self {
21183 IccTransformOptions {
21184 pcs: PCS::Lab,
21185 intent: Intent::Relative,
21186 black_point_compensation: false,
21187 embedded: false,
21188 input_profile: String::new(),
21189 depth: i32::from(8),
21190 }
21191 }
21192}
21193
21194pub fn icc_transform_with_opts(
21200 inp: &VipsImage,
21201 output_profile: &str,
21202 icc_transform_options: &IccTransformOptions,
21203) -> Result<VipsImage> {
21204 unsafe {
21205 let inp_in: *mut bindings::VipsImage = inp.ctx;
21206 let output_profile_in: CString = utils::new_c_string(output_profile)?;
21207 let mut out_out: *mut bindings::VipsImage = null_mut();
21208
21209 let pcs_in: i32 = icc_transform_options.pcs as i32;
21210 let pcs_in_name = utils::new_c_string("pcs")?;
21211
21212 let intent_in: i32 = icc_transform_options.intent as i32;
21213 let intent_in_name = utils::new_c_string("intent")?;
21214
21215 let black_point_compensation_in: i32 = if icc_transform_options.black_point_compensation {
21216 1
21217 } else {
21218 0
21219 };
21220 let black_point_compensation_in_name = utils::new_c_string("black-point-compensation")?;
21221
21222 let embedded_in: i32 = if icc_transform_options.embedded { 1 } else { 0 };
21223 let embedded_in_name = utils::new_c_string("embedded")?;
21224
21225 let input_profile_in: CString = utils::new_c_string(&icc_transform_options.input_profile)?;
21226 let input_profile_in_name = utils::new_c_string("input-profile")?;
21227
21228 let depth_in: i32 = icc_transform_options.depth;
21229 let depth_in_name = utils::new_c_string("depth")?;
21230
21231 let vips_op_response = bindings::vips_icc_transform(
21232 inp_in,
21233 &mut out_out,
21234 output_profile_in.as_ptr(),
21235 pcs_in_name.as_ptr(),
21236 pcs_in,
21237 intent_in_name.as_ptr(),
21238 intent_in,
21239 black_point_compensation_in_name.as_ptr(),
21240 black_point_compensation_in,
21241 embedded_in_name.as_ptr(),
21242 embedded_in,
21243 input_profile_in_name.as_ptr(),
21244 input_profile_in.as_ptr(),
21245 depth_in_name.as_ptr(),
21246 depth_in,
21247 NULL,
21248 );
21249 utils::result(
21250 vips_op_response,
21251 VipsImage { ctx: out_out },
21252 Error::IccTransformError,
21253 )
21254 }
21255}
21256
21257pub fn uhdr_2sc_rgb(inp: &VipsImage) -> Result<VipsImage> {
21261 unsafe {
21262 let inp_in: *mut bindings::VipsImage = inp.ctx;
21263 let mut out_out: *mut bindings::VipsImage = null_mut();
21264
21265 let vips_op_response = bindings::vips_uhdr2scRGB(inp_in, &mut out_out, NULL);
21266 utils::result(
21267 vips_op_response,
21268 VipsImage { ctx: out_out },
21269 Error::Uhdr2ScRgbError,
21270 )
21271 }
21272}
21273
21274pub fn d_e76(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
21279 unsafe {
21280 let left_in: *mut bindings::VipsImage = left.ctx;
21281 let right_in: *mut bindings::VipsImage = right.ctx;
21282 let mut out_out: *mut bindings::VipsImage = null_mut();
21283
21284 let vips_op_response = bindings::vips_dE76(left_in, right_in, &mut out_out, NULL);
21285 utils::result(
21286 vips_op_response,
21287 VipsImage { ctx: out_out },
21288 Error::DE76Error,
21289 )
21290 }
21291}
21292
21293pub fn d_e00(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
21298 unsafe {
21299 let left_in: *mut bindings::VipsImage = left.ctx;
21300 let right_in: *mut bindings::VipsImage = right.ctx;
21301 let mut out_out: *mut bindings::VipsImage = null_mut();
21302
21303 let vips_op_response = bindings::vips_dE00(left_in, right_in, &mut out_out, NULL);
21304 utils::result(
21305 vips_op_response,
21306 VipsImage { ctx: out_out },
21307 Error::DE00Error,
21308 )
21309 }
21310}
21311
21312pub fn d_ecmc(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
21317 unsafe {
21318 let left_in: *mut bindings::VipsImage = left.ctx;
21319 let right_in: *mut bindings::VipsImage = right.ctx;
21320 let mut out_out: *mut bindings::VipsImage = null_mut();
21321
21322 let vips_op_response = bindings::vips_dECMC(left_in, right_in, &mut out_out, NULL);
21323 utils::result(
21324 vips_op_response,
21325 VipsImage { ctx: out_out },
21326 Error::DEcmcError,
21327 )
21328 }
21329}
21330
21331pub fn cmyk2xyz(inp: &VipsImage) -> Result<VipsImage> {
21335 unsafe {
21336 let inp_in: *mut bindings::VipsImage = inp.ctx;
21337 let mut out_out: *mut bindings::VipsImage = null_mut();
21338
21339 let vips_op_response = bindings::vips_CMYK2XYZ(inp_in, &mut out_out, NULL);
21340 utils::result(
21341 vips_op_response,
21342 VipsImage { ctx: out_out },
21343 Error::Cmyk2XyzError,
21344 )
21345 }
21346}
21347
21348pub fn xyz2cmyk(inp: &VipsImage) -> Result<VipsImage> {
21352 unsafe {
21353 let inp_in: *mut bindings::VipsImage = inp.ctx;
21354 let mut out_out: *mut bindings::VipsImage = null_mut();
21355
21356 let vips_op_response = bindings::vips_XYZ2CMYK(inp_in, &mut out_out, NULL);
21357 utils::result(
21358 vips_op_response,
21359 VipsImage { ctx: out_out },
21360 Error::Xyz2CmykError,
21361 )
21362 }
21363}
21364
21365pub fn profile_load(name: &str) -> Result<Vec<u8>> {
21369 unsafe {
21370 let name_in: CString = utils::new_c_string(name)?;
21371 let mut profile_out: *mut bindings::VipsBlob = null_mut();
21372
21373 let vips_op_response =
21374 bindings::vips_profile_load(name_in.as_ptr(), &mut profile_out, NULL);
21375 utils::result(
21376 vips_op_response,
21377 VipsBlob { ctx: profile_out }.into(),
21378 Error::ProfileLoadError,
21379 )
21380 }
21381}
21382
21383pub fn maplut(inp: &VipsImage, lut: &VipsImage) -> Result<VipsImage> {
21388 unsafe {
21389 let inp_in: *mut bindings::VipsImage = inp.ctx;
21390 let lut_in: *mut bindings::VipsImage = lut.ctx;
21391 let mut out_out: *mut bindings::VipsImage = null_mut();
21392
21393 let vips_op_response = bindings::vips_maplut(inp_in, &mut out_out, lut_in, NULL);
21394 utils::result(
21395 vips_op_response,
21396 VipsImage { ctx: out_out },
21397 Error::MaplutError,
21398 )
21399 }
21400}
21401
21402#[derive(Clone, Debug)]
21404pub struct MaplutOptions {
21405 pub band: i32,
21408}
21409
21410impl std::default::Default for MaplutOptions {
21411 fn default() -> Self {
21412 MaplutOptions {
21413 band: i32::from(-1),
21414 }
21415 }
21416}
21417
21418pub fn maplut_with_opts(
21424 inp: &VipsImage,
21425 lut: &VipsImage,
21426 maplut_options: &MaplutOptions,
21427) -> Result<VipsImage> {
21428 unsafe {
21429 let inp_in: *mut bindings::VipsImage = inp.ctx;
21430 let lut_in: *mut bindings::VipsImage = lut.ctx;
21431 let mut out_out: *mut bindings::VipsImage = null_mut();
21432
21433 let band_in: i32 = maplut_options.band;
21434 let band_in_name = utils::new_c_string("band")?;
21435
21436 let vips_op_response = bindings::vips_maplut(
21437 inp_in,
21438 &mut out_out,
21439 lut_in,
21440 band_in_name.as_ptr(),
21441 band_in,
21442 NULL,
21443 );
21444 utils::result(
21445 vips_op_response,
21446 VipsImage { ctx: out_out },
21447 Error::MaplutError,
21448 )
21449 }
21450}
21451
21452pub fn percent(inp: &VipsImage, percent: f64) -> Result<i32> {
21458 unsafe {
21459 let inp_in: *mut bindings::VipsImage = inp.ctx;
21460 let percent_in: f64 = percent;
21461 let mut threshold_out: i32 = i32::from(0);
21462
21463 let vips_op_response = bindings::vips_percent(inp_in, percent_in, &mut threshold_out, NULL);
21464 utils::result(vips_op_response, threshold_out, Error::PercentError)
21465 }
21466}
21467
21468pub fn stdif(inp: &VipsImage, width: i32, height: i32) -> Result<VipsImage> {
21476 unsafe {
21477 let inp_in: *mut bindings::VipsImage = inp.ctx;
21478 let width_in: i32 = width;
21479 let height_in: i32 = height;
21480 let mut out_out: *mut bindings::VipsImage = null_mut();
21481
21482 let vips_op_response =
21483 bindings::vips_stdif(inp_in, &mut out_out, width_in, height_in, NULL);
21484 utils::result(
21485 vips_op_response,
21486 VipsImage { ctx: out_out },
21487 Error::StdifError,
21488 )
21489 }
21490}
21491
21492#[derive(Clone, Debug)]
21494pub struct StdifOptions {
21495 pub s_0: f64,
21498 pub b: f64,
21501 pub m_0: f64,
21504 pub a: f64,
21507}
21508
21509impl std::default::Default for StdifOptions {
21510 fn default() -> Self {
21511 StdifOptions {
21512 s_0: f64::from(50),
21513 b: f64::from(0.5),
21514 m_0: f64::from(128),
21515 a: f64::from(0.5),
21516 }
21517 }
21518}
21519
21520pub fn stdif_with_opts(
21529 inp: &VipsImage,
21530 width: i32,
21531 height: i32,
21532 stdif_options: &StdifOptions,
21533) -> Result<VipsImage> {
21534 unsafe {
21535 let inp_in: *mut bindings::VipsImage = inp.ctx;
21536 let width_in: i32 = width;
21537 let height_in: i32 = height;
21538 let mut out_out: *mut bindings::VipsImage = null_mut();
21539
21540 let s_0_in: f64 = stdif_options.s_0;
21541 let s_0_in_name = utils::new_c_string("s0")?;
21542
21543 let b_in: f64 = stdif_options.b;
21544 let b_in_name = utils::new_c_string("b")?;
21545
21546 let m_0_in: f64 = stdif_options.m_0;
21547 let m_0_in_name = utils::new_c_string("m0")?;
21548
21549 let a_in: f64 = stdif_options.a;
21550 let a_in_name = utils::new_c_string("a")?;
21551
21552 let vips_op_response = bindings::vips_stdif(
21553 inp_in,
21554 &mut out_out,
21555 width_in,
21556 height_in,
21557 s_0_in_name.as_ptr(),
21558 s_0_in,
21559 b_in_name.as_ptr(),
21560 b_in,
21561 m_0_in_name.as_ptr(),
21562 m_0_in,
21563 a_in_name.as_ptr(),
21564 a_in,
21565 NULL,
21566 );
21567 utils::result(
21568 vips_op_response,
21569 VipsImage { ctx: out_out },
21570 Error::StdifError,
21571 )
21572 }
21573}
21574
21575pub fn hist_cum(inp: &VipsImage) -> Result<VipsImage> {
21579 unsafe {
21580 let inp_in: *mut bindings::VipsImage = inp.ctx;
21581 let mut out_out: *mut bindings::VipsImage = null_mut();
21582
21583 let vips_op_response = bindings::vips_hist_cum(inp_in, &mut out_out, NULL);
21584 utils::result(
21585 vips_op_response,
21586 VipsImage { ctx: out_out },
21587 Error::HistCumError,
21588 )
21589 }
21590}
21591
21592pub fn hist_match(inp: &VipsImage, refp: &VipsImage) -> Result<VipsImage> {
21597 unsafe {
21598 let inp_in: *mut bindings::VipsImage = inp.ctx;
21599 let refp_in: *mut bindings::VipsImage = refp.ctx;
21600 let mut out_out: *mut bindings::VipsImage = null_mut();
21601
21602 let vips_op_response = bindings::vips_hist_match(inp_in, refp_in, &mut out_out, NULL);
21603 utils::result(
21604 vips_op_response,
21605 VipsImage { ctx: out_out },
21606 Error::HistMatchError,
21607 )
21608 }
21609}
21610
21611pub fn hist_norm(inp: &VipsImage) -> Result<VipsImage> {
21615 unsafe {
21616 let inp_in: *mut bindings::VipsImage = inp.ctx;
21617 let mut out_out: *mut bindings::VipsImage = null_mut();
21618
21619 let vips_op_response = bindings::vips_hist_norm(inp_in, &mut out_out, NULL);
21620 utils::result(
21621 vips_op_response,
21622 VipsImage { ctx: out_out },
21623 Error::HistNormError,
21624 )
21625 }
21626}
21627
21628pub fn hist_equal(inp: &VipsImage) -> Result<VipsImage> {
21632 unsafe {
21633 let inp_in: *mut bindings::VipsImage = inp.ctx;
21634 let mut out_out: *mut bindings::VipsImage = null_mut();
21635
21636 let vips_op_response = bindings::vips_hist_equal(inp_in, &mut out_out, NULL);
21637 utils::result(
21638 vips_op_response,
21639 VipsImage { ctx: out_out },
21640 Error::HistEqualError,
21641 )
21642 }
21643}
21644
21645#[derive(Clone, Debug)]
21647pub struct HistEqualOptions {
21648 pub band: i32,
21651}
21652
21653impl std::default::Default for HistEqualOptions {
21654 fn default() -> Self {
21655 HistEqualOptions {
21656 band: i32::from(-1),
21657 }
21658 }
21659}
21660
21661pub fn hist_equal_with_opts(
21666 inp: &VipsImage,
21667 hist_equal_options: &HistEqualOptions,
21668) -> Result<VipsImage> {
21669 unsafe {
21670 let inp_in: *mut bindings::VipsImage = inp.ctx;
21671 let mut out_out: *mut bindings::VipsImage = null_mut();
21672
21673 let band_in: i32 = hist_equal_options.band;
21674 let band_in_name = utils::new_c_string("band")?;
21675
21676 let vips_op_response =
21677 bindings::vips_hist_equal(inp_in, &mut out_out, band_in_name.as_ptr(), band_in, NULL);
21678 utils::result(
21679 vips_op_response,
21680 VipsImage { ctx: out_out },
21681 Error::HistEqualError,
21682 )
21683 }
21684}
21685
21686pub fn hist_plot(inp: &VipsImage) -> Result<VipsImage> {
21690 unsafe {
21691 let inp_in: *mut bindings::VipsImage = inp.ctx;
21692 let mut out_out: *mut bindings::VipsImage = null_mut();
21693
21694 let vips_op_response = bindings::vips_hist_plot(inp_in, &mut out_out, NULL);
21695 utils::result(
21696 vips_op_response,
21697 VipsImage { ctx: out_out },
21698 Error::HistPlotError,
21699 )
21700 }
21701}
21702
21703pub fn hist_local(inp: &VipsImage, width: i32, height: i32) -> Result<VipsImage> {
21711 unsafe {
21712 let inp_in: *mut bindings::VipsImage = inp.ctx;
21713 let width_in: i32 = width;
21714 let height_in: i32 = height;
21715 let mut out_out: *mut bindings::VipsImage = null_mut();
21716
21717 let vips_op_response =
21718 bindings::vips_hist_local(inp_in, &mut out_out, width_in, height_in, NULL);
21719 utils::result(
21720 vips_op_response,
21721 VipsImage { ctx: out_out },
21722 Error::HistLocalError,
21723 )
21724 }
21725}
21726
21727#[derive(Clone, Debug)]
21729pub struct HistLocalOptions {
21730 pub max_slope: i32,
21733}
21734
21735impl std::default::Default for HistLocalOptions {
21736 fn default() -> Self {
21737 HistLocalOptions {
21738 max_slope: i32::from(0),
21739 }
21740 }
21741}
21742
21743pub fn hist_local_with_opts(
21752 inp: &VipsImage,
21753 width: i32,
21754 height: i32,
21755 hist_local_options: &HistLocalOptions,
21756) -> Result<VipsImage> {
21757 unsafe {
21758 let inp_in: *mut bindings::VipsImage = inp.ctx;
21759 let width_in: i32 = width;
21760 let height_in: i32 = height;
21761 let mut out_out: *mut bindings::VipsImage = null_mut();
21762
21763 let max_slope_in: i32 = hist_local_options.max_slope;
21764 let max_slope_in_name = utils::new_c_string("max-slope")?;
21765
21766 let vips_op_response = bindings::vips_hist_local(
21767 inp_in,
21768 &mut out_out,
21769 width_in,
21770 height_in,
21771 max_slope_in_name.as_ptr(),
21772 max_slope_in,
21773 NULL,
21774 );
21775 utils::result(
21776 vips_op_response,
21777 VipsImage { ctx: out_out },
21778 Error::HistLocalError,
21779 )
21780 }
21781}
21782
21783pub fn hist_ismonotonic(inp: &VipsImage) -> Result<bool> {
21787 unsafe {
21788 let inp_in: *mut bindings::VipsImage = inp.ctx;
21789 let mut monotonic_out: i32 = 0;
21790
21791 let vips_op_response = bindings::vips_hist_ismonotonic(inp_in, &mut monotonic_out, NULL);
21792 utils::result(
21793 vips_op_response,
21794 monotonic_out != 0,
21795 Error::HistIsmonotonicError,
21796 )
21797 }
21798}
21799
21800pub fn hist_entropy(inp: &VipsImage) -> Result<f64> {
21804 unsafe {
21805 let inp_in: *mut bindings::VipsImage = inp.ctx;
21806 let mut out_out: f64 = f64::from(0);
21807
21808 let vips_op_response = bindings::vips_hist_entropy(inp_in, &mut out_out, NULL);
21809 utils::result(vips_op_response, out_out, Error::HistEntropyError)
21810 }
21811}
21812
21813pub fn conv(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21818 unsafe {
21819 let inp_in: *mut bindings::VipsImage = inp.ctx;
21820 let mask_in: *mut bindings::VipsImage = mask.ctx;
21821 let mut out_out: *mut bindings::VipsImage = null_mut();
21822
21823 let vips_op_response = bindings::vips_conv(inp_in, &mut out_out, mask_in, NULL);
21824 utils::result(
21825 vips_op_response,
21826 VipsImage { ctx: out_out },
21827 Error::ConvError,
21828 )
21829 }
21830}
21831
21832#[derive(Clone, Debug)]
21834pub struct ConvOptions {
21835 pub precision: Precision,
21840 pub layers: i32,
21843 pub cluster: i32,
21846}
21847
21848impl std::default::Default for ConvOptions {
21849 fn default() -> Self {
21850 ConvOptions {
21851 precision: Precision::Float,
21852 layers: i32::from(5),
21853 cluster: i32::from(1),
21854 }
21855 }
21856}
21857
21858pub fn conv_with_opts(
21864 inp: &VipsImage,
21865 mask: &VipsImage,
21866 conv_options: &ConvOptions,
21867) -> Result<VipsImage> {
21868 unsafe {
21869 let inp_in: *mut bindings::VipsImage = inp.ctx;
21870 let mask_in: *mut bindings::VipsImage = mask.ctx;
21871 let mut out_out: *mut bindings::VipsImage = null_mut();
21872
21873 let precision_in: i32 = conv_options.precision as i32;
21874 let precision_in_name = utils::new_c_string("precision")?;
21875
21876 let layers_in: i32 = conv_options.layers;
21877 let layers_in_name = utils::new_c_string("layers")?;
21878
21879 let cluster_in: i32 = conv_options.cluster;
21880 let cluster_in_name = utils::new_c_string("cluster")?;
21881
21882 let vips_op_response = bindings::vips_conv(
21883 inp_in,
21884 &mut out_out,
21885 mask_in,
21886 precision_in_name.as_ptr(),
21887 precision_in,
21888 layers_in_name.as_ptr(),
21889 layers_in,
21890 cluster_in_name.as_ptr(),
21891 cluster_in,
21892 NULL,
21893 );
21894 utils::result(
21895 vips_op_response,
21896 VipsImage { ctx: out_out },
21897 Error::ConvError,
21898 )
21899 }
21900}
21901
21902pub fn conva(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21907 unsafe {
21908 let inp_in: *mut bindings::VipsImage = inp.ctx;
21909 let mask_in: *mut bindings::VipsImage = mask.ctx;
21910 let mut out_out: *mut bindings::VipsImage = null_mut();
21911
21912 let vips_op_response = bindings::vips_conva(inp_in, &mut out_out, mask_in, NULL);
21913 utils::result(
21914 vips_op_response,
21915 VipsImage { ctx: out_out },
21916 Error::ConvaError,
21917 )
21918 }
21919}
21920
21921#[derive(Clone, Debug)]
21923pub struct ConvaOptions {
21924 pub layers: i32,
21927 pub cluster: i32,
21930}
21931
21932impl std::default::Default for ConvaOptions {
21933 fn default() -> Self {
21934 ConvaOptions {
21935 layers: i32::from(5),
21936 cluster: i32::from(1),
21937 }
21938 }
21939}
21940
21941pub fn conva_with_opts(
21947 inp: &VipsImage,
21948 mask: &VipsImage,
21949 conva_options: &ConvaOptions,
21950) -> Result<VipsImage> {
21951 unsafe {
21952 let inp_in: *mut bindings::VipsImage = inp.ctx;
21953 let mask_in: *mut bindings::VipsImage = mask.ctx;
21954 let mut out_out: *mut bindings::VipsImage = null_mut();
21955
21956 let layers_in: i32 = conva_options.layers;
21957 let layers_in_name = utils::new_c_string("layers")?;
21958
21959 let cluster_in: i32 = conva_options.cluster;
21960 let cluster_in_name = utils::new_c_string("cluster")?;
21961
21962 let vips_op_response = bindings::vips_conva(
21963 inp_in,
21964 &mut out_out,
21965 mask_in,
21966 layers_in_name.as_ptr(),
21967 layers_in,
21968 cluster_in_name.as_ptr(),
21969 cluster_in,
21970 NULL,
21971 );
21972 utils::result(
21973 vips_op_response,
21974 VipsImage { ctx: out_out },
21975 Error::ConvaError,
21976 )
21977 }
21978}
21979
21980pub fn convf(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21985 unsafe {
21986 let inp_in: *mut bindings::VipsImage = inp.ctx;
21987 let mask_in: *mut bindings::VipsImage = mask.ctx;
21988 let mut out_out: *mut bindings::VipsImage = null_mut();
21989
21990 let vips_op_response = bindings::vips_convf(inp_in, &mut out_out, mask_in, NULL);
21991 utils::result(
21992 vips_op_response,
21993 VipsImage { ctx: out_out },
21994 Error::ConvfError,
21995 )
21996 }
21997}
21998
21999pub fn convi(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22004 unsafe {
22005 let inp_in: *mut bindings::VipsImage = inp.ctx;
22006 let mask_in: *mut bindings::VipsImage = mask.ctx;
22007 let mut out_out: *mut bindings::VipsImage = null_mut();
22008
22009 let vips_op_response = bindings::vips_convi(inp_in, &mut out_out, mask_in, NULL);
22010 utils::result(
22011 vips_op_response,
22012 VipsImage { ctx: out_out },
22013 Error::ConviError,
22014 )
22015 }
22016}
22017
22018pub fn compass(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22023 unsafe {
22024 let inp_in: *mut bindings::VipsImage = inp.ctx;
22025 let mask_in: *mut bindings::VipsImage = mask.ctx;
22026 let mut out_out: *mut bindings::VipsImage = null_mut();
22027
22028 let vips_op_response = bindings::vips_compass(inp_in, &mut out_out, mask_in, NULL);
22029 utils::result(
22030 vips_op_response,
22031 VipsImage { ctx: out_out },
22032 Error::CompassError,
22033 )
22034 }
22035}
22036
22037#[derive(Clone, Debug)]
22039pub struct CompassOptions {
22040 pub times: i32,
22043 pub angle: Angle45,
22053 pub combine: Combine,
22058 pub precision: Precision,
22063 pub layers: i32,
22066 pub cluster: i32,
22069}
22070
22071impl std::default::Default for CompassOptions {
22072 fn default() -> Self {
22073 CompassOptions {
22074 times: i32::from(2),
22075 angle: Angle45::D90,
22076 combine: Combine::Max,
22077 precision: Precision::Float,
22078 layers: i32::from(5),
22079 cluster: i32::from(1),
22080 }
22081 }
22082}
22083
22084pub fn compass_with_opts(
22090 inp: &VipsImage,
22091 mask: &VipsImage,
22092 compass_options: &CompassOptions,
22093) -> Result<VipsImage> {
22094 unsafe {
22095 let inp_in: *mut bindings::VipsImage = inp.ctx;
22096 let mask_in: *mut bindings::VipsImage = mask.ctx;
22097 let mut out_out: *mut bindings::VipsImage = null_mut();
22098
22099 let times_in: i32 = compass_options.times;
22100 let times_in_name = utils::new_c_string("times")?;
22101
22102 let angle_in: i32 = compass_options.angle as i32;
22103 let angle_in_name = utils::new_c_string("angle")?;
22104
22105 let combine_in: i32 = compass_options.combine as i32;
22106 let combine_in_name = utils::new_c_string("combine")?;
22107
22108 let precision_in: i32 = compass_options.precision as i32;
22109 let precision_in_name = utils::new_c_string("precision")?;
22110
22111 let layers_in: i32 = compass_options.layers;
22112 let layers_in_name = utils::new_c_string("layers")?;
22113
22114 let cluster_in: i32 = compass_options.cluster;
22115 let cluster_in_name = utils::new_c_string("cluster")?;
22116
22117 let vips_op_response = bindings::vips_compass(
22118 inp_in,
22119 &mut out_out,
22120 mask_in,
22121 times_in_name.as_ptr(),
22122 times_in,
22123 angle_in_name.as_ptr(),
22124 angle_in,
22125 combine_in_name.as_ptr(),
22126 combine_in,
22127 precision_in_name.as_ptr(),
22128 precision_in,
22129 layers_in_name.as_ptr(),
22130 layers_in,
22131 cluster_in_name.as_ptr(),
22132 cluster_in,
22133 NULL,
22134 );
22135 utils::result(
22136 vips_op_response,
22137 VipsImage { ctx: out_out },
22138 Error::CompassError,
22139 )
22140 }
22141}
22142
22143pub fn convsep(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22148 unsafe {
22149 let inp_in: *mut bindings::VipsImage = inp.ctx;
22150 let mask_in: *mut bindings::VipsImage = mask.ctx;
22151 let mut out_out: *mut bindings::VipsImage = null_mut();
22152
22153 let vips_op_response = bindings::vips_convsep(inp_in, &mut out_out, mask_in, NULL);
22154 utils::result(
22155 vips_op_response,
22156 VipsImage { ctx: out_out },
22157 Error::ConvsepError,
22158 )
22159 }
22160}
22161
22162#[derive(Clone, Debug)]
22164pub struct ConvsepOptions {
22165 pub precision: Precision,
22170 pub layers: i32,
22173 pub cluster: i32,
22176}
22177
22178impl std::default::Default for ConvsepOptions {
22179 fn default() -> Self {
22180 ConvsepOptions {
22181 precision: Precision::Float,
22182 layers: i32::from(5),
22183 cluster: i32::from(1),
22184 }
22185 }
22186}
22187
22188pub fn convsep_with_opts(
22194 inp: &VipsImage,
22195 mask: &VipsImage,
22196 convsep_options: &ConvsepOptions,
22197) -> Result<VipsImage> {
22198 unsafe {
22199 let inp_in: *mut bindings::VipsImage = inp.ctx;
22200 let mask_in: *mut bindings::VipsImage = mask.ctx;
22201 let mut out_out: *mut bindings::VipsImage = null_mut();
22202
22203 let precision_in: i32 = convsep_options.precision as i32;
22204 let precision_in_name = utils::new_c_string("precision")?;
22205
22206 let layers_in: i32 = convsep_options.layers;
22207 let layers_in_name = utils::new_c_string("layers")?;
22208
22209 let cluster_in: i32 = convsep_options.cluster;
22210 let cluster_in_name = utils::new_c_string("cluster")?;
22211
22212 let vips_op_response = bindings::vips_convsep(
22213 inp_in,
22214 &mut out_out,
22215 mask_in,
22216 precision_in_name.as_ptr(),
22217 precision_in,
22218 layers_in_name.as_ptr(),
22219 layers_in,
22220 cluster_in_name.as_ptr(),
22221 cluster_in,
22222 NULL,
22223 );
22224 utils::result(
22225 vips_op_response,
22226 VipsImage { ctx: out_out },
22227 Error::ConvsepError,
22228 )
22229 }
22230}
22231
22232pub fn convasep(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22237 unsafe {
22238 let inp_in: *mut bindings::VipsImage = inp.ctx;
22239 let mask_in: *mut bindings::VipsImage = mask.ctx;
22240 let mut out_out: *mut bindings::VipsImage = null_mut();
22241
22242 let vips_op_response = bindings::vips_convasep(inp_in, &mut out_out, mask_in, NULL);
22243 utils::result(
22244 vips_op_response,
22245 VipsImage { ctx: out_out },
22246 Error::ConvasepError,
22247 )
22248 }
22249}
22250
22251#[derive(Clone, Debug)]
22253pub struct ConvasepOptions {
22254 pub layers: i32,
22257}
22258
22259impl std::default::Default for ConvasepOptions {
22260 fn default() -> Self {
22261 ConvasepOptions {
22262 layers: i32::from(5),
22263 }
22264 }
22265}
22266
22267pub fn convasep_with_opts(
22273 inp: &VipsImage,
22274 mask: &VipsImage,
22275 convasep_options: &ConvasepOptions,
22276) -> Result<VipsImage> {
22277 unsafe {
22278 let inp_in: *mut bindings::VipsImage = inp.ctx;
22279 let mask_in: *mut bindings::VipsImage = mask.ctx;
22280 let mut out_out: *mut bindings::VipsImage = null_mut();
22281
22282 let layers_in: i32 = convasep_options.layers;
22283 let layers_in_name = utils::new_c_string("layers")?;
22284
22285 let vips_op_response = bindings::vips_convasep(
22286 inp_in,
22287 &mut out_out,
22288 mask_in,
22289 layers_in_name.as_ptr(),
22290 layers_in,
22291 NULL,
22292 );
22293 utils::result(
22294 vips_op_response,
22295 VipsImage { ctx: out_out },
22296 Error::ConvasepError,
22297 )
22298 }
22299}
22300
22301pub fn fastcor(inp: &VipsImage, refp: &VipsImage) -> Result<VipsImage> {
22306 unsafe {
22307 let inp_in: *mut bindings::VipsImage = inp.ctx;
22308 let refp_in: *mut bindings::VipsImage = refp.ctx;
22309 let mut out_out: *mut bindings::VipsImage = null_mut();
22310
22311 let vips_op_response = bindings::vips_fastcor(inp_in, refp_in, &mut out_out, NULL);
22312 utils::result(
22313 vips_op_response,
22314 VipsImage { ctx: out_out },
22315 Error::FastcorError,
22316 )
22317 }
22318}
22319
22320pub fn spcor(inp: &VipsImage, refp: &VipsImage) -> Result<VipsImage> {
22325 unsafe {
22326 let inp_in: *mut bindings::VipsImage = inp.ctx;
22327 let refp_in: *mut bindings::VipsImage = refp.ctx;
22328 let mut out_out: *mut bindings::VipsImage = null_mut();
22329
22330 let vips_op_response = bindings::vips_spcor(inp_in, refp_in, &mut out_out, NULL);
22331 utils::result(
22332 vips_op_response,
22333 VipsImage { ctx: out_out },
22334 Error::SpcorError,
22335 )
22336 }
22337}
22338
22339pub fn sharpen(inp: &VipsImage) -> Result<VipsImage> {
22343 unsafe {
22344 let inp_in: *mut bindings::VipsImage = inp.ctx;
22345 let mut out_out: *mut bindings::VipsImage = null_mut();
22346
22347 let vips_op_response = bindings::vips_sharpen(inp_in, &mut out_out, NULL);
22348 utils::result(
22349 vips_op_response,
22350 VipsImage { ctx: out_out },
22351 Error::SharpenError,
22352 )
22353 }
22354}
22355
22356#[derive(Clone, Debug)]
22358pub struct SharpenOptions {
22359 pub sigma: f64,
22362 pub x_1: f64,
22365 pub y_2: f64,
22368 pub y_3: f64,
22371 pub m_1: f64,
22374 pub m_2: f64,
22377}
22378
22379impl std::default::Default for SharpenOptions {
22380 fn default() -> Self {
22381 SharpenOptions {
22382 sigma: f64::from(0.5),
22383 x_1: f64::from(2),
22384 y_2: f64::from(10),
22385 y_3: f64::from(20),
22386 m_1: f64::from(0),
22387 m_2: f64::from(3),
22388 }
22389 }
22390}
22391
22392pub fn sharpen_with_opts(inp: &VipsImage, sharpen_options: &SharpenOptions) -> Result<VipsImage> {
22397 unsafe {
22398 let inp_in: *mut bindings::VipsImage = inp.ctx;
22399 let mut out_out: *mut bindings::VipsImage = null_mut();
22400
22401 let sigma_in: f64 = sharpen_options.sigma;
22402 let sigma_in_name = utils::new_c_string("sigma")?;
22403
22404 let x_1_in: f64 = sharpen_options.x_1;
22405 let x_1_in_name = utils::new_c_string("x1")?;
22406
22407 let y_2_in: f64 = sharpen_options.y_2;
22408 let y_2_in_name = utils::new_c_string("y2")?;
22409
22410 let y_3_in: f64 = sharpen_options.y_3;
22411 let y_3_in_name = utils::new_c_string("y3")?;
22412
22413 let m_1_in: f64 = sharpen_options.m_1;
22414 let m_1_in_name = utils::new_c_string("m1")?;
22415
22416 let m_2_in: f64 = sharpen_options.m_2;
22417 let m_2_in_name = utils::new_c_string("m2")?;
22418
22419 let vips_op_response = bindings::vips_sharpen(
22420 inp_in,
22421 &mut out_out,
22422 sigma_in_name.as_ptr(),
22423 sigma_in,
22424 x_1_in_name.as_ptr(),
22425 x_1_in,
22426 y_2_in_name.as_ptr(),
22427 y_2_in,
22428 y_3_in_name.as_ptr(),
22429 y_3_in,
22430 m_1_in_name.as_ptr(),
22431 m_1_in,
22432 m_2_in_name.as_ptr(),
22433 m_2_in,
22434 NULL,
22435 );
22436 utils::result(
22437 vips_op_response,
22438 VipsImage { ctx: out_out },
22439 Error::SharpenError,
22440 )
22441 }
22442}
22443
22444pub fn gaussblur(inp: &VipsImage, sigma: f64) -> Result<VipsImage> {
22450 unsafe {
22451 let inp_in: *mut bindings::VipsImage = inp.ctx;
22452 let sigma_in: f64 = sigma;
22453 let mut out_out: *mut bindings::VipsImage = null_mut();
22454
22455 let vips_op_response = bindings::vips_gaussblur(inp_in, &mut out_out, sigma_in, NULL);
22456 utils::result(
22457 vips_op_response,
22458 VipsImage { ctx: out_out },
22459 Error::GaussblurError,
22460 )
22461 }
22462}
22463
22464#[derive(Clone, Debug)]
22466pub struct GaussblurOptions {
22467 pub min_ampl: f64,
22470 pub precision: Precision,
22475}
22476
22477impl std::default::Default for GaussblurOptions {
22478 fn default() -> Self {
22479 GaussblurOptions {
22480 min_ampl: f64::from(0.2),
22481 precision: Precision::Integer,
22482 }
22483 }
22484}
22485
22486pub fn gaussblur_with_opts(
22493 inp: &VipsImage,
22494 sigma: f64,
22495 gaussblur_options: &GaussblurOptions,
22496) -> Result<VipsImage> {
22497 unsafe {
22498 let inp_in: *mut bindings::VipsImage = inp.ctx;
22499 let sigma_in: f64 = sigma;
22500 let mut out_out: *mut bindings::VipsImage = null_mut();
22501
22502 let min_ampl_in: f64 = gaussblur_options.min_ampl;
22503 let min_ampl_in_name = utils::new_c_string("min-ampl")?;
22504
22505 let precision_in: i32 = gaussblur_options.precision as i32;
22506 let precision_in_name = utils::new_c_string("precision")?;
22507
22508 let vips_op_response = bindings::vips_gaussblur(
22509 inp_in,
22510 &mut out_out,
22511 sigma_in,
22512 min_ampl_in_name.as_ptr(),
22513 min_ampl_in,
22514 precision_in_name.as_ptr(),
22515 precision_in,
22516 NULL,
22517 );
22518 utils::result(
22519 vips_op_response,
22520 VipsImage { ctx: out_out },
22521 Error::GaussblurError,
22522 )
22523 }
22524}
22525
22526pub fn sobel(inp: &VipsImage) -> Result<VipsImage> {
22530 unsafe {
22531 let inp_in: *mut bindings::VipsImage = inp.ctx;
22532 let mut out_out: *mut bindings::VipsImage = null_mut();
22533
22534 let vips_op_response = bindings::vips_sobel(inp_in, &mut out_out, NULL);
22535 utils::result(
22536 vips_op_response,
22537 VipsImage { ctx: out_out },
22538 Error::SobelError,
22539 )
22540 }
22541}
22542
22543pub fn scharr(inp: &VipsImage) -> Result<VipsImage> {
22547 unsafe {
22548 let inp_in: *mut bindings::VipsImage = inp.ctx;
22549 let mut out_out: *mut bindings::VipsImage = null_mut();
22550
22551 let vips_op_response = bindings::vips_scharr(inp_in, &mut out_out, NULL);
22552 utils::result(
22553 vips_op_response,
22554 VipsImage { ctx: out_out },
22555 Error::ScharrError,
22556 )
22557 }
22558}
22559
22560pub fn prewitt(inp: &VipsImage) -> Result<VipsImage> {
22564 unsafe {
22565 let inp_in: *mut bindings::VipsImage = inp.ctx;
22566 let mut out_out: *mut bindings::VipsImage = null_mut();
22567
22568 let vips_op_response = bindings::vips_prewitt(inp_in, &mut out_out, NULL);
22569 utils::result(
22570 vips_op_response,
22571 VipsImage { ctx: out_out },
22572 Error::PrewittError,
22573 )
22574 }
22575}
22576
22577pub fn canny(inp: &VipsImage) -> Result<VipsImage> {
22581 unsafe {
22582 let inp_in: *mut bindings::VipsImage = inp.ctx;
22583 let mut out_out: *mut bindings::VipsImage = null_mut();
22584
22585 let vips_op_response = bindings::vips_canny(inp_in, &mut out_out, NULL);
22586 utils::result(
22587 vips_op_response,
22588 VipsImage { ctx: out_out },
22589 Error::CannyError,
22590 )
22591 }
22592}
22593
22594#[derive(Clone, Debug)]
22596pub struct CannyOptions {
22597 pub sigma: f64,
22600 pub precision: Precision,
22605}
22606
22607impl std::default::Default for CannyOptions {
22608 fn default() -> Self {
22609 CannyOptions {
22610 sigma: f64::from(1.4),
22611 precision: Precision::Float,
22612 }
22613 }
22614}
22615
22616pub fn canny_with_opts(inp: &VipsImage, canny_options: &CannyOptions) -> Result<VipsImage> {
22621 unsafe {
22622 let inp_in: *mut bindings::VipsImage = inp.ctx;
22623 let mut out_out: *mut bindings::VipsImage = null_mut();
22624
22625 let sigma_in: f64 = canny_options.sigma;
22626 let sigma_in_name = utils::new_c_string("sigma")?;
22627
22628 let precision_in: i32 = canny_options.precision as i32;
22629 let precision_in_name = utils::new_c_string("precision")?;
22630
22631 let vips_op_response = bindings::vips_canny(
22632 inp_in,
22633 &mut out_out,
22634 sigma_in_name.as_ptr(),
22635 sigma_in,
22636 precision_in_name.as_ptr(),
22637 precision_in,
22638 NULL,
22639 );
22640 utils::result(
22641 vips_op_response,
22642 VipsImage { ctx: out_out },
22643 Error::CannyError,
22644 )
22645 }
22646}
22647
22648pub fn fwfft(inp: &VipsImage) -> Result<VipsImage> {
22652 unsafe {
22653 let inp_in: *mut bindings::VipsImage = inp.ctx;
22654 let mut out_out: *mut bindings::VipsImage = null_mut();
22655
22656 let vips_op_response = bindings::vips_fwfft(inp_in, &mut out_out, NULL);
22657 utils::result(
22658 vips_op_response,
22659 VipsImage { ctx: out_out },
22660 Error::FwfftError,
22661 )
22662 }
22663}
22664
22665pub fn invfft(inp: &VipsImage) -> Result<VipsImage> {
22669 unsafe {
22670 let inp_in: *mut bindings::VipsImage = inp.ctx;
22671 let mut out_out: *mut bindings::VipsImage = null_mut();
22672
22673 let vips_op_response = bindings::vips_invfft(inp_in, &mut out_out, NULL);
22674 utils::result(
22675 vips_op_response,
22676 VipsImage { ctx: out_out },
22677 Error::InvfftError,
22678 )
22679 }
22680}
22681
22682#[derive(Clone, Debug)]
22684pub struct InvfftOptions {
22685 pub real: bool,
22688}
22689
22690impl std::default::Default for InvfftOptions {
22691 fn default() -> Self {
22692 InvfftOptions { real: false }
22693 }
22694}
22695
22696pub fn invfft_with_opts(inp: &VipsImage, invfft_options: &InvfftOptions) -> Result<VipsImage> {
22701 unsafe {
22702 let inp_in: *mut bindings::VipsImage = inp.ctx;
22703 let mut out_out: *mut bindings::VipsImage = null_mut();
22704
22705 let real_in: i32 = if invfft_options.real { 1 } else { 0 };
22706 let real_in_name = utils::new_c_string("real")?;
22707
22708 let vips_op_response =
22709 bindings::vips_invfft(inp_in, &mut out_out, real_in_name.as_ptr(), real_in, NULL);
22710 utils::result(
22711 vips_op_response,
22712 VipsImage { ctx: out_out },
22713 Error::InvfftError,
22714 )
22715 }
22716}
22717
22718pub fn freqmult(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22723 unsafe {
22724 let inp_in: *mut bindings::VipsImage = inp.ctx;
22725 let mask_in: *mut bindings::VipsImage = mask.ctx;
22726 let mut out_out: *mut bindings::VipsImage = null_mut();
22727
22728 let vips_op_response = bindings::vips_freqmult(inp_in, mask_in, &mut out_out, NULL);
22729 utils::result(
22730 vips_op_response,
22731 VipsImage { ctx: out_out },
22732 Error::FreqmultError,
22733 )
22734 }
22735}
22736
22737pub fn spectrum(inp: &VipsImage) -> Result<VipsImage> {
22741 unsafe {
22742 let inp_in: *mut bindings::VipsImage = inp.ctx;
22743 let mut out_out: *mut bindings::VipsImage = null_mut();
22744
22745 let vips_op_response = bindings::vips_spectrum(inp_in, &mut out_out, NULL);
22746 utils::result(
22747 vips_op_response,
22748 VipsImage { ctx: out_out },
22749 Error::SpectrumError,
22750 )
22751 }
22752}
22753
22754pub fn phasecor(inp: &VipsImage, in_2: &VipsImage) -> Result<VipsImage> {
22759 unsafe {
22760 let inp_in: *mut bindings::VipsImage = inp.ctx;
22761 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
22762 let mut out_out: *mut bindings::VipsImage = null_mut();
22763
22764 let vips_op_response = bindings::vips_phasecor(inp_in, in_2_in, &mut out_out, NULL);
22765 utils::result(
22766 vips_op_response,
22767 VipsImage { ctx: out_out },
22768 Error::PhasecorError,
22769 )
22770 }
22771}
22772
22773pub fn morph(inp: &VipsImage, mask: &VipsImage, morph: OperationMorphology) -> Result<VipsImage> {
22781 unsafe {
22782 let inp_in: *mut bindings::VipsImage = inp.ctx;
22783 let mask_in: *mut bindings::VipsImage = mask.ctx;
22784 let morph_in: i32 = morph as i32;
22785 let mut out_out: *mut bindings::VipsImage = null_mut();
22786
22787 let vips_op_response = bindings::vips_morph(
22788 inp_in,
22789 &mut out_out,
22790 mask_in,
22791 morph_in.try_into().unwrap(),
22792 NULL,
22793 );
22794 utils::result(
22795 vips_op_response,
22796 VipsImage { ctx: out_out },
22797 Error::MorphError,
22798 )
22799 }
22800}
22801
22802pub fn rank(inp: &VipsImage, width: i32, height: i32, index: i32) -> Result<VipsImage> {
22812 unsafe {
22813 let inp_in: *mut bindings::VipsImage = inp.ctx;
22814 let width_in: i32 = width;
22815 let height_in: i32 = height;
22816 let index_in: i32 = index;
22817 let mut out_out: *mut bindings::VipsImage = null_mut();
22818
22819 let vips_op_response =
22820 bindings::vips_rank(inp_in, &mut out_out, width_in, height_in, index_in, NULL);
22821 utils::result(
22822 vips_op_response,
22823 VipsImage { ctx: out_out },
22824 Error::RankError,
22825 )
22826 }
22827}
22828
22829pub fn countlines(inp: &VipsImage, direction: Direction) -> Result<f64> {
22836 unsafe {
22837 let inp_in: *mut bindings::VipsImage = inp.ctx;
22838 let direction_in: i32 = direction as i32;
22839 let mut nolines_out: f64 = f64::from(0);
22840
22841 let vips_op_response = bindings::vips_countlines(
22842 inp_in,
22843 &mut nolines_out,
22844 direction_in.try_into().unwrap(),
22845 NULL,
22846 );
22847 utils::result(vips_op_response, nolines_out, Error::CountlineError)
22848 }
22849}
22850
22851pub fn labelregions(inp: &VipsImage) -> Result<VipsImage> {
22855 unsafe {
22856 let inp_in: *mut bindings::VipsImage = inp.ctx;
22857 let mut mask_out: *mut bindings::VipsImage = null_mut();
22858
22859 let vips_op_response = bindings::vips_labelregions(inp_in, &mut mask_out, NULL);
22860 utils::result(
22861 vips_op_response,
22862 VipsImage { ctx: mask_out },
22863 Error::LabelregionError,
22864 )
22865 }
22866}
22867
22868#[derive(Clone, Debug)]
22870pub struct LabelregionOptions {
22871 pub segments: i32,
22874}
22875
22876impl std::default::Default for LabelregionOptions {
22877 fn default() -> Self {
22878 LabelregionOptions {
22879 segments: i32::from(0),
22880 }
22881 }
22882}
22883
22884pub fn labelregions_with_opts(
22889 inp: &VipsImage,
22890 labelregions_options: &LabelregionOptions,
22891) -> Result<VipsImage> {
22892 unsafe {
22893 let inp_in: *mut bindings::VipsImage = inp.ctx;
22894 let mut mask_out: *mut bindings::VipsImage = null_mut();
22895
22896 let segments_in: i32 = labelregions_options.segments;
22897 let segments_in_name = utils::new_c_string("segments")?;
22898
22899 let vips_op_response = bindings::vips_labelregions(
22900 inp_in,
22901 &mut mask_out,
22902 segments_in_name.as_ptr(),
22903 segments_in,
22904 NULL,
22905 );
22906 utils::result(
22907 vips_op_response,
22908 VipsImage { ctx: mask_out },
22909 Error::LabelregionError,
22910 )
22911 }
22912}
22913
22914pub fn fill_nearest(inp: &VipsImage) -> Result<VipsImage> {
22918 unsafe {
22919 let inp_in: *mut bindings::VipsImage = inp.ctx;
22920 let mut out_out: *mut bindings::VipsImage = null_mut();
22921
22922 let vips_op_response = bindings::vips_fill_nearest(inp_in, &mut out_out, NULL);
22923 utils::result(
22924 vips_op_response,
22925 VipsImage { ctx: out_out },
22926 Error::FillNearestError,
22927 )
22928 }
22929}
22930
22931#[derive(Clone, Debug)]
22933pub struct FillNearestOptions {
22934 pub distance: VipsImage,
22936}
22937
22938impl std::default::Default for FillNearestOptions {
22939 fn default() -> Self {
22940 FillNearestOptions {
22941 distance: VipsImage::new(),
22942 }
22943 }
22944}
22945
22946pub fn fill_nearest_with_opts(
22951 inp: &VipsImage,
22952 fill_nearest_options: &FillNearestOptions,
22953) -> Result<VipsImage> {
22954 unsafe {
22955 let inp_in: *mut bindings::VipsImage = inp.ctx;
22956 let mut out_out: *mut bindings::VipsImage = null_mut();
22957
22958 let distance_in: *mut bindings::VipsImage = fill_nearest_options.distance.ctx;
22959 let distance_in_name = utils::new_c_string("distance")?;
22960
22961 let vips_op_response = bindings::vips_fill_nearest(
22962 inp_in,
22963 &mut out_out,
22964 distance_in_name.as_ptr(),
22965 distance_in,
22966 NULL,
22967 );
22968 utils::result(
22969 vips_op_response,
22970 VipsImage { ctx: out_out },
22971 Error::FillNearestError,
22972 )
22973 }
22974}
22975
22976pub fn draw_rect(
22989 image: &VipsImage,
22990 ink: &mut [f64],
22991 left: i32,
22992 top: i32,
22993 width: i32,
22994 height: i32,
22995) -> Result<()> {
22996 unsafe {
22997 let image_in: *mut bindings::VipsImage = image.ctx;
22998 let ink_in: *mut f64 = ink.as_mut_ptr();
22999 let left_in: i32 = left;
23000 let top_in: i32 = top;
23001 let width_in: i32 = width;
23002 let height_in: i32 = height;
23003
23004 let vips_op_response = bindings::vips_draw_rect(
23005 image_in,
23006 ink_in,
23007 ink.len() as i32,
23008 left_in,
23009 top_in,
23010 width_in,
23011 height_in,
23012 NULL,
23013 );
23014 utils::result(vips_op_response, (), Error::DrawRectError)
23015 }
23016}
23017
23018#[derive(Clone, Debug)]
23020pub struct DrawRectOptions {
23021 pub fill: bool,
23024}
23025
23026impl std::default::Default for DrawRectOptions {
23027 fn default() -> Self {
23028 DrawRectOptions { fill: false }
23029 }
23030}
23031
23032pub fn draw_rect_with_opts(
23046 image: &VipsImage,
23047 ink: &mut [f64],
23048 left: i32,
23049 top: i32,
23050 width: i32,
23051 height: i32,
23052 draw_rect_options: &DrawRectOptions,
23053) -> Result<()> {
23054 unsafe {
23055 let image_in: *mut bindings::VipsImage = image.ctx;
23056 let ink_in: *mut f64 = ink.as_mut_ptr();
23057 let left_in: i32 = left;
23058 let top_in: i32 = top;
23059 let width_in: i32 = width;
23060 let height_in: i32 = height;
23061
23062 let fill_in: i32 = if draw_rect_options.fill { 1 } else { 0 };
23063 let fill_in_name = utils::new_c_string("fill")?;
23064
23065 let vips_op_response = bindings::vips_draw_rect(
23066 image_in,
23067 ink_in,
23068 ink.len() as i32,
23069 left_in,
23070 top_in,
23071 width_in,
23072 height_in,
23073 fill_in_name.as_ptr(),
23074 fill_in,
23075 NULL,
23076 );
23077 utils::result(vips_op_response, (), Error::DrawRectError)
23078 }
23079}
23080
23081pub fn draw_mask(
23091 image: &VipsImage,
23092 ink: &mut [f64],
23093 mask: &VipsImage,
23094 x: i32,
23095 y: i32,
23096) -> Result<()> {
23097 unsafe {
23098 let image_in: *mut bindings::VipsImage = image.ctx;
23099 let ink_in: *mut f64 = ink.as_mut_ptr();
23100 let mask_in: *mut bindings::VipsImage = mask.ctx;
23101 let x_in: i32 = x;
23102 let y_in: i32 = y;
23103
23104 let vips_op_response = bindings::vips_draw_mask(
23105 image_in,
23106 ink_in,
23107 ink.len() as i32,
23108 mask_in,
23109 x_in,
23110 y_in,
23111 NULL,
23112 );
23113 utils::result(vips_op_response, (), Error::DrawMaskError)
23114 }
23115}
23116
23117pub fn draw_line(
23130 image: &VipsImage,
23131 ink: &mut [f64],
23132 x_1: i32,
23133 y_1: i32,
23134 x_2: i32,
23135 y_2: i32,
23136) -> Result<()> {
23137 unsafe {
23138 let image_in: *mut bindings::VipsImage = image.ctx;
23139 let ink_in: *mut f64 = ink.as_mut_ptr();
23140 let x_1_in: i32 = x_1;
23141 let y_1_in: i32 = y_1;
23142 let x_2_in: i32 = x_2;
23143 let y_2_in: i32 = y_2;
23144
23145 let vips_op_response = bindings::vips_draw_line(
23146 image_in,
23147 ink_in,
23148 ink.len() as i32,
23149 x_1_in,
23150 y_1_in,
23151 x_2_in,
23152 y_2_in,
23153 NULL,
23154 );
23155 utils::result(vips_op_response, (), Error::DrawLineError)
23156 }
23157}
23158
23159pub fn draw_circle(
23170 image: &VipsImage,
23171 ink: &mut [f64],
23172 cx: i32,
23173 cy: i32,
23174 radius: i32,
23175) -> Result<()> {
23176 unsafe {
23177 let image_in: *mut bindings::VipsImage = image.ctx;
23178 let ink_in: *mut f64 = ink.as_mut_ptr();
23179 let cx_in: i32 = cx;
23180 let cy_in: i32 = cy;
23181 let radius_in: i32 = radius;
23182
23183 let vips_op_response = bindings::vips_draw_circle(
23184 image_in,
23185 ink_in,
23186 ink.len() as i32,
23187 cx_in,
23188 cy_in,
23189 radius_in,
23190 NULL,
23191 );
23192 utils::result(vips_op_response, (), Error::DrawCircleError)
23193 }
23194}
23195
23196#[derive(Clone, Debug)]
23198pub struct DrawCircleOptions {
23199 pub fill: bool,
23202}
23203
23204impl std::default::Default for DrawCircleOptions {
23205 fn default() -> Self {
23206 DrawCircleOptions { fill: false }
23207 }
23208}
23209
23210pub fn draw_circle_with_opts(
23222 image: &VipsImage,
23223 ink: &mut [f64],
23224 cx: i32,
23225 cy: i32,
23226 radius: i32,
23227 draw_circle_options: &DrawCircleOptions,
23228) -> Result<()> {
23229 unsafe {
23230 let image_in: *mut bindings::VipsImage = image.ctx;
23231 let ink_in: *mut f64 = ink.as_mut_ptr();
23232 let cx_in: i32 = cx;
23233 let cy_in: i32 = cy;
23234 let radius_in: i32 = radius;
23235
23236 let fill_in: i32 = if draw_circle_options.fill { 1 } else { 0 };
23237 let fill_in_name = utils::new_c_string("fill")?;
23238
23239 let vips_op_response = bindings::vips_draw_circle(
23240 image_in,
23241 ink_in,
23242 ink.len() as i32,
23243 cx_in,
23244 cy_in,
23245 radius_in,
23246 fill_in_name.as_ptr(),
23247 fill_in,
23248 NULL,
23249 );
23250 utils::result(vips_op_response, (), Error::DrawCircleError)
23251 }
23252}
23253
23254pub fn draw_flood(image: &VipsImage, ink: &mut [f64], x: i32, y: i32) -> Result<()> {
23263 unsafe {
23264 let image_in: *mut bindings::VipsImage = image.ctx;
23265 let ink_in: *mut f64 = ink.as_mut_ptr();
23266 let x_in: i32 = x;
23267 let y_in: i32 = y;
23268
23269 let vips_op_response =
23270 bindings::vips_draw_flood(image_in, ink_in, ink.len() as i32, x_in, y_in, NULL);
23271 utils::result(vips_op_response, (), Error::DrawFloodError)
23272 }
23273}
23274
23275#[derive(Clone, Debug)]
23277pub struct DrawFloodOptions {
23278 pub test: VipsImage,
23280 pub equal: bool,
23283 pub left: i32,
23286 pub top: i32,
23289 pub width: i32,
23292 pub height: i32,
23295}
23296
23297impl std::default::Default for DrawFloodOptions {
23298 fn default() -> Self {
23299 DrawFloodOptions {
23300 test: VipsImage::new(),
23301 equal: false,
23302 left: i32::from(0),
23303 top: i32::from(0),
23304 width: i32::from(0),
23305 height: i32::from(0),
23306 }
23307 }
23308}
23309
23310pub fn draw_flood_with_opts(
23320 image: &VipsImage,
23321 ink: &mut [f64],
23322 x: i32,
23323 y: i32,
23324 draw_flood_options: &DrawFloodOptions,
23325) -> Result<()> {
23326 unsafe {
23327 let image_in: *mut bindings::VipsImage = image.ctx;
23328 let ink_in: *mut f64 = ink.as_mut_ptr();
23329 let x_in: i32 = x;
23330 let y_in: i32 = y;
23331
23332 let test_in: *mut bindings::VipsImage = draw_flood_options.test.ctx;
23333 let test_in_name = utils::new_c_string("test")?;
23334
23335 let equal_in: i32 = if draw_flood_options.equal { 1 } else { 0 };
23336 let equal_in_name = utils::new_c_string("equal")?;
23337
23338 let left_in: i32 = draw_flood_options.left;
23339 let left_in_name = utils::new_c_string("left")?;
23340
23341 let top_in: i32 = draw_flood_options.top;
23342 let top_in_name = utils::new_c_string("top")?;
23343
23344 let width_in: i32 = draw_flood_options.width;
23345 let width_in_name = utils::new_c_string("width")?;
23346
23347 let height_in: i32 = draw_flood_options.height;
23348 let height_in_name = utils::new_c_string("height")?;
23349
23350 let vips_op_response = bindings::vips_draw_flood(
23351 image_in,
23352 ink_in,
23353 ink.len() as i32,
23354 x_in,
23355 y_in,
23356 test_in_name.as_ptr(),
23357 test_in,
23358 equal_in_name.as_ptr(),
23359 equal_in,
23360 left_in_name.as_ptr(),
23361 left_in,
23362 top_in_name.as_ptr(),
23363 top_in,
23364 width_in_name.as_ptr(),
23365 width_in,
23366 height_in_name.as_ptr(),
23367 height_in,
23368 NULL,
23369 );
23370 utils::result(vips_op_response, (), Error::DrawFloodError)
23371 }
23372}
23373
23374pub fn draw_image(image: &VipsImage, sub: &VipsImage, x: i32, y: i32) -> Result<()> {
23383 unsafe {
23384 let image_in: *mut bindings::VipsImage = image.ctx;
23385 let sub_in: *mut bindings::VipsImage = sub.ctx;
23386 let x_in: i32 = x;
23387 let y_in: i32 = y;
23388
23389 let vips_op_response = bindings::vips_draw_image(image_in, sub_in, x_in, y_in, NULL);
23390 utils::result(vips_op_response, (), Error::DrawImageError)
23391 }
23392}
23393
23394#[derive(Clone, Debug)]
23396pub struct DrawImageOptions {
23397 pub mode: CombineMode,
23401}
23402
23403impl std::default::Default for DrawImageOptions {
23404 fn default() -> Self {
23405 DrawImageOptions {
23406 mode: CombineMode::Set,
23407 }
23408 }
23409}
23410
23411pub fn draw_image_with_opts(
23421 image: &VipsImage,
23422 sub: &VipsImage,
23423 x: i32,
23424 y: i32,
23425 draw_image_options: &DrawImageOptions,
23426) -> Result<()> {
23427 unsafe {
23428 let image_in: *mut bindings::VipsImage = image.ctx;
23429 let sub_in: *mut bindings::VipsImage = sub.ctx;
23430 let x_in: i32 = x;
23431 let y_in: i32 = y;
23432
23433 let mode_in: i32 = draw_image_options.mode as i32;
23434 let mode_in_name = utils::new_c_string("mode")?;
23435
23436 let vips_op_response = bindings::vips_draw_image(
23437 image_in,
23438 sub_in,
23439 x_in,
23440 y_in,
23441 mode_in_name.as_ptr(),
23442 mode_in,
23443 NULL,
23444 );
23445 utils::result(vips_op_response, (), Error::DrawImageError)
23446 }
23447}
23448
23449pub fn draw_smudge(image: &VipsImage, left: i32, top: i32, width: i32, height: i32) -> Result<()> {
23461 unsafe {
23462 let image_in: *mut bindings::VipsImage = image.ctx;
23463 let left_in: i32 = left;
23464 let top_in: i32 = top;
23465 let width_in: i32 = width;
23466 let height_in: i32 = height;
23467
23468 let vips_op_response =
23469 bindings::vips_draw_smudge(image_in, left_in, top_in, width_in, height_in, NULL);
23470 utils::result(vips_op_response, (), Error::DrawSmudgeError)
23471 }
23472}
23473
23474pub fn merge(
23486 refp: &VipsImage,
23487 sec: &VipsImage,
23488 direction: Direction,
23489 dx: i32,
23490 dy: i32,
23491) -> Result<VipsImage> {
23492 unsafe {
23493 let refp_in: *mut bindings::VipsImage = refp.ctx;
23494 let sec_in: *mut bindings::VipsImage = sec.ctx;
23495 let direction_in: i32 = direction as i32;
23496 let dx_in: i32 = dx;
23497 let dy_in: i32 = dy;
23498 let mut out_out: *mut bindings::VipsImage = null_mut();
23499
23500 let vips_op_response = bindings::vips_merge(
23501 refp_in,
23502 sec_in,
23503 &mut out_out,
23504 direction_in.try_into().unwrap(),
23505 dx_in,
23506 dy_in,
23507 NULL,
23508 );
23509 utils::result(
23510 vips_op_response,
23511 VipsImage { ctx: out_out },
23512 Error::MergeError,
23513 )
23514 }
23515}
23516
23517#[derive(Clone, Debug)]
23519pub struct MergeOptions {
23520 pub mblend: i32,
23523}
23524
23525impl std::default::Default for MergeOptions {
23526 fn default() -> Self {
23527 MergeOptions {
23528 mblend: i32::from(10),
23529 }
23530 }
23531}
23532
23533pub fn merge_with_opts(
23546 refp: &VipsImage,
23547 sec: &VipsImage,
23548 direction: Direction,
23549 dx: i32,
23550 dy: i32,
23551 merge_options: &MergeOptions,
23552) -> Result<VipsImage> {
23553 unsafe {
23554 let refp_in: *mut bindings::VipsImage = refp.ctx;
23555 let sec_in: *mut bindings::VipsImage = sec.ctx;
23556 let direction_in: i32 = direction as i32;
23557 let dx_in: i32 = dx;
23558 let dy_in: i32 = dy;
23559 let mut out_out: *mut bindings::VipsImage = null_mut();
23560
23561 let mblend_in: i32 = merge_options.mblend;
23562 let mblend_in_name = utils::new_c_string("mblend")?;
23563
23564 let vips_op_response = bindings::vips_merge(
23565 refp_in,
23566 sec_in,
23567 &mut out_out,
23568 direction_in.try_into().unwrap(),
23569 dx_in,
23570 dy_in,
23571 mblend_in_name.as_ptr(),
23572 mblend_in,
23573 NULL,
23574 );
23575 utils::result(
23576 vips_op_response,
23577 VipsImage { ctx: out_out },
23578 Error::MergeError,
23579 )
23580 }
23581}
23582
23583pub fn mosaic(
23599 refp: &VipsImage,
23600 sec: &VipsImage,
23601 direction: Direction,
23602 xref: i32,
23603 yref: i32,
23604 xsec: i32,
23605 ysec: i32,
23606) -> Result<VipsImage> {
23607 unsafe {
23608 let refp_in: *mut bindings::VipsImage = refp.ctx;
23609 let sec_in: *mut bindings::VipsImage = sec.ctx;
23610 let direction_in: i32 = direction as i32;
23611 let xref_in: i32 = xref;
23612 let yref_in: i32 = yref;
23613 let xsec_in: i32 = xsec;
23614 let ysec_in: i32 = ysec;
23615 let mut out_out: *mut bindings::VipsImage = null_mut();
23616
23617 let vips_op_response = bindings::vips_mosaic(
23618 refp_in,
23619 sec_in,
23620 &mut out_out,
23621 direction_in.try_into().unwrap(),
23622 xref_in,
23623 yref_in,
23624 xsec_in,
23625 ysec_in,
23626 NULL,
23627 );
23628 utils::result(
23629 vips_op_response,
23630 VipsImage { ctx: out_out },
23631 Error::MosaicError,
23632 )
23633 }
23634}
23635
23636#[derive(Clone, Debug)]
23638pub struct MosaicOptions {
23639 pub hwindow: i32,
23642 pub harea: i32,
23645 pub mblend: i32,
23648 pub bandno: i32,
23651 pub dx_0: i32,
23654 pub dy_0: i32,
23657 pub scale_1: f64,
23660 pub angle_1: f64,
23663 pub dy_1: f64,
23666 pub dx_1: f64,
23669}
23670
23671impl std::default::Default for MosaicOptions {
23672 fn default() -> Self {
23673 MosaicOptions {
23674 hwindow: i32::from(5),
23675 harea: i32::from(15),
23676 mblend: i32::from(10),
23677 bandno: i32::from(0),
23678 dx_0: i32::from(0),
23679 dy_0: i32::from(0),
23680 scale_1: f64::from(1),
23681 angle_1: f64::from(0),
23682 dy_1: f64::from(0),
23683 dx_1: f64::from(0),
23684 }
23685 }
23686}
23687
23688pub fn mosaic_with_opts(
23705 refp: &VipsImage,
23706 sec: &VipsImage,
23707 direction: Direction,
23708 xref: i32,
23709 yref: i32,
23710 xsec: i32,
23711 ysec: i32,
23712 mosaic_options: &MosaicOptions,
23713) -> Result<VipsImage> {
23714 unsafe {
23715 let refp_in: *mut bindings::VipsImage = refp.ctx;
23716 let sec_in: *mut bindings::VipsImage = sec.ctx;
23717 let direction_in: i32 = direction as i32;
23718 let xref_in: i32 = xref;
23719 let yref_in: i32 = yref;
23720 let xsec_in: i32 = xsec;
23721 let ysec_in: i32 = ysec;
23722 let mut out_out: *mut bindings::VipsImage = null_mut();
23723
23724 let hwindow_in: i32 = mosaic_options.hwindow;
23725 let hwindow_in_name = utils::new_c_string("hwindow")?;
23726
23727 let harea_in: i32 = mosaic_options.harea;
23728 let harea_in_name = utils::new_c_string("harea")?;
23729
23730 let mblend_in: i32 = mosaic_options.mblend;
23731 let mblend_in_name = utils::new_c_string("mblend")?;
23732
23733 let bandno_in: i32 = mosaic_options.bandno;
23734 let bandno_in_name = utils::new_c_string("bandno")?;
23735
23736 let dx_0_in: i32 = mosaic_options.dx_0;
23737 let dx_0_in_name = utils::new_c_string("dx0")?;
23738
23739 let dy_0_in: i32 = mosaic_options.dy_0;
23740 let dy_0_in_name = utils::new_c_string("dy0")?;
23741
23742 let scale_1_in: f64 = mosaic_options.scale_1;
23743 let scale_1_in_name = utils::new_c_string("scale1")?;
23744
23745 let angle_1_in: f64 = mosaic_options.angle_1;
23746 let angle_1_in_name = utils::new_c_string("angle1")?;
23747
23748 let dy_1_in: f64 = mosaic_options.dy_1;
23749 let dy_1_in_name = utils::new_c_string("dy1")?;
23750
23751 let dx_1_in: f64 = mosaic_options.dx_1;
23752 let dx_1_in_name = utils::new_c_string("dx1")?;
23753
23754 let vips_op_response = bindings::vips_mosaic(
23755 refp_in,
23756 sec_in,
23757 &mut out_out,
23758 direction_in.try_into().unwrap(),
23759 xref_in,
23760 yref_in,
23761 xsec_in,
23762 ysec_in,
23763 hwindow_in_name.as_ptr(),
23764 hwindow_in,
23765 harea_in_name.as_ptr(),
23766 harea_in,
23767 mblend_in_name.as_ptr(),
23768 mblend_in,
23769 bandno_in_name.as_ptr(),
23770 bandno_in,
23771 dx_0_in_name.as_ptr(),
23772 dx_0_in,
23773 dy_0_in_name.as_ptr(),
23774 dy_0_in,
23775 scale_1_in_name.as_ptr(),
23776 scale_1_in,
23777 angle_1_in_name.as_ptr(),
23778 angle_1_in,
23779 dy_1_in_name.as_ptr(),
23780 dy_1_in,
23781 dx_1_in_name.as_ptr(),
23782 dx_1_in,
23783 NULL,
23784 );
23785 utils::result(
23786 vips_op_response,
23787 VipsImage { ctx: out_out },
23788 Error::MosaicError,
23789 )
23790 }
23791}
23792
23793pub fn mosaic_1(
23817 refp: &VipsImage,
23818 sec: &VipsImage,
23819 direction: Direction,
23820 xr_1: i32,
23821 yr_1: i32,
23822 xs_1: i32,
23823 ys_1: i32,
23824 xr_2: i32,
23825 yr_2: i32,
23826 xs_2: i32,
23827 ys_2: i32,
23828) -> Result<VipsImage> {
23829 unsafe {
23830 let refp_in: *mut bindings::VipsImage = refp.ctx;
23831 let sec_in: *mut bindings::VipsImage = sec.ctx;
23832 let direction_in: i32 = direction as i32;
23833 let xr_1_in: i32 = xr_1;
23834 let yr_1_in: i32 = yr_1;
23835 let xs_1_in: i32 = xs_1;
23836 let ys_1_in: i32 = ys_1;
23837 let xr_2_in: i32 = xr_2;
23838 let yr_2_in: i32 = yr_2;
23839 let xs_2_in: i32 = xs_2;
23840 let ys_2_in: i32 = ys_2;
23841 let mut out_out: *mut bindings::VipsImage = null_mut();
23842
23843 let vips_op_response = bindings::vips_mosaic1(
23844 refp_in,
23845 sec_in,
23846 &mut out_out,
23847 direction_in.try_into().unwrap(),
23848 xr_1_in,
23849 yr_1_in,
23850 xs_1_in,
23851 ys_1_in,
23852 xr_2_in,
23853 yr_2_in,
23854 xs_2_in,
23855 ys_2_in,
23856 NULL,
23857 );
23858 utils::result(
23859 vips_op_response,
23860 VipsImage { ctx: out_out },
23861 Error::Mosaic1Error,
23862 )
23863 }
23864}
23865
23866#[derive(Clone, Debug)]
23868pub struct Mosaic1Options {
23869 pub hwindow: i32,
23872 pub harea: i32,
23875 pub search: bool,
23878 pub interpolate: VipsInterpolate,
23880 pub mblend: i32,
23883}
23884
23885impl std::default::Default for Mosaic1Options {
23886 fn default() -> Self {
23887 Mosaic1Options {
23888 hwindow: i32::from(5),
23889 harea: i32::from(15),
23890 search: false,
23891 interpolate: VipsInterpolate::new(),
23892 mblend: i32::from(10),
23893 }
23894 }
23895}
23896
23897pub fn mosaic_1_with_opts(
23922 refp: &VipsImage,
23923 sec: &VipsImage,
23924 direction: Direction,
23925 xr_1: i32,
23926 yr_1: i32,
23927 xs_1: i32,
23928 ys_1: i32,
23929 xr_2: i32,
23930 yr_2: i32,
23931 xs_2: i32,
23932 ys_2: i32,
23933 mosaic_1_options: &Mosaic1Options,
23934) -> Result<VipsImage> {
23935 unsafe {
23936 let refp_in: *mut bindings::VipsImage = refp.ctx;
23937 let sec_in: *mut bindings::VipsImage = sec.ctx;
23938 let direction_in: i32 = direction as i32;
23939 let xr_1_in: i32 = xr_1;
23940 let yr_1_in: i32 = yr_1;
23941 let xs_1_in: i32 = xs_1;
23942 let ys_1_in: i32 = ys_1;
23943 let xr_2_in: i32 = xr_2;
23944 let yr_2_in: i32 = yr_2;
23945 let xs_2_in: i32 = xs_2;
23946 let ys_2_in: i32 = ys_2;
23947 let mut out_out: *mut bindings::VipsImage = null_mut();
23948
23949 let hwindow_in: i32 = mosaic_1_options.hwindow;
23950 let hwindow_in_name = utils::new_c_string("hwindow")?;
23951
23952 let harea_in: i32 = mosaic_1_options.harea;
23953 let harea_in_name = utils::new_c_string("harea")?;
23954
23955 let search_in: i32 = if mosaic_1_options.search { 1 } else { 0 };
23956 let search_in_name = utils::new_c_string("search")?;
23957
23958 let interpolate_in: *mut bindings::VipsInterpolate = mosaic_1_options.interpolate.ctx;
23959 let interpolate_in_name = utils::new_c_string("interpolate")?;
23960
23961 let mblend_in: i32 = mosaic_1_options.mblend;
23962 let mblend_in_name = utils::new_c_string("mblend")?;
23963
23964 let vips_op_response = bindings::vips_mosaic1(
23965 refp_in,
23966 sec_in,
23967 &mut out_out,
23968 direction_in.try_into().unwrap(),
23969 xr_1_in,
23970 yr_1_in,
23971 xs_1_in,
23972 ys_1_in,
23973 xr_2_in,
23974 yr_2_in,
23975 xs_2_in,
23976 ys_2_in,
23977 hwindow_in_name.as_ptr(),
23978 hwindow_in,
23979 harea_in_name.as_ptr(),
23980 harea_in,
23981 search_in_name.as_ptr(),
23982 search_in,
23983 interpolate_in_name.as_ptr(),
23984 interpolate_in,
23985 mblend_in_name.as_ptr(),
23986 mblend_in,
23987 NULL,
23988 );
23989 utils::result(
23990 vips_op_response,
23991 VipsImage { ctx: out_out },
23992 Error::Mosaic1Error,
23993 )
23994 }
23995}
23996
23997pub fn matrixinvert(inp: &VipsImage) -> Result<VipsImage> {
24001 unsafe {
24002 let inp_in: *mut bindings::VipsImage = inp.ctx;
24003 let mut out_out: *mut bindings::VipsImage = null_mut();
24004
24005 let vips_op_response = bindings::vips_matrixinvert(inp_in, &mut out_out, NULL);
24006 utils::result(
24007 vips_op_response,
24008 VipsImage { ctx: out_out },
24009 Error::MatrixinvertError,
24010 )
24011 }
24012}
24013
24014pub fn matrixmultiply(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
24019 unsafe {
24020 let left_in: *mut bindings::VipsImage = left.ctx;
24021 let right_in: *mut bindings::VipsImage = right.ctx;
24022 let mut out_out: *mut bindings::VipsImage = null_mut();
24023
24024 let vips_op_response = bindings::vips_matrixmultiply(left_in, right_in, &mut out_out, NULL);
24025 utils::result(
24026 vips_op_response,
24027 VipsImage { ctx: out_out },
24028 Error::MatrixmultiplyError,
24029 )
24030 }
24031}
24032
24033pub fn matches(
24054 refp: &VipsImage,
24055 sec: &VipsImage,
24056 xr_1: i32,
24057 yr_1: i32,
24058 xs_1: i32,
24059 ys_1: i32,
24060 xr_2: i32,
24061 yr_2: i32,
24062 xs_2: i32,
24063 ys_2: i32,
24064) -> Result<VipsImage> {
24065 unsafe {
24066 let refp_in: *mut bindings::VipsImage = refp.ctx;
24067 let sec_in: *mut bindings::VipsImage = sec.ctx;
24068 let xr_1_in: i32 = xr_1;
24069 let yr_1_in: i32 = yr_1;
24070 let xs_1_in: i32 = xs_1;
24071 let ys_1_in: i32 = ys_1;
24072 let xr_2_in: i32 = xr_2;
24073 let yr_2_in: i32 = yr_2;
24074 let xs_2_in: i32 = xs_2;
24075 let ys_2_in: i32 = ys_2;
24076 let mut out_out: *mut bindings::VipsImage = null_mut();
24077
24078 let vips_op_response = bindings::vips_match(
24079 refp_in,
24080 sec_in,
24081 &mut out_out,
24082 xr_1_in,
24083 yr_1_in,
24084 xs_1_in,
24085 ys_1_in,
24086 xr_2_in,
24087 yr_2_in,
24088 xs_2_in,
24089 ys_2_in,
24090 NULL,
24091 );
24092 utils::result(
24093 vips_op_response,
24094 VipsImage { ctx: out_out },
24095 Error::MatchError,
24096 )
24097 }
24098}
24099
24100#[derive(Clone, Debug)]
24102pub struct MatchOptions {
24103 pub hwindow: i32,
24106 pub harea: i32,
24109 pub search: bool,
24112 pub interpolate: VipsInterpolate,
24114}
24115
24116impl std::default::Default for MatchOptions {
24117 fn default() -> Self {
24118 MatchOptions {
24119 hwindow: i32::from(5),
24120 harea: i32::from(15),
24121 search: false,
24122 interpolate: VipsInterpolate::new(),
24123 }
24124 }
24125}
24126
24127pub fn matches_with_opts(
24149 refp: &VipsImage,
24150 sec: &VipsImage,
24151 xr_1: i32,
24152 yr_1: i32,
24153 xs_1: i32,
24154 ys_1: i32,
24155 xr_2: i32,
24156 yr_2: i32,
24157 xs_2: i32,
24158 ys_2: i32,
24159 matches_options: &MatchOptions,
24160) -> Result<VipsImage> {
24161 unsafe {
24162 let refp_in: *mut bindings::VipsImage = refp.ctx;
24163 let sec_in: *mut bindings::VipsImage = sec.ctx;
24164 let xr_1_in: i32 = xr_1;
24165 let yr_1_in: i32 = yr_1;
24166 let xs_1_in: i32 = xs_1;
24167 let ys_1_in: i32 = ys_1;
24168 let xr_2_in: i32 = xr_2;
24169 let yr_2_in: i32 = yr_2;
24170 let xs_2_in: i32 = xs_2;
24171 let ys_2_in: i32 = ys_2;
24172 let mut out_out: *mut bindings::VipsImage = null_mut();
24173
24174 let hwindow_in: i32 = matches_options.hwindow;
24175 let hwindow_in_name = utils::new_c_string("hwindow")?;
24176
24177 let harea_in: i32 = matches_options.harea;
24178 let harea_in_name = utils::new_c_string("harea")?;
24179
24180 let search_in: i32 = if matches_options.search { 1 } else { 0 };
24181 let search_in_name = utils::new_c_string("search")?;
24182
24183 let interpolate_in: *mut bindings::VipsInterpolate = matches_options.interpolate.ctx;
24184 let interpolate_in_name = utils::new_c_string("interpolate")?;
24185
24186 let vips_op_response = bindings::vips_match(
24187 refp_in,
24188 sec_in,
24189 &mut out_out,
24190 xr_1_in,
24191 yr_1_in,
24192 xs_1_in,
24193 ys_1_in,
24194 xr_2_in,
24195 yr_2_in,
24196 xs_2_in,
24197 ys_2_in,
24198 hwindow_in_name.as_ptr(),
24199 hwindow_in,
24200 harea_in_name.as_ptr(),
24201 harea_in,
24202 search_in_name.as_ptr(),
24203 search_in,
24204 interpolate_in_name.as_ptr(),
24205 interpolate_in,
24206 NULL,
24207 );
24208 utils::result(
24209 vips_op_response,
24210 VipsImage { ctx: out_out },
24211 Error::MatchError,
24212 )
24213 }
24214}
24215
24216pub fn globalbalance(inp: &VipsImage) -> Result<VipsImage> {
24220 unsafe {
24221 let inp_in: *mut bindings::VipsImage = inp.ctx;
24222 let mut out_out: *mut bindings::VipsImage = null_mut();
24223
24224 let vips_op_response = bindings::vips_globalbalance(inp_in, &mut out_out, NULL);
24225 utils::result(
24226 vips_op_response,
24227 VipsImage { ctx: out_out },
24228 Error::GlobalbalanceError,
24229 )
24230 }
24231}
24232
24233#[derive(Clone, Debug)]
24235pub struct GlobalbalanceOptions {
24236 pub gamma: f64,
24239 pub int_output: bool,
24242}
24243
24244impl std::default::Default for GlobalbalanceOptions {
24245 fn default() -> Self {
24246 GlobalbalanceOptions {
24247 gamma: f64::from(1.6),
24248 int_output: false,
24249 }
24250 }
24251}
24252
24253pub fn globalbalance_with_opts(
24258 inp: &VipsImage,
24259 globalbalance_options: &GlobalbalanceOptions,
24260) -> Result<VipsImage> {
24261 unsafe {
24262 let inp_in: *mut bindings::VipsImage = inp.ctx;
24263 let mut out_out: *mut bindings::VipsImage = null_mut();
24264
24265 let gamma_in: f64 = globalbalance_options.gamma;
24266 let gamma_in_name = utils::new_c_string("gamma")?;
24267
24268 let int_output_in: i32 = if globalbalance_options.int_output {
24269 1
24270 } else {
24271 0
24272 };
24273 let int_output_in_name = utils::new_c_string("int-output")?;
24274
24275 let vips_op_response = bindings::vips_globalbalance(
24276 inp_in,
24277 &mut out_out,
24278 gamma_in_name.as_ptr(),
24279 gamma_in,
24280 int_output_in_name.as_ptr(),
24281 int_output_in,
24282 NULL,
24283 );
24284 utils::result(
24285 vips_op_response,
24286 VipsImage { ctx: out_out },
24287 Error::GlobalbalanceError,
24288 )
24289 }
24290}
24291
24292pub fn remosaic(inp: &VipsImage, old_str: &str, new_str: &str) -> Result<VipsImage> {
24298 unsafe {
24299 let inp_in: *mut bindings::VipsImage = inp.ctx;
24300 let old_str_in: CString = utils::new_c_string(old_str)?;
24301 let new_str_in: CString = utils::new_c_string(new_str)?;
24302 let mut out_out: *mut bindings::VipsImage = null_mut();
24303
24304 let vips_op_response = bindings::vips_remosaic(
24305 inp_in,
24306 &mut out_out,
24307 old_str_in.as_ptr(),
24308 new_str_in.as_ptr(),
24309 NULL,
24310 );
24311 utils::result(
24312 vips_op_response,
24313 VipsImage { ctx: out_out },
24314 Error::RemosaicError,
24315 )
24316 }
24317}