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 Last = 3,
29}
30
31#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
32pub enum Align {
33 Low = 0,
35 Centre = 1,
37 High = 2,
39 Last = 3,
41}
42
43#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
44pub enum Angle {
45 D0 = 0,
47 D90 = 1,
49 D180 = 2,
51 D270 = 3,
53 Last = 4,
55}
56
57#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
58pub enum Angle45 {
59 D0 = 0,
61 D45 = 1,
63 D90 = 2,
65 D135 = 3,
67 D180 = 4,
69 D225 = 5,
71 D270 = 6,
73 D315 = 7,
75 Last = 8,
77}
78
79#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
80pub enum BandFormat {
81 Notset = -1,
83 Uchar = 0,
85 Char = 1,
87 Ushort = 2,
89 Short = 3,
91 Uint = 4,
93 Int = 5,
95 Float = 6,
97 Complex = 7,
99 Double = 8,
101 Dpcomplex = 9,
103 Last = 10,
105}
106
107#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
108pub enum BlendMode {
109 Clear = 0,
111 Source = 1,
113 Over = 2,
115 In = 3,
117 Out = 4,
119 Atop = 5,
121 Dest = 6,
123 DestOver = 7,
125 DestIn = 8,
127 DestOut = 9,
129 DestAtop = 10,
131 Xor = 11,
133 Add = 12,
135 Saturate = 13,
137 Multiply = 14,
139 Screen = 15,
141 Overlay = 16,
143 Darken = 17,
145 Lighten = 18,
147 ColourDodge = 19,
149 ColourBurn = 20,
151 HardLight = 21,
153 SoftLight = 22,
155 Difference = 23,
157 Exclusion = 24,
159 Last = 25,
161}
162
163#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
164pub enum Coding {
165 Error = -1,
167 None = 0,
169 Labq = 2,
171 Rad = 6,
173 Last = 7,
175}
176
177#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
178pub enum Combine {
179 Max = 0,
181 Sum = 1,
183 Min = 2,
185 Last = 3,
187}
188
189#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
190pub enum CombineMode {
191 Set = 0,
193 Add = 1,
195 Last = 2,
197}
198
199#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
200pub enum CompassDirection {
201 Centre = 0,
203 North = 1,
205 East = 2,
207 South = 3,
209 West = 4,
211 NorthEast = 5,
213 SouthEast = 6,
215 SouthWest = 7,
217 NorthWest = 8,
219 Last = 9,
221}
222
223#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
224pub enum Direction {
225 Horizontal = 0,
227 Vertical = 1,
229 Last = 2,
231}
232
233#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
234pub enum Extend {
235 Black = 0,
237 Copy = 1,
239 Repeat = 2,
241 Mirror = 3,
243 White = 4,
245 Background = 5,
247 Last = 6,
249}
250
251#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
252pub enum FailOn {
253 None = 0,
255 Truncated = 1,
257 Error = 2,
259 Warning = 3,
261 Last = 4,
263}
264
265#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
266pub enum ForeignDzDepth {
267 Onepixel = 0,
269 Onetile = 1,
271 One = 2,
273 Last = 3,
275}
276
277#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
278pub enum ForeignFlags {
279 None = 0,
281 Partial = 1,
283 Bigendian = 2,
285 Sequential = 4,
287 All = 7,
289}
290
291#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
292pub enum ForeignHeifCompression {
293 Hevc = 1,
295 Avc = 2,
297 Jpeg = 3,
299 Av1 = 4,
301 Last = 5,
303}
304
305#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
306pub enum ForeignHeifEncoder {
307 Auto = 0,
309 Aom = 1,
311 Rav1E = 2,
313 Svt = 3,
315 X265 = 4,
317 Last = 5,
319}
320
321#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
322pub enum ForeignKeep {
323 None = 0,
325 Exif = 1,
327 Xmp = 2,
329 Iptc = 4,
331 Icc = 8,
333 Other = 16,
335 All = 31,
337}
338
339#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
340pub enum ForeignPngFilter {
341 None = 8,
343 Sub = 16,
345 Up = 32,
347 Avg = 64,
349 Paeth = 128,
351 All = 248,
353}
354
355#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
356pub enum ForeignPpmFormat {
357 Pbm = 0,
359 Pgm = 1,
361 Ppm = 2,
363 Pfm = 3,
365 Pnm = 4,
367 Last = 5,
369}
370
371#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
372pub enum ForeignSubsample {
373 Auto = 0,
375 On = 1,
377 Off = 2,
379 Last = 3,
381}
382
383#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
384pub enum ForeignTiffCompression {
385 None = 0,
387 Jpeg = 1,
389 Deflate = 2,
391 Packbit = 3,
393 Ccittfax4 = 4,
395 Lzw = 5,
397 Webp = 6,
399 Zstd = 7,
401 Jp2K = 8,
403 Last = 9,
405}
406
407#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
408pub enum ForeignTiffPredictor {
409 None = 1,
411 Horizontal = 2,
413 Float = 3,
415 Last = 4,
417}
418
419#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
420pub enum ForeignTiffResunit {
421 Cm = 0,
423 Inch = 1,
425 Last = 2,
427}
428
429#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
430pub enum ForeignWebpPreset {
431 Default = 0,
433 Picture = 1,
435 Photo = 2,
437 Drawing = 3,
439 Icon = 4,
441 Text = 5,
443 Last = 6,
445}
446
447#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
448pub enum Intent {
449 Perceptual = 0,
451 Relative = 1,
453 Saturation = 2,
455 Absolute = 3,
457 Last = 4,
459}
460
461#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
462pub enum Interesting {
463 None = 0,
465 Centre = 1,
467 Entropy = 2,
469 Attention = 3,
471 Low = 4,
473 High = 5,
475 All = 6,
477 Last = 7,
479}
480
481#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
482pub enum Interpretation {
483 Error = -1,
485 Multiband = 0,
487 BW = 1,
489 Histogram = 10,
491 Xyz = 12,
493 Lab = 13,
495 Cmyk = 15,
497 Labq = 16,
499 Rgb = 17,
501 Cmc = 18,
503 Lch = 19,
505 Labs = 21,
507 Srgb = 22,
509 Yxy = 23,
511 Fourier = 24,
513 Rgb16 = 25,
515 Grey16 = 26,
517 Matrix = 27,
519 Scrgb = 28,
521 Hsv = 29,
523 Last = 30,
525}
526
527#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
528pub enum Kernel {
529 Nearest = 0,
531 Linear = 1,
533 Cubic = 2,
535 Mitchell = 3,
537 Lanczos2 = 4,
539 Lanczos3 = 5,
541 Last = 6,
543}
544
545#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
546pub enum OperationBoolean {
547 And = 0,
549 Or = 1,
551 Eor = 2,
553 Lshift = 3,
555 Rshift = 4,
557 Last = 5,
559}
560
561#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
562pub enum OperationComplex {
563 Polar = 0,
565 Rect = 1,
567 Conj = 2,
569 Last = 3,
571}
572
573#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
574pub enum OperationComplex2 {
575 CrossPhase = 0,
577 Last = 1,
579}
580
581#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
582pub enum OperationComplexget {
583 Real = 0,
585 Imag = 1,
587 Last = 2,
589}
590
591#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
592pub enum OperationMath {
593 Sin = 0,
595 Co = 1,
597 Tan = 2,
599 Asin = 3,
601 Aco = 4,
603 Atan = 5,
605 Log = 6,
607 Log10 = 7,
609 Exp = 8,
611 Exp10 = 9,
613 Sinh = 10,
615 Cosh = 11,
617 Tanh = 12,
619 Asinh = 13,
621 Acosh = 14,
623 Atanh = 15,
625 Last = 16,
627}
628
629#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
630pub enum OperationMath2 {
631 Pow = 0,
633 Wop = 1,
635 Atan2 = 2,
637 Last = 3,
639}
640
641#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
642pub enum OperationMorphology {
643 Erode = 0,
645 Dilate = 1,
647 Last = 2,
649}
650
651#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
652pub enum OperationRelational {
653 Equal = 0,
655 Noteq = 1,
657 Less = 2,
659 Lesseq = 3,
661 More = 4,
663 Moreeq = 5,
665 Last = 6,
667}
668
669#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
670pub enum OperationRound {
671 Rint = 0,
673 Ceil = 1,
675 Floor = 2,
677 Last = 3,
679}
680
681#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
682pub enum PCS {
683 Lab = 0,
685 Xyz = 1,
687 Last = 2,
689}
690
691#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
692pub enum Precision {
693 Integer = 0,
695 Float = 1,
697 Approximate = 2,
699 Last = 3,
701}
702
703#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
704pub enum RegionShrink {
705 Mean = 0,
707 Median = 1,
709 Mode = 2,
711 Max = 3,
713 Min = 4,
715 Nearest = 5,
717 Last = 6,
719}
720
721#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
722pub enum SdfShape {
723 Circle = 0,
725 Box = 1,
727 RoundedBox = 2,
729 Line = 3,
731 Last = 4,
733}
734
735#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
736pub enum Size {
737 Both = 0,
739 Up = 1,
741 Down = 2,
743 Force = 3,
745 Last = 4,
747}
748
749#[derive(Copy, Clone, Debug, FromPrimitive, ToPrimitive)]
750pub enum TextWrap {
751 Word = 0,
753 Char = 1,
755 WordChar = 2,
757 None = 3,
759 Last = 4,
761}
762
763pub fn system(cmd_format: &str) -> Result<()> {
767 unsafe {
768 let cmd_format_in: CString = utils::new_c_string(cmd_format)?;
769
770 let vips_op_response = bindings::vips_system(cmd_format_in.as_ptr(), NULL);
771 utils::result(vips_op_response, (), Error::SystemError)
772 }
773}
774
775#[derive(Clone, Debug)]
777pub struct SystemOptions {
778 pub inp: Vec<VipsImage>,
780 pub out: VipsImage,
782 pub log: String,
784 pub out_format: String,
786 pub in_format: String,
788}
789
790impl std::default::Default for SystemOptions {
791 fn default() -> Self {
792 SystemOptions {
793 inp: Vec::new(),
794 out: VipsImage::new(),
795 log: String::new(),
796 out_format: String::new(),
797 in_format: String::new(),
798 }
799 }
800}
801
802pub fn system_with_opts(cmd_format: &str, system_options: &SystemOptions) -> Result<()> {
807 unsafe {
808 let cmd_format_in: CString = utils::new_c_string(cmd_format)?;
809
810 let inp_wrapper = utils::VipsArrayImageWrapper::from(&system_options.inp[..]);
811 let inp_in = inp_wrapper.ctx;
812 let inp_in_name = utils::new_c_string("inp")?;
813
814 let out_in: *mut bindings::VipsImage = system_options.out.ctx;
815 let out_in_name = utils::new_c_string("out")?;
816
817 let log_in: CString = utils::new_c_string(&system_options.log)?;
818 let log_in_name = utils::new_c_string("log")?;
819
820 let out_format_in: CString = utils::new_c_string(&system_options.out_format)?;
821 let out_format_in_name = utils::new_c_string("out-format")?;
822
823 let in_format_in: CString = utils::new_c_string(&system_options.in_format)?;
824 let in_format_in_name = utils::new_c_string("in-format")?;
825
826 let vips_op_response = bindings::vips_system(
827 cmd_format_in.as_ptr(),
828 inp_in_name.as_ptr(),
829 inp_in,
830 out_in_name.as_ptr(),
831 out_in,
832 log_in_name.as_ptr(),
833 log_in.as_ptr(),
834 out_format_in_name.as_ptr(),
835 out_format_in.as_ptr(),
836 in_format_in_name.as_ptr(),
837 in_format_in.as_ptr(),
838 NULL,
839 );
840 utils::result(vips_op_response, (), Error::SystemError)
841 }
842}
843
844pub fn add(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
849 unsafe {
850 let left_in: *mut bindings::VipsImage = left.ctx;
851 let right_in: *mut bindings::VipsImage = right.ctx;
852 let mut out_out: *mut bindings::VipsImage = null_mut();
853
854 let vips_op_response = bindings::vips_add(left_in, right_in, &mut out_out, NULL);
855 utils::result(
856 vips_op_response,
857 VipsImage { ctx: out_out },
858 Error::AddError,
859 )
860 }
861}
862
863pub fn minpair(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
868 unsafe {
869 let left_in: *mut bindings::VipsImage = left.ctx;
870 let right_in: *mut bindings::VipsImage = right.ctx;
871 let mut out_out: *mut bindings::VipsImage = null_mut();
872
873 let vips_op_response = bindings::vips_minpair(left_in, right_in, &mut out_out, NULL);
874 utils::result(
875 vips_op_response,
876 VipsImage { ctx: out_out },
877 Error::MinpairError,
878 )
879 }
880}
881
882pub fn maxpair(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
887 unsafe {
888 let left_in: *mut bindings::VipsImage = left.ctx;
889 let right_in: *mut bindings::VipsImage = right.ctx;
890 let mut out_out: *mut bindings::VipsImage = null_mut();
891
892 let vips_op_response = bindings::vips_maxpair(left_in, right_in, &mut out_out, NULL);
893 utils::result(
894 vips_op_response,
895 VipsImage { ctx: out_out },
896 Error::MaxpairError,
897 )
898 }
899}
900
901pub fn subtract(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
906 unsafe {
907 let left_in: *mut bindings::VipsImage = left.ctx;
908 let right_in: *mut bindings::VipsImage = right.ctx;
909 let mut out_out: *mut bindings::VipsImage = null_mut();
910
911 let vips_op_response = bindings::vips_subtract(left_in, right_in, &mut out_out, NULL);
912 utils::result(
913 vips_op_response,
914 VipsImage { ctx: out_out },
915 Error::SubtractError,
916 )
917 }
918}
919
920pub fn multiply(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
925 unsafe {
926 let left_in: *mut bindings::VipsImage = left.ctx;
927 let right_in: *mut bindings::VipsImage = right.ctx;
928 let mut out_out: *mut bindings::VipsImage = null_mut();
929
930 let vips_op_response = bindings::vips_multiply(left_in, right_in, &mut out_out, NULL);
931 utils::result(
932 vips_op_response,
933 VipsImage { ctx: out_out },
934 Error::MultiplyError,
935 )
936 }
937}
938
939pub fn divide(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
944 unsafe {
945 let left_in: *mut bindings::VipsImage = left.ctx;
946 let right_in: *mut bindings::VipsImage = right.ctx;
947 let mut out_out: *mut bindings::VipsImage = null_mut();
948
949 let vips_op_response = bindings::vips_divide(left_in, right_in, &mut out_out, NULL);
950 utils::result(
951 vips_op_response,
952 VipsImage { ctx: out_out },
953 Error::DivideError,
954 )
955 }
956}
957
958pub fn relational(
971 left: &VipsImage,
972 right: &VipsImage,
973 relational: OperationRelational,
974) -> Result<VipsImage> {
975 unsafe {
976 let left_in: *mut bindings::VipsImage = left.ctx;
977 let right_in: *mut bindings::VipsImage = right.ctx;
978 let relational_in: i32 = relational as i32;
979 let mut out_out: *mut bindings::VipsImage = null_mut();
980
981 let vips_op_response = bindings::vips_relational(
982 left_in,
983 right_in,
984 &mut out_out,
985 relational_in.try_into().unwrap(),
986 NULL,
987 );
988 utils::result(
989 vips_op_response,
990 VipsImage { ctx: out_out },
991 Error::RelationalError,
992 )
993 }
994}
995
996pub fn remainder(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
1001 unsafe {
1002 let left_in: *mut bindings::VipsImage = left.ctx;
1003 let right_in: *mut bindings::VipsImage = right.ctx;
1004 let mut out_out: *mut bindings::VipsImage = null_mut();
1005
1006 let vips_op_response = bindings::vips_remainder(left_in, right_in, &mut out_out, NULL);
1007 utils::result(
1008 vips_op_response,
1009 VipsImage { ctx: out_out },
1010 Error::RemainderError,
1011 )
1012 }
1013}
1014
1015pub fn boolean(
1027 left: &VipsImage,
1028 right: &VipsImage,
1029 boolean: OperationBoolean,
1030) -> Result<VipsImage> {
1031 unsafe {
1032 let left_in: *mut bindings::VipsImage = left.ctx;
1033 let right_in: *mut bindings::VipsImage = right.ctx;
1034 let boolean_in: i32 = boolean as i32;
1035 let mut out_out: *mut bindings::VipsImage = null_mut();
1036
1037 let vips_op_response = bindings::vips_boolean(
1038 left_in,
1039 right_in,
1040 &mut out_out,
1041 boolean_in.try_into().unwrap(),
1042 NULL,
1043 );
1044 utils::result(
1045 vips_op_response,
1046 VipsImage { ctx: out_out },
1047 Error::BooleanError,
1048 )
1049 }
1050}
1051
1052pub fn math_2(left: &VipsImage, right: &VipsImage, math_2: OperationMath2) -> Result<VipsImage> {
1062 unsafe {
1063 let left_in: *mut bindings::VipsImage = left.ctx;
1064 let right_in: *mut bindings::VipsImage = right.ctx;
1065 let math_2_in: i32 = math_2 as i32;
1066 let mut out_out: *mut bindings::VipsImage = null_mut();
1067
1068 let vips_op_response = bindings::vips_math2(
1069 left_in,
1070 right_in,
1071 &mut out_out,
1072 math_2_in.try_into().unwrap(),
1073 NULL,
1074 );
1075 utils::result(
1076 vips_op_response,
1077 VipsImage { ctx: out_out },
1078 Error::Math2Error,
1079 )
1080 }
1081}
1082
1083pub fn complex_2(
1091 left: &VipsImage,
1092 right: &VipsImage,
1093 cmplx: OperationComplex2,
1094) -> Result<VipsImage> {
1095 unsafe {
1096 let left_in: *mut bindings::VipsImage = left.ctx;
1097 let right_in: *mut bindings::VipsImage = right.ctx;
1098 let cmplx_in: i32 = cmplx as i32;
1099 let mut out_out: *mut bindings::VipsImage = null_mut();
1100
1101 let vips_op_response = bindings::vips_complex2(
1102 left_in,
1103 right_in,
1104 &mut out_out,
1105 cmplx_in.try_into().unwrap(),
1106 NULL,
1107 );
1108 utils::result(
1109 vips_op_response,
1110 VipsImage { ctx: out_out },
1111 Error::Complex2Error,
1112 )
1113 }
1114}
1115
1116pub fn complexform(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
1121 unsafe {
1122 let left_in: *mut bindings::VipsImage = left.ctx;
1123 let right_in: *mut bindings::VipsImage = right.ctx;
1124 let mut out_out: *mut bindings::VipsImage = null_mut();
1125
1126 let vips_op_response = bindings::vips_complexform(left_in, right_in, &mut out_out, NULL);
1127 utils::result(
1128 vips_op_response,
1129 VipsImage { ctx: out_out },
1130 Error::ComplexformError,
1131 )
1132 }
1133}
1134
1135pub fn clamp(inp: &VipsImage) -> Result<VipsImage> {
1139 unsafe {
1140 let inp_in: *mut bindings::VipsImage = inp.ctx;
1141 let mut out_out: *mut bindings::VipsImage = null_mut();
1142
1143 let vips_op_response = bindings::vips_clamp(inp_in, &mut out_out, NULL);
1144 utils::result(
1145 vips_op_response,
1146 VipsImage { ctx: out_out },
1147 Error::ClampError,
1148 )
1149 }
1150}
1151
1152#[derive(Clone, Debug)]
1154pub struct ClampOptions {
1155 pub min: f64,
1158 pub max: f64,
1161}
1162
1163impl std::default::Default for ClampOptions {
1164 fn default() -> Self {
1165 ClampOptions {
1166 min: f64::from(0),
1167 max: f64::from(0),
1168 }
1169 }
1170}
1171
1172pub fn clamp_with_opts(inp: &VipsImage, clamp_options: &ClampOptions) -> Result<VipsImage> {
1177 unsafe {
1178 let inp_in: *mut bindings::VipsImage = inp.ctx;
1179 let mut out_out: *mut bindings::VipsImage = null_mut();
1180
1181 let min_in: f64 = clamp_options.min;
1182 let min_in_name = utils::new_c_string("min")?;
1183
1184 let max_in: f64 = clamp_options.max;
1185 let max_in_name = utils::new_c_string("max")?;
1186
1187 let vips_op_response = bindings::vips_clamp(
1188 inp_in,
1189 &mut out_out,
1190 min_in_name.as_ptr(),
1191 min_in,
1192 max_in_name.as_ptr(),
1193 max_in,
1194 NULL,
1195 );
1196 utils::result(
1197 vips_op_response,
1198 VipsImage { ctx: out_out },
1199 Error::ClampError,
1200 )
1201 }
1202}
1203
1204pub fn invert(inp: &VipsImage) -> Result<VipsImage> {
1208 unsafe {
1209 let inp_in: *mut bindings::VipsImage = inp.ctx;
1210 let mut out_out: *mut bindings::VipsImage = null_mut();
1211
1212 let vips_op_response = bindings::vips_invert(inp_in, &mut out_out, NULL);
1213 utils::result(
1214 vips_op_response,
1215 VipsImage { ctx: out_out },
1216 Error::InvertError,
1217 )
1218 }
1219}
1220
1221pub fn math(inp: &VipsImage, math: OperationMath) -> Result<VipsImage> {
1243 unsafe {
1244 let inp_in: *mut bindings::VipsImage = inp.ctx;
1245 let math_in: i32 = math as i32;
1246 let mut out_out: *mut bindings::VipsImage = null_mut();
1247
1248 let vips_op_response =
1249 bindings::vips_math(inp_in, &mut out_out, math_in.try_into().unwrap(), NULL);
1250 utils::result(
1251 vips_op_response,
1252 VipsImage { ctx: out_out },
1253 Error::MathError,
1254 )
1255 }
1256}
1257
1258pub fn abs(inp: &VipsImage) -> Result<VipsImage> {
1262 unsafe {
1263 let inp_in: *mut bindings::VipsImage = inp.ctx;
1264 let mut out_out: *mut bindings::VipsImage = null_mut();
1265
1266 let vips_op_response = bindings::vips_abs(inp_in, &mut out_out, NULL);
1267 utils::result(vips_op_response, VipsImage { ctx: out_out }, Error::AbError)
1268 }
1269}
1270
1271pub fn sign(inp: &VipsImage) -> Result<VipsImage> {
1275 unsafe {
1276 let inp_in: *mut bindings::VipsImage = inp.ctx;
1277 let mut out_out: *mut bindings::VipsImage = null_mut();
1278
1279 let vips_op_response = bindings::vips_sign(inp_in, &mut out_out, NULL);
1280 utils::result(
1281 vips_op_response,
1282 VipsImage { ctx: out_out },
1283 Error::SignError,
1284 )
1285 }
1286}
1287
1288pub fn round(inp: &VipsImage, round: OperationRound) -> Result<VipsImage> {
1297 unsafe {
1298 let inp_in: *mut bindings::VipsImage = inp.ctx;
1299 let round_in: i32 = round as i32;
1300 let mut out_out: *mut bindings::VipsImage = null_mut();
1301
1302 let vips_op_response =
1303 bindings::vips_round(inp_in, &mut out_out, round_in.try_into().unwrap(), NULL);
1304 utils::result(
1305 vips_op_response,
1306 VipsImage { ctx: out_out },
1307 Error::RoundError,
1308 )
1309 }
1310}
1311
1312pub fn relational_const(
1325 inp: &VipsImage,
1326 relational: OperationRelational,
1327 c: &mut [f64],
1328) -> Result<VipsImage> {
1329 unsafe {
1330 let inp_in: *mut bindings::VipsImage = inp.ctx;
1331 let relational_in: i32 = relational as i32;
1332 let c_in: *mut f64 = c.as_mut_ptr();
1333 let mut out_out: *mut bindings::VipsImage = null_mut();
1334
1335 let vips_op_response = bindings::vips_relational_const(
1336 inp_in,
1337 &mut out_out,
1338 relational_in.try_into().unwrap(),
1339 c_in,
1340 c.len() as i32,
1341 NULL,
1342 );
1343 utils::result(
1344 vips_op_response,
1345 VipsImage { ctx: out_out },
1346 Error::RelationalConstError,
1347 )
1348 }
1349}
1350
1351pub fn remainder_const(inp: &VipsImage, c: &mut [f64]) -> Result<VipsImage> {
1356 unsafe {
1357 let inp_in: *mut bindings::VipsImage = inp.ctx;
1358 let c_in: *mut f64 = c.as_mut_ptr();
1359 let mut out_out: *mut bindings::VipsImage = null_mut();
1360
1361 let vips_op_response =
1362 bindings::vips_remainder_const(inp_in, &mut out_out, c_in, c.len() as i32, NULL);
1363 utils::result(
1364 vips_op_response,
1365 VipsImage { ctx: out_out },
1366 Error::RemainderConstError,
1367 )
1368 }
1369}
1370
1371pub fn boolean_const(
1383 inp: &VipsImage,
1384 boolean: OperationBoolean,
1385 c: &mut [f64],
1386) -> Result<VipsImage> {
1387 unsafe {
1388 let inp_in: *mut bindings::VipsImage = inp.ctx;
1389 let boolean_in: i32 = boolean as i32;
1390 let c_in: *mut f64 = c.as_mut_ptr();
1391 let mut out_out: *mut bindings::VipsImage = null_mut();
1392
1393 let vips_op_response = bindings::vips_boolean_const(
1394 inp_in,
1395 &mut out_out,
1396 boolean_in.try_into().unwrap(),
1397 c_in,
1398 c.len() as i32,
1399 NULL,
1400 );
1401 utils::result(
1402 vips_op_response,
1403 VipsImage { ctx: out_out },
1404 Error::BooleanConstError,
1405 )
1406 }
1407}
1408
1409pub fn math_2_const(inp: &VipsImage, math_2: OperationMath2, c: &mut [f64]) -> Result<VipsImage> {
1419 unsafe {
1420 let inp_in: *mut bindings::VipsImage = inp.ctx;
1421 let math_2_in: i32 = math_2 as i32;
1422 let c_in: *mut f64 = c.as_mut_ptr();
1423 let mut out_out: *mut bindings::VipsImage = null_mut();
1424
1425 let vips_op_response = bindings::vips_math2_const(
1426 inp_in,
1427 &mut out_out,
1428 math_2_in.try_into().unwrap(),
1429 c_in,
1430 c.len() as i32,
1431 NULL,
1432 );
1433 utils::result(
1434 vips_op_response,
1435 VipsImage { ctx: out_out },
1436 Error::Math2ConstError,
1437 )
1438 }
1439}
1440
1441pub fn complex(inp: &VipsImage, cmplx: OperationComplex) -> Result<VipsImage> {
1450 unsafe {
1451 let inp_in: *mut bindings::VipsImage = inp.ctx;
1452 let cmplx_in: i32 = cmplx as i32;
1453 let mut out_out: *mut bindings::VipsImage = null_mut();
1454
1455 let vips_op_response =
1456 bindings::vips_complex(inp_in, &mut out_out, cmplx_in.try_into().unwrap(), NULL);
1457 utils::result(
1458 vips_op_response,
1459 VipsImage { ctx: out_out },
1460 Error::ComplexError,
1461 )
1462 }
1463}
1464
1465pub fn complexget(inp: &VipsImage, get: OperationComplexget) -> Result<VipsImage> {
1473 unsafe {
1474 let inp_in: *mut bindings::VipsImage = inp.ctx;
1475 let get_in: i32 = get as i32;
1476 let mut out_out: *mut bindings::VipsImage = null_mut();
1477
1478 let vips_op_response =
1479 bindings::vips_complexget(inp_in, &mut out_out, get_in.try_into().unwrap(), NULL);
1480 utils::result(
1481 vips_op_response,
1482 VipsImage { ctx: out_out },
1483 Error::ComplexgetError,
1484 )
1485 }
1486}
1487
1488pub fn sum(inp: &mut [VipsImage]) -> Result<VipsImage> {
1492 unsafe {
1493 let (inp_len, mut inp_in) = {
1494 let len = inp.len();
1495 let mut input = Vec::new();
1496 for img in inp {
1497 input.push(img.ctx)
1498 }
1499 (len as i32, input)
1500 };
1501 let mut out_out: *mut bindings::VipsImage = null_mut();
1502
1503 let vips_op_response = bindings::vips_sum(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
1504 utils::result(
1505 vips_op_response,
1506 VipsImage { ctx: out_out },
1507 Error::SumError,
1508 )
1509 }
1510}
1511
1512pub fn avg(inp: &VipsImage) -> Result<f64> {
1516 unsafe {
1517 let inp_in: *mut bindings::VipsImage = inp.ctx;
1518 let mut out_out: f64 = f64::from(0);
1519
1520 let vips_op_response = bindings::vips_avg(inp_in, &mut out_out, NULL);
1521 utils::result(vips_op_response, out_out, Error::AvgError)
1522 }
1523}
1524
1525pub fn min(inp: &VipsImage) -> Result<f64> {
1529 unsafe {
1530 let inp_in: *mut bindings::VipsImage = inp.ctx;
1531 let mut out_out: f64 = f64::from(0);
1532
1533 let vips_op_response = bindings::vips_min(inp_in, &mut out_out, NULL);
1534 utils::result(vips_op_response, out_out, Error::MinError)
1535 }
1536}
1537
1538#[derive(Clone, Debug)]
1540pub struct MinOptions {
1541 pub x: i32,
1544 pub y: i32,
1547 pub size: i32,
1550 pub out_array: Vec<f64>,
1552 pub x_array: Vec<i32>,
1554 pub y_array: Vec<i32>,
1556}
1557
1558impl std::default::Default for MinOptions {
1559 fn default() -> Self {
1560 MinOptions {
1561 x: i32::from(0),
1562 y: i32::from(0),
1563 size: i32::from(10),
1564 out_array: Vec::new(),
1565 x_array: Vec::new(),
1566 y_array: Vec::new(),
1567 }
1568 }
1569}
1570
1571pub fn min_with_opts(inp: &VipsImage, min_options: &MinOptions) -> Result<f64> {
1576 unsafe {
1577 let inp_in: *mut bindings::VipsImage = inp.ctx;
1578 let mut out_out: f64 = f64::from(0);
1579
1580 let x_in: i32 = min_options.x;
1581 let x_in_name = utils::new_c_string("x")?;
1582
1583 let y_in: i32 = min_options.y;
1584 let y_in_name = utils::new_c_string("y")?;
1585
1586 let size_in: i32 = min_options.size;
1587 let size_in_name = utils::new_c_string("size")?;
1588
1589 let out_array_wrapper = utils::VipsArrayDoubleWrapper::from(&min_options.out_array[..]);
1590 let out_array_in = out_array_wrapper.ctx;
1591 let out_array_in_name = utils::new_c_string("out-array")?;
1592
1593 let x_array_wrapper = utils::VipsArrayIntWrapper::from(&min_options.x_array[..]);
1594 let x_array_in = x_array_wrapper.ctx;
1595 let x_array_in_name = utils::new_c_string("x-array")?;
1596
1597 let y_array_wrapper = utils::VipsArrayIntWrapper::from(&min_options.y_array[..]);
1598 let y_array_in = y_array_wrapper.ctx;
1599 let y_array_in_name = utils::new_c_string("y-array")?;
1600
1601 let vips_op_response = bindings::vips_min(
1602 inp_in,
1603 &mut out_out,
1604 x_in_name.as_ptr(),
1605 x_in,
1606 y_in_name.as_ptr(),
1607 y_in,
1608 size_in_name.as_ptr(),
1609 size_in,
1610 out_array_in_name.as_ptr(),
1611 out_array_in,
1612 x_array_in_name.as_ptr(),
1613 x_array_in,
1614 y_array_in_name.as_ptr(),
1615 y_array_in,
1616 NULL,
1617 );
1618 utils::result(vips_op_response, out_out, Error::MinError)
1619 }
1620}
1621
1622pub fn max(inp: &VipsImage) -> Result<f64> {
1626 unsafe {
1627 let inp_in: *mut bindings::VipsImage = inp.ctx;
1628 let mut out_out: f64 = f64::from(0);
1629
1630 let vips_op_response = bindings::vips_max(inp_in, &mut out_out, NULL);
1631 utils::result(vips_op_response, out_out, Error::MaxError)
1632 }
1633}
1634
1635#[derive(Clone, Debug)]
1637pub struct MaxOptions {
1638 pub x: i32,
1641 pub y: i32,
1644 pub size: i32,
1647 pub out_array: Vec<f64>,
1649 pub x_array: Vec<i32>,
1651 pub y_array: Vec<i32>,
1653}
1654
1655impl std::default::Default for MaxOptions {
1656 fn default() -> Self {
1657 MaxOptions {
1658 x: i32::from(0),
1659 y: i32::from(0),
1660 size: i32::from(10),
1661 out_array: Vec::new(),
1662 x_array: Vec::new(),
1663 y_array: Vec::new(),
1664 }
1665 }
1666}
1667
1668pub fn max_with_opts(inp: &VipsImage, max_options: &MaxOptions) -> Result<f64> {
1673 unsafe {
1674 let inp_in: *mut bindings::VipsImage = inp.ctx;
1675 let mut out_out: f64 = f64::from(0);
1676
1677 let x_in: i32 = max_options.x;
1678 let x_in_name = utils::new_c_string("x")?;
1679
1680 let y_in: i32 = max_options.y;
1681 let y_in_name = utils::new_c_string("y")?;
1682
1683 let size_in: i32 = max_options.size;
1684 let size_in_name = utils::new_c_string("size")?;
1685
1686 let out_array_wrapper = utils::VipsArrayDoubleWrapper::from(&max_options.out_array[..]);
1687 let out_array_in = out_array_wrapper.ctx;
1688 let out_array_in_name = utils::new_c_string("out-array")?;
1689
1690 let x_array_wrapper = utils::VipsArrayIntWrapper::from(&max_options.x_array[..]);
1691 let x_array_in = x_array_wrapper.ctx;
1692 let x_array_in_name = utils::new_c_string("x-array")?;
1693
1694 let y_array_wrapper = utils::VipsArrayIntWrapper::from(&max_options.y_array[..]);
1695 let y_array_in = y_array_wrapper.ctx;
1696 let y_array_in_name = utils::new_c_string("y-array")?;
1697
1698 let vips_op_response = bindings::vips_max(
1699 inp_in,
1700 &mut out_out,
1701 x_in_name.as_ptr(),
1702 x_in,
1703 y_in_name.as_ptr(),
1704 y_in,
1705 size_in_name.as_ptr(),
1706 size_in,
1707 out_array_in_name.as_ptr(),
1708 out_array_in,
1709 x_array_in_name.as_ptr(),
1710 x_array_in,
1711 y_array_in_name.as_ptr(),
1712 y_array_in,
1713 NULL,
1714 );
1715 utils::result(vips_op_response, out_out, Error::MaxError)
1716 }
1717}
1718
1719pub fn deviate(inp: &VipsImage) -> Result<f64> {
1723 unsafe {
1724 let inp_in: *mut bindings::VipsImage = inp.ctx;
1725 let mut out_out: f64 = f64::from(0);
1726
1727 let vips_op_response = bindings::vips_deviate(inp_in, &mut out_out, NULL);
1728 utils::result(vips_op_response, out_out, Error::DeviateError)
1729 }
1730}
1731
1732pub fn stats(inp: &VipsImage) -> Result<VipsImage> {
1736 unsafe {
1737 let inp_in: *mut bindings::VipsImage = inp.ctx;
1738 let mut out_out: *mut bindings::VipsImage = null_mut();
1739
1740 let vips_op_response = bindings::vips_stats(inp_in, &mut out_out, NULL);
1741 utils::result(
1742 vips_op_response,
1743 VipsImage { ctx: out_out },
1744 Error::StatError,
1745 )
1746 }
1747}
1748
1749pub fn hist_find(inp: &VipsImage) -> Result<VipsImage> {
1753 unsafe {
1754 let inp_in: *mut bindings::VipsImage = inp.ctx;
1755 let mut out_out: *mut bindings::VipsImage = null_mut();
1756
1757 let vips_op_response = bindings::vips_hist_find(inp_in, &mut out_out, NULL);
1758 utils::result(
1759 vips_op_response,
1760 VipsImage { ctx: out_out },
1761 Error::HistFindError,
1762 )
1763 }
1764}
1765
1766#[derive(Clone, Debug)]
1768pub struct HistFindOptions {
1769 pub band: i32,
1772}
1773
1774impl std::default::Default for HistFindOptions {
1775 fn default() -> Self {
1776 HistFindOptions {
1777 band: i32::from(-1),
1778 }
1779 }
1780}
1781
1782pub fn hist_find_with_opts(
1787 inp: &VipsImage,
1788 hist_find_options: &HistFindOptions,
1789) -> Result<VipsImage> {
1790 unsafe {
1791 let inp_in: *mut bindings::VipsImage = inp.ctx;
1792 let mut out_out: *mut bindings::VipsImage = null_mut();
1793
1794 let band_in: i32 = hist_find_options.band;
1795 let band_in_name = utils::new_c_string("band")?;
1796
1797 let vips_op_response =
1798 bindings::vips_hist_find(inp_in, &mut out_out, band_in_name.as_ptr(), band_in, NULL);
1799 utils::result(
1800 vips_op_response,
1801 VipsImage { ctx: out_out },
1802 Error::HistFindError,
1803 )
1804 }
1805}
1806
1807pub fn hist_find_ndim(inp: &VipsImage) -> Result<VipsImage> {
1811 unsafe {
1812 let inp_in: *mut bindings::VipsImage = inp.ctx;
1813 let mut out_out: *mut bindings::VipsImage = null_mut();
1814
1815 let vips_op_response = bindings::vips_hist_find_ndim(inp_in, &mut out_out, NULL);
1816 utils::result(
1817 vips_op_response,
1818 VipsImage { ctx: out_out },
1819 Error::HistFindNdimError,
1820 )
1821 }
1822}
1823
1824#[derive(Clone, Debug)]
1826pub struct HistFindNdimOptions {
1827 pub bins: i32,
1830}
1831
1832impl std::default::Default for HistFindNdimOptions {
1833 fn default() -> Self {
1834 HistFindNdimOptions {
1835 bins: i32::from(10),
1836 }
1837 }
1838}
1839
1840pub fn hist_find_ndim_with_opts(
1845 inp: &VipsImage,
1846 hist_find_ndim_options: &HistFindNdimOptions,
1847) -> Result<VipsImage> {
1848 unsafe {
1849 let inp_in: *mut bindings::VipsImage = inp.ctx;
1850 let mut out_out: *mut bindings::VipsImage = null_mut();
1851
1852 let bins_in: i32 = hist_find_ndim_options.bins;
1853 let bins_in_name = utils::new_c_string("bins")?;
1854
1855 let vips_op_response = bindings::vips_hist_find_ndim(
1856 inp_in,
1857 &mut out_out,
1858 bins_in_name.as_ptr(),
1859 bins_in,
1860 NULL,
1861 );
1862 utils::result(
1863 vips_op_response,
1864 VipsImage { ctx: out_out },
1865 Error::HistFindNdimError,
1866 )
1867 }
1868}
1869
1870pub fn hist_find_indexed(inp: &VipsImage, index: &VipsImage) -> Result<VipsImage> {
1875 unsafe {
1876 let inp_in: *mut bindings::VipsImage = inp.ctx;
1877 let index_in: *mut bindings::VipsImage = index.ctx;
1878 let mut out_out: *mut bindings::VipsImage = null_mut();
1879
1880 let vips_op_response =
1881 bindings::vips_hist_find_indexed(inp_in, index_in, &mut out_out, NULL);
1882 utils::result(
1883 vips_op_response,
1884 VipsImage { ctx: out_out },
1885 Error::HistFindIndexedError,
1886 )
1887 }
1888}
1889
1890#[derive(Clone, Debug)]
1892pub struct HistFindIndexedOptions {
1893 pub combine: Combine,
1899}
1900
1901impl std::default::Default for HistFindIndexedOptions {
1902 fn default() -> Self {
1903 HistFindIndexedOptions {
1904 combine: Combine::Sum,
1905 }
1906 }
1907}
1908
1909pub fn hist_find_indexed_with_opts(
1915 inp: &VipsImage,
1916 index: &VipsImage,
1917 hist_find_indexed_options: &HistFindIndexedOptions,
1918) -> Result<VipsImage> {
1919 unsafe {
1920 let inp_in: *mut bindings::VipsImage = inp.ctx;
1921 let index_in: *mut bindings::VipsImage = index.ctx;
1922 let mut out_out: *mut bindings::VipsImage = null_mut();
1923
1924 let combine_in: i32 = hist_find_indexed_options.combine as i32;
1925 let combine_in_name = utils::new_c_string("combine")?;
1926
1927 let vips_op_response = bindings::vips_hist_find_indexed(
1928 inp_in,
1929 index_in,
1930 &mut out_out,
1931 combine_in_name.as_ptr(),
1932 combine_in,
1933 NULL,
1934 );
1935 utils::result(
1936 vips_op_response,
1937 VipsImage { ctx: out_out },
1938 Error::HistFindIndexedError,
1939 )
1940 }
1941}
1942
1943pub fn hough_line(inp: &VipsImage) -> Result<VipsImage> {
1947 unsafe {
1948 let inp_in: *mut bindings::VipsImage = inp.ctx;
1949 let mut out_out: *mut bindings::VipsImage = null_mut();
1950
1951 let vips_op_response = bindings::vips_hough_line(inp_in, &mut out_out, NULL);
1952 utils::result(
1953 vips_op_response,
1954 VipsImage { ctx: out_out },
1955 Error::HoughLineError,
1956 )
1957 }
1958}
1959
1960#[derive(Clone, Debug)]
1962pub struct HoughLineOptions {
1963 pub width: i32,
1966 pub height: i32,
1969}
1970
1971impl std::default::Default for HoughLineOptions {
1972 fn default() -> Self {
1973 HoughLineOptions {
1974 width: i32::from(256),
1975 height: i32::from(256),
1976 }
1977 }
1978}
1979
1980pub fn hough_line_with_opts(
1985 inp: &VipsImage,
1986 hough_line_options: &HoughLineOptions,
1987) -> Result<VipsImage> {
1988 unsafe {
1989 let inp_in: *mut bindings::VipsImage = inp.ctx;
1990 let mut out_out: *mut bindings::VipsImage = null_mut();
1991
1992 let width_in: i32 = hough_line_options.width;
1993 let width_in_name = utils::new_c_string("width")?;
1994
1995 let height_in: i32 = hough_line_options.height;
1996 let height_in_name = utils::new_c_string("height")?;
1997
1998 let vips_op_response = bindings::vips_hough_line(
1999 inp_in,
2000 &mut out_out,
2001 width_in_name.as_ptr(),
2002 width_in,
2003 height_in_name.as_ptr(),
2004 height_in,
2005 NULL,
2006 );
2007 utils::result(
2008 vips_op_response,
2009 VipsImage { ctx: out_out },
2010 Error::HoughLineError,
2011 )
2012 }
2013}
2014
2015pub fn hough_circle(inp: &VipsImage) -> Result<VipsImage> {
2019 unsafe {
2020 let inp_in: *mut bindings::VipsImage = inp.ctx;
2021 let mut out_out: *mut bindings::VipsImage = null_mut();
2022
2023 let vips_op_response = bindings::vips_hough_circle(inp_in, &mut out_out, NULL);
2024 utils::result(
2025 vips_op_response,
2026 VipsImage { ctx: out_out },
2027 Error::HoughCircleError,
2028 )
2029 }
2030}
2031
2032#[derive(Clone, Debug)]
2034pub struct HoughCircleOptions {
2035 pub scale: i32,
2038 pub min_radius: i32,
2041 pub max_radius: i32,
2044}
2045
2046impl std::default::Default for HoughCircleOptions {
2047 fn default() -> Self {
2048 HoughCircleOptions {
2049 scale: i32::from(3),
2050 min_radius: i32::from(10),
2051 max_radius: i32::from(20),
2052 }
2053 }
2054}
2055
2056pub fn hough_circle_with_opts(
2061 inp: &VipsImage,
2062 hough_circle_options: &HoughCircleOptions,
2063) -> Result<VipsImage> {
2064 unsafe {
2065 let inp_in: *mut bindings::VipsImage = inp.ctx;
2066 let mut out_out: *mut bindings::VipsImage = null_mut();
2067
2068 let scale_in: i32 = hough_circle_options.scale;
2069 let scale_in_name = utils::new_c_string("scale")?;
2070
2071 let min_radius_in: i32 = hough_circle_options.min_radius;
2072 let min_radius_in_name = utils::new_c_string("min-radius")?;
2073
2074 let max_radius_in: i32 = hough_circle_options.max_radius;
2075 let max_radius_in_name = utils::new_c_string("max-radius")?;
2076
2077 let vips_op_response = bindings::vips_hough_circle(
2078 inp_in,
2079 &mut out_out,
2080 scale_in_name.as_ptr(),
2081 scale_in,
2082 min_radius_in_name.as_ptr(),
2083 min_radius_in,
2084 max_radius_in_name.as_ptr(),
2085 max_radius_in,
2086 NULL,
2087 );
2088 utils::result(
2089 vips_op_response,
2090 VipsImage { ctx: out_out },
2091 Error::HoughCircleError,
2092 )
2093 }
2094}
2095
2096pub fn project(inp: &VipsImage) -> Result<(VipsImage, VipsImage)> {
2103 unsafe {
2104 let inp_in: *mut bindings::VipsImage = inp.ctx;
2105 let mut columns_out: *mut bindings::VipsImage = null_mut();
2106 let mut rows_out: *mut bindings::VipsImage = null_mut();
2107
2108 let vips_op_response =
2109 bindings::vips_project(inp_in, &mut columns_out, &mut rows_out, NULL);
2110 utils::result(
2111 vips_op_response,
2112 (VipsImage { ctx: columns_out }, VipsImage { ctx: rows_out }),
2113 Error::ProjectError,
2114 )
2115 }
2116}
2117
2118pub fn profile(inp: &VipsImage) -> Result<(VipsImage, VipsImage)> {
2125 unsafe {
2126 let inp_in: *mut bindings::VipsImage = inp.ctx;
2127 let mut columns_out: *mut bindings::VipsImage = null_mut();
2128 let mut rows_out: *mut bindings::VipsImage = null_mut();
2129
2130 let vips_op_response =
2131 bindings::vips_profile(inp_in, &mut columns_out, &mut rows_out, NULL);
2132 utils::result(
2133 vips_op_response,
2134 (VipsImage { ctx: columns_out }, VipsImage { ctx: rows_out }),
2135 Error::ProfileError,
2136 )
2137 }
2138}
2139
2140pub fn measure(inp: &VipsImage, h: i32, v: i32) -> Result<VipsImage> {
2148 unsafe {
2149 let inp_in: *mut bindings::VipsImage = inp.ctx;
2150 let h_in: i32 = h;
2151 let v_in: i32 = v;
2152 let mut out_out: *mut bindings::VipsImage = null_mut();
2153
2154 let vips_op_response = bindings::vips_measure(inp_in, &mut out_out, h_in, v_in, NULL);
2155 utils::result(
2156 vips_op_response,
2157 VipsImage { ctx: out_out },
2158 Error::MeasureError,
2159 )
2160 }
2161}
2162
2163#[derive(Clone, Debug)]
2165pub struct MeasureOptions {
2166 pub left: i32,
2169 pub top: i32,
2172 pub width: i32,
2175 pub height: i32,
2178}
2179
2180impl std::default::Default for MeasureOptions {
2181 fn default() -> Self {
2182 MeasureOptions {
2183 left: i32::from(0),
2184 top: i32::from(0),
2185 width: i32::from(1),
2186 height: i32::from(1),
2187 }
2188 }
2189}
2190
2191pub fn measure_with_opts(
2200 inp: &VipsImage,
2201 h: i32,
2202 v: i32,
2203 measure_options: &MeasureOptions,
2204) -> Result<VipsImage> {
2205 unsafe {
2206 let inp_in: *mut bindings::VipsImage = inp.ctx;
2207 let h_in: i32 = h;
2208 let v_in: i32 = v;
2209 let mut out_out: *mut bindings::VipsImage = null_mut();
2210
2211 let left_in: i32 = measure_options.left;
2212 let left_in_name = utils::new_c_string("left")?;
2213
2214 let top_in: i32 = measure_options.top;
2215 let top_in_name = utils::new_c_string("top")?;
2216
2217 let width_in: i32 = measure_options.width;
2218 let width_in_name = utils::new_c_string("width")?;
2219
2220 let height_in: i32 = measure_options.height;
2221 let height_in_name = utils::new_c_string("height")?;
2222
2223 let vips_op_response = bindings::vips_measure(
2224 inp_in,
2225 &mut out_out,
2226 h_in,
2227 v_in,
2228 left_in_name.as_ptr(),
2229 left_in,
2230 top_in_name.as_ptr(),
2231 top_in,
2232 width_in_name.as_ptr(),
2233 width_in,
2234 height_in_name.as_ptr(),
2235 height_in,
2236 NULL,
2237 );
2238 utils::result(
2239 vips_op_response,
2240 VipsImage { ctx: out_out },
2241 Error::MeasureError,
2242 )
2243 }
2244}
2245
2246pub fn find_trim(inp: &VipsImage) -> Result<(i32, i32, i32, i32)> {
2255 unsafe {
2256 let inp_in: *mut bindings::VipsImage = inp.ctx;
2257 let mut left_out: i32 = i32::from(1);
2258 let mut top_out: i32 = i32::from(0);
2259 let mut width_out: i32 = i32::from(1);
2260 let mut height_out: i32 = i32::from(1);
2261
2262 let vips_op_response = bindings::vips_find_trim(
2263 inp_in,
2264 &mut left_out,
2265 &mut top_out,
2266 &mut width_out,
2267 &mut height_out,
2268 NULL,
2269 );
2270 utils::result(
2271 vips_op_response,
2272 (left_out, top_out, width_out, height_out),
2273 Error::FindTrimError,
2274 )
2275 }
2276}
2277
2278#[derive(Clone, Debug)]
2280pub struct FindTrimOptions {
2281 pub threshold: f64,
2284 pub background: Vec<f64>,
2286 pub line_art: bool,
2289}
2290
2291impl std::default::Default for FindTrimOptions {
2292 fn default() -> Self {
2293 FindTrimOptions {
2294 threshold: f64::from(10),
2295 background: Vec::new(),
2296 line_art: false,
2297 }
2298 }
2299}
2300
2301pub fn find_trim_with_opts(
2311 inp: &VipsImage,
2312 find_trim_options: &FindTrimOptions,
2313) -> Result<(i32, i32, i32, i32)> {
2314 unsafe {
2315 let inp_in: *mut bindings::VipsImage = inp.ctx;
2316 let mut left_out: i32 = i32::from(1);
2317 let mut top_out: i32 = i32::from(0);
2318 let mut width_out: i32 = i32::from(1);
2319 let mut height_out: i32 = i32::from(1);
2320
2321 let threshold_in: f64 = find_trim_options.threshold;
2322 let threshold_in_name = utils::new_c_string("threshold")?;
2323
2324 let background_wrapper =
2325 utils::VipsArrayDoubleWrapper::from(&find_trim_options.background[..]);
2326 let background_in = background_wrapper.ctx;
2327 let background_in_name = utils::new_c_string("background")?;
2328
2329 let line_art_in: i32 = if find_trim_options.line_art { 1 } else { 0 };
2330 let line_art_in_name = utils::new_c_string("line-art")?;
2331
2332 let vips_op_response = bindings::vips_find_trim(
2333 inp_in,
2334 &mut left_out,
2335 &mut top_out,
2336 &mut width_out,
2337 &mut height_out,
2338 threshold_in_name.as_ptr(),
2339 threshold_in,
2340 background_in_name.as_ptr(),
2341 background_in,
2342 line_art_in_name.as_ptr(),
2343 line_art_in,
2344 NULL,
2345 );
2346 utils::result(
2347 vips_op_response,
2348 (left_out, top_out, width_out, height_out),
2349 Error::FindTrimError,
2350 )
2351 }
2352}
2353
2354pub fn copy(inp: &VipsImage) -> Result<VipsImage> {
2358 unsafe {
2359 let inp_in: *mut bindings::VipsImage = inp.ctx;
2360 let mut out_out: *mut bindings::VipsImage = null_mut();
2361
2362 let vips_op_response = bindings::vips_copy(inp_in, &mut out_out, NULL);
2363 utils::result(
2364 vips_op_response,
2365 VipsImage { ctx: out_out },
2366 Error::CopyError,
2367 )
2368 }
2369}
2370
2371#[derive(Clone, Debug)]
2373pub struct CopyOptions {
2374 pub width: i32,
2377 pub height: i32,
2380 pub bands: i32,
2383 pub format: BandFormat,
2397 pub coding: Coding,
2404 pub interpretation: Interpretation,
2427 pub xres: f64,
2430 pub yres: f64,
2433 pub xoffset: i32,
2436 pub yoffset: i32,
2439}
2440
2441impl std::default::Default for CopyOptions {
2442 fn default() -> Self {
2443 CopyOptions {
2444 width: i32::from(0),
2445 height: i32::from(0),
2446 bands: i32::from(0),
2447 format: BandFormat::Uchar,
2448 coding: Coding::None,
2449 interpretation: Interpretation::Multiband,
2450 xres: f64::from(0),
2451 yres: f64::from(0),
2452 xoffset: i32::from(0),
2453 yoffset: i32::from(0),
2454 }
2455 }
2456}
2457
2458pub fn copy_with_opts(inp: &VipsImage, copy_options: &CopyOptions) -> Result<VipsImage> {
2463 unsafe {
2464 let inp_in: *mut bindings::VipsImage = inp.ctx;
2465 let mut out_out: *mut bindings::VipsImage = null_mut();
2466
2467 let width_in: i32 = copy_options.width;
2468 let width_in_name = utils::new_c_string("width")?;
2469
2470 let height_in: i32 = copy_options.height;
2471 let height_in_name = utils::new_c_string("height")?;
2472
2473 let bands_in: i32 = copy_options.bands;
2474 let bands_in_name = utils::new_c_string("bands")?;
2475
2476 let format_in: i32 = copy_options.format as i32;
2477 let format_in_name = utils::new_c_string("format")?;
2478
2479 let coding_in: i32 = copy_options.coding as i32;
2480 let coding_in_name = utils::new_c_string("coding")?;
2481
2482 let interpretation_in: i32 = copy_options.interpretation as i32;
2483 let interpretation_in_name = utils::new_c_string("interpretation")?;
2484
2485 let xres_in: f64 = copy_options.xres;
2486 let xres_in_name = utils::new_c_string("xres")?;
2487
2488 let yres_in: f64 = copy_options.yres;
2489 let yres_in_name = utils::new_c_string("yres")?;
2490
2491 let xoffset_in: i32 = copy_options.xoffset;
2492 let xoffset_in_name = utils::new_c_string("xoffset")?;
2493
2494 let yoffset_in: i32 = copy_options.yoffset;
2495 let yoffset_in_name = utils::new_c_string("yoffset")?;
2496
2497 let vips_op_response = bindings::vips_copy(
2498 inp_in,
2499 &mut out_out,
2500 width_in_name.as_ptr(),
2501 width_in,
2502 height_in_name.as_ptr(),
2503 height_in,
2504 bands_in_name.as_ptr(),
2505 bands_in,
2506 format_in_name.as_ptr(),
2507 format_in,
2508 coding_in_name.as_ptr(),
2509 coding_in,
2510 interpretation_in_name.as_ptr(),
2511 interpretation_in,
2512 xres_in_name.as_ptr(),
2513 xres_in,
2514 yres_in_name.as_ptr(),
2515 yres_in,
2516 xoffset_in_name.as_ptr(),
2517 xoffset_in,
2518 yoffset_in_name.as_ptr(),
2519 yoffset_in,
2520 NULL,
2521 );
2522 utils::result(
2523 vips_op_response,
2524 VipsImage { ctx: out_out },
2525 Error::CopyError,
2526 )
2527 }
2528}
2529
2530pub fn tilecache(inp: &VipsImage) -> Result<VipsImage> {
2534 unsafe {
2535 let inp_in: *mut bindings::VipsImage = inp.ctx;
2536 let mut out_out: *mut bindings::VipsImage = null_mut();
2537
2538 let vips_op_response = bindings::vips_tilecache(inp_in, &mut out_out, NULL);
2539 utils::result(
2540 vips_op_response,
2541 VipsImage { ctx: out_out },
2542 Error::TilecacheError,
2543 )
2544 }
2545}
2546
2547#[derive(Clone, Debug)]
2549pub struct TilecacheOptions {
2550 pub tile_width: i32,
2553 pub tile_height: i32,
2556 pub max_tiles: i32,
2559 pub access: Access,
2565 pub threaded: bool,
2568 pub persistent: bool,
2571}
2572
2573impl std::default::Default for TilecacheOptions {
2574 fn default() -> Self {
2575 TilecacheOptions {
2576 tile_width: i32::from(128),
2577 tile_height: i32::from(128),
2578 max_tiles: i32::from(1000),
2579 access: Access::Random,
2580 threaded: false,
2581 persistent: false,
2582 }
2583 }
2584}
2585
2586pub fn tilecache_with_opts(
2591 inp: &VipsImage,
2592 tilecache_options: &TilecacheOptions,
2593) -> Result<VipsImage> {
2594 unsafe {
2595 let inp_in: *mut bindings::VipsImage = inp.ctx;
2596 let mut out_out: *mut bindings::VipsImage = null_mut();
2597
2598 let tile_width_in: i32 = tilecache_options.tile_width;
2599 let tile_width_in_name = utils::new_c_string("tile-width")?;
2600
2601 let tile_height_in: i32 = tilecache_options.tile_height;
2602 let tile_height_in_name = utils::new_c_string("tile-height")?;
2603
2604 let max_tiles_in: i32 = tilecache_options.max_tiles;
2605 let max_tiles_in_name = utils::new_c_string("max-tiles")?;
2606
2607 let access_in: i32 = tilecache_options.access as i32;
2608 let access_in_name = utils::new_c_string("access")?;
2609
2610 let threaded_in: i32 = if tilecache_options.threaded { 1 } else { 0 };
2611 let threaded_in_name = utils::new_c_string("threaded")?;
2612
2613 let persistent_in: i32 = if tilecache_options.persistent { 1 } else { 0 };
2614 let persistent_in_name = utils::new_c_string("persistent")?;
2615
2616 let vips_op_response = bindings::vips_tilecache(
2617 inp_in,
2618 &mut out_out,
2619 tile_width_in_name.as_ptr(),
2620 tile_width_in,
2621 tile_height_in_name.as_ptr(),
2622 tile_height_in,
2623 max_tiles_in_name.as_ptr(),
2624 max_tiles_in,
2625 access_in_name.as_ptr(),
2626 access_in,
2627 threaded_in_name.as_ptr(),
2628 threaded_in,
2629 persistent_in_name.as_ptr(),
2630 persistent_in,
2631 NULL,
2632 );
2633 utils::result(
2634 vips_op_response,
2635 VipsImage { ctx: out_out },
2636 Error::TilecacheError,
2637 )
2638 }
2639}
2640
2641pub fn linecache(inp: &VipsImage) -> Result<VipsImage> {
2645 unsafe {
2646 let inp_in: *mut bindings::VipsImage = inp.ctx;
2647 let mut out_out: *mut bindings::VipsImage = null_mut();
2648
2649 let vips_op_response = bindings::vips_linecache(inp_in, &mut out_out, NULL);
2650 utils::result(
2651 vips_op_response,
2652 VipsImage { ctx: out_out },
2653 Error::LinecacheError,
2654 )
2655 }
2656}
2657
2658#[derive(Clone, Debug)]
2660pub struct LinecacheOptions {
2661 pub tile_height: i32,
2664 pub access: Access,
2670 pub threaded: bool,
2673 pub persistent: bool,
2676}
2677
2678impl std::default::Default for LinecacheOptions {
2679 fn default() -> Self {
2680 LinecacheOptions {
2681 tile_height: i32::from(128),
2682 access: Access::Random,
2683 threaded: false,
2684 persistent: false,
2685 }
2686 }
2687}
2688
2689pub fn linecache_with_opts(
2694 inp: &VipsImage,
2695 linecache_options: &LinecacheOptions,
2696) -> Result<VipsImage> {
2697 unsafe {
2698 let inp_in: *mut bindings::VipsImage = inp.ctx;
2699 let mut out_out: *mut bindings::VipsImage = null_mut();
2700
2701 let tile_height_in: i32 = linecache_options.tile_height;
2702 let tile_height_in_name = utils::new_c_string("tile-height")?;
2703
2704 let access_in: i32 = linecache_options.access as i32;
2705 let access_in_name = utils::new_c_string("access")?;
2706
2707 let threaded_in: i32 = if linecache_options.threaded { 1 } else { 0 };
2708 let threaded_in_name = utils::new_c_string("threaded")?;
2709
2710 let persistent_in: i32 = if linecache_options.persistent { 1 } else { 0 };
2711 let persistent_in_name = utils::new_c_string("persistent")?;
2712
2713 let vips_op_response = bindings::vips_linecache(
2714 inp_in,
2715 &mut out_out,
2716 tile_height_in_name.as_ptr(),
2717 tile_height_in,
2718 access_in_name.as_ptr(),
2719 access_in,
2720 threaded_in_name.as_ptr(),
2721 threaded_in,
2722 persistent_in_name.as_ptr(),
2723 persistent_in,
2724 NULL,
2725 );
2726 utils::result(
2727 vips_op_response,
2728 VipsImage { ctx: out_out },
2729 Error::LinecacheError,
2730 )
2731 }
2732}
2733
2734pub fn sequential(inp: &VipsImage) -> Result<VipsImage> {
2738 unsafe {
2739 let inp_in: *mut bindings::VipsImage = inp.ctx;
2740 let mut out_out: *mut bindings::VipsImage = null_mut();
2741
2742 let vips_op_response = bindings::vips_sequential(inp_in, &mut out_out, NULL);
2743 utils::result(
2744 vips_op_response,
2745 VipsImage { ctx: out_out },
2746 Error::SequentialError,
2747 )
2748 }
2749}
2750
2751#[derive(Clone, Debug)]
2753pub struct SequentialOptions {
2754 pub tile_height: i32,
2757}
2758
2759impl std::default::Default for SequentialOptions {
2760 fn default() -> Self {
2761 SequentialOptions {
2762 tile_height: i32::from(1),
2763 }
2764 }
2765}
2766
2767pub fn sequential_with_opts(
2772 inp: &VipsImage,
2773 sequential_options: &SequentialOptions,
2774) -> Result<VipsImage> {
2775 unsafe {
2776 let inp_in: *mut bindings::VipsImage = inp.ctx;
2777 let mut out_out: *mut bindings::VipsImage = null_mut();
2778
2779 let tile_height_in: i32 = sequential_options.tile_height;
2780 let tile_height_in_name = utils::new_c_string("tile-height")?;
2781
2782 let vips_op_response = bindings::vips_sequential(
2783 inp_in,
2784 &mut out_out,
2785 tile_height_in_name.as_ptr(),
2786 tile_height_in,
2787 NULL,
2788 );
2789 utils::result(
2790 vips_op_response,
2791 VipsImage { ctx: out_out },
2792 Error::SequentialError,
2793 )
2794 }
2795}
2796
2797pub fn embed(inp: &VipsImage, x: i32, y: i32, width: i32, height: i32) -> Result<VipsImage> {
2809 unsafe {
2810 let inp_in: *mut bindings::VipsImage = inp.ctx;
2811 let x_in: i32 = x;
2812 let y_in: i32 = y;
2813 let width_in: i32 = width;
2814 let height_in: i32 = height;
2815 let mut out_out: *mut bindings::VipsImage = null_mut();
2816
2817 let vips_op_response =
2818 bindings::vips_embed(inp_in, &mut out_out, x_in, y_in, width_in, height_in, NULL);
2819 utils::result(
2820 vips_op_response,
2821 VipsImage { ctx: out_out },
2822 Error::EmbedError,
2823 )
2824 }
2825}
2826
2827#[derive(Clone, Debug)]
2829pub struct EmbedOptions {
2830 pub extend: Extend,
2839 pub background: Vec<f64>,
2841}
2842
2843impl std::default::Default for EmbedOptions {
2844 fn default() -> Self {
2845 EmbedOptions {
2846 extend: Extend::Black,
2847 background: Vec::new(),
2848 }
2849 }
2850}
2851
2852pub fn embed_with_opts(
2865 inp: &VipsImage,
2866 x: i32,
2867 y: i32,
2868 width: i32,
2869 height: i32,
2870 embed_options: &EmbedOptions,
2871) -> Result<VipsImage> {
2872 unsafe {
2873 let inp_in: *mut bindings::VipsImage = inp.ctx;
2874 let x_in: i32 = x;
2875 let y_in: i32 = y;
2876 let width_in: i32 = width;
2877 let height_in: i32 = height;
2878 let mut out_out: *mut bindings::VipsImage = null_mut();
2879
2880 let extend_in: i32 = embed_options.extend as i32;
2881 let extend_in_name = utils::new_c_string("extend")?;
2882
2883 let background_wrapper = utils::VipsArrayDoubleWrapper::from(&embed_options.background[..]);
2884 let background_in = background_wrapper.ctx;
2885 let background_in_name = utils::new_c_string("background")?;
2886
2887 let vips_op_response = bindings::vips_embed(
2888 inp_in,
2889 &mut out_out,
2890 x_in,
2891 y_in,
2892 width_in,
2893 height_in,
2894 extend_in_name.as_ptr(),
2895 extend_in,
2896 background_in_name.as_ptr(),
2897 background_in,
2898 NULL,
2899 );
2900 utils::result(
2901 vips_op_response,
2902 VipsImage { ctx: out_out },
2903 Error::EmbedError,
2904 )
2905 }
2906}
2907
2908pub fn gravity(
2927 inp: &VipsImage,
2928 direction: CompassDirection,
2929 width: i32,
2930 height: i32,
2931) -> Result<VipsImage> {
2932 unsafe {
2933 let inp_in: *mut bindings::VipsImage = inp.ctx;
2934 let direction_in: i32 = direction as i32;
2935 let width_in: i32 = width;
2936 let height_in: i32 = height;
2937 let mut out_out: *mut bindings::VipsImage = null_mut();
2938
2939 let vips_op_response = bindings::vips_gravity(
2940 inp_in,
2941 &mut out_out,
2942 direction_in.try_into().unwrap(),
2943 width_in,
2944 height_in,
2945 NULL,
2946 );
2947 utils::result(
2948 vips_op_response,
2949 VipsImage { ctx: out_out },
2950 Error::GravityError,
2951 )
2952 }
2953}
2954
2955#[derive(Clone, Debug)]
2957pub struct GravityOptions {
2958 pub extend: Extend,
2967 pub background: Vec<f64>,
2969}
2970
2971impl std::default::Default for GravityOptions {
2972 fn default() -> Self {
2973 GravityOptions {
2974 extend: Extend::Black,
2975 background: Vec::new(),
2976 }
2977 }
2978}
2979
2980pub fn gravity_with_opts(
3000 inp: &VipsImage,
3001 direction: CompassDirection,
3002 width: i32,
3003 height: i32,
3004 gravity_options: &GravityOptions,
3005) -> Result<VipsImage> {
3006 unsafe {
3007 let inp_in: *mut bindings::VipsImage = inp.ctx;
3008 let direction_in: i32 = direction as i32;
3009 let width_in: i32 = width;
3010 let height_in: i32 = height;
3011 let mut out_out: *mut bindings::VipsImage = null_mut();
3012
3013 let extend_in: i32 = gravity_options.extend as i32;
3014 let extend_in_name = utils::new_c_string("extend")?;
3015
3016 let background_wrapper =
3017 utils::VipsArrayDoubleWrapper::from(&gravity_options.background[..]);
3018 let background_in = background_wrapper.ctx;
3019 let background_in_name = utils::new_c_string("background")?;
3020
3021 let vips_op_response = bindings::vips_gravity(
3022 inp_in,
3023 &mut out_out,
3024 direction_in.try_into().unwrap(),
3025 width_in,
3026 height_in,
3027 extend_in_name.as_ptr(),
3028 extend_in,
3029 background_in_name.as_ptr(),
3030 background_in,
3031 NULL,
3032 );
3033 utils::result(
3034 vips_op_response,
3035 VipsImage { ctx: out_out },
3036 Error::GravityError,
3037 )
3038 }
3039}
3040
3041pub fn flip(inp: &VipsImage, direction: Direction) -> Result<VipsImage> {
3049 unsafe {
3050 let inp_in: *mut bindings::VipsImage = inp.ctx;
3051 let direction_in: i32 = direction as i32;
3052 let mut out_out: *mut bindings::VipsImage = null_mut();
3053
3054 let vips_op_response =
3055 bindings::vips_flip(inp_in, &mut out_out, direction_in.try_into().unwrap(), NULL);
3056 utils::result(
3057 vips_op_response,
3058 VipsImage { ctx: out_out },
3059 Error::FlipError,
3060 )
3061 }
3062}
3063
3064pub fn insert(main: &VipsImage, sub: &VipsImage, x: i32, y: i32) -> Result<VipsImage> {
3073 unsafe {
3074 let main_in: *mut bindings::VipsImage = main.ctx;
3075 let sub_in: *mut bindings::VipsImage = sub.ctx;
3076 let x_in: i32 = x;
3077 let y_in: i32 = y;
3078 let mut out_out: *mut bindings::VipsImage = null_mut();
3079
3080 let vips_op_response =
3081 bindings::vips_insert(main_in, sub_in, &mut out_out, x_in, y_in, NULL);
3082 utils::result(
3083 vips_op_response,
3084 VipsImage { ctx: out_out },
3085 Error::InsertError,
3086 )
3087 }
3088}
3089
3090#[derive(Clone, Debug)]
3092pub struct InsertOptions {
3093 pub expand: bool,
3096 pub background: Vec<f64>,
3098}
3099
3100impl std::default::Default for InsertOptions {
3101 fn default() -> Self {
3102 InsertOptions {
3103 expand: false,
3104 background: Vec::new(),
3105 }
3106 }
3107}
3108
3109pub fn insert_with_opts(
3119 main: &VipsImage,
3120 sub: &VipsImage,
3121 x: i32,
3122 y: i32,
3123 insert_options: &InsertOptions,
3124) -> Result<VipsImage> {
3125 unsafe {
3126 let main_in: *mut bindings::VipsImage = main.ctx;
3127 let sub_in: *mut bindings::VipsImage = sub.ctx;
3128 let x_in: i32 = x;
3129 let y_in: i32 = y;
3130 let mut out_out: *mut bindings::VipsImage = null_mut();
3131
3132 let expand_in: i32 = if insert_options.expand { 1 } else { 0 };
3133 let expand_in_name = utils::new_c_string("expand")?;
3134
3135 let background_wrapper =
3136 utils::VipsArrayDoubleWrapper::from(&insert_options.background[..]);
3137 let background_in = background_wrapper.ctx;
3138 let background_in_name = utils::new_c_string("background")?;
3139
3140 let vips_op_response = bindings::vips_insert(
3141 main_in,
3142 sub_in,
3143 &mut out_out,
3144 x_in,
3145 y_in,
3146 expand_in_name.as_ptr(),
3147 expand_in,
3148 background_in_name.as_ptr(),
3149 background_in,
3150 NULL,
3151 );
3152 utils::result(
3153 vips_op_response,
3154 VipsImage { ctx: out_out },
3155 Error::InsertError,
3156 )
3157 }
3158}
3159
3160pub fn join(in_1: &VipsImage, in_2: &VipsImage, direction: Direction) -> Result<VipsImage> {
3169 unsafe {
3170 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
3171 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
3172 let direction_in: i32 = direction as i32;
3173 let mut out_out: *mut bindings::VipsImage = null_mut();
3174
3175 let vips_op_response = bindings::vips_join(
3176 in_1_in,
3177 in_2_in,
3178 &mut out_out,
3179 direction_in.try_into().unwrap(),
3180 NULL,
3181 );
3182 utils::result(
3183 vips_op_response,
3184 VipsImage { ctx: out_out },
3185 Error::JoinError,
3186 )
3187 }
3188}
3189
3190#[derive(Clone, Debug)]
3192pub struct JoinOptions {
3193 pub expand: bool,
3196 pub shim: i32,
3199 pub background: Vec<f64>,
3201 pub align: Align,
3207}
3208
3209impl std::default::Default for JoinOptions {
3210 fn default() -> Self {
3211 JoinOptions {
3212 expand: false,
3213 shim: i32::from(0),
3214 background: Vec::new(),
3215 align: Align::Low,
3216 }
3217 }
3218}
3219
3220pub fn join_with_opts(
3230 in_1: &VipsImage,
3231 in_2: &VipsImage,
3232 direction: Direction,
3233 join_options: &JoinOptions,
3234) -> Result<VipsImage> {
3235 unsafe {
3236 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
3237 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
3238 let direction_in: i32 = direction as i32;
3239 let mut out_out: *mut bindings::VipsImage = null_mut();
3240
3241 let expand_in: i32 = if join_options.expand { 1 } else { 0 };
3242 let expand_in_name = utils::new_c_string("expand")?;
3243
3244 let shim_in: i32 = join_options.shim;
3245 let shim_in_name = utils::new_c_string("shim")?;
3246
3247 let background_wrapper = utils::VipsArrayDoubleWrapper::from(&join_options.background[..]);
3248 let background_in = background_wrapper.ctx;
3249 let background_in_name = utils::new_c_string("background")?;
3250
3251 let align_in: i32 = join_options.align as i32;
3252 let align_in_name = utils::new_c_string("align")?;
3253
3254 let vips_op_response = bindings::vips_join(
3255 in_1_in,
3256 in_2_in,
3257 &mut out_out,
3258 direction_in.try_into().unwrap(),
3259 expand_in_name.as_ptr(),
3260 expand_in,
3261 shim_in_name.as_ptr(),
3262 shim_in,
3263 background_in_name.as_ptr(),
3264 background_in,
3265 align_in_name.as_ptr(),
3266 align_in,
3267 NULL,
3268 );
3269 utils::result(
3270 vips_op_response,
3271 VipsImage { ctx: out_out },
3272 Error::JoinError,
3273 )
3274 }
3275}
3276
3277pub fn arrayjoin(inp: &mut [VipsImage]) -> Result<VipsImage> {
3281 unsafe {
3282 let (inp_len, mut inp_in) = {
3283 let len = inp.len();
3284 let mut input = Vec::new();
3285 for img in inp {
3286 input.push(img.ctx)
3287 }
3288 (len as i32, input)
3289 };
3290 let mut out_out: *mut bindings::VipsImage = null_mut();
3291
3292 let vips_op_response =
3293 bindings::vips_arrayjoin(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
3294 utils::result(
3295 vips_op_response,
3296 VipsImage { ctx: out_out },
3297 Error::ArrayjoinError,
3298 )
3299 }
3300}
3301
3302#[derive(Clone, Debug)]
3304pub struct ArrayjoinOptions {
3305 pub across: i32,
3308 pub shim: i32,
3311 pub background: Vec<f64>,
3313 pub halign: Align,
3319 pub valign: Align,
3325 pub hspacing: i32,
3328 pub vspacing: i32,
3331}
3332
3333impl std::default::Default for ArrayjoinOptions {
3334 fn default() -> Self {
3335 ArrayjoinOptions {
3336 across: i32::from(1),
3337 shim: i32::from(0),
3338 background: Vec::new(),
3339 halign: Align::Low,
3340 valign: Align::Low,
3341 hspacing: i32::from(1),
3342 vspacing: i32::from(1),
3343 }
3344 }
3345}
3346
3347pub fn arrayjoin_with_opts(
3352 inp: &mut [VipsImage],
3353 arrayjoin_options: &ArrayjoinOptions,
3354) -> Result<VipsImage> {
3355 unsafe {
3356 let (inp_len, mut inp_in) = {
3357 let len = inp.len();
3358 let mut input = Vec::new();
3359 for img in inp {
3360 input.push(img.ctx)
3361 }
3362 (len as i32, input)
3363 };
3364 let mut out_out: *mut bindings::VipsImage = null_mut();
3365
3366 let across_in: i32 = arrayjoin_options.across;
3367 let across_in_name = utils::new_c_string("across")?;
3368
3369 let shim_in: i32 = arrayjoin_options.shim;
3370 let shim_in_name = utils::new_c_string("shim")?;
3371
3372 let background_wrapper =
3373 utils::VipsArrayDoubleWrapper::from(&arrayjoin_options.background[..]);
3374 let background_in = background_wrapper.ctx;
3375 let background_in_name = utils::new_c_string("background")?;
3376
3377 let halign_in: i32 = arrayjoin_options.halign as i32;
3378 let halign_in_name = utils::new_c_string("halign")?;
3379
3380 let valign_in: i32 = arrayjoin_options.valign as i32;
3381 let valign_in_name = utils::new_c_string("valign")?;
3382
3383 let hspacing_in: i32 = arrayjoin_options.hspacing;
3384 let hspacing_in_name = utils::new_c_string("hspacing")?;
3385
3386 let vspacing_in: i32 = arrayjoin_options.vspacing;
3387 let vspacing_in_name = utils::new_c_string("vspacing")?;
3388
3389 let vips_op_response = bindings::vips_arrayjoin(
3390 inp_in.as_mut_ptr(),
3391 &mut out_out,
3392 inp_len,
3393 across_in_name.as_ptr(),
3394 across_in,
3395 shim_in_name.as_ptr(),
3396 shim_in,
3397 background_in_name.as_ptr(),
3398 background_in,
3399 halign_in_name.as_ptr(),
3400 halign_in,
3401 valign_in_name.as_ptr(),
3402 valign_in,
3403 hspacing_in_name.as_ptr(),
3404 hspacing_in,
3405 vspacing_in_name.as_ptr(),
3406 vspacing_in,
3407 NULL,
3408 );
3409 utils::result(
3410 vips_op_response,
3411 VipsImage { ctx: out_out },
3412 Error::ArrayjoinError,
3413 )
3414 }
3415}
3416
3417pub fn extract_area(
3429 input: &VipsImage,
3430 left: i32,
3431 top: i32,
3432 width: i32,
3433 height: i32,
3434) -> Result<VipsImage> {
3435 unsafe {
3436 let input_in: *mut bindings::VipsImage = input.ctx;
3437 let left_in: i32 = left;
3438 let top_in: i32 = top;
3439 let width_in: i32 = width;
3440 let height_in: i32 = height;
3441 let mut out_out: *mut bindings::VipsImage = null_mut();
3442
3443 let vips_op_response = bindings::vips_extract_area(
3444 input_in,
3445 &mut out_out,
3446 left_in,
3447 top_in,
3448 width_in,
3449 height_in,
3450 NULL,
3451 );
3452 utils::result(
3453 vips_op_response,
3454 VipsImage { ctx: out_out },
3455 Error::ExtractAreaError,
3456 )
3457 }
3458}
3459
3460pub fn smartcrop(input: &VipsImage, width: i32, height: i32) -> Result<VipsImage> {
3468 unsafe {
3469 let input_in: *mut bindings::VipsImage = input.ctx;
3470 let width_in: i32 = width;
3471 let height_in: i32 = height;
3472 let mut out_out: *mut bindings::VipsImage = null_mut();
3473
3474 let vips_op_response =
3475 bindings::vips_smartcrop(input_in, &mut out_out, width_in, height_in, NULL);
3476 utils::result(
3477 vips_op_response,
3478 VipsImage { ctx: out_out },
3479 Error::SmartcropError,
3480 )
3481 }
3482}
3483
3484#[derive(Clone, Debug)]
3486pub struct SmartcropOptions {
3487 pub attention_x: i32,
3490 pub attention_y: i32,
3493 pub interesting: Interesting,
3503 pub premultiplied: bool,
3506}
3507
3508impl std::default::Default for SmartcropOptions {
3509 fn default() -> Self {
3510 SmartcropOptions {
3511 attention_x: i32::from(0),
3512 attention_y: i32::from(0),
3513 interesting: Interesting::Attention,
3514 premultiplied: false,
3515 }
3516 }
3517}
3518
3519pub fn smartcrop_with_opts(
3528 input: &VipsImage,
3529 width: i32,
3530 height: i32,
3531 smartcrop_options: &SmartcropOptions,
3532) -> Result<VipsImage> {
3533 unsafe {
3534 let input_in: *mut bindings::VipsImage = input.ctx;
3535 let width_in: i32 = width;
3536 let height_in: i32 = height;
3537 let mut out_out: *mut bindings::VipsImage = null_mut();
3538
3539 let attention_x_in: i32 = smartcrop_options.attention_x;
3540 let attention_x_in_name = utils::new_c_string("attention-x")?;
3541
3542 let attention_y_in: i32 = smartcrop_options.attention_y;
3543 let attention_y_in_name = utils::new_c_string("attention-y")?;
3544
3545 let interesting_in: i32 = smartcrop_options.interesting as i32;
3546 let interesting_in_name = utils::new_c_string("interesting")?;
3547
3548 let premultiplied_in: i32 = if smartcrop_options.premultiplied {
3549 1
3550 } else {
3551 0
3552 };
3553 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
3554
3555 let vips_op_response = bindings::vips_smartcrop(
3556 input_in,
3557 &mut out_out,
3558 width_in,
3559 height_in,
3560 attention_x_in_name.as_ptr(),
3561 attention_x_in,
3562 attention_y_in_name.as_ptr(),
3563 attention_y_in,
3564 interesting_in_name.as_ptr(),
3565 interesting_in,
3566 premultiplied_in_name.as_ptr(),
3567 premultiplied_in,
3568 NULL,
3569 );
3570 utils::result(
3571 vips_op_response,
3572 VipsImage { ctx: out_out },
3573 Error::SmartcropError,
3574 )
3575 }
3576}
3577
3578pub fn extract_band(inp: &VipsImage, band: i32) -> Result<VipsImage> {
3584 unsafe {
3585 let inp_in: *mut bindings::VipsImage = inp.ctx;
3586 let band_in: i32 = band;
3587 let mut out_out: *mut bindings::VipsImage = null_mut();
3588
3589 let vips_op_response = bindings::vips_extract_band(inp_in, &mut out_out, band_in, NULL);
3590 utils::result(
3591 vips_op_response,
3592 VipsImage { ctx: out_out },
3593 Error::ExtractBandError,
3594 )
3595 }
3596}
3597
3598#[derive(Clone, Debug)]
3600pub struct ExtractBandOptions {
3601 pub n: i32,
3604}
3605
3606impl std::default::Default for ExtractBandOptions {
3607 fn default() -> Self {
3608 ExtractBandOptions { n: i32::from(1) }
3609 }
3610}
3611
3612pub fn extract_band_with_opts(
3619 inp: &VipsImage,
3620 band: i32,
3621 extract_band_options: &ExtractBandOptions,
3622) -> Result<VipsImage> {
3623 unsafe {
3624 let inp_in: *mut bindings::VipsImage = inp.ctx;
3625 let band_in: i32 = band;
3626 let mut out_out: *mut bindings::VipsImage = null_mut();
3627
3628 let n_in: i32 = extract_band_options.n;
3629 let n_in_name = utils::new_c_string("n")?;
3630
3631 let vips_op_response = bindings::vips_extract_band(
3632 inp_in,
3633 &mut out_out,
3634 band_in,
3635 n_in_name.as_ptr(),
3636 n_in,
3637 NULL,
3638 );
3639 utils::result(
3640 vips_op_response,
3641 VipsImage { ctx: out_out },
3642 Error::ExtractBandError,
3643 )
3644 }
3645}
3646
3647pub fn bandjoin(inp: &mut [VipsImage]) -> Result<VipsImage> {
3651 unsafe {
3652 let (inp_len, mut inp_in) = {
3653 let len = inp.len();
3654 let mut input = Vec::new();
3655 for img in inp {
3656 input.push(img.ctx)
3657 }
3658 (len as i32, input)
3659 };
3660 let mut out_out: *mut bindings::VipsImage = null_mut();
3661
3662 let vips_op_response =
3663 bindings::vips_bandjoin(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
3664 utils::result(
3665 vips_op_response,
3666 VipsImage { ctx: out_out },
3667 Error::BandjoinError,
3668 )
3669 }
3670}
3671
3672pub fn bandjoin_const(inp: &VipsImage, c: &mut [f64]) -> Result<VipsImage> {
3677 unsafe {
3678 let inp_in: *mut bindings::VipsImage = inp.ctx;
3679 let c_in: *mut f64 = c.as_mut_ptr();
3680 let mut out_out: *mut bindings::VipsImage = null_mut();
3681
3682 let vips_op_response =
3683 bindings::vips_bandjoin_const(inp_in, &mut out_out, c_in, c.len() as i32, NULL);
3684 utils::result(
3685 vips_op_response,
3686 VipsImage { ctx: out_out },
3687 Error::BandjoinConstError,
3688 )
3689 }
3690}
3691
3692pub fn bandrank(inp: &mut [VipsImage]) -> Result<VipsImage> {
3696 unsafe {
3697 let (inp_len, mut inp_in) = {
3698 let len = inp.len();
3699 let mut input = Vec::new();
3700 for img in inp {
3701 input.push(img.ctx)
3702 }
3703 (len as i32, input)
3704 };
3705 let mut out_out: *mut bindings::VipsImage = null_mut();
3706
3707 let vips_op_response =
3708 bindings::vips_bandrank(inp_in.as_mut_ptr(), &mut out_out, inp_len, NULL);
3709 utils::result(
3710 vips_op_response,
3711 VipsImage { ctx: out_out },
3712 Error::BandrankError,
3713 )
3714 }
3715}
3716
3717#[derive(Clone, Debug)]
3719pub struct BandrankOptions {
3720 pub index: i32,
3723}
3724
3725impl std::default::Default for BandrankOptions {
3726 fn default() -> Self {
3727 BandrankOptions {
3728 index: i32::from(-1),
3729 }
3730 }
3731}
3732
3733pub fn bandrank_with_opts(
3738 inp: &mut [VipsImage],
3739 bandrank_options: &BandrankOptions,
3740) -> Result<VipsImage> {
3741 unsafe {
3742 let (inp_len, mut inp_in) = {
3743 let len = inp.len();
3744 let mut input = Vec::new();
3745 for img in inp {
3746 input.push(img.ctx)
3747 }
3748 (len as i32, input)
3749 };
3750 let mut out_out: *mut bindings::VipsImage = null_mut();
3751
3752 let index_in: i32 = bandrank_options.index;
3753 let index_in_name = utils::new_c_string("index")?;
3754
3755 let vips_op_response = bindings::vips_bandrank(
3756 inp_in.as_mut_ptr(),
3757 &mut out_out,
3758 inp_len,
3759 index_in_name.as_ptr(),
3760 index_in,
3761 NULL,
3762 );
3763 utils::result(
3764 vips_op_response,
3765 VipsImage { ctx: out_out },
3766 Error::BandrankError,
3767 )
3768 }
3769}
3770
3771pub fn bandmean(inp: &VipsImage) -> Result<VipsImage> {
3775 unsafe {
3776 let inp_in: *mut bindings::VipsImage = inp.ctx;
3777 let mut out_out: *mut bindings::VipsImage = null_mut();
3778
3779 let vips_op_response = bindings::vips_bandmean(inp_in, &mut out_out, NULL);
3780 utils::result(
3781 vips_op_response,
3782 VipsImage { ctx: out_out },
3783 Error::BandmeanError,
3784 )
3785 }
3786}
3787
3788pub fn bandbool(inp: &VipsImage, boolean: OperationBoolean) -> Result<VipsImage> {
3799 unsafe {
3800 let inp_in: *mut bindings::VipsImage = inp.ctx;
3801 let boolean_in: i32 = boolean as i32;
3802 let mut out_out: *mut bindings::VipsImage = null_mut();
3803
3804 let vips_op_response =
3805 bindings::vips_bandbool(inp_in, &mut out_out, boolean_in.try_into().unwrap(), NULL);
3806 utils::result(
3807 vips_op_response,
3808 VipsImage { ctx: out_out },
3809 Error::BandboolError,
3810 )
3811 }
3812}
3813
3814pub fn replicate(inp: &VipsImage, across: i32, down: i32) -> Result<VipsImage> {
3822 unsafe {
3823 let inp_in: *mut bindings::VipsImage = inp.ctx;
3824 let across_in: i32 = across;
3825 let down_in: i32 = down;
3826 let mut out_out: *mut bindings::VipsImage = null_mut();
3827
3828 let vips_op_response =
3829 bindings::vips_replicate(inp_in, &mut out_out, across_in, down_in, NULL);
3830 utils::result(
3831 vips_op_response,
3832 VipsImage { ctx: out_out },
3833 Error::ReplicateError,
3834 )
3835 }
3836}
3837
3838pub fn cast(inp: &VipsImage, format: BandFormat) -> Result<VipsImage> {
3855 unsafe {
3856 let inp_in: *mut bindings::VipsImage = inp.ctx;
3857 let format_in: i32 = format as i32;
3858 let mut out_out: *mut bindings::VipsImage = null_mut();
3859
3860 let vips_op_response =
3861 bindings::vips_cast(inp_in, &mut out_out, format_in.try_into().unwrap(), NULL);
3862 utils::result(
3863 vips_op_response,
3864 VipsImage { ctx: out_out },
3865 Error::CastError,
3866 )
3867 }
3868}
3869
3870#[derive(Clone, Debug)]
3872pub struct CastOptions {
3873 pub shift: bool,
3876}
3877
3878impl std::default::Default for CastOptions {
3879 fn default() -> Self {
3880 CastOptions { shift: false }
3881 }
3882}
3883
3884pub fn cast_with_opts(
3902 inp: &VipsImage,
3903 format: BandFormat,
3904 cast_options: &CastOptions,
3905) -> Result<VipsImage> {
3906 unsafe {
3907 let inp_in: *mut bindings::VipsImage = inp.ctx;
3908 let format_in: i32 = format as i32;
3909 let mut out_out: *mut bindings::VipsImage = null_mut();
3910
3911 let shift_in: i32 = if cast_options.shift { 1 } else { 0 };
3912 let shift_in_name = utils::new_c_string("shift")?;
3913
3914 let vips_op_response = bindings::vips_cast(
3915 inp_in,
3916 &mut out_out,
3917 format_in.try_into().unwrap(),
3918 shift_in_name.as_ptr(),
3919 shift_in,
3920 NULL,
3921 );
3922 utils::result(
3923 vips_op_response,
3924 VipsImage { ctx: out_out },
3925 Error::CastError,
3926 )
3927 }
3928}
3929
3930pub fn rot(inp: &VipsImage, angle: Angle) -> Result<VipsImage> {
3940 unsafe {
3941 let inp_in: *mut bindings::VipsImage = inp.ctx;
3942 let angle_in: i32 = angle as i32;
3943 let mut out_out: *mut bindings::VipsImage = null_mut();
3944
3945 let vips_op_response =
3946 bindings::vips_rot(inp_in, &mut out_out, angle_in.try_into().unwrap(), NULL);
3947 utils::result(
3948 vips_op_response,
3949 VipsImage { ctx: out_out },
3950 Error::RotError,
3951 )
3952 }
3953}
3954
3955pub fn rot_45(inp: &VipsImage) -> Result<VipsImage> {
3959 unsafe {
3960 let inp_in: *mut bindings::VipsImage = inp.ctx;
3961 let mut out_out: *mut bindings::VipsImage = null_mut();
3962
3963 let vips_op_response = bindings::vips_rot45(inp_in, &mut out_out, NULL);
3964 utils::result(
3965 vips_op_response,
3966 VipsImage { ctx: out_out },
3967 Error::Rot45Error,
3968 )
3969 }
3970}
3971
3972#[derive(Clone, Debug)]
3974pub struct Rot45Options {
3975 pub angle: Angle45,
3986}
3987
3988impl std::default::Default for Rot45Options {
3989 fn default() -> Self {
3990 Rot45Options {
3991 angle: Angle45::D45,
3992 }
3993 }
3994}
3995
3996pub fn rot_45_with_opts(inp: &VipsImage, rot_45_options: &Rot45Options) -> Result<VipsImage> {
4001 unsafe {
4002 let inp_in: *mut bindings::VipsImage = inp.ctx;
4003 let mut out_out: *mut bindings::VipsImage = null_mut();
4004
4005 let angle_in: i32 = rot_45_options.angle as i32;
4006 let angle_in_name = utils::new_c_string("angle")?;
4007
4008 let vips_op_response =
4009 bindings::vips_rot45(inp_in, &mut out_out, angle_in_name.as_ptr(), angle_in, NULL);
4010 utils::result(
4011 vips_op_response,
4012 VipsImage { ctx: out_out },
4013 Error::Rot45Error,
4014 )
4015 }
4016}
4017
4018pub fn autorot(inp: &VipsImage) -> Result<VipsImage> {
4022 unsafe {
4023 let inp_in: *mut bindings::VipsImage = inp.ctx;
4024 let mut out_out: *mut bindings::VipsImage = null_mut();
4025
4026 let vips_op_response = bindings::vips_autorot(inp_in, &mut out_out, NULL);
4027 utils::result(
4028 vips_op_response,
4029 VipsImage { ctx: out_out },
4030 Error::AutorotError,
4031 )
4032 }
4033}
4034
4035#[derive(Clone, Debug)]
4037pub struct AutorotOptions {
4038 pub angle: Angle,
4045 pub flip: bool,
4048}
4049
4050impl std::default::Default for AutorotOptions {
4051 fn default() -> Self {
4052 AutorotOptions {
4053 angle: Angle::D0,
4054 flip: false,
4055 }
4056 }
4057}
4058
4059pub fn autorot_with_opts(inp: &VipsImage, autorot_options: &AutorotOptions) -> Result<VipsImage> {
4064 unsafe {
4065 let inp_in: *mut bindings::VipsImage = inp.ctx;
4066 let mut out_out: *mut bindings::VipsImage = null_mut();
4067
4068 let angle_in: i32 = autorot_options.angle as i32;
4069 let angle_in_name = utils::new_c_string("angle")?;
4070
4071 let flip_in: i32 = if autorot_options.flip { 1 } else { 0 };
4072 let flip_in_name = utils::new_c_string("flip")?;
4073
4074 let vips_op_response = bindings::vips_autorot(
4075 inp_in,
4076 &mut out_out,
4077 angle_in_name.as_ptr(),
4078 angle_in,
4079 flip_in_name.as_ptr(),
4080 flip_in,
4081 NULL,
4082 );
4083 utils::result(
4084 vips_op_response,
4085 VipsImage { ctx: out_out },
4086 Error::AutorotError,
4087 )
4088 }
4089}
4090
4091pub fn ifthenelse(cond: &VipsImage, in_1: &VipsImage, in_2: &VipsImage) -> Result<VipsImage> {
4097 unsafe {
4098 let cond_in: *mut bindings::VipsImage = cond.ctx;
4099 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
4100 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
4101 let mut out_out: *mut bindings::VipsImage = null_mut();
4102
4103 let vips_op_response =
4104 bindings::vips_ifthenelse(cond_in, in_1_in, in_2_in, &mut out_out, NULL);
4105 utils::result(
4106 vips_op_response,
4107 VipsImage { ctx: out_out },
4108 Error::IfthenelseError,
4109 )
4110 }
4111}
4112
4113#[derive(Clone, Debug)]
4115pub struct IfthenelseOptions {
4116 pub blend: bool,
4119}
4120
4121impl std::default::Default for IfthenelseOptions {
4122 fn default() -> Self {
4123 IfthenelseOptions { blend: false }
4124 }
4125}
4126
4127pub fn ifthenelse_with_opts(
4134 cond: &VipsImage,
4135 in_1: &VipsImage,
4136 in_2: &VipsImage,
4137 ifthenelse_options: &IfthenelseOptions,
4138) -> Result<VipsImage> {
4139 unsafe {
4140 let cond_in: *mut bindings::VipsImage = cond.ctx;
4141 let in_1_in: *mut bindings::VipsImage = in_1.ctx;
4142 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
4143 let mut out_out: *mut bindings::VipsImage = null_mut();
4144
4145 let blend_in: i32 = if ifthenelse_options.blend { 1 } else { 0 };
4146 let blend_in_name = utils::new_c_string("blend")?;
4147
4148 let vips_op_response = bindings::vips_ifthenelse(
4149 cond_in,
4150 in_1_in,
4151 in_2_in,
4152 &mut out_out,
4153 blend_in_name.as_ptr(),
4154 blend_in,
4155 NULL,
4156 );
4157 utils::result(
4158 vips_op_response,
4159 VipsImage { ctx: out_out },
4160 Error::IfthenelseError,
4161 )
4162 }
4163}
4164
4165pub fn recomb(inp: &VipsImage, m: &VipsImage) -> Result<VipsImage> {
4170 unsafe {
4171 let inp_in: *mut bindings::VipsImage = inp.ctx;
4172 let m_in: *mut bindings::VipsImage = m.ctx;
4173 let mut out_out: *mut bindings::VipsImage = null_mut();
4174
4175 let vips_op_response = bindings::vips_recomb(inp_in, &mut out_out, m_in, NULL);
4176 utils::result(
4177 vips_op_response,
4178 VipsImage { ctx: out_out },
4179 Error::RecombError,
4180 )
4181 }
4182}
4183
4184pub fn bandfold(inp: &VipsImage) -> Result<VipsImage> {
4188 unsafe {
4189 let inp_in: *mut bindings::VipsImage = inp.ctx;
4190 let mut out_out: *mut bindings::VipsImage = null_mut();
4191
4192 let vips_op_response = bindings::vips_bandfold(inp_in, &mut out_out, NULL);
4193 utils::result(
4194 vips_op_response,
4195 VipsImage { ctx: out_out },
4196 Error::BandfoldError,
4197 )
4198 }
4199}
4200
4201#[derive(Clone, Debug)]
4203pub struct BandfoldOptions {
4204 pub factor: i32,
4207}
4208
4209impl std::default::Default for BandfoldOptions {
4210 fn default() -> Self {
4211 BandfoldOptions {
4212 factor: i32::from(0),
4213 }
4214 }
4215}
4216
4217pub fn bandfold_with_opts(
4222 inp: &VipsImage,
4223 bandfold_options: &BandfoldOptions,
4224) -> Result<VipsImage> {
4225 unsafe {
4226 let inp_in: *mut bindings::VipsImage = inp.ctx;
4227 let mut out_out: *mut bindings::VipsImage = null_mut();
4228
4229 let factor_in: i32 = bandfold_options.factor;
4230 let factor_in_name = utils::new_c_string("factor")?;
4231
4232 let vips_op_response = bindings::vips_bandfold(
4233 inp_in,
4234 &mut out_out,
4235 factor_in_name.as_ptr(),
4236 factor_in,
4237 NULL,
4238 );
4239 utils::result(
4240 vips_op_response,
4241 VipsImage { ctx: out_out },
4242 Error::BandfoldError,
4243 )
4244 }
4245}
4246
4247pub fn bandunfold(inp: &VipsImage) -> Result<VipsImage> {
4251 unsafe {
4252 let inp_in: *mut bindings::VipsImage = inp.ctx;
4253 let mut out_out: *mut bindings::VipsImage = null_mut();
4254
4255 let vips_op_response = bindings::vips_bandunfold(inp_in, &mut out_out, NULL);
4256 utils::result(
4257 vips_op_response,
4258 VipsImage { ctx: out_out },
4259 Error::BandunfoldError,
4260 )
4261 }
4262}
4263
4264#[derive(Clone, Debug)]
4266pub struct BandunfoldOptions {
4267 pub factor: i32,
4270}
4271
4272impl std::default::Default for BandunfoldOptions {
4273 fn default() -> Self {
4274 BandunfoldOptions {
4275 factor: i32::from(0),
4276 }
4277 }
4278}
4279
4280pub fn bandunfold_with_opts(
4285 inp: &VipsImage,
4286 bandunfold_options: &BandunfoldOptions,
4287) -> Result<VipsImage> {
4288 unsafe {
4289 let inp_in: *mut bindings::VipsImage = inp.ctx;
4290 let mut out_out: *mut bindings::VipsImage = null_mut();
4291
4292 let factor_in: i32 = bandunfold_options.factor;
4293 let factor_in_name = utils::new_c_string("factor")?;
4294
4295 let vips_op_response = bindings::vips_bandunfold(
4296 inp_in,
4297 &mut out_out,
4298 factor_in_name.as_ptr(),
4299 factor_in,
4300 NULL,
4301 );
4302 utils::result(
4303 vips_op_response,
4304 VipsImage { ctx: out_out },
4305 Error::BandunfoldError,
4306 )
4307 }
4308}
4309
4310pub fn flatten(inp: &VipsImage) -> Result<VipsImage> {
4314 unsafe {
4315 let inp_in: *mut bindings::VipsImage = inp.ctx;
4316 let mut out_out: *mut bindings::VipsImage = null_mut();
4317
4318 let vips_op_response = bindings::vips_flatten(inp_in, &mut out_out, NULL);
4319 utils::result(
4320 vips_op_response,
4321 VipsImage { ctx: out_out },
4322 Error::FlattenError,
4323 )
4324 }
4325}
4326
4327#[derive(Clone, Debug)]
4329pub struct FlattenOptions {
4330 pub background: Vec<f64>,
4332 pub max_alpha: f64,
4335}
4336
4337impl std::default::Default for FlattenOptions {
4338 fn default() -> Self {
4339 FlattenOptions {
4340 background: Vec::new(),
4341 max_alpha: f64::from(255),
4342 }
4343 }
4344}
4345
4346pub fn flatten_with_opts(inp: &VipsImage, flatten_options: &FlattenOptions) -> Result<VipsImage> {
4351 unsafe {
4352 let inp_in: *mut bindings::VipsImage = inp.ctx;
4353 let mut out_out: *mut bindings::VipsImage = null_mut();
4354
4355 let background_wrapper =
4356 utils::VipsArrayDoubleWrapper::from(&flatten_options.background[..]);
4357 let background_in = background_wrapper.ctx;
4358 let background_in_name = utils::new_c_string("background")?;
4359
4360 let max_alpha_in: f64 = flatten_options.max_alpha;
4361 let max_alpha_in_name = utils::new_c_string("max-alpha")?;
4362
4363 let vips_op_response = bindings::vips_flatten(
4364 inp_in,
4365 &mut out_out,
4366 background_in_name.as_ptr(),
4367 background_in,
4368 max_alpha_in_name.as_ptr(),
4369 max_alpha_in,
4370 NULL,
4371 );
4372 utils::result(
4373 vips_op_response,
4374 VipsImage { ctx: out_out },
4375 Error::FlattenError,
4376 )
4377 }
4378}
4379
4380pub fn premultiply(inp: &VipsImage) -> Result<VipsImage> {
4384 unsafe {
4385 let inp_in: *mut bindings::VipsImage = inp.ctx;
4386 let mut out_out: *mut bindings::VipsImage = null_mut();
4387
4388 let vips_op_response = bindings::vips_premultiply(inp_in, &mut out_out, NULL);
4389 utils::result(
4390 vips_op_response,
4391 VipsImage { ctx: out_out },
4392 Error::PremultiplyError,
4393 )
4394 }
4395}
4396
4397#[derive(Clone, Debug)]
4399pub struct PremultiplyOptions {
4400 pub max_alpha: f64,
4403}
4404
4405impl std::default::Default for PremultiplyOptions {
4406 fn default() -> Self {
4407 PremultiplyOptions {
4408 max_alpha: f64::from(255),
4409 }
4410 }
4411}
4412
4413pub fn premultiply_with_opts(
4418 inp: &VipsImage,
4419 premultiply_options: &PremultiplyOptions,
4420) -> Result<VipsImage> {
4421 unsafe {
4422 let inp_in: *mut bindings::VipsImage = inp.ctx;
4423 let mut out_out: *mut bindings::VipsImage = null_mut();
4424
4425 let max_alpha_in: f64 = premultiply_options.max_alpha;
4426 let max_alpha_in_name = utils::new_c_string("max-alpha")?;
4427
4428 let vips_op_response = bindings::vips_premultiply(
4429 inp_in,
4430 &mut out_out,
4431 max_alpha_in_name.as_ptr(),
4432 max_alpha_in,
4433 NULL,
4434 );
4435 utils::result(
4436 vips_op_response,
4437 VipsImage { ctx: out_out },
4438 Error::PremultiplyError,
4439 )
4440 }
4441}
4442
4443pub fn unpremultiply(inp: &VipsImage) -> Result<VipsImage> {
4447 unsafe {
4448 let inp_in: *mut bindings::VipsImage = inp.ctx;
4449 let mut out_out: *mut bindings::VipsImage = null_mut();
4450
4451 let vips_op_response = bindings::vips_unpremultiply(inp_in, &mut out_out, NULL);
4452 utils::result(
4453 vips_op_response,
4454 VipsImage { ctx: out_out },
4455 Error::UnpremultiplyError,
4456 )
4457 }
4458}
4459
4460#[derive(Clone, Debug)]
4462pub struct UnpremultiplyOptions {
4463 pub max_alpha: f64,
4466 pub alpha_band: i32,
4469}
4470
4471impl std::default::Default for UnpremultiplyOptions {
4472 fn default() -> Self {
4473 UnpremultiplyOptions {
4474 max_alpha: f64::from(255),
4475 alpha_band: i32::from(3),
4476 }
4477 }
4478}
4479
4480pub fn unpremultiply_with_opts(
4485 inp: &VipsImage,
4486 unpremultiply_options: &UnpremultiplyOptions,
4487) -> Result<VipsImage> {
4488 unsafe {
4489 let inp_in: *mut bindings::VipsImage = inp.ctx;
4490 let mut out_out: *mut bindings::VipsImage = null_mut();
4491
4492 let max_alpha_in: f64 = unpremultiply_options.max_alpha;
4493 let max_alpha_in_name = utils::new_c_string("max-alpha")?;
4494
4495 let alpha_band_in: i32 = unpremultiply_options.alpha_band;
4496 let alpha_band_in_name = utils::new_c_string("alpha-band")?;
4497
4498 let vips_op_response = bindings::vips_unpremultiply(
4499 inp_in,
4500 &mut out_out,
4501 max_alpha_in_name.as_ptr(),
4502 max_alpha_in,
4503 alpha_band_in_name.as_ptr(),
4504 alpha_band_in,
4505 NULL,
4506 );
4507 utils::result(
4508 vips_op_response,
4509 VipsImage { ctx: out_out },
4510 Error::UnpremultiplyError,
4511 )
4512 }
4513}
4514
4515pub fn grid(inp: &VipsImage, tile_height: i32, across: i32, down: i32) -> Result<VipsImage> {
4525 unsafe {
4526 let inp_in: *mut bindings::VipsImage = inp.ctx;
4527 let tile_height_in: i32 = tile_height;
4528 let across_in: i32 = across;
4529 let down_in: i32 = down;
4530 let mut out_out: *mut bindings::VipsImage = null_mut();
4531
4532 let vips_op_response = bindings::vips_grid(
4533 inp_in,
4534 &mut out_out,
4535 tile_height_in,
4536 across_in,
4537 down_in,
4538 NULL,
4539 );
4540 utils::result(
4541 vips_op_response,
4542 VipsImage { ctx: out_out },
4543 Error::GridError,
4544 )
4545 }
4546}
4547
4548pub fn transpose_3d(inp: &VipsImage) -> Result<VipsImage> {
4552 unsafe {
4553 let inp_in: *mut bindings::VipsImage = inp.ctx;
4554 let mut out_out: *mut bindings::VipsImage = null_mut();
4555
4556 let vips_op_response = bindings::vips_transpose3d(inp_in, &mut out_out, NULL);
4557 utils::result(
4558 vips_op_response,
4559 VipsImage { ctx: out_out },
4560 Error::Transpose3DError,
4561 )
4562 }
4563}
4564
4565#[derive(Clone, Debug)]
4567pub struct Transpose3DOptions {
4568 pub page_height: i32,
4571}
4572
4573impl std::default::Default for Transpose3DOptions {
4574 fn default() -> Self {
4575 Transpose3DOptions {
4576 page_height: i32::from(0),
4577 }
4578 }
4579}
4580
4581pub fn transpose_3d_with_opts(
4586 inp: &VipsImage,
4587 transpose_3d_options: &Transpose3DOptions,
4588) -> Result<VipsImage> {
4589 unsafe {
4590 let inp_in: *mut bindings::VipsImage = inp.ctx;
4591 let mut out_out: *mut bindings::VipsImage = null_mut();
4592
4593 let page_height_in: i32 = transpose_3d_options.page_height;
4594 let page_height_in_name = utils::new_c_string("page-height")?;
4595
4596 let vips_op_response = bindings::vips_transpose3d(
4597 inp_in,
4598 &mut out_out,
4599 page_height_in_name.as_ptr(),
4600 page_height_in,
4601 NULL,
4602 );
4603 utils::result(
4604 vips_op_response,
4605 VipsImage { ctx: out_out },
4606 Error::Transpose3DError,
4607 )
4608 }
4609}
4610
4611pub fn scale(inp: &VipsImage) -> Result<VipsImage> {
4615 unsafe {
4616 let inp_in: *mut bindings::VipsImage = inp.ctx;
4617 let mut out_out: *mut bindings::VipsImage = null_mut();
4618
4619 let vips_op_response = bindings::vips_scale(inp_in, &mut out_out, NULL);
4620 utils::result(
4621 vips_op_response,
4622 VipsImage { ctx: out_out },
4623 Error::ScaleError,
4624 )
4625 }
4626}
4627
4628#[derive(Clone, Debug)]
4630pub struct ScaleOptions {
4631 pub exp: f64,
4634 pub log: bool,
4637}
4638
4639impl std::default::Default for ScaleOptions {
4640 fn default() -> Self {
4641 ScaleOptions {
4642 exp: f64::from(0.25),
4643 log: false,
4644 }
4645 }
4646}
4647
4648pub fn scale_with_opts(inp: &VipsImage, scale_options: &ScaleOptions) -> Result<VipsImage> {
4653 unsafe {
4654 let inp_in: *mut bindings::VipsImage = inp.ctx;
4655 let mut out_out: *mut bindings::VipsImage = null_mut();
4656
4657 let exp_in: f64 = scale_options.exp;
4658 let exp_in_name = utils::new_c_string("exp")?;
4659
4660 let log_in: i32 = if scale_options.log { 1 } else { 0 };
4661 let log_in_name = utils::new_c_string("log")?;
4662
4663 let vips_op_response = bindings::vips_scale(
4664 inp_in,
4665 &mut out_out,
4666 exp_in_name.as_ptr(),
4667 exp_in,
4668 log_in_name.as_ptr(),
4669 log_in,
4670 NULL,
4671 );
4672 utils::result(
4673 vips_op_response,
4674 VipsImage { ctx: out_out },
4675 Error::ScaleError,
4676 )
4677 }
4678}
4679
4680pub fn wrap(inp: &VipsImage) -> Result<VipsImage> {
4684 unsafe {
4685 let inp_in: *mut bindings::VipsImage = inp.ctx;
4686 let mut out_out: *mut bindings::VipsImage = null_mut();
4687
4688 let vips_op_response = bindings::vips_wrap(inp_in, &mut out_out, NULL);
4689 utils::result(
4690 vips_op_response,
4691 VipsImage { ctx: out_out },
4692 Error::WrapError,
4693 )
4694 }
4695}
4696
4697#[derive(Clone, Debug)]
4699pub struct WrapOptions {
4700 pub x: i32,
4703 pub y: i32,
4706}
4707
4708impl std::default::Default for WrapOptions {
4709 fn default() -> Self {
4710 WrapOptions {
4711 x: i32::from(0),
4712 y: i32::from(0),
4713 }
4714 }
4715}
4716
4717pub fn wrap_with_opts(inp: &VipsImage, wrap_options: &WrapOptions) -> Result<VipsImage> {
4722 unsafe {
4723 let inp_in: *mut bindings::VipsImage = inp.ctx;
4724 let mut out_out: *mut bindings::VipsImage = null_mut();
4725
4726 let x_in: i32 = wrap_options.x;
4727 let x_in_name = utils::new_c_string("x")?;
4728
4729 let y_in: i32 = wrap_options.y;
4730 let y_in_name = utils::new_c_string("y")?;
4731
4732 let vips_op_response = bindings::vips_wrap(
4733 inp_in,
4734 &mut out_out,
4735 x_in_name.as_ptr(),
4736 x_in,
4737 y_in_name.as_ptr(),
4738 y_in,
4739 NULL,
4740 );
4741 utils::result(
4742 vips_op_response,
4743 VipsImage { ctx: out_out },
4744 Error::WrapError,
4745 )
4746 }
4747}
4748
4749pub fn zoom(input: &VipsImage, xfac: i32, yfac: i32) -> Result<VipsImage> {
4757 unsafe {
4758 let input_in: *mut bindings::VipsImage = input.ctx;
4759 let xfac_in: i32 = xfac;
4760 let yfac_in: i32 = yfac;
4761 let mut out_out: *mut bindings::VipsImage = null_mut();
4762
4763 let vips_op_response = bindings::vips_zoom(input_in, &mut out_out, xfac_in, yfac_in, NULL);
4764 utils::result(
4765 vips_op_response,
4766 VipsImage { ctx: out_out },
4767 Error::ZoomError,
4768 )
4769 }
4770}
4771
4772pub fn subsample(input: &VipsImage, xfac: i32, yfac: i32) -> Result<VipsImage> {
4780 unsafe {
4781 let input_in: *mut bindings::VipsImage = input.ctx;
4782 let xfac_in: i32 = xfac;
4783 let yfac_in: i32 = yfac;
4784 let mut out_out: *mut bindings::VipsImage = null_mut();
4785
4786 let vips_op_response =
4787 bindings::vips_subsample(input_in, &mut out_out, xfac_in, yfac_in, NULL);
4788 utils::result(
4789 vips_op_response,
4790 VipsImage { ctx: out_out },
4791 Error::SubsampleError,
4792 )
4793 }
4794}
4795
4796#[derive(Clone, Debug)]
4798pub struct SubsampleOptions {
4799 pub point: bool,
4802}
4803
4804impl std::default::Default for SubsampleOptions {
4805 fn default() -> Self {
4806 SubsampleOptions { point: false }
4807 }
4808}
4809
4810pub fn subsample_with_opts(
4819 input: &VipsImage,
4820 xfac: i32,
4821 yfac: i32,
4822 subsample_options: &SubsampleOptions,
4823) -> Result<VipsImage> {
4824 unsafe {
4825 let input_in: *mut bindings::VipsImage = input.ctx;
4826 let xfac_in: i32 = xfac;
4827 let yfac_in: i32 = yfac;
4828 let mut out_out: *mut bindings::VipsImage = null_mut();
4829
4830 let point_in: i32 = if subsample_options.point { 1 } else { 0 };
4831 let point_in_name = utils::new_c_string("point")?;
4832
4833 let vips_op_response = bindings::vips_subsample(
4834 input_in,
4835 &mut out_out,
4836 xfac_in,
4837 yfac_in,
4838 point_in_name.as_ptr(),
4839 point_in,
4840 NULL,
4841 );
4842 utils::result(
4843 vips_op_response,
4844 VipsImage { ctx: out_out },
4845 Error::SubsampleError,
4846 )
4847 }
4848}
4849
4850pub fn msb(inp: &VipsImage) -> Result<VipsImage> {
4854 unsafe {
4855 let inp_in: *mut bindings::VipsImage = inp.ctx;
4856 let mut out_out: *mut bindings::VipsImage = null_mut();
4857
4858 let vips_op_response = bindings::vips_msb(inp_in, &mut out_out, NULL);
4859 utils::result(
4860 vips_op_response,
4861 VipsImage { ctx: out_out },
4862 Error::MsbError,
4863 )
4864 }
4865}
4866
4867#[derive(Clone, Debug)]
4869pub struct MsbOptions {
4870 pub band: i32,
4873}
4874
4875impl std::default::Default for MsbOptions {
4876 fn default() -> Self {
4877 MsbOptions { band: i32::from(0) }
4878 }
4879}
4880
4881pub fn msb_with_opts(inp: &VipsImage, msb_options: &MsbOptions) -> Result<VipsImage> {
4886 unsafe {
4887 let inp_in: *mut bindings::VipsImage = inp.ctx;
4888 let mut out_out: *mut bindings::VipsImage = null_mut();
4889
4890 let band_in: i32 = msb_options.band;
4891 let band_in_name = utils::new_c_string("band")?;
4892
4893 let vips_op_response =
4894 bindings::vips_msb(inp_in, &mut out_out, band_in_name.as_ptr(), band_in, NULL);
4895 utils::result(
4896 vips_op_response,
4897 VipsImage { ctx: out_out },
4898 Error::MsbError,
4899 )
4900 }
4901}
4902
4903pub fn byteswap(inp: &VipsImage) -> Result<VipsImage> {
4907 unsafe {
4908 let inp_in: *mut bindings::VipsImage = inp.ctx;
4909 let mut out_out: *mut bindings::VipsImage = null_mut();
4910
4911 let vips_op_response = bindings::vips_byteswap(inp_in, &mut out_out, NULL);
4912 utils::result(
4913 vips_op_response,
4914 VipsImage { ctx: out_out },
4915 Error::ByteswapError,
4916 )
4917 }
4918}
4919
4920pub fn falsecolour(inp: &VipsImage) -> Result<VipsImage> {
4924 unsafe {
4925 let inp_in: *mut bindings::VipsImage = inp.ctx;
4926 let mut out_out: *mut bindings::VipsImage = null_mut();
4927
4928 let vips_op_response = bindings::vips_falsecolour(inp_in, &mut out_out, NULL);
4929 utils::result(
4930 vips_op_response,
4931 VipsImage { ctx: out_out },
4932 Error::FalsecolourError,
4933 )
4934 }
4935}
4936
4937pub fn gamma(inp: &VipsImage) -> Result<VipsImage> {
4941 unsafe {
4942 let inp_in: *mut bindings::VipsImage = inp.ctx;
4943 let mut out_out: *mut bindings::VipsImage = null_mut();
4944
4945 let vips_op_response = bindings::vips_gamma(inp_in, &mut out_out, NULL);
4946 utils::result(
4947 vips_op_response,
4948 VipsImage { ctx: out_out },
4949 Error::GammaError,
4950 )
4951 }
4952}
4953
4954#[derive(Clone, Debug)]
4956pub struct GammaOptions {
4957 pub exponent: f64,
4960}
4961
4962impl std::default::Default for GammaOptions {
4963 fn default() -> Self {
4964 GammaOptions {
4965 exponent: f64::from(2.4),
4966 }
4967 }
4968}
4969
4970pub fn gamma_with_opts(inp: &VipsImage, gamma_options: &GammaOptions) -> Result<VipsImage> {
4975 unsafe {
4976 let inp_in: *mut bindings::VipsImage = inp.ctx;
4977 let mut out_out: *mut bindings::VipsImage = null_mut();
4978
4979 let exponent_in: f64 = gamma_options.exponent;
4980 let exponent_in_name = utils::new_c_string("exponent")?;
4981
4982 let vips_op_response = bindings::vips_gamma(
4983 inp_in,
4984 &mut out_out,
4985 exponent_in_name.as_ptr(),
4986 exponent_in,
4987 NULL,
4988 );
4989 utils::result(
4990 vips_op_response,
4991 VipsImage { ctx: out_out },
4992 Error::GammaError,
4993 )
4994 }
4995}
4996
4997pub fn composite(inp: &mut [VipsImage], mode: &mut [i32]) -> Result<VipsImage> {
5002 unsafe {
5003 let (inp_len, mut inp_in) = {
5004 let len = inp.len();
5005 let mut input = Vec::new();
5006 for img in inp {
5007 input.push(img.ctx)
5008 }
5009 (len as i32, input)
5010 };
5011 let mode_in: *mut i32 = mode.as_mut_ptr();
5012 let mut out_out: *mut bindings::VipsImage = null_mut();
5013
5014 let vips_op_response = bindings::vips_composite(
5015 inp_in.as_mut_ptr(),
5016 &mut out_out,
5017 inp_len,
5018 mode_in,
5019 mode.len() as i32,
5020 NULL,
5021 );
5022 utils::result(
5023 vips_op_response,
5024 VipsImage { ctx: out_out },
5025 Error::CompositeError,
5026 )
5027 }
5028}
5029
5030#[derive(Clone, Debug)]
5032pub struct CompositeOptions {
5033 pub x: Vec<i32>,
5035 pub y: Vec<i32>,
5037 pub compositing_space: Interpretation,
5060 pub premultiplied: bool,
5063}
5064
5065impl std::default::Default for CompositeOptions {
5066 fn default() -> Self {
5067 CompositeOptions {
5068 x: Vec::new(),
5069 y: Vec::new(),
5070 compositing_space: Interpretation::Srgb,
5071 premultiplied: false,
5072 }
5073 }
5074}
5075
5076pub fn composite_with_opts(
5082 inp: &mut [VipsImage],
5083 mode: &mut [i32],
5084 composite_options: &CompositeOptions,
5085) -> Result<VipsImage> {
5086 unsafe {
5087 let (inp_len, mut inp_in) = {
5088 let len = inp.len();
5089 let mut input = Vec::new();
5090 for img in inp {
5091 input.push(img.ctx)
5092 }
5093 (len as i32, input)
5094 };
5095 let mode_in: *mut i32 = mode.as_mut_ptr();
5096 let mut out_out: *mut bindings::VipsImage = null_mut();
5097
5098 let x_wrapper = utils::VipsArrayIntWrapper::from(&composite_options.x[..]);
5099 let x_in = x_wrapper.ctx;
5100 let x_in_name = utils::new_c_string("x")?;
5101
5102 let y_wrapper = utils::VipsArrayIntWrapper::from(&composite_options.y[..]);
5103 let y_in = y_wrapper.ctx;
5104 let y_in_name = utils::new_c_string("y")?;
5105
5106 let compositing_space_in: i32 = composite_options.compositing_space as i32;
5107 let compositing_space_in_name = utils::new_c_string("compositing-space")?;
5108
5109 let premultiplied_in: i32 = if composite_options.premultiplied {
5110 1
5111 } else {
5112 0
5113 };
5114 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
5115
5116 let vips_op_response = bindings::vips_composite(
5117 inp_in.as_mut_ptr(),
5118 &mut out_out,
5119 inp_len,
5120 mode_in,
5121 mode.len() as i32,
5122 x_in_name.as_ptr(),
5123 x_in,
5124 y_in_name.as_ptr(),
5125 y_in,
5126 compositing_space_in_name.as_ptr(),
5127 compositing_space_in,
5128 premultiplied_in_name.as_ptr(),
5129 premultiplied_in,
5130 NULL,
5131 );
5132 utils::result(
5133 vips_op_response,
5134 VipsImage { ctx: out_out },
5135 Error::CompositeError,
5136 )
5137 }
5138}
5139
5140pub fn composite_2(base: &VipsImage, overlay: &VipsImage, mode: BlendMode) -> Result<VipsImage> {
5172 unsafe {
5173 let base_in: *mut bindings::VipsImage = base.ctx;
5174 let overlay_in: *mut bindings::VipsImage = overlay.ctx;
5175 let mode_in: i32 = mode as i32;
5176 let mut out_out: *mut bindings::VipsImage = null_mut();
5177
5178 let vips_op_response = bindings::vips_composite2(
5179 base_in,
5180 overlay_in,
5181 &mut out_out,
5182 mode_in.try_into().unwrap(),
5183 NULL,
5184 );
5185 utils::result(
5186 vips_op_response,
5187 VipsImage { ctx: out_out },
5188 Error::Composite2Error,
5189 )
5190 }
5191}
5192
5193#[derive(Clone, Debug)]
5195pub struct Composite2Options {
5196 pub x: i32,
5199 pub y: i32,
5202 pub compositing_space: Interpretation,
5225 pub premultiplied: bool,
5228}
5229
5230impl std::default::Default for Composite2Options {
5231 fn default() -> Self {
5232 Composite2Options {
5233 x: i32::from(0),
5234 y: i32::from(0),
5235 compositing_space: Interpretation::Srgb,
5236 premultiplied: false,
5237 }
5238 }
5239}
5240
5241pub fn composite_2_with_opts(
5274 base: &VipsImage,
5275 overlay: &VipsImage,
5276 mode: BlendMode,
5277 composite_2_options: &Composite2Options,
5278) -> Result<VipsImage> {
5279 unsafe {
5280 let base_in: *mut bindings::VipsImage = base.ctx;
5281 let overlay_in: *mut bindings::VipsImage = overlay.ctx;
5282 let mode_in: i32 = mode as i32;
5283 let mut out_out: *mut bindings::VipsImage = null_mut();
5284
5285 let x_in: i32 = composite_2_options.x;
5286 let x_in_name = utils::new_c_string("x")?;
5287
5288 let y_in: i32 = composite_2_options.y;
5289 let y_in_name = utils::new_c_string("y")?;
5290
5291 let compositing_space_in: i32 = composite_2_options.compositing_space as i32;
5292 let compositing_space_in_name = utils::new_c_string("compositing-space")?;
5293
5294 let premultiplied_in: i32 = if composite_2_options.premultiplied {
5295 1
5296 } else {
5297 0
5298 };
5299 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
5300
5301 let vips_op_response = bindings::vips_composite2(
5302 base_in,
5303 overlay_in,
5304 &mut out_out,
5305 mode_in.try_into().unwrap(),
5306 x_in_name.as_ptr(),
5307 x_in,
5308 y_in_name.as_ptr(),
5309 y_in,
5310 compositing_space_in_name.as_ptr(),
5311 compositing_space_in,
5312 premultiplied_in_name.as_ptr(),
5313 premultiplied_in,
5314 NULL,
5315 );
5316 utils::result(
5317 vips_op_response,
5318 VipsImage { ctx: out_out },
5319 Error::Composite2Error,
5320 )
5321 }
5322}
5323
5324pub fn addalpha(inp: &VipsImage) -> Result<VipsImage> {
5328 unsafe {
5329 let inp_in: *mut bindings::VipsImage = inp.ctx;
5330 let mut out_out: *mut bindings::VipsImage = null_mut();
5331
5332 let vips_op_response = bindings::vips_addalpha(inp_in, &mut out_out, NULL);
5333 utils::result(
5334 vips_op_response,
5335 VipsImage { ctx: out_out },
5336 Error::AddalphaError,
5337 )
5338 }
5339}
5340
5341pub fn black(width: i32, height: i32) -> Result<VipsImage> {
5348 unsafe {
5349 let width_in: i32 = width;
5350 let height_in: i32 = height;
5351 let mut out_out: *mut bindings::VipsImage = null_mut();
5352
5353 let vips_op_response = bindings::vips_black(&mut out_out, width_in, height_in, NULL);
5354 utils::result(
5355 vips_op_response,
5356 VipsImage { ctx: out_out },
5357 Error::BlackError,
5358 )
5359 }
5360}
5361
5362#[derive(Clone, Debug)]
5364pub struct BlackOptions {
5365 pub bands: i32,
5368}
5369
5370impl std::default::Default for BlackOptions {
5371 fn default() -> Self {
5372 BlackOptions {
5373 bands: i32::from(1),
5374 }
5375 }
5376}
5377
5378pub fn black_with_opts(width: i32, height: i32, black_options: &BlackOptions) -> Result<VipsImage> {
5386 unsafe {
5387 let width_in: i32 = width;
5388 let height_in: i32 = height;
5389 let mut out_out: *mut bindings::VipsImage = null_mut();
5390
5391 let bands_in: i32 = black_options.bands;
5392 let bands_in_name = utils::new_c_string("bands")?;
5393
5394 let vips_op_response = bindings::vips_black(
5395 &mut out_out,
5396 width_in,
5397 height_in,
5398 bands_in_name.as_ptr(),
5399 bands_in,
5400 NULL,
5401 );
5402 utils::result(
5403 vips_op_response,
5404 VipsImage { ctx: out_out },
5405 Error::BlackError,
5406 )
5407 }
5408}
5409
5410pub fn gaussnoise(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_gaussnoise(&mut out_out, width_in, height_in, NULL);
5423 utils::result(
5424 vips_op_response,
5425 VipsImage { ctx: out_out },
5426 Error::GaussnoiseError,
5427 )
5428 }
5429}
5430
5431#[derive(Clone, Debug)]
5433pub struct GaussnoiseOptions {
5434 pub sigma: f64,
5437 pub mean: f64,
5440 pub seed: i32,
5443}
5444
5445impl std::default::Default for GaussnoiseOptions {
5446 fn default() -> Self {
5447 GaussnoiseOptions {
5448 sigma: f64::from(30),
5449 mean: f64::from(128),
5450 seed: i32::from(0),
5451 }
5452 }
5453}
5454
5455pub fn gaussnoise_with_opts(
5463 width: i32,
5464 height: i32,
5465 gaussnoise_options: &GaussnoiseOptions,
5466) -> Result<VipsImage> {
5467 unsafe {
5468 let width_in: i32 = width;
5469 let height_in: i32 = height;
5470 let mut out_out: *mut bindings::VipsImage = null_mut();
5471
5472 let sigma_in: f64 = gaussnoise_options.sigma;
5473 let sigma_in_name = utils::new_c_string("sigma")?;
5474
5475 let mean_in: f64 = gaussnoise_options.mean;
5476 let mean_in_name = utils::new_c_string("mean")?;
5477
5478 let seed_in: i32 = gaussnoise_options.seed;
5479 let seed_in_name = utils::new_c_string("seed")?;
5480
5481 let vips_op_response = bindings::vips_gaussnoise(
5482 &mut out_out,
5483 width_in,
5484 height_in,
5485 sigma_in_name.as_ptr(),
5486 sigma_in,
5487 mean_in_name.as_ptr(),
5488 mean_in,
5489 seed_in_name.as_ptr(),
5490 seed_in,
5491 NULL,
5492 );
5493 utils::result(
5494 vips_op_response,
5495 VipsImage { ctx: out_out },
5496 Error::GaussnoiseError,
5497 )
5498 }
5499}
5500
5501pub fn xyz(width: i32, height: i32) -> Result<VipsImage> {
5508 unsafe {
5509 let width_in: i32 = width;
5510 let height_in: i32 = height;
5511 let mut out_out: *mut bindings::VipsImage = null_mut();
5512
5513 let vips_op_response = bindings::vips_xyz(&mut out_out, width_in, height_in, NULL);
5514 utils::result(
5515 vips_op_response,
5516 VipsImage { ctx: out_out },
5517 Error::XyzError,
5518 )
5519 }
5520}
5521
5522#[derive(Clone, Debug)]
5524pub struct XyzOptions {
5525 pub csize: i32,
5528 pub dsize: i32,
5531 pub esize: i32,
5534}
5535
5536impl std::default::Default for XyzOptions {
5537 fn default() -> Self {
5538 XyzOptions {
5539 csize: i32::from(1),
5540 dsize: i32::from(1),
5541 esize: i32::from(1),
5542 }
5543 }
5544}
5545
5546pub fn xyz_with_opts(width: i32, height: i32, xyz_options: &XyzOptions) -> Result<VipsImage> {
5554 unsafe {
5555 let width_in: i32 = width;
5556 let height_in: i32 = height;
5557 let mut out_out: *mut bindings::VipsImage = null_mut();
5558
5559 let csize_in: i32 = xyz_options.csize;
5560 let csize_in_name = utils::new_c_string("csize")?;
5561
5562 let dsize_in: i32 = xyz_options.dsize;
5563 let dsize_in_name = utils::new_c_string("dsize")?;
5564
5565 let esize_in: i32 = xyz_options.esize;
5566 let esize_in_name = utils::new_c_string("esize")?;
5567
5568 let vips_op_response = bindings::vips_xyz(
5569 &mut out_out,
5570 width_in,
5571 height_in,
5572 csize_in_name.as_ptr(),
5573 csize_in,
5574 dsize_in_name.as_ptr(),
5575 dsize_in,
5576 esize_in_name.as_ptr(),
5577 esize_in,
5578 NULL,
5579 );
5580 utils::result(
5581 vips_op_response,
5582 VipsImage { ctx: out_out },
5583 Error::XyzError,
5584 )
5585 }
5586}
5587
5588pub fn gaussmat(sigma: f64, min_ampl: f64) -> Result<VipsImage> {
5595 unsafe {
5596 let sigma_in: f64 = sigma;
5597 let min_ampl_in: f64 = min_ampl;
5598 let mut out_out: *mut bindings::VipsImage = null_mut();
5599
5600 let vips_op_response = bindings::vips_gaussmat(&mut out_out, sigma_in, min_ampl_in, NULL);
5601 utils::result(
5602 vips_op_response,
5603 VipsImage { ctx: out_out },
5604 Error::GaussmatError,
5605 )
5606 }
5607}
5608
5609#[derive(Clone, Debug)]
5611pub struct GaussmatOptions {
5612 pub separable: bool,
5615 pub precision: Precision,
5621}
5622
5623impl std::default::Default for GaussmatOptions {
5624 fn default() -> Self {
5625 GaussmatOptions {
5626 separable: false,
5627 precision: Precision::Integer,
5628 }
5629 }
5630}
5631
5632pub fn gaussmat_with_opts(
5640 sigma: f64,
5641 min_ampl: f64,
5642 gaussmat_options: &GaussmatOptions,
5643) -> Result<VipsImage> {
5644 unsafe {
5645 let sigma_in: f64 = sigma;
5646 let min_ampl_in: f64 = min_ampl;
5647 let mut out_out: *mut bindings::VipsImage = null_mut();
5648
5649 let separable_in: i32 = if gaussmat_options.separable { 1 } else { 0 };
5650 let separable_in_name = utils::new_c_string("separable")?;
5651
5652 let precision_in: i32 = gaussmat_options.precision as i32;
5653 let precision_in_name = utils::new_c_string("precision")?;
5654
5655 let vips_op_response = bindings::vips_gaussmat(
5656 &mut out_out,
5657 sigma_in,
5658 min_ampl_in,
5659 separable_in_name.as_ptr(),
5660 separable_in,
5661 precision_in_name.as_ptr(),
5662 precision_in,
5663 NULL,
5664 );
5665 utils::result(
5666 vips_op_response,
5667 VipsImage { ctx: out_out },
5668 Error::GaussmatError,
5669 )
5670 }
5671}
5672
5673pub fn logmat(sigma: f64, min_ampl: f64) -> Result<VipsImage> {
5680 unsafe {
5681 let sigma_in: f64 = sigma;
5682 let min_ampl_in: f64 = min_ampl;
5683 let mut out_out: *mut bindings::VipsImage = null_mut();
5684
5685 let vips_op_response = bindings::vips_logmat(&mut out_out, sigma_in, min_ampl_in, NULL);
5686 utils::result(
5687 vips_op_response,
5688 VipsImage { ctx: out_out },
5689 Error::LogmatError,
5690 )
5691 }
5692}
5693
5694#[derive(Clone, Debug)]
5696pub struct LogmatOptions {
5697 pub separable: bool,
5700 pub precision: Precision,
5706}
5707
5708impl std::default::Default for LogmatOptions {
5709 fn default() -> Self {
5710 LogmatOptions {
5711 separable: false,
5712 precision: Precision::Integer,
5713 }
5714 }
5715}
5716
5717pub fn logmat_with_opts(
5725 sigma: f64,
5726 min_ampl: f64,
5727 logmat_options: &LogmatOptions,
5728) -> Result<VipsImage> {
5729 unsafe {
5730 let sigma_in: f64 = sigma;
5731 let min_ampl_in: f64 = min_ampl;
5732 let mut out_out: *mut bindings::VipsImage = null_mut();
5733
5734 let separable_in: i32 = if logmat_options.separable { 1 } else { 0 };
5735 let separable_in_name = utils::new_c_string("separable")?;
5736
5737 let precision_in: i32 = logmat_options.precision as i32;
5738 let precision_in_name = utils::new_c_string("precision")?;
5739
5740 let vips_op_response = bindings::vips_logmat(
5741 &mut out_out,
5742 sigma_in,
5743 min_ampl_in,
5744 separable_in_name.as_ptr(),
5745 separable_in,
5746 precision_in_name.as_ptr(),
5747 precision_in,
5748 NULL,
5749 );
5750 utils::result(
5751 vips_op_response,
5752 VipsImage { ctx: out_out },
5753 Error::LogmatError,
5754 )
5755 }
5756}
5757
5758pub fn text(text: &str) -> Result<VipsImage> {
5762 unsafe {
5763 let text_in: CString = utils::new_c_string(text)?;
5764 let mut out_out: *mut bindings::VipsImage = null_mut();
5765
5766 let vips_op_response = bindings::vips_text(&mut out_out, text_in.as_ptr(), NULL);
5767 utils::result(
5768 vips_op_response,
5769 VipsImage { ctx: out_out },
5770 Error::TextError,
5771 )
5772 }
5773}
5774
5775#[derive(Clone, Debug)]
5777pub struct TextOptions {
5778 pub font: String,
5780 pub width: i32,
5783 pub height: i32,
5786 pub align: Align,
5792 pub justify: bool,
5795 pub dpi: i32,
5798 pub autofit_dpi: i32,
5801 pub spacing: i32,
5804 pub fontfile: String,
5806 pub rgba: bool,
5809 pub wrap: TextWrap,
5816}
5817
5818impl std::default::Default for TextOptions {
5819 fn default() -> Self {
5820 TextOptions {
5821 font: String::new(),
5822 width: i32::from(0),
5823 height: i32::from(0),
5824 align: Align::Low,
5825 justify: false,
5826 dpi: i32::from(72),
5827 autofit_dpi: i32::from(72),
5828 spacing: i32::from(0),
5829 fontfile: String::new(),
5830 rgba: false,
5831 wrap: TextWrap::Word,
5832 }
5833 }
5834}
5835
5836pub fn text_with_opts(text: &str, text_options: &TextOptions) -> Result<VipsImage> {
5841 unsafe {
5842 let text_in: CString = utils::new_c_string(text)?;
5843 let mut out_out: *mut bindings::VipsImage = null_mut();
5844
5845 let font_in: CString = utils::new_c_string(&text_options.font)?;
5846 let font_in_name = utils::new_c_string("font")?;
5847
5848 let width_in: i32 = text_options.width;
5849 let width_in_name = utils::new_c_string("width")?;
5850
5851 let height_in: i32 = text_options.height;
5852 let height_in_name = utils::new_c_string("height")?;
5853
5854 let align_in: i32 = text_options.align as i32;
5855 let align_in_name = utils::new_c_string("align")?;
5856
5857 let justify_in: i32 = if text_options.justify { 1 } else { 0 };
5858 let justify_in_name = utils::new_c_string("justify")?;
5859
5860 let dpi_in: i32 = text_options.dpi;
5861 let dpi_in_name = utils::new_c_string("dpi")?;
5862
5863 let autofit_dpi_in: i32 = text_options.autofit_dpi;
5864 let autofit_dpi_in_name = utils::new_c_string("autofit-dpi")?;
5865
5866 let spacing_in: i32 = text_options.spacing;
5867 let spacing_in_name = utils::new_c_string("spacing")?;
5868
5869 let fontfile_in: CString = utils::new_c_string(&text_options.fontfile)?;
5870 let fontfile_in_name = utils::new_c_string("fontfile")?;
5871
5872 let rgba_in: i32 = if text_options.rgba { 1 } else { 0 };
5873 let rgba_in_name = utils::new_c_string("rgba")?;
5874
5875 let wrap_in: i32 = text_options.wrap as i32;
5876 let wrap_in_name = utils::new_c_string("wrap")?;
5877
5878 let vips_op_response = bindings::vips_text(
5879 &mut out_out,
5880 text_in.as_ptr(),
5881 font_in_name.as_ptr(),
5882 font_in.as_ptr(),
5883 width_in_name.as_ptr(),
5884 width_in,
5885 height_in_name.as_ptr(),
5886 height_in,
5887 align_in_name.as_ptr(),
5888 align_in,
5889 justify_in_name.as_ptr(),
5890 justify_in,
5891 dpi_in_name.as_ptr(),
5892 dpi_in,
5893 autofit_dpi_in_name.as_ptr(),
5894 autofit_dpi_in,
5895 spacing_in_name.as_ptr(),
5896 spacing_in,
5897 fontfile_in_name.as_ptr(),
5898 fontfile_in.as_ptr(),
5899 rgba_in_name.as_ptr(),
5900 rgba_in,
5901 wrap_in_name.as_ptr(),
5902 wrap_in,
5903 NULL,
5904 );
5905 utils::result(
5906 vips_op_response,
5907 VipsImage { ctx: out_out },
5908 Error::TextError,
5909 )
5910 }
5911}
5912
5913pub fn sdf(width: i32, height: i32, shape: SdfShape) -> Result<VipsImage> {
5926 unsafe {
5927 let width_in: i32 = width;
5928 let height_in: i32 = height;
5929 let shape_in: i32 = shape as i32;
5930 let mut out_out: *mut bindings::VipsImage = null_mut();
5931
5932 let vips_op_response = bindings::vips_sdf(
5933 &mut out_out,
5934 width_in,
5935 height_in,
5936 shape_in.try_into().unwrap(),
5937 NULL,
5938 );
5939 utils::result(
5940 vips_op_response,
5941 VipsImage { ctx: out_out },
5942 Error::SdfError,
5943 )
5944 }
5945}
5946
5947#[derive(Clone, Debug)]
5949pub struct SdfOptions {
5950 pub r: f64,
5953 pub a: Vec<f64>,
5955 pub b: Vec<f64>,
5957 pub corners: Vec<f64>,
5959}
5960
5961impl std::default::Default for SdfOptions {
5962 fn default() -> Self {
5963 SdfOptions {
5964 r: f64::from(50),
5965 a: Vec::new(),
5966 b: Vec::new(),
5967 corners: Vec::new(),
5968 }
5969 }
5970}
5971
5972pub fn sdf_with_opts(
5986 width: i32,
5987 height: i32,
5988 shape: SdfShape,
5989 sdf_options: &SdfOptions,
5990) -> Result<VipsImage> {
5991 unsafe {
5992 let width_in: i32 = width;
5993 let height_in: i32 = height;
5994 let shape_in: i32 = shape as i32;
5995 let mut out_out: *mut bindings::VipsImage = null_mut();
5996
5997 let r_in: f64 = sdf_options.r;
5998 let r_in_name = utils::new_c_string("r")?;
5999
6000 let a_wrapper = utils::VipsArrayDoubleWrapper::from(&sdf_options.a[..]);
6001 let a_in = a_wrapper.ctx;
6002 let a_in_name = utils::new_c_string("a")?;
6003
6004 let b_wrapper = utils::VipsArrayDoubleWrapper::from(&sdf_options.b[..]);
6005 let b_in = b_wrapper.ctx;
6006 let b_in_name = utils::new_c_string("b")?;
6007
6008 let corners_wrapper = utils::VipsArrayDoubleWrapper::from(&sdf_options.corners[..]);
6009 let corners_in = corners_wrapper.ctx;
6010 let corners_in_name = utils::new_c_string("corners")?;
6011
6012 let vips_op_response = bindings::vips_sdf(
6013 &mut out_out,
6014 width_in,
6015 height_in,
6016 shape_in.try_into().unwrap(),
6017 r_in_name.as_ptr(),
6018 r_in,
6019 a_in_name.as_ptr(),
6020 a_in,
6021 b_in_name.as_ptr(),
6022 b_in,
6023 corners_in_name.as_ptr(),
6024 corners_in,
6025 NULL,
6026 );
6027 utils::result(
6028 vips_op_response,
6029 VipsImage { ctx: out_out },
6030 Error::SdfError,
6031 )
6032 }
6033}
6034
6035pub fn eye(width: i32, height: i32) -> Result<VipsImage> {
6042 unsafe {
6043 let width_in: i32 = width;
6044 let height_in: i32 = height;
6045 let mut out_out: *mut bindings::VipsImage = null_mut();
6046
6047 let vips_op_response = bindings::vips_eye(&mut out_out, width_in, height_in, NULL);
6048 utils::result(
6049 vips_op_response,
6050 VipsImage { ctx: out_out },
6051 Error::EyeError,
6052 )
6053 }
6054}
6055
6056#[derive(Clone, Debug)]
6058pub struct EyeOptions {
6059 pub uchar: bool,
6062 pub factor: f64,
6065}
6066
6067impl std::default::Default for EyeOptions {
6068 fn default() -> Self {
6069 EyeOptions {
6070 uchar: false,
6071 factor: f64::from(0.5),
6072 }
6073 }
6074}
6075
6076pub fn eye_with_opts(width: i32, height: i32, eye_options: &EyeOptions) -> Result<VipsImage> {
6084 unsafe {
6085 let width_in: i32 = width;
6086 let height_in: i32 = height;
6087 let mut out_out: *mut bindings::VipsImage = null_mut();
6088
6089 let uchar_in: i32 = if eye_options.uchar { 1 } else { 0 };
6090 let uchar_in_name = utils::new_c_string("uchar")?;
6091
6092 let factor_in: f64 = eye_options.factor;
6093 let factor_in_name = utils::new_c_string("factor")?;
6094
6095 let vips_op_response = bindings::vips_eye(
6096 &mut out_out,
6097 width_in,
6098 height_in,
6099 uchar_in_name.as_ptr(),
6100 uchar_in,
6101 factor_in_name.as_ptr(),
6102 factor_in,
6103 NULL,
6104 );
6105 utils::result(
6106 vips_op_response,
6107 VipsImage { ctx: out_out },
6108 Error::EyeError,
6109 )
6110 }
6111}
6112
6113pub fn grey(width: i32, height: i32) -> Result<VipsImage> {
6120 unsafe {
6121 let width_in: i32 = width;
6122 let height_in: i32 = height;
6123 let mut out_out: *mut bindings::VipsImage = null_mut();
6124
6125 let vips_op_response = bindings::vips_grey(&mut out_out, width_in, height_in, NULL);
6126 utils::result(
6127 vips_op_response,
6128 VipsImage { ctx: out_out },
6129 Error::GreyError,
6130 )
6131 }
6132}
6133
6134#[derive(Clone, Debug)]
6136pub struct GreyOptions {
6137 pub uchar: bool,
6140}
6141
6142impl std::default::Default for GreyOptions {
6143 fn default() -> Self {
6144 GreyOptions { uchar: false }
6145 }
6146}
6147
6148pub fn grey_with_opts(width: i32, height: i32, grey_options: &GreyOptions) -> Result<VipsImage> {
6156 unsafe {
6157 let width_in: i32 = width;
6158 let height_in: i32 = height;
6159 let mut out_out: *mut bindings::VipsImage = null_mut();
6160
6161 let uchar_in: i32 = if grey_options.uchar { 1 } else { 0 };
6162 let uchar_in_name = utils::new_c_string("uchar")?;
6163
6164 let vips_op_response = bindings::vips_grey(
6165 &mut out_out,
6166 width_in,
6167 height_in,
6168 uchar_in_name.as_ptr(),
6169 uchar_in,
6170 NULL,
6171 );
6172 utils::result(
6173 vips_op_response,
6174 VipsImage { ctx: out_out },
6175 Error::GreyError,
6176 )
6177 }
6178}
6179
6180pub fn zone(width: i32, height: i32) -> Result<VipsImage> {
6187 unsafe {
6188 let width_in: i32 = width;
6189 let height_in: i32 = height;
6190 let mut out_out: *mut bindings::VipsImage = null_mut();
6191
6192 let vips_op_response = bindings::vips_zone(&mut out_out, width_in, height_in, NULL);
6193 utils::result(
6194 vips_op_response,
6195 VipsImage { ctx: out_out },
6196 Error::ZoneError,
6197 )
6198 }
6199}
6200
6201#[derive(Clone, Debug)]
6203pub struct ZoneOptions {
6204 pub uchar: bool,
6207}
6208
6209impl std::default::Default for ZoneOptions {
6210 fn default() -> Self {
6211 ZoneOptions { uchar: false }
6212 }
6213}
6214
6215pub fn zone_with_opts(width: i32, height: i32, zone_options: &ZoneOptions) -> Result<VipsImage> {
6223 unsafe {
6224 let width_in: i32 = width;
6225 let height_in: i32 = height;
6226 let mut out_out: *mut bindings::VipsImage = null_mut();
6227
6228 let uchar_in: i32 = if zone_options.uchar { 1 } else { 0 };
6229 let uchar_in_name = utils::new_c_string("uchar")?;
6230
6231 let vips_op_response = bindings::vips_zone(
6232 &mut out_out,
6233 width_in,
6234 height_in,
6235 uchar_in_name.as_ptr(),
6236 uchar_in,
6237 NULL,
6238 );
6239 utils::result(
6240 vips_op_response,
6241 VipsImage { ctx: out_out },
6242 Error::ZoneError,
6243 )
6244 }
6245}
6246
6247pub fn sines(width: i32, height: i32) -> Result<VipsImage> {
6254 unsafe {
6255 let width_in: i32 = width;
6256 let height_in: i32 = height;
6257 let mut out_out: *mut bindings::VipsImage = null_mut();
6258
6259 let vips_op_response = bindings::vips_sines(&mut out_out, width_in, height_in, NULL);
6260 utils::result(
6261 vips_op_response,
6262 VipsImage { ctx: out_out },
6263 Error::SineError,
6264 )
6265 }
6266}
6267
6268#[derive(Clone, Debug)]
6270pub struct SineOptions {
6271 pub uchar: bool,
6274 pub hfreq: f64,
6277 pub vfreq: f64,
6280}
6281
6282impl std::default::Default for SineOptions {
6283 fn default() -> Self {
6284 SineOptions {
6285 uchar: false,
6286 hfreq: f64::from(0.5),
6287 vfreq: f64::from(0.5),
6288 }
6289 }
6290}
6291
6292pub fn sines_with_opts(width: i32, height: i32, sines_options: &SineOptions) -> Result<VipsImage> {
6300 unsafe {
6301 let width_in: i32 = width;
6302 let height_in: i32 = height;
6303 let mut out_out: *mut bindings::VipsImage = null_mut();
6304
6305 let uchar_in: i32 = if sines_options.uchar { 1 } else { 0 };
6306 let uchar_in_name = utils::new_c_string("uchar")?;
6307
6308 let hfreq_in: f64 = sines_options.hfreq;
6309 let hfreq_in_name = utils::new_c_string("hfreq")?;
6310
6311 let vfreq_in: f64 = sines_options.vfreq;
6312 let vfreq_in_name = utils::new_c_string("vfreq")?;
6313
6314 let vips_op_response = bindings::vips_sines(
6315 &mut out_out,
6316 width_in,
6317 height_in,
6318 uchar_in_name.as_ptr(),
6319 uchar_in,
6320 hfreq_in_name.as_ptr(),
6321 hfreq_in,
6322 vfreq_in_name.as_ptr(),
6323 vfreq_in,
6324 NULL,
6325 );
6326 utils::result(
6327 vips_op_response,
6328 VipsImage { ctx: out_out },
6329 Error::SineError,
6330 )
6331 }
6332}
6333
6334pub fn mask_ideal(width: i32, height: i32, frequency_cutoff: f64) -> Result<VipsImage> {
6343 unsafe {
6344 let width_in: i32 = width;
6345 let height_in: i32 = height;
6346 let frequency_cutoff_in: f64 = frequency_cutoff;
6347 let mut out_out: *mut bindings::VipsImage = null_mut();
6348
6349 let vips_op_response =
6350 bindings::vips_mask_ideal(&mut out_out, width_in, height_in, frequency_cutoff_in, NULL);
6351 utils::result(
6352 vips_op_response,
6353 VipsImage { ctx: out_out },
6354 Error::MaskIdealError,
6355 )
6356 }
6357}
6358
6359#[derive(Clone, Debug)]
6361pub struct MaskIdealOptions {
6362 pub uchar: bool,
6365 pub nodc: bool,
6368 pub reject: bool,
6371 pub optical: bool,
6374}
6375
6376impl std::default::Default for MaskIdealOptions {
6377 fn default() -> Self {
6378 MaskIdealOptions {
6379 uchar: false,
6380 nodc: false,
6381 reject: false,
6382 optical: false,
6383 }
6384 }
6385}
6386
6387pub fn mask_ideal_with_opts(
6397 width: i32,
6398 height: i32,
6399 frequency_cutoff: f64,
6400 mask_ideal_options: &MaskIdealOptions,
6401) -> Result<VipsImage> {
6402 unsafe {
6403 let width_in: i32 = width;
6404 let height_in: i32 = height;
6405 let frequency_cutoff_in: f64 = frequency_cutoff;
6406 let mut out_out: *mut bindings::VipsImage = null_mut();
6407
6408 let uchar_in: i32 = if mask_ideal_options.uchar { 1 } else { 0 };
6409 let uchar_in_name = utils::new_c_string("uchar")?;
6410
6411 let nodc_in: i32 = if mask_ideal_options.nodc { 1 } else { 0 };
6412 let nodc_in_name = utils::new_c_string("nodc")?;
6413
6414 let reject_in: i32 = if mask_ideal_options.reject { 1 } else { 0 };
6415 let reject_in_name = utils::new_c_string("reject")?;
6416
6417 let optical_in: i32 = if mask_ideal_options.optical { 1 } else { 0 };
6418 let optical_in_name = utils::new_c_string("optical")?;
6419
6420 let vips_op_response = bindings::vips_mask_ideal(
6421 &mut out_out,
6422 width_in,
6423 height_in,
6424 frequency_cutoff_in,
6425 uchar_in_name.as_ptr(),
6426 uchar_in,
6427 nodc_in_name.as_ptr(),
6428 nodc_in,
6429 reject_in_name.as_ptr(),
6430 reject_in,
6431 optical_in_name.as_ptr(),
6432 optical_in,
6433 NULL,
6434 );
6435 utils::result(
6436 vips_op_response,
6437 VipsImage { ctx: out_out },
6438 Error::MaskIdealError,
6439 )
6440 }
6441}
6442
6443pub fn mask_ideal_ring(
6454 width: i32,
6455 height: i32,
6456 frequency_cutoff: f64,
6457 ringwidth: f64,
6458) -> Result<VipsImage> {
6459 unsafe {
6460 let width_in: i32 = width;
6461 let height_in: i32 = height;
6462 let frequency_cutoff_in: f64 = frequency_cutoff;
6463 let ringwidth_in: f64 = ringwidth;
6464 let mut out_out: *mut bindings::VipsImage = null_mut();
6465
6466 let vips_op_response = bindings::vips_mask_ideal_ring(
6467 &mut out_out,
6468 width_in,
6469 height_in,
6470 frequency_cutoff_in,
6471 ringwidth_in,
6472 NULL,
6473 );
6474 utils::result(
6475 vips_op_response,
6476 VipsImage { ctx: out_out },
6477 Error::MaskIdealRingError,
6478 )
6479 }
6480}
6481
6482#[derive(Clone, Debug)]
6484pub struct MaskIdealRingOptions {
6485 pub uchar: bool,
6488 pub nodc: bool,
6491 pub reject: bool,
6494 pub optical: bool,
6497}
6498
6499impl std::default::Default for MaskIdealRingOptions {
6500 fn default() -> Self {
6501 MaskIdealRingOptions {
6502 uchar: false,
6503 nodc: false,
6504 reject: false,
6505 optical: false,
6506 }
6507 }
6508}
6509
6510pub fn mask_ideal_ring_with_opts(
6522 width: i32,
6523 height: i32,
6524 frequency_cutoff: f64,
6525 ringwidth: f64,
6526 mask_ideal_ring_options: &MaskIdealRingOptions,
6527) -> Result<VipsImage> {
6528 unsafe {
6529 let width_in: i32 = width;
6530 let height_in: i32 = height;
6531 let frequency_cutoff_in: f64 = frequency_cutoff;
6532 let ringwidth_in: f64 = ringwidth;
6533 let mut out_out: *mut bindings::VipsImage = null_mut();
6534
6535 let uchar_in: i32 = if mask_ideal_ring_options.uchar { 1 } else { 0 };
6536 let uchar_in_name = utils::new_c_string("uchar")?;
6537
6538 let nodc_in: i32 = if mask_ideal_ring_options.nodc { 1 } else { 0 };
6539 let nodc_in_name = utils::new_c_string("nodc")?;
6540
6541 let reject_in: i32 = if mask_ideal_ring_options.reject { 1 } else { 0 };
6542 let reject_in_name = utils::new_c_string("reject")?;
6543
6544 let optical_in: i32 = if mask_ideal_ring_options.optical {
6545 1
6546 } else {
6547 0
6548 };
6549 let optical_in_name = utils::new_c_string("optical")?;
6550
6551 let vips_op_response = bindings::vips_mask_ideal_ring(
6552 &mut out_out,
6553 width_in,
6554 height_in,
6555 frequency_cutoff_in,
6556 ringwidth_in,
6557 uchar_in_name.as_ptr(),
6558 uchar_in,
6559 nodc_in_name.as_ptr(),
6560 nodc_in,
6561 reject_in_name.as_ptr(),
6562 reject_in,
6563 optical_in_name.as_ptr(),
6564 optical_in,
6565 NULL,
6566 );
6567 utils::result(
6568 vips_op_response,
6569 VipsImage { ctx: out_out },
6570 Error::MaskIdealRingError,
6571 )
6572 }
6573}
6574
6575pub fn mask_ideal_band(
6588 width: i32,
6589 height: i32,
6590 frequency_cutoff_x: f64,
6591 frequency_cutoff_y: f64,
6592 radius: f64,
6593) -> Result<VipsImage> {
6594 unsafe {
6595 let width_in: i32 = width;
6596 let height_in: i32 = height;
6597 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
6598 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
6599 let radius_in: f64 = radius;
6600 let mut out_out: *mut bindings::VipsImage = null_mut();
6601
6602 let vips_op_response = bindings::vips_mask_ideal_band(
6603 &mut out_out,
6604 width_in,
6605 height_in,
6606 frequency_cutoff_x_in,
6607 frequency_cutoff_y_in,
6608 radius_in,
6609 NULL,
6610 );
6611 utils::result(
6612 vips_op_response,
6613 VipsImage { ctx: out_out },
6614 Error::MaskIdealBandError,
6615 )
6616 }
6617}
6618
6619#[derive(Clone, Debug)]
6621pub struct MaskIdealBandOptions {
6622 pub uchar: bool,
6625 pub nodc: bool,
6628 pub reject: bool,
6631 pub optical: bool,
6634}
6635
6636impl std::default::Default for MaskIdealBandOptions {
6637 fn default() -> Self {
6638 MaskIdealBandOptions {
6639 uchar: false,
6640 nodc: false,
6641 reject: false,
6642 optical: false,
6643 }
6644 }
6645}
6646
6647pub fn mask_ideal_band_with_opts(
6661 width: i32,
6662 height: i32,
6663 frequency_cutoff_x: f64,
6664 frequency_cutoff_y: f64,
6665 radius: f64,
6666 mask_ideal_band_options: &MaskIdealBandOptions,
6667) -> Result<VipsImage> {
6668 unsafe {
6669 let width_in: i32 = width;
6670 let height_in: i32 = height;
6671 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
6672 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
6673 let radius_in: f64 = radius;
6674 let mut out_out: *mut bindings::VipsImage = null_mut();
6675
6676 let uchar_in: i32 = if mask_ideal_band_options.uchar { 1 } else { 0 };
6677 let uchar_in_name = utils::new_c_string("uchar")?;
6678
6679 let nodc_in: i32 = if mask_ideal_band_options.nodc { 1 } else { 0 };
6680 let nodc_in_name = utils::new_c_string("nodc")?;
6681
6682 let reject_in: i32 = if mask_ideal_band_options.reject { 1 } else { 0 };
6683 let reject_in_name = utils::new_c_string("reject")?;
6684
6685 let optical_in: i32 = if mask_ideal_band_options.optical {
6686 1
6687 } else {
6688 0
6689 };
6690 let optical_in_name = utils::new_c_string("optical")?;
6691
6692 let vips_op_response = bindings::vips_mask_ideal_band(
6693 &mut out_out,
6694 width_in,
6695 height_in,
6696 frequency_cutoff_x_in,
6697 frequency_cutoff_y_in,
6698 radius_in,
6699 uchar_in_name.as_ptr(),
6700 uchar_in,
6701 nodc_in_name.as_ptr(),
6702 nodc_in,
6703 reject_in_name.as_ptr(),
6704 reject_in,
6705 optical_in_name.as_ptr(),
6706 optical_in,
6707 NULL,
6708 );
6709 utils::result(
6710 vips_op_response,
6711 VipsImage { ctx: out_out },
6712 Error::MaskIdealBandError,
6713 )
6714 }
6715}
6716
6717pub fn mask_butterworth(
6730 width: i32,
6731 height: i32,
6732 order: f64,
6733 frequency_cutoff: f64,
6734 amplitude_cutoff: f64,
6735) -> Result<VipsImage> {
6736 unsafe {
6737 let width_in: i32 = width;
6738 let height_in: i32 = height;
6739 let order_in: f64 = order;
6740 let frequency_cutoff_in: f64 = frequency_cutoff;
6741 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6742 let mut out_out: *mut bindings::VipsImage = null_mut();
6743
6744 let vips_op_response = bindings::vips_mask_butterworth(
6745 &mut out_out,
6746 width_in,
6747 height_in,
6748 order_in,
6749 frequency_cutoff_in,
6750 amplitude_cutoff_in,
6751 NULL,
6752 );
6753 utils::result(
6754 vips_op_response,
6755 VipsImage { ctx: out_out },
6756 Error::MaskButterworthError,
6757 )
6758 }
6759}
6760
6761#[derive(Clone, Debug)]
6763pub struct MaskButterworthOptions {
6764 pub uchar: bool,
6767 pub nodc: bool,
6770 pub reject: bool,
6773 pub optical: bool,
6776}
6777
6778impl std::default::Default for MaskButterworthOptions {
6779 fn default() -> Self {
6780 MaskButterworthOptions {
6781 uchar: false,
6782 nodc: false,
6783 reject: false,
6784 optical: false,
6785 }
6786 }
6787}
6788
6789pub fn mask_butterworth_with_opts(
6803 width: i32,
6804 height: i32,
6805 order: f64,
6806 frequency_cutoff: f64,
6807 amplitude_cutoff: f64,
6808 mask_butterworth_options: &MaskButterworthOptions,
6809) -> Result<VipsImage> {
6810 unsafe {
6811 let width_in: i32 = width;
6812 let height_in: i32 = height;
6813 let order_in: f64 = order;
6814 let frequency_cutoff_in: f64 = frequency_cutoff;
6815 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6816 let mut out_out: *mut bindings::VipsImage = null_mut();
6817
6818 let uchar_in: i32 = if mask_butterworth_options.uchar { 1 } else { 0 };
6819 let uchar_in_name = utils::new_c_string("uchar")?;
6820
6821 let nodc_in: i32 = if mask_butterworth_options.nodc { 1 } else { 0 };
6822 let nodc_in_name = utils::new_c_string("nodc")?;
6823
6824 let reject_in: i32 = if mask_butterworth_options.reject {
6825 1
6826 } else {
6827 0
6828 };
6829 let reject_in_name = utils::new_c_string("reject")?;
6830
6831 let optical_in: i32 = if mask_butterworth_options.optical {
6832 1
6833 } else {
6834 0
6835 };
6836 let optical_in_name = utils::new_c_string("optical")?;
6837
6838 let vips_op_response = bindings::vips_mask_butterworth(
6839 &mut out_out,
6840 width_in,
6841 height_in,
6842 order_in,
6843 frequency_cutoff_in,
6844 amplitude_cutoff_in,
6845 uchar_in_name.as_ptr(),
6846 uchar_in,
6847 nodc_in_name.as_ptr(),
6848 nodc_in,
6849 reject_in_name.as_ptr(),
6850 reject_in,
6851 optical_in_name.as_ptr(),
6852 optical_in,
6853 NULL,
6854 );
6855 utils::result(
6856 vips_op_response,
6857 VipsImage { ctx: out_out },
6858 Error::MaskButterworthError,
6859 )
6860 }
6861}
6862
6863pub fn mask_butterworth_ring(
6878 width: i32,
6879 height: i32,
6880 order: f64,
6881 frequency_cutoff: f64,
6882 amplitude_cutoff: f64,
6883 ringwidth: f64,
6884) -> Result<VipsImage> {
6885 unsafe {
6886 let width_in: i32 = width;
6887 let height_in: i32 = height;
6888 let order_in: f64 = order;
6889 let frequency_cutoff_in: f64 = frequency_cutoff;
6890 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6891 let ringwidth_in: f64 = ringwidth;
6892 let mut out_out: *mut bindings::VipsImage = null_mut();
6893
6894 let vips_op_response = bindings::vips_mask_butterworth_ring(
6895 &mut out_out,
6896 width_in,
6897 height_in,
6898 order_in,
6899 frequency_cutoff_in,
6900 amplitude_cutoff_in,
6901 ringwidth_in,
6902 NULL,
6903 );
6904 utils::result(
6905 vips_op_response,
6906 VipsImage { ctx: out_out },
6907 Error::MaskButterworthRingError,
6908 )
6909 }
6910}
6911
6912#[derive(Clone, Debug)]
6914pub struct MaskButterworthRingOptions {
6915 pub uchar: bool,
6918 pub nodc: bool,
6921 pub reject: bool,
6924 pub optical: bool,
6927}
6928
6929impl std::default::Default for MaskButterworthRingOptions {
6930 fn default() -> Self {
6931 MaskButterworthRingOptions {
6932 uchar: false,
6933 nodc: false,
6934 reject: false,
6935 optical: false,
6936 }
6937 }
6938}
6939
6940pub fn mask_butterworth_ring_with_opts(
6956 width: i32,
6957 height: i32,
6958 order: f64,
6959 frequency_cutoff: f64,
6960 amplitude_cutoff: f64,
6961 ringwidth: f64,
6962 mask_butterworth_ring_options: &MaskButterworthRingOptions,
6963) -> Result<VipsImage> {
6964 unsafe {
6965 let width_in: i32 = width;
6966 let height_in: i32 = height;
6967 let order_in: f64 = order;
6968 let frequency_cutoff_in: f64 = frequency_cutoff;
6969 let amplitude_cutoff_in: f64 = amplitude_cutoff;
6970 let ringwidth_in: f64 = ringwidth;
6971 let mut out_out: *mut bindings::VipsImage = null_mut();
6972
6973 let uchar_in: i32 = if mask_butterworth_ring_options.uchar {
6974 1
6975 } else {
6976 0
6977 };
6978 let uchar_in_name = utils::new_c_string("uchar")?;
6979
6980 let nodc_in: i32 = if mask_butterworth_ring_options.nodc {
6981 1
6982 } else {
6983 0
6984 };
6985 let nodc_in_name = utils::new_c_string("nodc")?;
6986
6987 let reject_in: i32 = if mask_butterworth_ring_options.reject {
6988 1
6989 } else {
6990 0
6991 };
6992 let reject_in_name = utils::new_c_string("reject")?;
6993
6994 let optical_in: i32 = if mask_butterworth_ring_options.optical {
6995 1
6996 } else {
6997 0
6998 };
6999 let optical_in_name = utils::new_c_string("optical")?;
7000
7001 let vips_op_response = bindings::vips_mask_butterworth_ring(
7002 &mut out_out,
7003 width_in,
7004 height_in,
7005 order_in,
7006 frequency_cutoff_in,
7007 amplitude_cutoff_in,
7008 ringwidth_in,
7009 uchar_in_name.as_ptr(),
7010 uchar_in,
7011 nodc_in_name.as_ptr(),
7012 nodc_in,
7013 reject_in_name.as_ptr(),
7014 reject_in,
7015 optical_in_name.as_ptr(),
7016 optical_in,
7017 NULL,
7018 );
7019 utils::result(
7020 vips_op_response,
7021 VipsImage { ctx: out_out },
7022 Error::MaskButterworthRingError,
7023 )
7024 }
7025}
7026
7027pub fn mask_butterworth_band(
7044 width: i32,
7045 height: i32,
7046 order: f64,
7047 frequency_cutoff_x: f64,
7048 frequency_cutoff_y: f64,
7049 radius: f64,
7050 amplitude_cutoff: f64,
7051) -> Result<VipsImage> {
7052 unsafe {
7053 let width_in: i32 = width;
7054 let height_in: i32 = height;
7055 let order_in: f64 = order;
7056 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7057 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7058 let radius_in: f64 = radius;
7059 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7060 let mut out_out: *mut bindings::VipsImage = null_mut();
7061
7062 let vips_op_response = bindings::vips_mask_butterworth_band(
7063 &mut out_out,
7064 width_in,
7065 height_in,
7066 order_in,
7067 frequency_cutoff_x_in,
7068 frequency_cutoff_y_in,
7069 radius_in,
7070 amplitude_cutoff_in,
7071 NULL,
7072 );
7073 utils::result(
7074 vips_op_response,
7075 VipsImage { ctx: out_out },
7076 Error::MaskButterworthBandError,
7077 )
7078 }
7079}
7080
7081#[derive(Clone, Debug)]
7083pub struct MaskButterworthBandOptions {
7084 pub uchar: bool,
7087 pub nodc: bool,
7090 pub reject: bool,
7093 pub optical: bool,
7096}
7097
7098impl std::default::Default for MaskButterworthBandOptions {
7099 fn default() -> Self {
7100 MaskButterworthBandOptions {
7101 uchar: false,
7102 nodc: false,
7103 reject: false,
7104 optical: false,
7105 }
7106 }
7107}
7108
7109pub fn mask_butterworth_band_with_opts(
7127 width: i32,
7128 height: i32,
7129 order: f64,
7130 frequency_cutoff_x: f64,
7131 frequency_cutoff_y: f64,
7132 radius: f64,
7133 amplitude_cutoff: f64,
7134 mask_butterworth_band_options: &MaskButterworthBandOptions,
7135) -> Result<VipsImage> {
7136 unsafe {
7137 let width_in: i32 = width;
7138 let height_in: i32 = height;
7139 let order_in: f64 = order;
7140 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7141 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7142 let radius_in: f64 = radius;
7143 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7144 let mut out_out: *mut bindings::VipsImage = null_mut();
7145
7146 let uchar_in: i32 = if mask_butterworth_band_options.uchar {
7147 1
7148 } else {
7149 0
7150 };
7151 let uchar_in_name = utils::new_c_string("uchar")?;
7152
7153 let nodc_in: i32 = if mask_butterworth_band_options.nodc {
7154 1
7155 } else {
7156 0
7157 };
7158 let nodc_in_name = utils::new_c_string("nodc")?;
7159
7160 let reject_in: i32 = if mask_butterworth_band_options.reject {
7161 1
7162 } else {
7163 0
7164 };
7165 let reject_in_name = utils::new_c_string("reject")?;
7166
7167 let optical_in: i32 = if mask_butterworth_band_options.optical {
7168 1
7169 } else {
7170 0
7171 };
7172 let optical_in_name = utils::new_c_string("optical")?;
7173
7174 let vips_op_response = bindings::vips_mask_butterworth_band(
7175 &mut out_out,
7176 width_in,
7177 height_in,
7178 order_in,
7179 frequency_cutoff_x_in,
7180 frequency_cutoff_y_in,
7181 radius_in,
7182 amplitude_cutoff_in,
7183 uchar_in_name.as_ptr(),
7184 uchar_in,
7185 nodc_in_name.as_ptr(),
7186 nodc_in,
7187 reject_in_name.as_ptr(),
7188 reject_in,
7189 optical_in_name.as_ptr(),
7190 optical_in,
7191 NULL,
7192 );
7193 utils::result(
7194 vips_op_response,
7195 VipsImage { ctx: out_out },
7196 Error::MaskButterworthBandError,
7197 )
7198 }
7199}
7200
7201pub fn mask_gaussian(
7212 width: i32,
7213 height: i32,
7214 frequency_cutoff: f64,
7215 amplitude_cutoff: f64,
7216) -> Result<VipsImage> {
7217 unsafe {
7218 let width_in: i32 = width;
7219 let height_in: i32 = height;
7220 let frequency_cutoff_in: f64 = frequency_cutoff;
7221 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7222 let mut out_out: *mut bindings::VipsImage = null_mut();
7223
7224 let vips_op_response = bindings::vips_mask_gaussian(
7225 &mut out_out,
7226 width_in,
7227 height_in,
7228 frequency_cutoff_in,
7229 amplitude_cutoff_in,
7230 NULL,
7231 );
7232 utils::result(
7233 vips_op_response,
7234 VipsImage { ctx: out_out },
7235 Error::MaskGaussianError,
7236 )
7237 }
7238}
7239
7240#[derive(Clone, Debug)]
7242pub struct MaskGaussianOptions {
7243 pub uchar: bool,
7246 pub nodc: bool,
7249 pub reject: bool,
7252 pub optical: bool,
7255}
7256
7257impl std::default::Default for MaskGaussianOptions {
7258 fn default() -> Self {
7259 MaskGaussianOptions {
7260 uchar: false,
7261 nodc: false,
7262 reject: false,
7263 optical: false,
7264 }
7265 }
7266}
7267
7268pub fn mask_gaussian_with_opts(
7280 width: i32,
7281 height: i32,
7282 frequency_cutoff: f64,
7283 amplitude_cutoff: f64,
7284 mask_gaussian_options: &MaskGaussianOptions,
7285) -> Result<VipsImage> {
7286 unsafe {
7287 let width_in: i32 = width;
7288 let height_in: i32 = height;
7289 let frequency_cutoff_in: f64 = frequency_cutoff;
7290 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7291 let mut out_out: *mut bindings::VipsImage = null_mut();
7292
7293 let uchar_in: i32 = if mask_gaussian_options.uchar { 1 } else { 0 };
7294 let uchar_in_name = utils::new_c_string("uchar")?;
7295
7296 let nodc_in: i32 = if mask_gaussian_options.nodc { 1 } else { 0 };
7297 let nodc_in_name = utils::new_c_string("nodc")?;
7298
7299 let reject_in: i32 = if mask_gaussian_options.reject { 1 } else { 0 };
7300 let reject_in_name = utils::new_c_string("reject")?;
7301
7302 let optical_in: i32 = if mask_gaussian_options.optical { 1 } else { 0 };
7303 let optical_in_name = utils::new_c_string("optical")?;
7304
7305 let vips_op_response = bindings::vips_mask_gaussian(
7306 &mut out_out,
7307 width_in,
7308 height_in,
7309 frequency_cutoff_in,
7310 amplitude_cutoff_in,
7311 uchar_in_name.as_ptr(),
7312 uchar_in,
7313 nodc_in_name.as_ptr(),
7314 nodc_in,
7315 reject_in_name.as_ptr(),
7316 reject_in,
7317 optical_in_name.as_ptr(),
7318 optical_in,
7319 NULL,
7320 );
7321 utils::result(
7322 vips_op_response,
7323 VipsImage { ctx: out_out },
7324 Error::MaskGaussianError,
7325 )
7326 }
7327}
7328
7329pub fn mask_gaussian_ring(
7342 width: i32,
7343 height: i32,
7344 frequency_cutoff: f64,
7345 amplitude_cutoff: f64,
7346 ringwidth: f64,
7347) -> Result<VipsImage> {
7348 unsafe {
7349 let width_in: i32 = width;
7350 let height_in: i32 = height;
7351 let frequency_cutoff_in: f64 = frequency_cutoff;
7352 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7353 let ringwidth_in: f64 = ringwidth;
7354 let mut out_out: *mut bindings::VipsImage = null_mut();
7355
7356 let vips_op_response = bindings::vips_mask_gaussian_ring(
7357 &mut out_out,
7358 width_in,
7359 height_in,
7360 frequency_cutoff_in,
7361 amplitude_cutoff_in,
7362 ringwidth_in,
7363 NULL,
7364 );
7365 utils::result(
7366 vips_op_response,
7367 VipsImage { ctx: out_out },
7368 Error::MaskGaussianRingError,
7369 )
7370 }
7371}
7372
7373#[derive(Clone, Debug)]
7375pub struct MaskGaussianRingOptions {
7376 pub uchar: bool,
7379 pub nodc: bool,
7382 pub reject: bool,
7385 pub optical: bool,
7388}
7389
7390impl std::default::Default for MaskGaussianRingOptions {
7391 fn default() -> Self {
7392 MaskGaussianRingOptions {
7393 uchar: false,
7394 nodc: false,
7395 reject: false,
7396 optical: false,
7397 }
7398 }
7399}
7400
7401pub fn mask_gaussian_ring_with_opts(
7415 width: i32,
7416 height: i32,
7417 frequency_cutoff: f64,
7418 amplitude_cutoff: f64,
7419 ringwidth: f64,
7420 mask_gaussian_ring_options: &MaskGaussianRingOptions,
7421) -> Result<VipsImage> {
7422 unsafe {
7423 let width_in: i32 = width;
7424 let height_in: i32 = height;
7425 let frequency_cutoff_in: f64 = frequency_cutoff;
7426 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7427 let ringwidth_in: f64 = ringwidth;
7428 let mut out_out: *mut bindings::VipsImage = null_mut();
7429
7430 let uchar_in: i32 = if mask_gaussian_ring_options.uchar {
7431 1
7432 } else {
7433 0
7434 };
7435 let uchar_in_name = utils::new_c_string("uchar")?;
7436
7437 let nodc_in: i32 = if mask_gaussian_ring_options.nodc {
7438 1
7439 } else {
7440 0
7441 };
7442 let nodc_in_name = utils::new_c_string("nodc")?;
7443
7444 let reject_in: i32 = if mask_gaussian_ring_options.reject {
7445 1
7446 } else {
7447 0
7448 };
7449 let reject_in_name = utils::new_c_string("reject")?;
7450
7451 let optical_in: i32 = if mask_gaussian_ring_options.optical {
7452 1
7453 } else {
7454 0
7455 };
7456 let optical_in_name = utils::new_c_string("optical")?;
7457
7458 let vips_op_response = bindings::vips_mask_gaussian_ring(
7459 &mut out_out,
7460 width_in,
7461 height_in,
7462 frequency_cutoff_in,
7463 amplitude_cutoff_in,
7464 ringwidth_in,
7465 uchar_in_name.as_ptr(),
7466 uchar_in,
7467 nodc_in_name.as_ptr(),
7468 nodc_in,
7469 reject_in_name.as_ptr(),
7470 reject_in,
7471 optical_in_name.as_ptr(),
7472 optical_in,
7473 NULL,
7474 );
7475 utils::result(
7476 vips_op_response,
7477 VipsImage { ctx: out_out },
7478 Error::MaskGaussianRingError,
7479 )
7480 }
7481}
7482
7483pub fn mask_gaussian_band(
7498 width: i32,
7499 height: i32,
7500 frequency_cutoff_x: f64,
7501 frequency_cutoff_y: f64,
7502 radius: f64,
7503 amplitude_cutoff: f64,
7504) -> Result<VipsImage> {
7505 unsafe {
7506 let width_in: i32 = width;
7507 let height_in: i32 = height;
7508 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7509 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7510 let radius_in: f64 = radius;
7511 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7512 let mut out_out: *mut bindings::VipsImage = null_mut();
7513
7514 let vips_op_response = bindings::vips_mask_gaussian_band(
7515 &mut out_out,
7516 width_in,
7517 height_in,
7518 frequency_cutoff_x_in,
7519 frequency_cutoff_y_in,
7520 radius_in,
7521 amplitude_cutoff_in,
7522 NULL,
7523 );
7524 utils::result(
7525 vips_op_response,
7526 VipsImage { ctx: out_out },
7527 Error::MaskGaussianBandError,
7528 )
7529 }
7530}
7531
7532#[derive(Clone, Debug)]
7534pub struct MaskGaussianBandOptions {
7535 pub uchar: bool,
7538 pub nodc: bool,
7541 pub reject: bool,
7544 pub optical: bool,
7547}
7548
7549impl std::default::Default for MaskGaussianBandOptions {
7550 fn default() -> Self {
7551 MaskGaussianBandOptions {
7552 uchar: false,
7553 nodc: false,
7554 reject: false,
7555 optical: false,
7556 }
7557 }
7558}
7559
7560pub fn mask_gaussian_band_with_opts(
7576 width: i32,
7577 height: i32,
7578 frequency_cutoff_x: f64,
7579 frequency_cutoff_y: f64,
7580 radius: f64,
7581 amplitude_cutoff: f64,
7582 mask_gaussian_band_options: &MaskGaussianBandOptions,
7583) -> Result<VipsImage> {
7584 unsafe {
7585 let width_in: i32 = width;
7586 let height_in: i32 = height;
7587 let frequency_cutoff_x_in: f64 = frequency_cutoff_x;
7588 let frequency_cutoff_y_in: f64 = frequency_cutoff_y;
7589 let radius_in: f64 = radius;
7590 let amplitude_cutoff_in: f64 = amplitude_cutoff;
7591 let mut out_out: *mut bindings::VipsImage = null_mut();
7592
7593 let uchar_in: i32 = if mask_gaussian_band_options.uchar {
7594 1
7595 } else {
7596 0
7597 };
7598 let uchar_in_name = utils::new_c_string("uchar")?;
7599
7600 let nodc_in: i32 = if mask_gaussian_band_options.nodc {
7601 1
7602 } else {
7603 0
7604 };
7605 let nodc_in_name = utils::new_c_string("nodc")?;
7606
7607 let reject_in: i32 = if mask_gaussian_band_options.reject {
7608 1
7609 } else {
7610 0
7611 };
7612 let reject_in_name = utils::new_c_string("reject")?;
7613
7614 let optical_in: i32 = if mask_gaussian_band_options.optical {
7615 1
7616 } else {
7617 0
7618 };
7619 let optical_in_name = utils::new_c_string("optical")?;
7620
7621 let vips_op_response = bindings::vips_mask_gaussian_band(
7622 &mut out_out,
7623 width_in,
7624 height_in,
7625 frequency_cutoff_x_in,
7626 frequency_cutoff_y_in,
7627 radius_in,
7628 amplitude_cutoff_in,
7629 uchar_in_name.as_ptr(),
7630 uchar_in,
7631 nodc_in_name.as_ptr(),
7632 nodc_in,
7633 reject_in_name.as_ptr(),
7634 reject_in,
7635 optical_in_name.as_ptr(),
7636 optical_in,
7637 NULL,
7638 );
7639 utils::result(
7640 vips_op_response,
7641 VipsImage { ctx: out_out },
7642 Error::MaskGaussianBandError,
7643 )
7644 }
7645}
7646
7647pub fn mask_fractal(width: i32, height: i32, fractal_dimension: f64) -> Result<VipsImage> {
7656 unsafe {
7657 let width_in: i32 = width;
7658 let height_in: i32 = height;
7659 let fractal_dimension_in: f64 = fractal_dimension;
7660 let mut out_out: *mut bindings::VipsImage = null_mut();
7661
7662 let vips_op_response = bindings::vips_mask_fractal(
7663 &mut out_out,
7664 width_in,
7665 height_in,
7666 fractal_dimension_in,
7667 NULL,
7668 );
7669 utils::result(
7670 vips_op_response,
7671 VipsImage { ctx: out_out },
7672 Error::MaskFractalError,
7673 )
7674 }
7675}
7676
7677#[derive(Clone, Debug)]
7679pub struct MaskFractalOptions {
7680 pub uchar: bool,
7683 pub nodc: bool,
7686 pub reject: bool,
7689 pub optical: bool,
7692}
7693
7694impl std::default::Default for MaskFractalOptions {
7695 fn default() -> Self {
7696 MaskFractalOptions {
7697 uchar: false,
7698 nodc: false,
7699 reject: false,
7700 optical: false,
7701 }
7702 }
7703}
7704
7705pub fn mask_fractal_with_opts(
7715 width: i32,
7716 height: i32,
7717 fractal_dimension: f64,
7718 mask_fractal_options: &MaskFractalOptions,
7719) -> Result<VipsImage> {
7720 unsafe {
7721 let width_in: i32 = width;
7722 let height_in: i32 = height;
7723 let fractal_dimension_in: f64 = fractal_dimension;
7724 let mut out_out: *mut bindings::VipsImage = null_mut();
7725
7726 let uchar_in: i32 = if mask_fractal_options.uchar { 1 } else { 0 };
7727 let uchar_in_name = utils::new_c_string("uchar")?;
7728
7729 let nodc_in: i32 = if mask_fractal_options.nodc { 1 } else { 0 };
7730 let nodc_in_name = utils::new_c_string("nodc")?;
7731
7732 let reject_in: i32 = if mask_fractal_options.reject { 1 } else { 0 };
7733 let reject_in_name = utils::new_c_string("reject")?;
7734
7735 let optical_in: i32 = if mask_fractal_options.optical { 1 } else { 0 };
7736 let optical_in_name = utils::new_c_string("optical")?;
7737
7738 let vips_op_response = bindings::vips_mask_fractal(
7739 &mut out_out,
7740 width_in,
7741 height_in,
7742 fractal_dimension_in,
7743 uchar_in_name.as_ptr(),
7744 uchar_in,
7745 nodc_in_name.as_ptr(),
7746 nodc_in,
7747 reject_in_name.as_ptr(),
7748 reject_in,
7749 optical_in_name.as_ptr(),
7750 optical_in,
7751 NULL,
7752 );
7753 utils::result(
7754 vips_op_response,
7755 VipsImage { ctx: out_out },
7756 Error::MaskFractalError,
7757 )
7758 }
7759}
7760
7761pub fn buildlut(inp: &VipsImage) -> Result<VipsImage> {
7765 unsafe {
7766 let inp_in: *mut bindings::VipsImage = inp.ctx;
7767 let mut out_out: *mut bindings::VipsImage = null_mut();
7768
7769 let vips_op_response = bindings::vips_buildlut(inp_in, &mut out_out, NULL);
7770 utils::result(
7771 vips_op_response,
7772 VipsImage { ctx: out_out },
7773 Error::BuildlutError,
7774 )
7775 }
7776}
7777
7778pub fn invertlut(inp: &VipsImage) -> Result<VipsImage> {
7782 unsafe {
7783 let inp_in: *mut bindings::VipsImage = inp.ctx;
7784 let mut out_out: *mut bindings::VipsImage = null_mut();
7785
7786 let vips_op_response = bindings::vips_invertlut(inp_in, &mut out_out, NULL);
7787 utils::result(
7788 vips_op_response,
7789 VipsImage { ctx: out_out },
7790 Error::InvertlutError,
7791 )
7792 }
7793}
7794
7795#[derive(Clone, Debug)]
7797pub struct InvertlutOptions {
7798 pub size: i32,
7801}
7802
7803impl std::default::Default for InvertlutOptions {
7804 fn default() -> Self {
7805 InvertlutOptions {
7806 size: i32::from(256),
7807 }
7808 }
7809}
7810
7811pub fn invertlut_with_opts(
7816 inp: &VipsImage,
7817 invertlut_options: &InvertlutOptions,
7818) -> Result<VipsImage> {
7819 unsafe {
7820 let inp_in: *mut bindings::VipsImage = inp.ctx;
7821 let mut out_out: *mut bindings::VipsImage = null_mut();
7822
7823 let size_in: i32 = invertlut_options.size;
7824 let size_in_name = utils::new_c_string("size")?;
7825
7826 let vips_op_response =
7827 bindings::vips_invertlut(inp_in, &mut out_out, size_in_name.as_ptr(), size_in, NULL);
7828 utils::result(
7829 vips_op_response,
7830 VipsImage { ctx: out_out },
7831 Error::InvertlutError,
7832 )
7833 }
7834}
7835
7836pub fn tonelut() -> Result<VipsImage> {
7840 unsafe {
7841 let mut out_out: *mut bindings::VipsImage = null_mut();
7842
7843 let vips_op_response = bindings::vips_tonelut(&mut out_out, NULL);
7844 utils::result(
7845 vips_op_response,
7846 VipsImage { ctx: out_out },
7847 Error::TonelutError,
7848 )
7849 }
7850}
7851
7852#[derive(Clone, Debug)]
7854pub struct TonelutOptions {
7855 pub in_max: i32,
7858 pub out_max: i32,
7861 pub lb: f64,
7864 pub lw: f64,
7867 pub ps: f64,
7870 pub pm: f64,
7873 pub ph: f64,
7876 pub s: f64,
7879 pub m: f64,
7882 pub h: f64,
7885}
7886
7887impl std::default::Default for TonelutOptions {
7888 fn default() -> Self {
7889 TonelutOptions {
7890 in_max: i32::from(32767),
7891 out_max: i32::from(32767),
7892 lb: f64::from(0),
7893 lw: f64::from(100),
7894 ps: f64::from(0.2),
7895 pm: f64::from(0.5),
7896 ph: f64::from(0.8),
7897 s: f64::from(0),
7898 m: f64::from(0),
7899 h: f64::from(0),
7900 }
7901 }
7902}
7903
7904pub fn tonelut_with_opts(tonelut_options: &TonelutOptions) -> Result<VipsImage> {
7909 unsafe {
7910 let mut out_out: *mut bindings::VipsImage = null_mut();
7911
7912 let in_max_in: i32 = tonelut_options.in_max;
7913 let in_max_in_name = utils::new_c_string("in-max")?;
7914
7915 let out_max_in: i32 = tonelut_options.out_max;
7916 let out_max_in_name = utils::new_c_string("out-max")?;
7917
7918 let lb_in: f64 = tonelut_options.lb;
7919 let lb_in_name = utils::new_c_string("Lb")?;
7920
7921 let lw_in: f64 = tonelut_options.lw;
7922 let lw_in_name = utils::new_c_string("Lw")?;
7923
7924 let ps_in: f64 = tonelut_options.ps;
7925 let ps_in_name = utils::new_c_string("Ps")?;
7926
7927 let pm_in: f64 = tonelut_options.pm;
7928 let pm_in_name = utils::new_c_string("Pm")?;
7929
7930 let ph_in: f64 = tonelut_options.ph;
7931 let ph_in_name = utils::new_c_string("Ph")?;
7932
7933 let s_in: f64 = tonelut_options.s;
7934 let s_in_name = utils::new_c_string("S")?;
7935
7936 let m_in: f64 = tonelut_options.m;
7937 let m_in_name = utils::new_c_string("M")?;
7938
7939 let h_in: f64 = tonelut_options.h;
7940 let h_in_name = utils::new_c_string("H")?;
7941
7942 let vips_op_response = bindings::vips_tonelut(
7943 &mut out_out,
7944 in_max_in_name.as_ptr(),
7945 in_max_in,
7946 out_max_in_name.as_ptr(),
7947 out_max_in,
7948 lb_in_name.as_ptr(),
7949 lb_in,
7950 lw_in_name.as_ptr(),
7951 lw_in,
7952 ps_in_name.as_ptr(),
7953 ps_in,
7954 pm_in_name.as_ptr(),
7955 pm_in,
7956 ph_in_name.as_ptr(),
7957 ph_in,
7958 s_in_name.as_ptr(),
7959 s_in,
7960 m_in_name.as_ptr(),
7961 m_in,
7962 h_in_name.as_ptr(),
7963 h_in,
7964 NULL,
7965 );
7966 utils::result(
7967 vips_op_response,
7968 VipsImage { ctx: out_out },
7969 Error::TonelutError,
7970 )
7971 }
7972}
7973
7974pub fn identity() -> Result<VipsImage> {
7978 unsafe {
7979 let mut out_out: *mut bindings::VipsImage = null_mut();
7980
7981 let vips_op_response = bindings::vips_identity(&mut out_out, NULL);
7982 utils::result(
7983 vips_op_response,
7984 VipsImage { ctx: out_out },
7985 Error::IdentityError,
7986 )
7987 }
7988}
7989
7990#[derive(Clone, Debug)]
7992pub struct IdentityOptions {
7993 pub bands: i32,
7996 pub ushort: bool,
7999 pub size: i32,
8002}
8003
8004impl std::default::Default for IdentityOptions {
8005 fn default() -> Self {
8006 IdentityOptions {
8007 bands: i32::from(1),
8008 ushort: false,
8009 size: i32::from(65536),
8010 }
8011 }
8012}
8013
8014pub fn identity_with_opts(identity_options: &IdentityOptions) -> Result<VipsImage> {
8019 unsafe {
8020 let mut out_out: *mut bindings::VipsImage = null_mut();
8021
8022 let bands_in: i32 = identity_options.bands;
8023 let bands_in_name = utils::new_c_string("bands")?;
8024
8025 let ushort_in: i32 = if identity_options.ushort { 1 } else { 0 };
8026 let ushort_in_name = utils::new_c_string("ushort")?;
8027
8028 let size_in: i32 = identity_options.size;
8029 let size_in_name = utils::new_c_string("size")?;
8030
8031 let vips_op_response = bindings::vips_identity(
8032 &mut out_out,
8033 bands_in_name.as_ptr(),
8034 bands_in,
8035 ushort_in_name.as_ptr(),
8036 ushort_in,
8037 size_in_name.as_ptr(),
8038 size_in,
8039 NULL,
8040 );
8041 utils::result(
8042 vips_op_response,
8043 VipsImage { ctx: out_out },
8044 Error::IdentityError,
8045 )
8046 }
8047}
8048
8049pub fn fractsurf(width: i32, height: i32, fractal_dimension: f64) -> Result<VipsImage> {
8058 unsafe {
8059 let width_in: i32 = width;
8060 let height_in: i32 = height;
8061 let fractal_dimension_in: f64 = fractal_dimension;
8062 let mut out_out: *mut bindings::VipsImage = null_mut();
8063
8064 let vips_op_response = bindings::vips_fractsurf(
8065 &mut out_out,
8066 width_in,
8067 height_in,
8068 fractal_dimension_in,
8069 NULL,
8070 );
8071 utils::result(
8072 vips_op_response,
8073 VipsImage { ctx: out_out },
8074 Error::FractsurfError,
8075 )
8076 }
8077}
8078
8079pub fn worley(width: i32, height: i32) -> Result<VipsImage> {
8086 unsafe {
8087 let width_in: i32 = width;
8088 let height_in: i32 = height;
8089 let mut out_out: *mut bindings::VipsImage = null_mut();
8090
8091 let vips_op_response = bindings::vips_worley(&mut out_out, width_in, height_in, NULL);
8092 utils::result(
8093 vips_op_response,
8094 VipsImage { ctx: out_out },
8095 Error::WorleyError,
8096 )
8097 }
8098}
8099
8100#[derive(Clone, Debug)]
8102pub struct WorleyOptions {
8103 pub cell_size: i32,
8106 pub seed: i32,
8109}
8110
8111impl std::default::Default for WorleyOptions {
8112 fn default() -> Self {
8113 WorleyOptions {
8114 cell_size: i32::from(256),
8115 seed: i32::from(0),
8116 }
8117 }
8118}
8119
8120pub fn worley_with_opts(
8128 width: i32,
8129 height: i32,
8130 worley_options: &WorleyOptions,
8131) -> Result<VipsImage> {
8132 unsafe {
8133 let width_in: i32 = width;
8134 let height_in: i32 = height;
8135 let mut out_out: *mut bindings::VipsImage = null_mut();
8136
8137 let cell_size_in: i32 = worley_options.cell_size;
8138 let cell_size_in_name = utils::new_c_string("cell-size")?;
8139
8140 let seed_in: i32 = worley_options.seed;
8141 let seed_in_name = utils::new_c_string("seed")?;
8142
8143 let vips_op_response = bindings::vips_worley(
8144 &mut out_out,
8145 width_in,
8146 height_in,
8147 cell_size_in_name.as_ptr(),
8148 cell_size_in,
8149 seed_in_name.as_ptr(),
8150 seed_in,
8151 NULL,
8152 );
8153 utils::result(
8154 vips_op_response,
8155 VipsImage { ctx: out_out },
8156 Error::WorleyError,
8157 )
8158 }
8159}
8160
8161pub fn perlin(width: i32, height: i32) -> Result<VipsImage> {
8168 unsafe {
8169 let width_in: i32 = width;
8170 let height_in: i32 = height;
8171 let mut out_out: *mut bindings::VipsImage = null_mut();
8172
8173 let vips_op_response = bindings::vips_perlin(&mut out_out, width_in, height_in, NULL);
8174 utils::result(
8175 vips_op_response,
8176 VipsImage { ctx: out_out },
8177 Error::PerlinError,
8178 )
8179 }
8180}
8181
8182#[derive(Clone, Debug)]
8184pub struct PerlinOptions {
8185 pub cell_size: i32,
8188 pub uchar: bool,
8191 pub seed: i32,
8194}
8195
8196impl std::default::Default for PerlinOptions {
8197 fn default() -> Self {
8198 PerlinOptions {
8199 cell_size: i32::from(256),
8200 uchar: false,
8201 seed: i32::from(0),
8202 }
8203 }
8204}
8205
8206pub fn perlin_with_opts(
8214 width: i32,
8215 height: i32,
8216 perlin_options: &PerlinOptions,
8217) -> Result<VipsImage> {
8218 unsafe {
8219 let width_in: i32 = width;
8220 let height_in: i32 = height;
8221 let mut out_out: *mut bindings::VipsImage = null_mut();
8222
8223 let cell_size_in: i32 = perlin_options.cell_size;
8224 let cell_size_in_name = utils::new_c_string("cell-size")?;
8225
8226 let uchar_in: i32 = if perlin_options.uchar { 1 } else { 0 };
8227 let uchar_in_name = utils::new_c_string("uchar")?;
8228
8229 let seed_in: i32 = perlin_options.seed;
8230 let seed_in_name = utils::new_c_string("seed")?;
8231
8232 let vips_op_response = bindings::vips_perlin(
8233 &mut out_out,
8234 width_in,
8235 height_in,
8236 cell_size_in_name.as_ptr(),
8237 cell_size_in,
8238 uchar_in_name.as_ptr(),
8239 uchar_in,
8240 seed_in_name.as_ptr(),
8241 seed_in,
8242 NULL,
8243 );
8244 utils::result(
8245 vips_op_response,
8246 VipsImage { ctx: out_out },
8247 Error::PerlinError,
8248 )
8249 }
8250}
8251
8252pub fn switch(tests: &mut [VipsImage]) -> Result<VipsImage> {
8256 unsafe {
8257 let (tests_len, mut tests_in) = {
8258 let len = tests.len();
8259 let mut input = Vec::new();
8260 for img in tests {
8261 input.push(img.ctx)
8262 }
8263 (len as i32, input)
8264 };
8265 let mut out_out: *mut bindings::VipsImage = null_mut();
8266
8267 let vips_op_response =
8268 bindings::vips_switch(tests_in.as_mut_ptr(), &mut out_out, tests_len, NULL);
8269 utils::result(
8270 vips_op_response,
8271 VipsImage { ctx: out_out },
8272 Error::SwitchError,
8273 )
8274 }
8275}
8276
8277pub fn csvload(filename: &str) -> Result<VipsImage> {
8281 unsafe {
8282 let filename_in: CString = utils::new_c_string(filename)?;
8283 let mut out_out: *mut bindings::VipsImage = null_mut();
8284
8285 let vips_op_response = bindings::vips_csvload(filename_in.as_ptr(), &mut out_out, NULL);
8286 utils::result(
8287 vips_op_response,
8288 VipsImage { ctx: out_out },
8289 Error::CsvloadError,
8290 )
8291 }
8292}
8293
8294#[derive(Clone, Debug)]
8296pub struct CsvloadOptions {
8297 pub skip: i32,
8300 pub lines: i32,
8303 pub whitespace: String,
8305 pub separator: String,
8307 pub flags: ForeignFlags,
8314 pub memory: bool,
8317 pub access: Access,
8323 pub fail_on: FailOn,
8330 pub revalidate: bool,
8333}
8334
8335impl std::default::Default for CsvloadOptions {
8336 fn default() -> Self {
8337 CsvloadOptions {
8338 skip: i32::from(0),
8339 lines: i32::from(0),
8340 whitespace: String::new(),
8341 separator: String::new(),
8342 flags: ForeignFlags::None,
8343 memory: false,
8344 access: Access::Random,
8345 fail_on: FailOn::None,
8346 revalidate: false,
8347 }
8348 }
8349}
8350
8351pub fn csvload_with_opts(filename: &str, csvload_options: &CsvloadOptions) -> Result<VipsImage> {
8356 unsafe {
8357 let filename_in: CString = utils::new_c_string(filename)?;
8358 let mut out_out: *mut bindings::VipsImage = null_mut();
8359
8360 let skip_in: i32 = csvload_options.skip;
8361 let skip_in_name = utils::new_c_string("skip")?;
8362
8363 let lines_in: i32 = csvload_options.lines;
8364 let lines_in_name = utils::new_c_string("lines")?;
8365
8366 let whitespace_in: CString = utils::new_c_string(&csvload_options.whitespace)?;
8367 let whitespace_in_name = utils::new_c_string("whitespace")?;
8368
8369 let separator_in: CString = utils::new_c_string(&csvload_options.separator)?;
8370 let separator_in_name = utils::new_c_string("separator")?;
8371
8372 let flags_in: i32 = csvload_options.flags as i32;
8373 let flags_in_name = utils::new_c_string("flags")?;
8374
8375 let memory_in: i32 = if csvload_options.memory { 1 } else { 0 };
8376 let memory_in_name = utils::new_c_string("memory")?;
8377
8378 let access_in: i32 = csvload_options.access as i32;
8379 let access_in_name = utils::new_c_string("access")?;
8380
8381 let fail_on_in: i32 = csvload_options.fail_on as i32;
8382 let fail_on_in_name = utils::new_c_string("fail-on")?;
8383
8384 let revalidate_in: i32 = if csvload_options.revalidate { 1 } else { 0 };
8385 let revalidate_in_name = utils::new_c_string("revalidate")?;
8386
8387 let vips_op_response = bindings::vips_csvload(
8388 filename_in.as_ptr(),
8389 &mut out_out,
8390 skip_in_name.as_ptr(),
8391 skip_in,
8392 lines_in_name.as_ptr(),
8393 lines_in,
8394 whitespace_in_name.as_ptr(),
8395 whitespace_in.as_ptr(),
8396 separator_in_name.as_ptr(),
8397 separator_in.as_ptr(),
8398 flags_in_name.as_ptr(),
8399 flags_in,
8400 memory_in_name.as_ptr(),
8401 memory_in,
8402 access_in_name.as_ptr(),
8403 access_in,
8404 fail_on_in_name.as_ptr(),
8405 fail_on_in,
8406 revalidate_in_name.as_ptr(),
8407 revalidate_in,
8408 NULL,
8409 );
8410 utils::result(
8411 vips_op_response,
8412 VipsImage { ctx: out_out },
8413 Error::CsvloadError,
8414 )
8415 }
8416}
8417
8418pub fn csvload_source(source: &VipsSource) -> Result<VipsImage> {
8422 unsafe {
8423 let source_in: *mut bindings::VipsSource = source.ctx;
8424 let mut out_out: *mut bindings::VipsImage = null_mut();
8425
8426 let vips_op_response = bindings::vips_csvload_source(source_in, &mut out_out, NULL);
8427 utils::result(
8428 vips_op_response,
8429 VipsImage { ctx: out_out },
8430 Error::CsvloadSourceError,
8431 )
8432 }
8433}
8434
8435#[derive(Clone, Debug)]
8437pub struct CsvloadSourceOptions {
8438 pub skip: i32,
8441 pub lines: i32,
8444 pub whitespace: String,
8446 pub separator: String,
8448 pub flags: ForeignFlags,
8455 pub memory: bool,
8458 pub access: Access,
8464 pub fail_on: FailOn,
8471 pub revalidate: bool,
8474}
8475
8476impl std::default::Default for CsvloadSourceOptions {
8477 fn default() -> Self {
8478 CsvloadSourceOptions {
8479 skip: i32::from(0),
8480 lines: i32::from(0),
8481 whitespace: String::new(),
8482 separator: String::new(),
8483 flags: ForeignFlags::None,
8484 memory: false,
8485 access: Access::Random,
8486 fail_on: FailOn::None,
8487 revalidate: false,
8488 }
8489 }
8490}
8491
8492pub fn csvload_source_with_opts(
8497 source: &VipsSource,
8498 csvload_source_options: &CsvloadSourceOptions,
8499) -> Result<VipsImage> {
8500 unsafe {
8501 let source_in: *mut bindings::VipsSource = source.ctx;
8502 let mut out_out: *mut bindings::VipsImage = null_mut();
8503
8504 let skip_in: i32 = csvload_source_options.skip;
8505 let skip_in_name = utils::new_c_string("skip")?;
8506
8507 let lines_in: i32 = csvload_source_options.lines;
8508 let lines_in_name = utils::new_c_string("lines")?;
8509
8510 let whitespace_in: CString = utils::new_c_string(&csvload_source_options.whitespace)?;
8511 let whitespace_in_name = utils::new_c_string("whitespace")?;
8512
8513 let separator_in: CString = utils::new_c_string(&csvload_source_options.separator)?;
8514 let separator_in_name = utils::new_c_string("separator")?;
8515
8516 let flags_in: i32 = csvload_source_options.flags as i32;
8517 let flags_in_name = utils::new_c_string("flags")?;
8518
8519 let memory_in: i32 = if csvload_source_options.memory { 1 } else { 0 };
8520 let memory_in_name = utils::new_c_string("memory")?;
8521
8522 let access_in: i32 = csvload_source_options.access as i32;
8523 let access_in_name = utils::new_c_string("access")?;
8524
8525 let fail_on_in: i32 = csvload_source_options.fail_on as i32;
8526 let fail_on_in_name = utils::new_c_string("fail-on")?;
8527
8528 let revalidate_in: i32 = if csvload_source_options.revalidate {
8529 1
8530 } else {
8531 0
8532 };
8533 let revalidate_in_name = utils::new_c_string("revalidate")?;
8534
8535 let vips_op_response = bindings::vips_csvload_source(
8536 source_in,
8537 &mut out_out,
8538 skip_in_name.as_ptr(),
8539 skip_in,
8540 lines_in_name.as_ptr(),
8541 lines_in,
8542 whitespace_in_name.as_ptr(),
8543 whitespace_in.as_ptr(),
8544 separator_in_name.as_ptr(),
8545 separator_in.as_ptr(),
8546 flags_in_name.as_ptr(),
8547 flags_in,
8548 memory_in_name.as_ptr(),
8549 memory_in,
8550 access_in_name.as_ptr(),
8551 access_in,
8552 fail_on_in_name.as_ptr(),
8553 fail_on_in,
8554 revalidate_in_name.as_ptr(),
8555 revalidate_in,
8556 NULL,
8557 );
8558 utils::result(
8559 vips_op_response,
8560 VipsImage { ctx: out_out },
8561 Error::CsvloadSourceError,
8562 )
8563 }
8564}
8565
8566pub fn matrixload(filename: &str) -> Result<VipsImage> {
8570 unsafe {
8571 let filename_in: CString = utils::new_c_string(filename)?;
8572 let mut out_out: *mut bindings::VipsImage = null_mut();
8573
8574 let vips_op_response = bindings::vips_matrixload(filename_in.as_ptr(), &mut out_out, NULL);
8575 utils::result(
8576 vips_op_response,
8577 VipsImage { ctx: out_out },
8578 Error::MatrixloadError,
8579 )
8580 }
8581}
8582
8583#[derive(Clone, Debug)]
8585pub struct MatrixloadOptions {
8586 pub flags: ForeignFlags,
8593 pub memory: bool,
8596 pub access: Access,
8602 pub fail_on: FailOn,
8609 pub revalidate: bool,
8612}
8613
8614impl std::default::Default for MatrixloadOptions {
8615 fn default() -> Self {
8616 MatrixloadOptions {
8617 flags: ForeignFlags::None,
8618 memory: false,
8619 access: Access::Random,
8620 fail_on: FailOn::None,
8621 revalidate: false,
8622 }
8623 }
8624}
8625
8626pub fn matrixload_with_opts(
8631 filename: &str,
8632 matrixload_options: &MatrixloadOptions,
8633) -> Result<VipsImage> {
8634 unsafe {
8635 let filename_in: CString = utils::new_c_string(filename)?;
8636 let mut out_out: *mut bindings::VipsImage = null_mut();
8637
8638 let flags_in: i32 = matrixload_options.flags as i32;
8639 let flags_in_name = utils::new_c_string("flags")?;
8640
8641 let memory_in: i32 = if matrixload_options.memory { 1 } else { 0 };
8642 let memory_in_name = utils::new_c_string("memory")?;
8643
8644 let access_in: i32 = matrixload_options.access as i32;
8645 let access_in_name = utils::new_c_string("access")?;
8646
8647 let fail_on_in: i32 = matrixload_options.fail_on as i32;
8648 let fail_on_in_name = utils::new_c_string("fail-on")?;
8649
8650 let revalidate_in: i32 = if matrixload_options.revalidate { 1 } else { 0 };
8651 let revalidate_in_name = utils::new_c_string("revalidate")?;
8652
8653 let vips_op_response = bindings::vips_matrixload(
8654 filename_in.as_ptr(),
8655 &mut out_out,
8656 flags_in_name.as_ptr(),
8657 flags_in,
8658 memory_in_name.as_ptr(),
8659 memory_in,
8660 access_in_name.as_ptr(),
8661 access_in,
8662 fail_on_in_name.as_ptr(),
8663 fail_on_in,
8664 revalidate_in_name.as_ptr(),
8665 revalidate_in,
8666 NULL,
8667 );
8668 utils::result(
8669 vips_op_response,
8670 VipsImage { ctx: out_out },
8671 Error::MatrixloadError,
8672 )
8673 }
8674}
8675
8676pub fn matrixload_source(source: &VipsSource) -> Result<VipsImage> {
8680 unsafe {
8681 let source_in: *mut bindings::VipsSource = source.ctx;
8682 let mut out_out: *mut bindings::VipsImage = null_mut();
8683
8684 let vips_op_response = bindings::vips_matrixload_source(source_in, &mut out_out, NULL);
8685 utils::result(
8686 vips_op_response,
8687 VipsImage { ctx: out_out },
8688 Error::MatrixloadSourceError,
8689 )
8690 }
8691}
8692
8693#[derive(Clone, Debug)]
8695pub struct MatrixloadSourceOptions {
8696 pub flags: ForeignFlags,
8703 pub memory: bool,
8706 pub access: Access,
8712 pub fail_on: FailOn,
8719 pub revalidate: bool,
8722}
8723
8724impl std::default::Default for MatrixloadSourceOptions {
8725 fn default() -> Self {
8726 MatrixloadSourceOptions {
8727 flags: ForeignFlags::None,
8728 memory: false,
8729 access: Access::Random,
8730 fail_on: FailOn::None,
8731 revalidate: false,
8732 }
8733 }
8734}
8735
8736pub fn matrixload_source_with_opts(
8741 source: &VipsSource,
8742 matrixload_source_options: &MatrixloadSourceOptions,
8743) -> Result<VipsImage> {
8744 unsafe {
8745 let source_in: *mut bindings::VipsSource = source.ctx;
8746 let mut out_out: *mut bindings::VipsImage = null_mut();
8747
8748 let flags_in: i32 = matrixload_source_options.flags as i32;
8749 let flags_in_name = utils::new_c_string("flags")?;
8750
8751 let memory_in: i32 = if matrixload_source_options.memory {
8752 1
8753 } else {
8754 0
8755 };
8756 let memory_in_name = utils::new_c_string("memory")?;
8757
8758 let access_in: i32 = matrixload_source_options.access as i32;
8759 let access_in_name = utils::new_c_string("access")?;
8760
8761 let fail_on_in: i32 = matrixload_source_options.fail_on as i32;
8762 let fail_on_in_name = utils::new_c_string("fail-on")?;
8763
8764 let revalidate_in: i32 = if matrixload_source_options.revalidate {
8765 1
8766 } else {
8767 0
8768 };
8769 let revalidate_in_name = utils::new_c_string("revalidate")?;
8770
8771 let vips_op_response = bindings::vips_matrixload_source(
8772 source_in,
8773 &mut out_out,
8774 flags_in_name.as_ptr(),
8775 flags_in,
8776 memory_in_name.as_ptr(),
8777 memory_in,
8778 access_in_name.as_ptr(),
8779 access_in,
8780 fail_on_in_name.as_ptr(),
8781 fail_on_in,
8782 revalidate_in_name.as_ptr(),
8783 revalidate_in,
8784 NULL,
8785 );
8786 utils::result(
8787 vips_op_response,
8788 VipsImage { ctx: out_out },
8789 Error::MatrixloadSourceError,
8790 )
8791 }
8792}
8793
8794pub fn rawload(filename: &str, width: i32, height: i32, bands: i32) -> Result<VipsImage> {
8804 unsafe {
8805 let filename_in: CString = utils::new_c_string(filename)?;
8806 let width_in: i32 = width;
8807 let height_in: i32 = height;
8808 let bands_in: i32 = bands;
8809 let mut out_out: *mut bindings::VipsImage = null_mut();
8810
8811 let vips_op_response = bindings::vips_rawload(
8812 filename_in.as_ptr(),
8813 &mut out_out,
8814 width_in,
8815 height_in,
8816 bands_in,
8817 NULL,
8818 );
8819 utils::result(
8820 vips_op_response,
8821 VipsImage { ctx: out_out },
8822 Error::RawloadError,
8823 )
8824 }
8825}
8826
8827#[derive(Clone, Debug)]
8829pub struct RawloadOptions {
8830 pub offset: u64,
8833 pub format: BandFormat,
8847 pub interpretation: Interpretation,
8870 pub flags: ForeignFlags,
8877 pub memory: bool,
8880 pub access: Access,
8886 pub fail_on: FailOn,
8893 pub revalidate: bool,
8896}
8897
8898impl std::default::Default for RawloadOptions {
8899 fn default() -> Self {
8900 RawloadOptions {
8901 offset: 0,
8902 format: BandFormat::Uchar,
8903 interpretation: Interpretation::Multiband,
8904 flags: ForeignFlags::None,
8905 memory: false,
8906 access: Access::Random,
8907 fail_on: FailOn::None,
8908 revalidate: false,
8909 }
8910 }
8911}
8912
8913pub fn rawload_with_opts(
8924 filename: &str,
8925 width: i32,
8926 height: i32,
8927 bands: i32,
8928 rawload_options: &RawloadOptions,
8929) -> Result<VipsImage> {
8930 unsafe {
8931 let filename_in: CString = utils::new_c_string(filename)?;
8932 let width_in: i32 = width;
8933 let height_in: i32 = height;
8934 let bands_in: i32 = bands;
8935 let mut out_out: *mut bindings::VipsImage = null_mut();
8936
8937 let offset_in: u64 = rawload_options.offset;
8938 let offset_in_name = utils::new_c_string("offset")?;
8939
8940 let format_in: i32 = rawload_options.format as i32;
8941 let format_in_name = utils::new_c_string("format")?;
8942
8943 let interpretation_in: i32 = rawload_options.interpretation as i32;
8944 let interpretation_in_name = utils::new_c_string("interpretation")?;
8945
8946 let flags_in: i32 = rawload_options.flags as i32;
8947 let flags_in_name = utils::new_c_string("flags")?;
8948
8949 let memory_in: i32 = if rawload_options.memory { 1 } else { 0 };
8950 let memory_in_name = utils::new_c_string("memory")?;
8951
8952 let access_in: i32 = rawload_options.access as i32;
8953 let access_in_name = utils::new_c_string("access")?;
8954
8955 let fail_on_in: i32 = rawload_options.fail_on as i32;
8956 let fail_on_in_name = utils::new_c_string("fail-on")?;
8957
8958 let revalidate_in: i32 = if rawload_options.revalidate { 1 } else { 0 };
8959 let revalidate_in_name = utils::new_c_string("revalidate")?;
8960
8961 let vips_op_response = bindings::vips_rawload(
8962 filename_in.as_ptr(),
8963 &mut out_out,
8964 width_in,
8965 height_in,
8966 bands_in,
8967 offset_in_name.as_ptr(),
8968 offset_in,
8969 format_in_name.as_ptr(),
8970 format_in,
8971 interpretation_in_name.as_ptr(),
8972 interpretation_in,
8973 flags_in_name.as_ptr(),
8974 flags_in,
8975 memory_in_name.as_ptr(),
8976 memory_in,
8977 access_in_name.as_ptr(),
8978 access_in,
8979 fail_on_in_name.as_ptr(),
8980 fail_on_in,
8981 revalidate_in_name.as_ptr(),
8982 revalidate_in,
8983 NULL,
8984 );
8985 utils::result(
8986 vips_op_response,
8987 VipsImage { ctx: out_out },
8988 Error::RawloadError,
8989 )
8990 }
8991}
8992
8993pub fn vipsload(filename: &str) -> Result<VipsImage> {
8997 unsafe {
8998 let filename_in: CString = utils::new_c_string(filename)?;
8999 let mut out_out: *mut bindings::VipsImage = null_mut();
9000
9001 let vips_op_response = bindings::vips_vipsload(filename_in.as_ptr(), &mut out_out, NULL);
9002 utils::result(
9003 vips_op_response,
9004 VipsImage { ctx: out_out },
9005 Error::VipsloadError,
9006 )
9007 }
9008}
9009
9010#[derive(Clone, Debug)]
9012pub struct VipsloadOptions {
9013 pub flags: ForeignFlags,
9020 pub memory: bool,
9023 pub access: Access,
9029 pub fail_on: FailOn,
9036 pub revalidate: bool,
9039}
9040
9041impl std::default::Default for VipsloadOptions {
9042 fn default() -> Self {
9043 VipsloadOptions {
9044 flags: ForeignFlags::None,
9045 memory: false,
9046 access: Access::Random,
9047 fail_on: FailOn::None,
9048 revalidate: false,
9049 }
9050 }
9051}
9052
9053pub fn vipsload_with_opts(filename: &str, vipsload_options: &VipsloadOptions) -> Result<VipsImage> {
9058 unsafe {
9059 let filename_in: CString = utils::new_c_string(filename)?;
9060 let mut out_out: *mut bindings::VipsImage = null_mut();
9061
9062 let flags_in: i32 = vipsload_options.flags as i32;
9063 let flags_in_name = utils::new_c_string("flags")?;
9064
9065 let memory_in: i32 = if vipsload_options.memory { 1 } else { 0 };
9066 let memory_in_name = utils::new_c_string("memory")?;
9067
9068 let access_in: i32 = vipsload_options.access as i32;
9069 let access_in_name = utils::new_c_string("access")?;
9070
9071 let fail_on_in: i32 = vipsload_options.fail_on as i32;
9072 let fail_on_in_name = utils::new_c_string("fail-on")?;
9073
9074 let revalidate_in: i32 = if vipsload_options.revalidate { 1 } else { 0 };
9075 let revalidate_in_name = utils::new_c_string("revalidate")?;
9076
9077 let vips_op_response = bindings::vips_vipsload(
9078 filename_in.as_ptr(),
9079 &mut out_out,
9080 flags_in_name.as_ptr(),
9081 flags_in,
9082 memory_in_name.as_ptr(),
9083 memory_in,
9084 access_in_name.as_ptr(),
9085 access_in,
9086 fail_on_in_name.as_ptr(),
9087 fail_on_in,
9088 revalidate_in_name.as_ptr(),
9089 revalidate_in,
9090 NULL,
9091 );
9092 utils::result(
9093 vips_op_response,
9094 VipsImage { ctx: out_out },
9095 Error::VipsloadError,
9096 )
9097 }
9098}
9099
9100pub fn vipsload_source(source: &VipsSource) -> Result<VipsImage> {
9104 unsafe {
9105 let source_in: *mut bindings::VipsSource = source.ctx;
9106 let mut out_out: *mut bindings::VipsImage = null_mut();
9107
9108 let vips_op_response = bindings::vips_vipsload_source(source_in, &mut out_out, NULL);
9109 utils::result(
9110 vips_op_response,
9111 VipsImage { ctx: out_out },
9112 Error::VipsloadSourceError,
9113 )
9114 }
9115}
9116
9117#[derive(Clone, Debug)]
9119pub struct VipsloadSourceOptions {
9120 pub flags: ForeignFlags,
9127 pub memory: bool,
9130 pub access: Access,
9136 pub fail_on: FailOn,
9143 pub revalidate: bool,
9146}
9147
9148impl std::default::Default for VipsloadSourceOptions {
9149 fn default() -> Self {
9150 VipsloadSourceOptions {
9151 flags: ForeignFlags::None,
9152 memory: false,
9153 access: Access::Random,
9154 fail_on: FailOn::None,
9155 revalidate: false,
9156 }
9157 }
9158}
9159
9160pub fn vipsload_source_with_opts(
9165 source: &VipsSource,
9166 vipsload_source_options: &VipsloadSourceOptions,
9167) -> Result<VipsImage> {
9168 unsafe {
9169 let source_in: *mut bindings::VipsSource = source.ctx;
9170 let mut out_out: *mut bindings::VipsImage = null_mut();
9171
9172 let flags_in: i32 = vipsload_source_options.flags as i32;
9173 let flags_in_name = utils::new_c_string("flags")?;
9174
9175 let memory_in: i32 = if vipsload_source_options.memory { 1 } else { 0 };
9176 let memory_in_name = utils::new_c_string("memory")?;
9177
9178 let access_in: i32 = vipsload_source_options.access as i32;
9179 let access_in_name = utils::new_c_string("access")?;
9180
9181 let fail_on_in: i32 = vipsload_source_options.fail_on as i32;
9182 let fail_on_in_name = utils::new_c_string("fail-on")?;
9183
9184 let revalidate_in: i32 = if vipsload_source_options.revalidate {
9185 1
9186 } else {
9187 0
9188 };
9189 let revalidate_in_name = utils::new_c_string("revalidate")?;
9190
9191 let vips_op_response = bindings::vips_vipsload_source(
9192 source_in,
9193 &mut out_out,
9194 flags_in_name.as_ptr(),
9195 flags_in,
9196 memory_in_name.as_ptr(),
9197 memory_in,
9198 access_in_name.as_ptr(),
9199 access_in,
9200 fail_on_in_name.as_ptr(),
9201 fail_on_in,
9202 revalidate_in_name.as_ptr(),
9203 revalidate_in,
9204 NULL,
9205 );
9206 utils::result(
9207 vips_op_response,
9208 VipsImage { ctx: out_out },
9209 Error::VipsloadSourceError,
9210 )
9211 }
9212}
9213
9214pub fn analyzeload(filename: &str) -> Result<VipsImage> {
9218 unsafe {
9219 let filename_in: CString = utils::new_c_string(filename)?;
9220 let mut out_out: *mut bindings::VipsImage = null_mut();
9221
9222 let vips_op_response = bindings::vips_analyzeload(filename_in.as_ptr(), &mut out_out, NULL);
9223 utils::result(
9224 vips_op_response,
9225 VipsImage { ctx: out_out },
9226 Error::AnalyzeloadError,
9227 )
9228 }
9229}
9230
9231#[derive(Clone, Debug)]
9233pub struct AnalyzeloadOptions {
9234 pub flags: ForeignFlags,
9241 pub memory: bool,
9244 pub access: Access,
9250 pub fail_on: FailOn,
9257 pub revalidate: bool,
9260}
9261
9262impl std::default::Default for AnalyzeloadOptions {
9263 fn default() -> Self {
9264 AnalyzeloadOptions {
9265 flags: ForeignFlags::None,
9266 memory: false,
9267 access: Access::Random,
9268 fail_on: FailOn::None,
9269 revalidate: false,
9270 }
9271 }
9272}
9273
9274pub fn analyzeload_with_opts(
9279 filename: &str,
9280 analyzeload_options: &AnalyzeloadOptions,
9281) -> Result<VipsImage> {
9282 unsafe {
9283 let filename_in: CString = utils::new_c_string(filename)?;
9284 let mut out_out: *mut bindings::VipsImage = null_mut();
9285
9286 let flags_in: i32 = analyzeload_options.flags as i32;
9287 let flags_in_name = utils::new_c_string("flags")?;
9288
9289 let memory_in: i32 = if analyzeload_options.memory { 1 } else { 0 };
9290 let memory_in_name = utils::new_c_string("memory")?;
9291
9292 let access_in: i32 = analyzeload_options.access as i32;
9293 let access_in_name = utils::new_c_string("access")?;
9294
9295 let fail_on_in: i32 = analyzeload_options.fail_on as i32;
9296 let fail_on_in_name = utils::new_c_string("fail-on")?;
9297
9298 let revalidate_in: i32 = if analyzeload_options.revalidate { 1 } else { 0 };
9299 let revalidate_in_name = utils::new_c_string("revalidate")?;
9300
9301 let vips_op_response = bindings::vips_analyzeload(
9302 filename_in.as_ptr(),
9303 &mut out_out,
9304 flags_in_name.as_ptr(),
9305 flags_in,
9306 memory_in_name.as_ptr(),
9307 memory_in,
9308 access_in_name.as_ptr(),
9309 access_in,
9310 fail_on_in_name.as_ptr(),
9311 fail_on_in,
9312 revalidate_in_name.as_ptr(),
9313 revalidate_in,
9314 NULL,
9315 );
9316 utils::result(
9317 vips_op_response,
9318 VipsImage { ctx: out_out },
9319 Error::AnalyzeloadError,
9320 )
9321 }
9322}
9323
9324pub fn ppmload(filename: &str) -> Result<VipsImage> {
9328 unsafe {
9329 let filename_in: CString = utils::new_c_string(filename)?;
9330 let mut out_out: *mut bindings::VipsImage = null_mut();
9331
9332 let vips_op_response = bindings::vips_ppmload(filename_in.as_ptr(), &mut out_out, NULL);
9333 utils::result(
9334 vips_op_response,
9335 VipsImage { ctx: out_out },
9336 Error::PpmloadError,
9337 )
9338 }
9339}
9340
9341#[derive(Clone, Debug)]
9343pub struct PpmloadOptions {
9344 pub flags: ForeignFlags,
9351 pub memory: bool,
9354 pub access: Access,
9360 pub fail_on: FailOn,
9367 pub revalidate: bool,
9370}
9371
9372impl std::default::Default for PpmloadOptions {
9373 fn default() -> Self {
9374 PpmloadOptions {
9375 flags: ForeignFlags::None,
9376 memory: false,
9377 access: Access::Random,
9378 fail_on: FailOn::None,
9379 revalidate: false,
9380 }
9381 }
9382}
9383
9384pub fn ppmload_with_opts(filename: &str, ppmload_options: &PpmloadOptions) -> Result<VipsImage> {
9389 unsafe {
9390 let filename_in: CString = utils::new_c_string(filename)?;
9391 let mut out_out: *mut bindings::VipsImage = null_mut();
9392
9393 let flags_in: i32 = ppmload_options.flags as i32;
9394 let flags_in_name = utils::new_c_string("flags")?;
9395
9396 let memory_in: i32 = if ppmload_options.memory { 1 } else { 0 };
9397 let memory_in_name = utils::new_c_string("memory")?;
9398
9399 let access_in: i32 = ppmload_options.access as i32;
9400 let access_in_name = utils::new_c_string("access")?;
9401
9402 let fail_on_in: i32 = ppmload_options.fail_on as i32;
9403 let fail_on_in_name = utils::new_c_string("fail-on")?;
9404
9405 let revalidate_in: i32 = if ppmload_options.revalidate { 1 } else { 0 };
9406 let revalidate_in_name = utils::new_c_string("revalidate")?;
9407
9408 let vips_op_response = bindings::vips_ppmload(
9409 filename_in.as_ptr(),
9410 &mut out_out,
9411 flags_in_name.as_ptr(),
9412 flags_in,
9413 memory_in_name.as_ptr(),
9414 memory_in,
9415 access_in_name.as_ptr(),
9416 access_in,
9417 fail_on_in_name.as_ptr(),
9418 fail_on_in,
9419 revalidate_in_name.as_ptr(),
9420 revalidate_in,
9421 NULL,
9422 );
9423 utils::result(
9424 vips_op_response,
9425 VipsImage { ctx: out_out },
9426 Error::PpmloadError,
9427 )
9428 }
9429}
9430
9431pub fn ppmload_source(source: &VipsSource) -> Result<VipsImage> {
9435 unsafe {
9436 let source_in: *mut bindings::VipsSource = source.ctx;
9437 let mut out_out: *mut bindings::VipsImage = null_mut();
9438
9439 let vips_op_response = bindings::vips_ppmload_source(source_in, &mut out_out, NULL);
9440 utils::result(
9441 vips_op_response,
9442 VipsImage { ctx: out_out },
9443 Error::PpmloadSourceError,
9444 )
9445 }
9446}
9447
9448#[derive(Clone, Debug)]
9450pub struct PpmloadSourceOptions {
9451 pub flags: ForeignFlags,
9458 pub memory: bool,
9461 pub access: Access,
9467 pub fail_on: FailOn,
9474 pub revalidate: bool,
9477}
9478
9479impl std::default::Default for PpmloadSourceOptions {
9480 fn default() -> Self {
9481 PpmloadSourceOptions {
9482 flags: ForeignFlags::None,
9483 memory: false,
9484 access: Access::Random,
9485 fail_on: FailOn::None,
9486 revalidate: false,
9487 }
9488 }
9489}
9490
9491pub fn ppmload_source_with_opts(
9496 source: &VipsSource,
9497 ppmload_source_options: &PpmloadSourceOptions,
9498) -> Result<VipsImage> {
9499 unsafe {
9500 let source_in: *mut bindings::VipsSource = source.ctx;
9501 let mut out_out: *mut bindings::VipsImage = null_mut();
9502
9503 let flags_in: i32 = ppmload_source_options.flags as i32;
9504 let flags_in_name = utils::new_c_string("flags")?;
9505
9506 let memory_in: i32 = if ppmload_source_options.memory { 1 } else { 0 };
9507 let memory_in_name = utils::new_c_string("memory")?;
9508
9509 let access_in: i32 = ppmload_source_options.access as i32;
9510 let access_in_name = utils::new_c_string("access")?;
9511
9512 let fail_on_in: i32 = ppmload_source_options.fail_on as i32;
9513 let fail_on_in_name = utils::new_c_string("fail-on")?;
9514
9515 let revalidate_in: i32 = if ppmload_source_options.revalidate {
9516 1
9517 } else {
9518 0
9519 };
9520 let revalidate_in_name = utils::new_c_string("revalidate")?;
9521
9522 let vips_op_response = bindings::vips_ppmload_source(
9523 source_in,
9524 &mut out_out,
9525 flags_in_name.as_ptr(),
9526 flags_in,
9527 memory_in_name.as_ptr(),
9528 memory_in,
9529 access_in_name.as_ptr(),
9530 access_in,
9531 fail_on_in_name.as_ptr(),
9532 fail_on_in,
9533 revalidate_in_name.as_ptr(),
9534 revalidate_in,
9535 NULL,
9536 );
9537 utils::result(
9538 vips_op_response,
9539 VipsImage { ctx: out_out },
9540 Error::PpmloadSourceError,
9541 )
9542 }
9543}
9544
9545pub fn radload(filename: &str) -> Result<VipsImage> {
9549 unsafe {
9550 let filename_in: CString = utils::new_c_string(filename)?;
9551 let mut out_out: *mut bindings::VipsImage = null_mut();
9552
9553 let vips_op_response = bindings::vips_radload(filename_in.as_ptr(), &mut out_out, NULL);
9554 utils::result(
9555 vips_op_response,
9556 VipsImage { ctx: out_out },
9557 Error::RadloadError,
9558 )
9559 }
9560}
9561
9562#[derive(Clone, Debug)]
9564pub struct RadloadOptions {
9565 pub flags: ForeignFlags,
9572 pub memory: bool,
9575 pub access: Access,
9581 pub fail_on: FailOn,
9588 pub revalidate: bool,
9591}
9592
9593impl std::default::Default for RadloadOptions {
9594 fn default() -> Self {
9595 RadloadOptions {
9596 flags: ForeignFlags::None,
9597 memory: false,
9598 access: Access::Random,
9599 fail_on: FailOn::None,
9600 revalidate: false,
9601 }
9602 }
9603}
9604
9605pub fn radload_with_opts(filename: &str, radload_options: &RadloadOptions) -> Result<VipsImage> {
9610 unsafe {
9611 let filename_in: CString = utils::new_c_string(filename)?;
9612 let mut out_out: *mut bindings::VipsImage = null_mut();
9613
9614 let flags_in: i32 = radload_options.flags as i32;
9615 let flags_in_name = utils::new_c_string("flags")?;
9616
9617 let memory_in: i32 = if radload_options.memory { 1 } else { 0 };
9618 let memory_in_name = utils::new_c_string("memory")?;
9619
9620 let access_in: i32 = radload_options.access as i32;
9621 let access_in_name = utils::new_c_string("access")?;
9622
9623 let fail_on_in: i32 = radload_options.fail_on as i32;
9624 let fail_on_in_name = utils::new_c_string("fail-on")?;
9625
9626 let revalidate_in: i32 = if radload_options.revalidate { 1 } else { 0 };
9627 let revalidate_in_name = utils::new_c_string("revalidate")?;
9628
9629 let vips_op_response = bindings::vips_radload(
9630 filename_in.as_ptr(),
9631 &mut out_out,
9632 flags_in_name.as_ptr(),
9633 flags_in,
9634 memory_in_name.as_ptr(),
9635 memory_in,
9636 access_in_name.as_ptr(),
9637 access_in,
9638 fail_on_in_name.as_ptr(),
9639 fail_on_in,
9640 revalidate_in_name.as_ptr(),
9641 revalidate_in,
9642 NULL,
9643 );
9644 utils::result(
9645 vips_op_response,
9646 VipsImage { ctx: out_out },
9647 Error::RadloadError,
9648 )
9649 }
9650}
9651
9652pub fn radload_buffer(buffer: &[u8]) -> Result<VipsImage> {
9656 unsafe {
9657 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
9658 let mut out_out: *mut bindings::VipsImage = null_mut();
9659
9660 let vips_op_response =
9661 bindings::vips_radload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
9662 utils::result(
9663 vips_op_response,
9664 VipsImage { ctx: out_out },
9665 Error::RadloadBufferError,
9666 )
9667 }
9668}
9669
9670#[derive(Clone, Debug)]
9672pub struct RadloadBufferOptions {
9673 pub flags: ForeignFlags,
9680 pub memory: bool,
9683 pub access: Access,
9689 pub fail_on: FailOn,
9696 pub revalidate: bool,
9699}
9700
9701impl std::default::Default for RadloadBufferOptions {
9702 fn default() -> Self {
9703 RadloadBufferOptions {
9704 flags: ForeignFlags::None,
9705 memory: false,
9706 access: Access::Random,
9707 fail_on: FailOn::None,
9708 revalidate: false,
9709 }
9710 }
9711}
9712
9713pub fn radload_buffer_with_opts(
9718 buffer: &[u8],
9719 radload_buffer_options: &RadloadBufferOptions,
9720) -> Result<VipsImage> {
9721 unsafe {
9722 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
9723 let mut out_out: *mut bindings::VipsImage = null_mut();
9724
9725 let flags_in: i32 = radload_buffer_options.flags as i32;
9726 let flags_in_name = utils::new_c_string("flags")?;
9727
9728 let memory_in: i32 = if radload_buffer_options.memory { 1 } else { 0 };
9729 let memory_in_name = utils::new_c_string("memory")?;
9730
9731 let access_in: i32 = radload_buffer_options.access as i32;
9732 let access_in_name = utils::new_c_string("access")?;
9733
9734 let fail_on_in: i32 = radload_buffer_options.fail_on as i32;
9735 let fail_on_in_name = utils::new_c_string("fail-on")?;
9736
9737 let revalidate_in: i32 = if radload_buffer_options.revalidate {
9738 1
9739 } else {
9740 0
9741 };
9742 let revalidate_in_name = utils::new_c_string("revalidate")?;
9743
9744 let vips_op_response = bindings::vips_radload_buffer(
9745 buffer_in,
9746 buffer.len() as u64,
9747 &mut out_out,
9748 flags_in_name.as_ptr(),
9749 flags_in,
9750 memory_in_name.as_ptr(),
9751 memory_in,
9752 access_in_name.as_ptr(),
9753 access_in,
9754 fail_on_in_name.as_ptr(),
9755 fail_on_in,
9756 revalidate_in_name.as_ptr(),
9757 revalidate_in,
9758 NULL,
9759 );
9760 utils::result(
9761 vips_op_response,
9762 VipsImage { ctx: out_out },
9763 Error::RadloadBufferError,
9764 )
9765 }
9766}
9767
9768pub fn radload_source(source: &VipsSource) -> Result<VipsImage> {
9772 unsafe {
9773 let source_in: *mut bindings::VipsSource = source.ctx;
9774 let mut out_out: *mut bindings::VipsImage = null_mut();
9775
9776 let vips_op_response = bindings::vips_radload_source(source_in, &mut out_out, NULL);
9777 utils::result(
9778 vips_op_response,
9779 VipsImage { ctx: out_out },
9780 Error::RadloadSourceError,
9781 )
9782 }
9783}
9784
9785#[derive(Clone, Debug)]
9787pub struct RadloadSourceOptions {
9788 pub flags: ForeignFlags,
9795 pub memory: bool,
9798 pub access: Access,
9804 pub fail_on: FailOn,
9811 pub revalidate: bool,
9814}
9815
9816impl std::default::Default for RadloadSourceOptions {
9817 fn default() -> Self {
9818 RadloadSourceOptions {
9819 flags: ForeignFlags::None,
9820 memory: false,
9821 access: Access::Random,
9822 fail_on: FailOn::None,
9823 revalidate: false,
9824 }
9825 }
9826}
9827
9828pub fn radload_source_with_opts(
9833 source: &VipsSource,
9834 radload_source_options: &RadloadSourceOptions,
9835) -> Result<VipsImage> {
9836 unsafe {
9837 let source_in: *mut bindings::VipsSource = source.ctx;
9838 let mut out_out: *mut bindings::VipsImage = null_mut();
9839
9840 let flags_in: i32 = radload_source_options.flags as i32;
9841 let flags_in_name = utils::new_c_string("flags")?;
9842
9843 let memory_in: i32 = if radload_source_options.memory { 1 } else { 0 };
9844 let memory_in_name = utils::new_c_string("memory")?;
9845
9846 let access_in: i32 = radload_source_options.access as i32;
9847 let access_in_name = utils::new_c_string("access")?;
9848
9849 let fail_on_in: i32 = radload_source_options.fail_on as i32;
9850 let fail_on_in_name = utils::new_c_string("fail-on")?;
9851
9852 let revalidate_in: i32 = if radload_source_options.revalidate {
9853 1
9854 } else {
9855 0
9856 };
9857 let revalidate_in_name = utils::new_c_string("revalidate")?;
9858
9859 let vips_op_response = bindings::vips_radload_source(
9860 source_in,
9861 &mut out_out,
9862 flags_in_name.as_ptr(),
9863 flags_in,
9864 memory_in_name.as_ptr(),
9865 memory_in,
9866 access_in_name.as_ptr(),
9867 access_in,
9868 fail_on_in_name.as_ptr(),
9869 fail_on_in,
9870 revalidate_in_name.as_ptr(),
9871 revalidate_in,
9872 NULL,
9873 );
9874 utils::result(
9875 vips_op_response,
9876 VipsImage { ctx: out_out },
9877 Error::RadloadSourceError,
9878 )
9879 }
9880}
9881
9882pub fn svgload(filename: &str) -> Result<VipsImage> {
9886 unsafe {
9887 let filename_in: CString = utils::new_c_string(filename)?;
9888 let mut out_out: *mut bindings::VipsImage = null_mut();
9889
9890 let vips_op_response = bindings::vips_svgload(filename_in.as_ptr(), &mut out_out, NULL);
9891 utils::result(
9892 vips_op_response,
9893 VipsImage { ctx: out_out },
9894 Error::SvgloadError,
9895 )
9896 }
9897}
9898
9899#[derive(Clone, Debug)]
9901pub struct SvgloadOptions {
9902 pub dpi: f64,
9905 pub scale: f64,
9908 pub unlimited: bool,
9911 pub flags: ForeignFlags,
9918 pub memory: bool,
9921 pub access: Access,
9927 pub fail_on: FailOn,
9934 pub revalidate: bool,
9937}
9938
9939impl std::default::Default for SvgloadOptions {
9940 fn default() -> Self {
9941 SvgloadOptions {
9942 dpi: f64::from(72),
9943 scale: f64::from(1),
9944 unlimited: false,
9945 flags: ForeignFlags::None,
9946 memory: false,
9947 access: Access::Random,
9948 fail_on: FailOn::None,
9949 revalidate: false,
9950 }
9951 }
9952}
9953
9954pub fn svgload_with_opts(filename: &str, svgload_options: &SvgloadOptions) -> Result<VipsImage> {
9959 unsafe {
9960 let filename_in: CString = utils::new_c_string(filename)?;
9961 let mut out_out: *mut bindings::VipsImage = null_mut();
9962
9963 let dpi_in: f64 = svgload_options.dpi;
9964 let dpi_in_name = utils::new_c_string("dpi")?;
9965
9966 let scale_in: f64 = svgload_options.scale;
9967 let scale_in_name = utils::new_c_string("scale")?;
9968
9969 let unlimited_in: i32 = if svgload_options.unlimited { 1 } else { 0 };
9970 let unlimited_in_name = utils::new_c_string("unlimited")?;
9971
9972 let flags_in: i32 = svgload_options.flags as i32;
9973 let flags_in_name = utils::new_c_string("flags")?;
9974
9975 let memory_in: i32 = if svgload_options.memory { 1 } else { 0 };
9976 let memory_in_name = utils::new_c_string("memory")?;
9977
9978 let access_in: i32 = svgload_options.access as i32;
9979 let access_in_name = utils::new_c_string("access")?;
9980
9981 let fail_on_in: i32 = svgload_options.fail_on as i32;
9982 let fail_on_in_name = utils::new_c_string("fail-on")?;
9983
9984 let revalidate_in: i32 = if svgload_options.revalidate { 1 } else { 0 };
9985 let revalidate_in_name = utils::new_c_string("revalidate")?;
9986
9987 let vips_op_response = bindings::vips_svgload(
9988 filename_in.as_ptr(),
9989 &mut out_out,
9990 dpi_in_name.as_ptr(),
9991 dpi_in,
9992 scale_in_name.as_ptr(),
9993 scale_in,
9994 unlimited_in_name.as_ptr(),
9995 unlimited_in,
9996 flags_in_name.as_ptr(),
9997 flags_in,
9998 memory_in_name.as_ptr(),
9999 memory_in,
10000 access_in_name.as_ptr(),
10001 access_in,
10002 fail_on_in_name.as_ptr(),
10003 fail_on_in,
10004 revalidate_in_name.as_ptr(),
10005 revalidate_in,
10006 NULL,
10007 );
10008 utils::result(
10009 vips_op_response,
10010 VipsImage { ctx: out_out },
10011 Error::SvgloadError,
10012 )
10013 }
10014}
10015
10016pub fn svgload_buffer(buffer: &[u8]) -> Result<VipsImage> {
10020 unsafe {
10021 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10022 let mut out_out: *mut bindings::VipsImage = null_mut();
10023
10024 let vips_op_response =
10025 bindings::vips_svgload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
10026 utils::result(
10027 vips_op_response,
10028 VipsImage { ctx: out_out },
10029 Error::SvgloadBufferError,
10030 )
10031 }
10032}
10033
10034#[derive(Clone, Debug)]
10036pub struct SvgloadBufferOptions {
10037 pub dpi: f64,
10040 pub scale: f64,
10043 pub unlimited: bool,
10046 pub flags: ForeignFlags,
10053 pub memory: bool,
10056 pub access: Access,
10062 pub fail_on: FailOn,
10069 pub revalidate: bool,
10072}
10073
10074impl std::default::Default for SvgloadBufferOptions {
10075 fn default() -> Self {
10076 SvgloadBufferOptions {
10077 dpi: f64::from(72),
10078 scale: f64::from(1),
10079 unlimited: false,
10080 flags: ForeignFlags::None,
10081 memory: false,
10082 access: Access::Random,
10083 fail_on: FailOn::None,
10084 revalidate: false,
10085 }
10086 }
10087}
10088
10089pub fn svgload_buffer_with_opts(
10094 buffer: &[u8],
10095 svgload_buffer_options: &SvgloadBufferOptions,
10096) -> Result<VipsImage> {
10097 unsafe {
10098 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10099 let mut out_out: *mut bindings::VipsImage = null_mut();
10100
10101 let dpi_in: f64 = svgload_buffer_options.dpi;
10102 let dpi_in_name = utils::new_c_string("dpi")?;
10103
10104 let scale_in: f64 = svgload_buffer_options.scale;
10105 let scale_in_name = utils::new_c_string("scale")?;
10106
10107 let unlimited_in: i32 = if svgload_buffer_options.unlimited {
10108 1
10109 } else {
10110 0
10111 };
10112 let unlimited_in_name = utils::new_c_string("unlimited")?;
10113
10114 let flags_in: i32 = svgload_buffer_options.flags as i32;
10115 let flags_in_name = utils::new_c_string("flags")?;
10116
10117 let memory_in: i32 = if svgload_buffer_options.memory { 1 } else { 0 };
10118 let memory_in_name = utils::new_c_string("memory")?;
10119
10120 let access_in: i32 = svgload_buffer_options.access as i32;
10121 let access_in_name = utils::new_c_string("access")?;
10122
10123 let fail_on_in: i32 = svgload_buffer_options.fail_on as i32;
10124 let fail_on_in_name = utils::new_c_string("fail-on")?;
10125
10126 let revalidate_in: i32 = if svgload_buffer_options.revalidate {
10127 1
10128 } else {
10129 0
10130 };
10131 let revalidate_in_name = utils::new_c_string("revalidate")?;
10132
10133 let vips_op_response = bindings::vips_svgload_buffer(
10134 buffer_in,
10135 buffer.len() as u64,
10136 &mut out_out,
10137 dpi_in_name.as_ptr(),
10138 dpi_in,
10139 scale_in_name.as_ptr(),
10140 scale_in,
10141 unlimited_in_name.as_ptr(),
10142 unlimited_in,
10143 flags_in_name.as_ptr(),
10144 flags_in,
10145 memory_in_name.as_ptr(),
10146 memory_in,
10147 access_in_name.as_ptr(),
10148 access_in,
10149 fail_on_in_name.as_ptr(),
10150 fail_on_in,
10151 revalidate_in_name.as_ptr(),
10152 revalidate_in,
10153 NULL,
10154 );
10155 utils::result(
10156 vips_op_response,
10157 VipsImage { ctx: out_out },
10158 Error::SvgloadBufferError,
10159 )
10160 }
10161}
10162
10163pub fn gifload(filename: &str) -> Result<VipsImage> {
10167 unsafe {
10168 let filename_in: CString = utils::new_c_string(filename)?;
10169 let mut out_out: *mut bindings::VipsImage = null_mut();
10170
10171 let vips_op_response = bindings::vips_gifload(filename_in.as_ptr(), &mut out_out, NULL);
10172 utils::result(
10173 vips_op_response,
10174 VipsImage { ctx: out_out },
10175 Error::GifloadError,
10176 )
10177 }
10178}
10179
10180#[derive(Clone, Debug)]
10182pub struct GifloadOptions {
10183 pub n: i32,
10186 pub page: i32,
10189 pub flags: ForeignFlags,
10196 pub memory: bool,
10199 pub access: Access,
10205 pub fail_on: FailOn,
10212 pub revalidate: bool,
10215}
10216
10217impl std::default::Default for GifloadOptions {
10218 fn default() -> Self {
10219 GifloadOptions {
10220 n: i32::from(1),
10221 page: i32::from(0),
10222 flags: ForeignFlags::None,
10223 memory: false,
10224 access: Access::Random,
10225 fail_on: FailOn::None,
10226 revalidate: false,
10227 }
10228 }
10229}
10230
10231pub fn gifload_with_opts(filename: &str, gifload_options: &GifloadOptions) -> Result<VipsImage> {
10236 unsafe {
10237 let filename_in: CString = utils::new_c_string(filename)?;
10238 let mut out_out: *mut bindings::VipsImage = null_mut();
10239
10240 let n_in: i32 = gifload_options.n;
10241 let n_in_name = utils::new_c_string("n")?;
10242
10243 let page_in: i32 = gifload_options.page;
10244 let page_in_name = utils::new_c_string("page")?;
10245
10246 let flags_in: i32 = gifload_options.flags as i32;
10247 let flags_in_name = utils::new_c_string("flags")?;
10248
10249 let memory_in: i32 = if gifload_options.memory { 1 } else { 0 };
10250 let memory_in_name = utils::new_c_string("memory")?;
10251
10252 let access_in: i32 = gifload_options.access as i32;
10253 let access_in_name = utils::new_c_string("access")?;
10254
10255 let fail_on_in: i32 = gifload_options.fail_on as i32;
10256 let fail_on_in_name = utils::new_c_string("fail-on")?;
10257
10258 let revalidate_in: i32 = if gifload_options.revalidate { 1 } else { 0 };
10259 let revalidate_in_name = utils::new_c_string("revalidate")?;
10260
10261 let vips_op_response = bindings::vips_gifload(
10262 filename_in.as_ptr(),
10263 &mut out_out,
10264 n_in_name.as_ptr(),
10265 n_in,
10266 page_in_name.as_ptr(),
10267 page_in,
10268 flags_in_name.as_ptr(),
10269 flags_in,
10270 memory_in_name.as_ptr(),
10271 memory_in,
10272 access_in_name.as_ptr(),
10273 access_in,
10274 fail_on_in_name.as_ptr(),
10275 fail_on_in,
10276 revalidate_in_name.as_ptr(),
10277 revalidate_in,
10278 NULL,
10279 );
10280 utils::result(
10281 vips_op_response,
10282 VipsImage { ctx: out_out },
10283 Error::GifloadError,
10284 )
10285 }
10286}
10287
10288pub fn gifload_buffer(buffer: &[u8]) -> Result<VipsImage> {
10292 unsafe {
10293 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10294 let mut out_out: *mut bindings::VipsImage = null_mut();
10295
10296 let vips_op_response =
10297 bindings::vips_gifload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
10298 utils::result(
10299 vips_op_response,
10300 VipsImage { ctx: out_out },
10301 Error::GifloadBufferError,
10302 )
10303 }
10304}
10305
10306#[derive(Clone, Debug)]
10308pub struct GifloadBufferOptions {
10309 pub n: i32,
10312 pub page: i32,
10315 pub flags: ForeignFlags,
10322 pub memory: bool,
10325 pub access: Access,
10331 pub fail_on: FailOn,
10338 pub revalidate: bool,
10341}
10342
10343impl std::default::Default for GifloadBufferOptions {
10344 fn default() -> Self {
10345 GifloadBufferOptions {
10346 n: i32::from(1),
10347 page: i32::from(0),
10348 flags: ForeignFlags::None,
10349 memory: false,
10350 access: Access::Random,
10351 fail_on: FailOn::None,
10352 revalidate: false,
10353 }
10354 }
10355}
10356
10357pub fn gifload_buffer_with_opts(
10362 buffer: &[u8],
10363 gifload_buffer_options: &GifloadBufferOptions,
10364) -> Result<VipsImage> {
10365 unsafe {
10366 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10367 let mut out_out: *mut bindings::VipsImage = null_mut();
10368
10369 let n_in: i32 = gifload_buffer_options.n;
10370 let n_in_name = utils::new_c_string("n")?;
10371
10372 let page_in: i32 = gifload_buffer_options.page;
10373 let page_in_name = utils::new_c_string("page")?;
10374
10375 let flags_in: i32 = gifload_buffer_options.flags as i32;
10376 let flags_in_name = utils::new_c_string("flags")?;
10377
10378 let memory_in: i32 = if gifload_buffer_options.memory { 1 } else { 0 };
10379 let memory_in_name = utils::new_c_string("memory")?;
10380
10381 let access_in: i32 = gifload_buffer_options.access as i32;
10382 let access_in_name = utils::new_c_string("access")?;
10383
10384 let fail_on_in: i32 = gifload_buffer_options.fail_on as i32;
10385 let fail_on_in_name = utils::new_c_string("fail-on")?;
10386
10387 let revalidate_in: i32 = if gifload_buffer_options.revalidate {
10388 1
10389 } else {
10390 0
10391 };
10392 let revalidate_in_name = utils::new_c_string("revalidate")?;
10393
10394 let vips_op_response = bindings::vips_gifload_buffer(
10395 buffer_in,
10396 buffer.len() as u64,
10397 &mut out_out,
10398 n_in_name.as_ptr(),
10399 n_in,
10400 page_in_name.as_ptr(),
10401 page_in,
10402 flags_in_name.as_ptr(),
10403 flags_in,
10404 memory_in_name.as_ptr(),
10405 memory_in,
10406 access_in_name.as_ptr(),
10407 access_in,
10408 fail_on_in_name.as_ptr(),
10409 fail_on_in,
10410 revalidate_in_name.as_ptr(),
10411 revalidate_in,
10412 NULL,
10413 );
10414 utils::result(
10415 vips_op_response,
10416 VipsImage { ctx: out_out },
10417 Error::GifloadBufferError,
10418 )
10419 }
10420}
10421
10422pub fn gifload_source(source: &VipsSource) -> Result<VipsImage> {
10426 unsafe {
10427 let source_in: *mut bindings::VipsSource = source.ctx;
10428 let mut out_out: *mut bindings::VipsImage = null_mut();
10429
10430 let vips_op_response = bindings::vips_gifload_source(source_in, &mut out_out, NULL);
10431 utils::result(
10432 vips_op_response,
10433 VipsImage { ctx: out_out },
10434 Error::GifloadSourceError,
10435 )
10436 }
10437}
10438
10439#[derive(Clone, Debug)]
10441pub struct GifloadSourceOptions {
10442 pub n: i32,
10445 pub page: i32,
10448 pub flags: ForeignFlags,
10455 pub memory: bool,
10458 pub access: Access,
10464 pub fail_on: FailOn,
10471 pub revalidate: bool,
10474}
10475
10476impl std::default::Default for GifloadSourceOptions {
10477 fn default() -> Self {
10478 GifloadSourceOptions {
10479 n: i32::from(1),
10480 page: i32::from(0),
10481 flags: ForeignFlags::None,
10482 memory: false,
10483 access: Access::Random,
10484 fail_on: FailOn::None,
10485 revalidate: false,
10486 }
10487 }
10488}
10489
10490pub fn gifload_source_with_opts(
10495 source: &VipsSource,
10496 gifload_source_options: &GifloadSourceOptions,
10497) -> Result<VipsImage> {
10498 unsafe {
10499 let source_in: *mut bindings::VipsSource = source.ctx;
10500 let mut out_out: *mut bindings::VipsImage = null_mut();
10501
10502 let n_in: i32 = gifload_source_options.n;
10503 let n_in_name = utils::new_c_string("n")?;
10504
10505 let page_in: i32 = gifload_source_options.page;
10506 let page_in_name = utils::new_c_string("page")?;
10507
10508 let flags_in: i32 = gifload_source_options.flags as i32;
10509 let flags_in_name = utils::new_c_string("flags")?;
10510
10511 let memory_in: i32 = if gifload_source_options.memory { 1 } else { 0 };
10512 let memory_in_name = utils::new_c_string("memory")?;
10513
10514 let access_in: i32 = gifload_source_options.access as i32;
10515 let access_in_name = utils::new_c_string("access")?;
10516
10517 let fail_on_in: i32 = gifload_source_options.fail_on as i32;
10518 let fail_on_in_name = utils::new_c_string("fail-on")?;
10519
10520 let revalidate_in: i32 = if gifload_source_options.revalidate {
10521 1
10522 } else {
10523 0
10524 };
10525 let revalidate_in_name = utils::new_c_string("revalidate")?;
10526
10527 let vips_op_response = bindings::vips_gifload_source(
10528 source_in,
10529 &mut out_out,
10530 n_in_name.as_ptr(),
10531 n_in,
10532 page_in_name.as_ptr(),
10533 page_in,
10534 flags_in_name.as_ptr(),
10535 flags_in,
10536 memory_in_name.as_ptr(),
10537 memory_in,
10538 access_in_name.as_ptr(),
10539 access_in,
10540 fail_on_in_name.as_ptr(),
10541 fail_on_in,
10542 revalidate_in_name.as_ptr(),
10543 revalidate_in,
10544 NULL,
10545 );
10546 utils::result(
10547 vips_op_response,
10548 VipsImage { ctx: out_out },
10549 Error::GifloadSourceError,
10550 )
10551 }
10552}
10553
10554pub fn pngload(filename: &str) -> Result<VipsImage> {
10558 unsafe {
10559 let filename_in: CString = utils::new_c_string(filename)?;
10560 let mut out_out: *mut bindings::VipsImage = null_mut();
10561
10562 let vips_op_response = bindings::vips_pngload(filename_in.as_ptr(), &mut out_out, NULL);
10563 utils::result(
10564 vips_op_response,
10565 VipsImage { ctx: out_out },
10566 Error::PngloadError,
10567 )
10568 }
10569}
10570
10571#[derive(Clone, Debug)]
10573pub struct PngloadOptions {
10574 pub unlimited: bool,
10577 pub flags: ForeignFlags,
10584 pub memory: bool,
10587 pub access: Access,
10593 pub fail_on: FailOn,
10600 pub revalidate: bool,
10603}
10604
10605impl std::default::Default for PngloadOptions {
10606 fn default() -> Self {
10607 PngloadOptions {
10608 unlimited: false,
10609 flags: ForeignFlags::None,
10610 memory: false,
10611 access: Access::Random,
10612 fail_on: FailOn::None,
10613 revalidate: false,
10614 }
10615 }
10616}
10617
10618pub fn pngload_with_opts(filename: &str, pngload_options: &PngloadOptions) -> Result<VipsImage> {
10623 unsafe {
10624 let filename_in: CString = utils::new_c_string(filename)?;
10625 let mut out_out: *mut bindings::VipsImage = null_mut();
10626
10627 let unlimited_in: i32 = if pngload_options.unlimited { 1 } else { 0 };
10628 let unlimited_in_name = utils::new_c_string("unlimited")?;
10629
10630 let flags_in: i32 = pngload_options.flags as i32;
10631 let flags_in_name = utils::new_c_string("flags")?;
10632
10633 let memory_in: i32 = if pngload_options.memory { 1 } else { 0 };
10634 let memory_in_name = utils::new_c_string("memory")?;
10635
10636 let access_in: i32 = pngload_options.access as i32;
10637 let access_in_name = utils::new_c_string("access")?;
10638
10639 let fail_on_in: i32 = pngload_options.fail_on as i32;
10640 let fail_on_in_name = utils::new_c_string("fail-on")?;
10641
10642 let revalidate_in: i32 = if pngload_options.revalidate { 1 } else { 0 };
10643 let revalidate_in_name = utils::new_c_string("revalidate")?;
10644
10645 let vips_op_response = bindings::vips_pngload(
10646 filename_in.as_ptr(),
10647 &mut out_out,
10648 unlimited_in_name.as_ptr(),
10649 unlimited_in,
10650 flags_in_name.as_ptr(),
10651 flags_in,
10652 memory_in_name.as_ptr(),
10653 memory_in,
10654 access_in_name.as_ptr(),
10655 access_in,
10656 fail_on_in_name.as_ptr(),
10657 fail_on_in,
10658 revalidate_in_name.as_ptr(),
10659 revalidate_in,
10660 NULL,
10661 );
10662 utils::result(
10663 vips_op_response,
10664 VipsImage { ctx: out_out },
10665 Error::PngloadError,
10666 )
10667 }
10668}
10669
10670pub fn pngload_buffer(buffer: &[u8]) -> Result<VipsImage> {
10674 unsafe {
10675 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10676 let mut out_out: *mut bindings::VipsImage = null_mut();
10677
10678 let vips_op_response =
10679 bindings::vips_pngload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
10680 utils::result(
10681 vips_op_response,
10682 VipsImage { ctx: out_out },
10683 Error::PngloadBufferError,
10684 )
10685 }
10686}
10687
10688#[derive(Clone, Debug)]
10690pub struct PngloadBufferOptions {
10691 pub unlimited: bool,
10694 pub flags: ForeignFlags,
10701 pub memory: bool,
10704 pub access: Access,
10710 pub fail_on: FailOn,
10717 pub revalidate: bool,
10720}
10721
10722impl std::default::Default for PngloadBufferOptions {
10723 fn default() -> Self {
10724 PngloadBufferOptions {
10725 unlimited: false,
10726 flags: ForeignFlags::None,
10727 memory: false,
10728 access: Access::Random,
10729 fail_on: FailOn::None,
10730 revalidate: false,
10731 }
10732 }
10733}
10734
10735pub fn pngload_buffer_with_opts(
10740 buffer: &[u8],
10741 pngload_buffer_options: &PngloadBufferOptions,
10742) -> Result<VipsImage> {
10743 unsafe {
10744 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
10745 let mut out_out: *mut bindings::VipsImage = null_mut();
10746
10747 let unlimited_in: i32 = if pngload_buffer_options.unlimited {
10748 1
10749 } else {
10750 0
10751 };
10752 let unlimited_in_name = utils::new_c_string("unlimited")?;
10753
10754 let flags_in: i32 = pngload_buffer_options.flags as i32;
10755 let flags_in_name = utils::new_c_string("flags")?;
10756
10757 let memory_in: i32 = if pngload_buffer_options.memory { 1 } else { 0 };
10758 let memory_in_name = utils::new_c_string("memory")?;
10759
10760 let access_in: i32 = pngload_buffer_options.access as i32;
10761 let access_in_name = utils::new_c_string("access")?;
10762
10763 let fail_on_in: i32 = pngload_buffer_options.fail_on as i32;
10764 let fail_on_in_name = utils::new_c_string("fail-on")?;
10765
10766 let revalidate_in: i32 = if pngload_buffer_options.revalidate {
10767 1
10768 } else {
10769 0
10770 };
10771 let revalidate_in_name = utils::new_c_string("revalidate")?;
10772
10773 let vips_op_response = bindings::vips_pngload_buffer(
10774 buffer_in,
10775 buffer.len() as u64,
10776 &mut out_out,
10777 unlimited_in_name.as_ptr(),
10778 unlimited_in,
10779 flags_in_name.as_ptr(),
10780 flags_in,
10781 memory_in_name.as_ptr(),
10782 memory_in,
10783 access_in_name.as_ptr(),
10784 access_in,
10785 fail_on_in_name.as_ptr(),
10786 fail_on_in,
10787 revalidate_in_name.as_ptr(),
10788 revalidate_in,
10789 NULL,
10790 );
10791 utils::result(
10792 vips_op_response,
10793 VipsImage { ctx: out_out },
10794 Error::PngloadBufferError,
10795 )
10796 }
10797}
10798
10799pub fn pngload_source(source: &VipsSource) -> Result<VipsImage> {
10803 unsafe {
10804 let source_in: *mut bindings::VipsSource = source.ctx;
10805 let mut out_out: *mut bindings::VipsImage = null_mut();
10806
10807 let vips_op_response = bindings::vips_pngload_source(source_in, &mut out_out, NULL);
10808 utils::result(
10809 vips_op_response,
10810 VipsImage { ctx: out_out },
10811 Error::PngloadSourceError,
10812 )
10813 }
10814}
10815
10816#[derive(Clone, Debug)]
10818pub struct PngloadSourceOptions {
10819 pub unlimited: bool,
10822 pub flags: ForeignFlags,
10829 pub memory: bool,
10832 pub access: Access,
10838 pub fail_on: FailOn,
10845 pub revalidate: bool,
10848}
10849
10850impl std::default::Default for PngloadSourceOptions {
10851 fn default() -> Self {
10852 PngloadSourceOptions {
10853 unlimited: false,
10854 flags: ForeignFlags::None,
10855 memory: false,
10856 access: Access::Random,
10857 fail_on: FailOn::None,
10858 revalidate: false,
10859 }
10860 }
10861}
10862
10863pub fn pngload_source_with_opts(
10868 source: &VipsSource,
10869 pngload_source_options: &PngloadSourceOptions,
10870) -> Result<VipsImage> {
10871 unsafe {
10872 let source_in: *mut bindings::VipsSource = source.ctx;
10873 let mut out_out: *mut bindings::VipsImage = null_mut();
10874
10875 let unlimited_in: i32 = if pngload_source_options.unlimited {
10876 1
10877 } else {
10878 0
10879 };
10880 let unlimited_in_name = utils::new_c_string("unlimited")?;
10881
10882 let flags_in: i32 = pngload_source_options.flags as i32;
10883 let flags_in_name = utils::new_c_string("flags")?;
10884
10885 let memory_in: i32 = if pngload_source_options.memory { 1 } else { 0 };
10886 let memory_in_name = utils::new_c_string("memory")?;
10887
10888 let access_in: i32 = pngload_source_options.access as i32;
10889 let access_in_name = utils::new_c_string("access")?;
10890
10891 let fail_on_in: i32 = pngload_source_options.fail_on as i32;
10892 let fail_on_in_name = utils::new_c_string("fail-on")?;
10893
10894 let revalidate_in: i32 = if pngload_source_options.revalidate {
10895 1
10896 } else {
10897 0
10898 };
10899 let revalidate_in_name = utils::new_c_string("revalidate")?;
10900
10901 let vips_op_response = bindings::vips_pngload_source(
10902 source_in,
10903 &mut out_out,
10904 unlimited_in_name.as_ptr(),
10905 unlimited_in,
10906 flags_in_name.as_ptr(),
10907 flags_in,
10908 memory_in_name.as_ptr(),
10909 memory_in,
10910 access_in_name.as_ptr(),
10911 access_in,
10912 fail_on_in_name.as_ptr(),
10913 fail_on_in,
10914 revalidate_in_name.as_ptr(),
10915 revalidate_in,
10916 NULL,
10917 );
10918 utils::result(
10919 vips_op_response,
10920 VipsImage { ctx: out_out },
10921 Error::PngloadSourceError,
10922 )
10923 }
10924}
10925
10926pub fn jpegload(filename: &str) -> Result<VipsImage> {
10930 unsafe {
10931 let filename_in: CString = utils::new_c_string(filename)?;
10932 let mut out_out: *mut bindings::VipsImage = null_mut();
10933
10934 let vips_op_response = bindings::vips_jpegload(filename_in.as_ptr(), &mut out_out, NULL);
10935 utils::result(
10936 vips_op_response,
10937 VipsImage { ctx: out_out },
10938 Error::JpegloadError,
10939 )
10940 }
10941}
10942
10943#[derive(Clone, Debug)]
10945pub struct JpegloadOptions {
10946 pub shrink: i32,
10949 pub autorotate: bool,
10952 pub unlimited: bool,
10955 pub flags: ForeignFlags,
10962 pub memory: bool,
10965 pub access: Access,
10971 pub fail_on: FailOn,
10978 pub revalidate: bool,
10981}
10982
10983impl std::default::Default for JpegloadOptions {
10984 fn default() -> Self {
10985 JpegloadOptions {
10986 shrink: i32::from(1),
10987 autorotate: false,
10988 unlimited: false,
10989 flags: ForeignFlags::None,
10990 memory: false,
10991 access: Access::Random,
10992 fail_on: FailOn::None,
10993 revalidate: false,
10994 }
10995 }
10996}
10997
10998pub fn jpegload_with_opts(filename: &str, jpegload_options: &JpegloadOptions) -> Result<VipsImage> {
11003 unsafe {
11004 let filename_in: CString = utils::new_c_string(filename)?;
11005 let mut out_out: *mut bindings::VipsImage = null_mut();
11006
11007 let shrink_in: i32 = jpegload_options.shrink;
11008 let shrink_in_name = utils::new_c_string("shrink")?;
11009
11010 let autorotate_in: i32 = if jpegload_options.autorotate { 1 } else { 0 };
11011 let autorotate_in_name = utils::new_c_string("autorotate")?;
11012
11013 let unlimited_in: i32 = if jpegload_options.unlimited { 1 } else { 0 };
11014 let unlimited_in_name = utils::new_c_string("unlimited")?;
11015
11016 let flags_in: i32 = jpegload_options.flags as i32;
11017 let flags_in_name = utils::new_c_string("flags")?;
11018
11019 let memory_in: i32 = if jpegload_options.memory { 1 } else { 0 };
11020 let memory_in_name = utils::new_c_string("memory")?;
11021
11022 let access_in: i32 = jpegload_options.access as i32;
11023 let access_in_name = utils::new_c_string("access")?;
11024
11025 let fail_on_in: i32 = jpegload_options.fail_on as i32;
11026 let fail_on_in_name = utils::new_c_string("fail-on")?;
11027
11028 let revalidate_in: i32 = if jpegload_options.revalidate { 1 } else { 0 };
11029 let revalidate_in_name = utils::new_c_string("revalidate")?;
11030
11031 let vips_op_response = bindings::vips_jpegload(
11032 filename_in.as_ptr(),
11033 &mut out_out,
11034 shrink_in_name.as_ptr(),
11035 shrink_in,
11036 autorotate_in_name.as_ptr(),
11037 autorotate_in,
11038 unlimited_in_name.as_ptr(),
11039 unlimited_in,
11040 flags_in_name.as_ptr(),
11041 flags_in,
11042 memory_in_name.as_ptr(),
11043 memory_in,
11044 access_in_name.as_ptr(),
11045 access_in,
11046 fail_on_in_name.as_ptr(),
11047 fail_on_in,
11048 revalidate_in_name.as_ptr(),
11049 revalidate_in,
11050 NULL,
11051 );
11052 utils::result(
11053 vips_op_response,
11054 VipsImage { ctx: out_out },
11055 Error::JpegloadError,
11056 )
11057 }
11058}
11059
11060pub fn jpegload_buffer(buffer: &[u8]) -> Result<VipsImage> {
11064 unsafe {
11065 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11066 let mut out_out: *mut bindings::VipsImage = null_mut();
11067
11068 let vips_op_response =
11069 bindings::vips_jpegload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
11070 utils::result(
11071 vips_op_response,
11072 VipsImage { ctx: out_out },
11073 Error::JpegloadBufferError,
11074 )
11075 }
11076}
11077
11078#[derive(Clone, Debug)]
11080pub struct JpegloadBufferOptions {
11081 pub shrink: i32,
11084 pub autorotate: bool,
11087 pub unlimited: bool,
11090 pub flags: ForeignFlags,
11097 pub memory: bool,
11100 pub access: Access,
11106 pub fail_on: FailOn,
11113 pub revalidate: bool,
11116}
11117
11118impl std::default::Default for JpegloadBufferOptions {
11119 fn default() -> Self {
11120 JpegloadBufferOptions {
11121 shrink: i32::from(1),
11122 autorotate: false,
11123 unlimited: false,
11124 flags: ForeignFlags::None,
11125 memory: false,
11126 access: Access::Random,
11127 fail_on: FailOn::None,
11128 revalidate: false,
11129 }
11130 }
11131}
11132
11133pub fn jpegload_buffer_with_opts(
11138 buffer: &[u8],
11139 jpegload_buffer_options: &JpegloadBufferOptions,
11140) -> Result<VipsImage> {
11141 unsafe {
11142 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11143 let mut out_out: *mut bindings::VipsImage = null_mut();
11144
11145 let shrink_in: i32 = jpegload_buffer_options.shrink;
11146 let shrink_in_name = utils::new_c_string("shrink")?;
11147
11148 let autorotate_in: i32 = if jpegload_buffer_options.autorotate {
11149 1
11150 } else {
11151 0
11152 };
11153 let autorotate_in_name = utils::new_c_string("autorotate")?;
11154
11155 let unlimited_in: i32 = if jpegload_buffer_options.unlimited {
11156 1
11157 } else {
11158 0
11159 };
11160 let unlimited_in_name = utils::new_c_string("unlimited")?;
11161
11162 let flags_in: i32 = jpegload_buffer_options.flags as i32;
11163 let flags_in_name = utils::new_c_string("flags")?;
11164
11165 let memory_in: i32 = if jpegload_buffer_options.memory { 1 } else { 0 };
11166 let memory_in_name = utils::new_c_string("memory")?;
11167
11168 let access_in: i32 = jpegload_buffer_options.access as i32;
11169 let access_in_name = utils::new_c_string("access")?;
11170
11171 let fail_on_in: i32 = jpegload_buffer_options.fail_on as i32;
11172 let fail_on_in_name = utils::new_c_string("fail-on")?;
11173
11174 let revalidate_in: i32 = if jpegload_buffer_options.revalidate {
11175 1
11176 } else {
11177 0
11178 };
11179 let revalidate_in_name = utils::new_c_string("revalidate")?;
11180
11181 let vips_op_response = bindings::vips_jpegload_buffer(
11182 buffer_in,
11183 buffer.len() as u64,
11184 &mut out_out,
11185 shrink_in_name.as_ptr(),
11186 shrink_in,
11187 autorotate_in_name.as_ptr(),
11188 autorotate_in,
11189 unlimited_in_name.as_ptr(),
11190 unlimited_in,
11191 flags_in_name.as_ptr(),
11192 flags_in,
11193 memory_in_name.as_ptr(),
11194 memory_in,
11195 access_in_name.as_ptr(),
11196 access_in,
11197 fail_on_in_name.as_ptr(),
11198 fail_on_in,
11199 revalidate_in_name.as_ptr(),
11200 revalidate_in,
11201 NULL,
11202 );
11203 utils::result(
11204 vips_op_response,
11205 VipsImage { ctx: out_out },
11206 Error::JpegloadBufferError,
11207 )
11208 }
11209}
11210
11211pub fn webpload(filename: &str) -> Result<VipsImage> {
11215 unsafe {
11216 let filename_in: CString = utils::new_c_string(filename)?;
11217 let mut out_out: *mut bindings::VipsImage = null_mut();
11218
11219 let vips_op_response = bindings::vips_webpload(filename_in.as_ptr(), &mut out_out, NULL);
11220 utils::result(
11221 vips_op_response,
11222 VipsImage { ctx: out_out },
11223 Error::WebploadError,
11224 )
11225 }
11226}
11227
11228#[derive(Clone, Debug)]
11230pub struct WebploadOptions {
11231 pub page: i32,
11234 pub n: i32,
11237 pub scale: f64,
11240 pub flags: ForeignFlags,
11247 pub memory: bool,
11250 pub access: Access,
11256 pub fail_on: FailOn,
11263 pub revalidate: bool,
11266}
11267
11268impl std::default::Default for WebploadOptions {
11269 fn default() -> Self {
11270 WebploadOptions {
11271 page: i32::from(0),
11272 n: i32::from(1),
11273 scale: f64::from(1),
11274 flags: ForeignFlags::None,
11275 memory: false,
11276 access: Access::Random,
11277 fail_on: FailOn::None,
11278 revalidate: false,
11279 }
11280 }
11281}
11282
11283pub fn webpload_with_opts(filename: &str, webpload_options: &WebploadOptions) -> Result<VipsImage> {
11288 unsafe {
11289 let filename_in: CString = utils::new_c_string(filename)?;
11290 let mut out_out: *mut bindings::VipsImage = null_mut();
11291
11292 let page_in: i32 = webpload_options.page;
11293 let page_in_name = utils::new_c_string("page")?;
11294
11295 let n_in: i32 = webpload_options.n;
11296 let n_in_name = utils::new_c_string("n")?;
11297
11298 let scale_in: f64 = webpload_options.scale;
11299 let scale_in_name = utils::new_c_string("scale")?;
11300
11301 let flags_in: i32 = webpload_options.flags as i32;
11302 let flags_in_name = utils::new_c_string("flags")?;
11303
11304 let memory_in: i32 = if webpload_options.memory { 1 } else { 0 };
11305 let memory_in_name = utils::new_c_string("memory")?;
11306
11307 let access_in: i32 = webpload_options.access as i32;
11308 let access_in_name = utils::new_c_string("access")?;
11309
11310 let fail_on_in: i32 = webpload_options.fail_on as i32;
11311 let fail_on_in_name = utils::new_c_string("fail-on")?;
11312
11313 let revalidate_in: i32 = if webpload_options.revalidate { 1 } else { 0 };
11314 let revalidate_in_name = utils::new_c_string("revalidate")?;
11315
11316 let vips_op_response = bindings::vips_webpload(
11317 filename_in.as_ptr(),
11318 &mut out_out,
11319 page_in_name.as_ptr(),
11320 page_in,
11321 n_in_name.as_ptr(),
11322 n_in,
11323 scale_in_name.as_ptr(),
11324 scale_in,
11325 flags_in_name.as_ptr(),
11326 flags_in,
11327 memory_in_name.as_ptr(),
11328 memory_in,
11329 access_in_name.as_ptr(),
11330 access_in,
11331 fail_on_in_name.as_ptr(),
11332 fail_on_in,
11333 revalidate_in_name.as_ptr(),
11334 revalidate_in,
11335 NULL,
11336 );
11337 utils::result(
11338 vips_op_response,
11339 VipsImage { ctx: out_out },
11340 Error::WebploadError,
11341 )
11342 }
11343}
11344
11345pub fn webpload_buffer(buffer: &[u8]) -> Result<VipsImage> {
11349 unsafe {
11350 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11351 let mut out_out: *mut bindings::VipsImage = null_mut();
11352
11353 let vips_op_response =
11354 bindings::vips_webpload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
11355 utils::result(
11356 vips_op_response,
11357 VipsImage { ctx: out_out },
11358 Error::WebploadBufferError,
11359 )
11360 }
11361}
11362
11363#[derive(Clone, Debug)]
11365pub struct WebploadBufferOptions {
11366 pub page: i32,
11369 pub n: i32,
11372 pub scale: f64,
11375 pub flags: ForeignFlags,
11382 pub memory: bool,
11385 pub access: Access,
11391 pub fail_on: FailOn,
11398 pub revalidate: bool,
11401}
11402
11403impl std::default::Default for WebploadBufferOptions {
11404 fn default() -> Self {
11405 WebploadBufferOptions {
11406 page: i32::from(0),
11407 n: i32::from(1),
11408 scale: f64::from(1),
11409 flags: ForeignFlags::None,
11410 memory: false,
11411 access: Access::Random,
11412 fail_on: FailOn::None,
11413 revalidate: false,
11414 }
11415 }
11416}
11417
11418pub fn webpload_buffer_with_opts(
11423 buffer: &[u8],
11424 webpload_buffer_options: &WebploadBufferOptions,
11425) -> Result<VipsImage> {
11426 unsafe {
11427 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11428 let mut out_out: *mut bindings::VipsImage = null_mut();
11429
11430 let page_in: i32 = webpload_buffer_options.page;
11431 let page_in_name = utils::new_c_string("page")?;
11432
11433 let n_in: i32 = webpload_buffer_options.n;
11434 let n_in_name = utils::new_c_string("n")?;
11435
11436 let scale_in: f64 = webpload_buffer_options.scale;
11437 let scale_in_name = utils::new_c_string("scale")?;
11438
11439 let flags_in: i32 = webpload_buffer_options.flags as i32;
11440 let flags_in_name = utils::new_c_string("flags")?;
11441
11442 let memory_in: i32 = if webpload_buffer_options.memory { 1 } else { 0 };
11443 let memory_in_name = utils::new_c_string("memory")?;
11444
11445 let access_in: i32 = webpload_buffer_options.access as i32;
11446 let access_in_name = utils::new_c_string("access")?;
11447
11448 let fail_on_in: i32 = webpload_buffer_options.fail_on as i32;
11449 let fail_on_in_name = utils::new_c_string("fail-on")?;
11450
11451 let revalidate_in: i32 = if webpload_buffer_options.revalidate {
11452 1
11453 } else {
11454 0
11455 };
11456 let revalidate_in_name = utils::new_c_string("revalidate")?;
11457
11458 let vips_op_response = bindings::vips_webpload_buffer(
11459 buffer_in,
11460 buffer.len() as u64,
11461 &mut out_out,
11462 page_in_name.as_ptr(),
11463 page_in,
11464 n_in_name.as_ptr(),
11465 n_in,
11466 scale_in_name.as_ptr(),
11467 scale_in,
11468 flags_in_name.as_ptr(),
11469 flags_in,
11470 memory_in_name.as_ptr(),
11471 memory_in,
11472 access_in_name.as_ptr(),
11473 access_in,
11474 fail_on_in_name.as_ptr(),
11475 fail_on_in,
11476 revalidate_in_name.as_ptr(),
11477 revalidate_in,
11478 NULL,
11479 );
11480 utils::result(
11481 vips_op_response,
11482 VipsImage { ctx: out_out },
11483 Error::WebploadBufferError,
11484 )
11485 }
11486}
11487
11488pub fn webpload_source(source: &VipsSource) -> Result<VipsImage> {
11492 unsafe {
11493 let source_in: *mut bindings::VipsSource = source.ctx;
11494 let mut out_out: *mut bindings::VipsImage = null_mut();
11495
11496 let vips_op_response = bindings::vips_webpload_source(source_in, &mut out_out, NULL);
11497 utils::result(
11498 vips_op_response,
11499 VipsImage { ctx: out_out },
11500 Error::WebploadSourceError,
11501 )
11502 }
11503}
11504
11505#[derive(Clone, Debug)]
11507pub struct WebploadSourceOptions {
11508 pub page: i32,
11511 pub n: i32,
11514 pub scale: f64,
11517 pub flags: ForeignFlags,
11524 pub memory: bool,
11527 pub access: Access,
11533 pub fail_on: FailOn,
11540 pub revalidate: bool,
11543}
11544
11545impl std::default::Default for WebploadSourceOptions {
11546 fn default() -> Self {
11547 WebploadSourceOptions {
11548 page: i32::from(0),
11549 n: i32::from(1),
11550 scale: f64::from(1),
11551 flags: ForeignFlags::None,
11552 memory: false,
11553 access: Access::Random,
11554 fail_on: FailOn::None,
11555 revalidate: false,
11556 }
11557 }
11558}
11559
11560pub fn webpload_source_with_opts(
11565 source: &VipsSource,
11566 webpload_source_options: &WebploadSourceOptions,
11567) -> Result<VipsImage> {
11568 unsafe {
11569 let source_in: *mut bindings::VipsSource = source.ctx;
11570 let mut out_out: *mut bindings::VipsImage = null_mut();
11571
11572 let page_in: i32 = webpload_source_options.page;
11573 let page_in_name = utils::new_c_string("page")?;
11574
11575 let n_in: i32 = webpload_source_options.n;
11576 let n_in_name = utils::new_c_string("n")?;
11577
11578 let scale_in: f64 = webpload_source_options.scale;
11579 let scale_in_name = utils::new_c_string("scale")?;
11580
11581 let flags_in: i32 = webpload_source_options.flags as i32;
11582 let flags_in_name = utils::new_c_string("flags")?;
11583
11584 let memory_in: i32 = if webpload_source_options.memory { 1 } else { 0 };
11585 let memory_in_name = utils::new_c_string("memory")?;
11586
11587 let access_in: i32 = webpload_source_options.access as i32;
11588 let access_in_name = utils::new_c_string("access")?;
11589
11590 let fail_on_in: i32 = webpload_source_options.fail_on as i32;
11591 let fail_on_in_name = utils::new_c_string("fail-on")?;
11592
11593 let revalidate_in: i32 = if webpload_source_options.revalidate {
11594 1
11595 } else {
11596 0
11597 };
11598 let revalidate_in_name = utils::new_c_string("revalidate")?;
11599
11600 let vips_op_response = bindings::vips_webpload_source(
11601 source_in,
11602 &mut out_out,
11603 page_in_name.as_ptr(),
11604 page_in,
11605 n_in_name.as_ptr(),
11606 n_in,
11607 scale_in_name.as_ptr(),
11608 scale_in,
11609 flags_in_name.as_ptr(),
11610 flags_in,
11611 memory_in_name.as_ptr(),
11612 memory_in,
11613 access_in_name.as_ptr(),
11614 access_in,
11615 fail_on_in_name.as_ptr(),
11616 fail_on_in,
11617 revalidate_in_name.as_ptr(),
11618 revalidate_in,
11619 NULL,
11620 );
11621 utils::result(
11622 vips_op_response,
11623 VipsImage { ctx: out_out },
11624 Error::WebploadSourceError,
11625 )
11626 }
11627}
11628
11629pub fn tiffload(filename: &str) -> Result<VipsImage> {
11633 unsafe {
11634 let filename_in: CString = utils::new_c_string(filename)?;
11635 let mut out_out: *mut bindings::VipsImage = null_mut();
11636
11637 let vips_op_response = bindings::vips_tiffload(filename_in.as_ptr(), &mut out_out, NULL);
11638 utils::result(
11639 vips_op_response,
11640 VipsImage { ctx: out_out },
11641 Error::TiffloadError,
11642 )
11643 }
11644}
11645
11646#[derive(Clone, Debug)]
11648pub struct TiffloadOptions {
11649 pub page: i32,
11652 pub subifd: i32,
11655 pub n: i32,
11658 pub autorotate: bool,
11661 pub flags: ForeignFlags,
11668 pub memory: bool,
11671 pub access: Access,
11677 pub fail_on: FailOn,
11684 pub revalidate: bool,
11687}
11688
11689impl std::default::Default for TiffloadOptions {
11690 fn default() -> Self {
11691 TiffloadOptions {
11692 page: i32::from(0),
11693 subifd: i32::from(-1),
11694 n: i32::from(1),
11695 autorotate: false,
11696 flags: ForeignFlags::None,
11697 memory: false,
11698 access: Access::Random,
11699 fail_on: FailOn::None,
11700 revalidate: false,
11701 }
11702 }
11703}
11704
11705pub fn tiffload_with_opts(filename: &str, tiffload_options: &TiffloadOptions) -> Result<VipsImage> {
11710 unsafe {
11711 let filename_in: CString = utils::new_c_string(filename)?;
11712 let mut out_out: *mut bindings::VipsImage = null_mut();
11713
11714 let page_in: i32 = tiffload_options.page;
11715 let page_in_name = utils::new_c_string("page")?;
11716
11717 let subifd_in: i32 = tiffload_options.subifd;
11718 let subifd_in_name = utils::new_c_string("subifd")?;
11719
11720 let n_in: i32 = tiffload_options.n;
11721 let n_in_name = utils::new_c_string("n")?;
11722
11723 let autorotate_in: i32 = if tiffload_options.autorotate { 1 } else { 0 };
11724 let autorotate_in_name = utils::new_c_string("autorotate")?;
11725
11726 let flags_in: i32 = tiffload_options.flags as i32;
11727 let flags_in_name = utils::new_c_string("flags")?;
11728
11729 let memory_in: i32 = if tiffload_options.memory { 1 } else { 0 };
11730 let memory_in_name = utils::new_c_string("memory")?;
11731
11732 let access_in: i32 = tiffload_options.access as i32;
11733 let access_in_name = utils::new_c_string("access")?;
11734
11735 let fail_on_in: i32 = tiffload_options.fail_on as i32;
11736 let fail_on_in_name = utils::new_c_string("fail-on")?;
11737
11738 let revalidate_in: i32 = if tiffload_options.revalidate { 1 } else { 0 };
11739 let revalidate_in_name = utils::new_c_string("revalidate")?;
11740
11741 let vips_op_response = bindings::vips_tiffload(
11742 filename_in.as_ptr(),
11743 &mut out_out,
11744 page_in_name.as_ptr(),
11745 page_in,
11746 subifd_in_name.as_ptr(),
11747 subifd_in,
11748 n_in_name.as_ptr(),
11749 n_in,
11750 autorotate_in_name.as_ptr(),
11751 autorotate_in,
11752 flags_in_name.as_ptr(),
11753 flags_in,
11754 memory_in_name.as_ptr(),
11755 memory_in,
11756 access_in_name.as_ptr(),
11757 access_in,
11758 fail_on_in_name.as_ptr(),
11759 fail_on_in,
11760 revalidate_in_name.as_ptr(),
11761 revalidate_in,
11762 NULL,
11763 );
11764 utils::result(
11765 vips_op_response,
11766 VipsImage { ctx: out_out },
11767 Error::TiffloadError,
11768 )
11769 }
11770}
11771
11772pub fn tiffload_buffer(buffer: &[u8]) -> Result<VipsImage> {
11776 unsafe {
11777 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11778 let mut out_out: *mut bindings::VipsImage = null_mut();
11779
11780 let vips_op_response =
11781 bindings::vips_tiffload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
11782 utils::result(
11783 vips_op_response,
11784 VipsImage { ctx: out_out },
11785 Error::TiffloadBufferError,
11786 )
11787 }
11788}
11789
11790#[derive(Clone, Debug)]
11792pub struct TiffloadBufferOptions {
11793 pub page: i32,
11796 pub subifd: i32,
11799 pub n: i32,
11802 pub autorotate: bool,
11805 pub flags: ForeignFlags,
11812 pub memory: bool,
11815 pub access: Access,
11821 pub fail_on: FailOn,
11828 pub revalidate: bool,
11831}
11832
11833impl std::default::Default for TiffloadBufferOptions {
11834 fn default() -> Self {
11835 TiffloadBufferOptions {
11836 page: i32::from(0),
11837 subifd: i32::from(-1),
11838 n: i32::from(1),
11839 autorotate: false,
11840 flags: ForeignFlags::None,
11841 memory: false,
11842 access: Access::Random,
11843 fail_on: FailOn::None,
11844 revalidate: false,
11845 }
11846 }
11847}
11848
11849pub fn tiffload_buffer_with_opts(
11854 buffer: &[u8],
11855 tiffload_buffer_options: &TiffloadBufferOptions,
11856) -> Result<VipsImage> {
11857 unsafe {
11858 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
11859 let mut out_out: *mut bindings::VipsImage = null_mut();
11860
11861 let page_in: i32 = tiffload_buffer_options.page;
11862 let page_in_name = utils::new_c_string("page")?;
11863
11864 let subifd_in: i32 = tiffload_buffer_options.subifd;
11865 let subifd_in_name = utils::new_c_string("subifd")?;
11866
11867 let n_in: i32 = tiffload_buffer_options.n;
11868 let n_in_name = utils::new_c_string("n")?;
11869
11870 let autorotate_in: i32 = if tiffload_buffer_options.autorotate {
11871 1
11872 } else {
11873 0
11874 };
11875 let autorotate_in_name = utils::new_c_string("autorotate")?;
11876
11877 let flags_in: i32 = tiffload_buffer_options.flags as i32;
11878 let flags_in_name = utils::new_c_string("flags")?;
11879
11880 let memory_in: i32 = if tiffload_buffer_options.memory { 1 } else { 0 };
11881 let memory_in_name = utils::new_c_string("memory")?;
11882
11883 let access_in: i32 = tiffload_buffer_options.access as i32;
11884 let access_in_name = utils::new_c_string("access")?;
11885
11886 let fail_on_in: i32 = tiffload_buffer_options.fail_on as i32;
11887 let fail_on_in_name = utils::new_c_string("fail-on")?;
11888
11889 let revalidate_in: i32 = if tiffload_buffer_options.revalidate {
11890 1
11891 } else {
11892 0
11893 };
11894 let revalidate_in_name = utils::new_c_string("revalidate")?;
11895
11896 let vips_op_response = bindings::vips_tiffload_buffer(
11897 buffer_in,
11898 buffer.len() as u64,
11899 &mut out_out,
11900 page_in_name.as_ptr(),
11901 page_in,
11902 subifd_in_name.as_ptr(),
11903 subifd_in,
11904 n_in_name.as_ptr(),
11905 n_in,
11906 autorotate_in_name.as_ptr(),
11907 autorotate_in,
11908 flags_in_name.as_ptr(),
11909 flags_in,
11910 memory_in_name.as_ptr(),
11911 memory_in,
11912 access_in_name.as_ptr(),
11913 access_in,
11914 fail_on_in_name.as_ptr(),
11915 fail_on_in,
11916 revalidate_in_name.as_ptr(),
11917 revalidate_in,
11918 NULL,
11919 );
11920 utils::result(
11921 vips_op_response,
11922 VipsImage { ctx: out_out },
11923 Error::TiffloadBufferError,
11924 )
11925 }
11926}
11927
11928pub fn tiffload_source(source: &VipsSource) -> Result<VipsImage> {
11932 unsafe {
11933 let source_in: *mut bindings::VipsSource = source.ctx;
11934 let mut out_out: *mut bindings::VipsImage = null_mut();
11935
11936 let vips_op_response = bindings::vips_tiffload_source(source_in, &mut out_out, NULL);
11937 utils::result(
11938 vips_op_response,
11939 VipsImage { ctx: out_out },
11940 Error::TiffloadSourceError,
11941 )
11942 }
11943}
11944
11945#[derive(Clone, Debug)]
11947pub struct TiffloadSourceOptions {
11948 pub page: i32,
11951 pub subifd: i32,
11954 pub n: i32,
11957 pub autorotate: bool,
11960 pub flags: ForeignFlags,
11967 pub memory: bool,
11970 pub access: Access,
11976 pub fail_on: FailOn,
11983 pub revalidate: bool,
11986}
11987
11988impl std::default::Default for TiffloadSourceOptions {
11989 fn default() -> Self {
11990 TiffloadSourceOptions {
11991 page: i32::from(0),
11992 subifd: i32::from(-1),
11993 n: i32::from(1),
11994 autorotate: false,
11995 flags: ForeignFlags::None,
11996 memory: false,
11997 access: Access::Random,
11998 fail_on: FailOn::None,
11999 revalidate: false,
12000 }
12001 }
12002}
12003
12004pub fn tiffload_source_with_opts(
12009 source: &VipsSource,
12010 tiffload_source_options: &TiffloadSourceOptions,
12011) -> Result<VipsImage> {
12012 unsafe {
12013 let source_in: *mut bindings::VipsSource = source.ctx;
12014 let mut out_out: *mut bindings::VipsImage = null_mut();
12015
12016 let page_in: i32 = tiffload_source_options.page;
12017 let page_in_name = utils::new_c_string("page")?;
12018
12019 let subifd_in: i32 = tiffload_source_options.subifd;
12020 let subifd_in_name = utils::new_c_string("subifd")?;
12021
12022 let n_in: i32 = tiffload_source_options.n;
12023 let n_in_name = utils::new_c_string("n")?;
12024
12025 let autorotate_in: i32 = if tiffload_source_options.autorotate {
12026 1
12027 } else {
12028 0
12029 };
12030 let autorotate_in_name = utils::new_c_string("autorotate")?;
12031
12032 let flags_in: i32 = tiffload_source_options.flags as i32;
12033 let flags_in_name = utils::new_c_string("flags")?;
12034
12035 let memory_in: i32 = if tiffload_source_options.memory { 1 } else { 0 };
12036 let memory_in_name = utils::new_c_string("memory")?;
12037
12038 let access_in: i32 = tiffload_source_options.access as i32;
12039 let access_in_name = utils::new_c_string("access")?;
12040
12041 let fail_on_in: i32 = tiffload_source_options.fail_on as i32;
12042 let fail_on_in_name = utils::new_c_string("fail-on")?;
12043
12044 let revalidate_in: i32 = if tiffload_source_options.revalidate {
12045 1
12046 } else {
12047 0
12048 };
12049 let revalidate_in_name = utils::new_c_string("revalidate")?;
12050
12051 let vips_op_response = bindings::vips_tiffload_source(
12052 source_in,
12053 &mut out_out,
12054 page_in_name.as_ptr(),
12055 page_in,
12056 subifd_in_name.as_ptr(),
12057 subifd_in,
12058 n_in_name.as_ptr(),
12059 n_in,
12060 autorotate_in_name.as_ptr(),
12061 autorotate_in,
12062 flags_in_name.as_ptr(),
12063 flags_in,
12064 memory_in_name.as_ptr(),
12065 memory_in,
12066 access_in_name.as_ptr(),
12067 access_in,
12068 fail_on_in_name.as_ptr(),
12069 fail_on_in,
12070 revalidate_in_name.as_ptr(),
12071 revalidate_in,
12072 NULL,
12073 );
12074 utils::result(
12075 vips_op_response,
12076 VipsImage { ctx: out_out },
12077 Error::TiffloadSourceError,
12078 )
12079 }
12080}
12081
12082pub fn heifload(filename: &str) -> Result<VipsImage> {
12086 unsafe {
12087 let filename_in: CString = utils::new_c_string(filename)?;
12088 let mut out_out: *mut bindings::VipsImage = null_mut();
12089
12090 let vips_op_response = bindings::vips_heifload(filename_in.as_ptr(), &mut out_out, NULL);
12091 utils::result(
12092 vips_op_response,
12093 VipsImage { ctx: out_out },
12094 Error::HeifloadError,
12095 )
12096 }
12097}
12098
12099#[derive(Clone, Debug)]
12101pub struct HeifloadOptions {
12102 pub page: i32,
12105 pub n: i32,
12108 pub thumbnail: bool,
12111 pub unlimited: bool,
12114 pub flags: ForeignFlags,
12121 pub memory: bool,
12124 pub access: Access,
12130 pub fail_on: FailOn,
12137 pub revalidate: bool,
12140}
12141
12142impl std::default::Default for HeifloadOptions {
12143 fn default() -> Self {
12144 HeifloadOptions {
12145 page: i32::from(0),
12146 n: i32::from(1),
12147 thumbnail: false,
12148 unlimited: false,
12149 flags: ForeignFlags::None,
12150 memory: false,
12151 access: Access::Random,
12152 fail_on: FailOn::None,
12153 revalidate: false,
12154 }
12155 }
12156}
12157
12158pub fn heifload_with_opts(filename: &str, heifload_options: &HeifloadOptions) -> Result<VipsImage> {
12163 unsafe {
12164 let filename_in: CString = utils::new_c_string(filename)?;
12165 let mut out_out: *mut bindings::VipsImage = null_mut();
12166
12167 let page_in: i32 = heifload_options.page;
12168 let page_in_name = utils::new_c_string("page")?;
12169
12170 let n_in: i32 = heifload_options.n;
12171 let n_in_name = utils::new_c_string("n")?;
12172
12173 let thumbnail_in: i32 = if heifload_options.thumbnail { 1 } else { 0 };
12174 let thumbnail_in_name = utils::new_c_string("thumbnail")?;
12175
12176 let unlimited_in: i32 = if heifload_options.unlimited { 1 } else { 0 };
12177 let unlimited_in_name = utils::new_c_string("unlimited")?;
12178
12179 let flags_in: i32 = heifload_options.flags as i32;
12180 let flags_in_name = utils::new_c_string("flags")?;
12181
12182 let memory_in: i32 = if heifload_options.memory { 1 } else { 0 };
12183 let memory_in_name = utils::new_c_string("memory")?;
12184
12185 let access_in: i32 = heifload_options.access as i32;
12186 let access_in_name = utils::new_c_string("access")?;
12187
12188 let fail_on_in: i32 = heifload_options.fail_on as i32;
12189 let fail_on_in_name = utils::new_c_string("fail-on")?;
12190
12191 let revalidate_in: i32 = if heifload_options.revalidate { 1 } else { 0 };
12192 let revalidate_in_name = utils::new_c_string("revalidate")?;
12193
12194 let vips_op_response = bindings::vips_heifload(
12195 filename_in.as_ptr(),
12196 &mut out_out,
12197 page_in_name.as_ptr(),
12198 page_in,
12199 n_in_name.as_ptr(),
12200 n_in,
12201 thumbnail_in_name.as_ptr(),
12202 thumbnail_in,
12203 unlimited_in_name.as_ptr(),
12204 unlimited_in,
12205 flags_in_name.as_ptr(),
12206 flags_in,
12207 memory_in_name.as_ptr(),
12208 memory_in,
12209 access_in_name.as_ptr(),
12210 access_in,
12211 fail_on_in_name.as_ptr(),
12212 fail_on_in,
12213 revalidate_in_name.as_ptr(),
12214 revalidate_in,
12215 NULL,
12216 );
12217 utils::result(
12218 vips_op_response,
12219 VipsImage { ctx: out_out },
12220 Error::HeifloadError,
12221 )
12222 }
12223}
12224
12225pub fn heifload_buffer(buffer: &[u8]) -> Result<VipsImage> {
12229 unsafe {
12230 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
12231 let mut out_out: *mut bindings::VipsImage = null_mut();
12232
12233 let vips_op_response =
12234 bindings::vips_heifload_buffer(buffer_in, buffer.len() as u64, &mut out_out, NULL);
12235 utils::result(
12236 vips_op_response,
12237 VipsImage { ctx: out_out },
12238 Error::HeifloadBufferError,
12239 )
12240 }
12241}
12242
12243#[derive(Clone, Debug)]
12245pub struct HeifloadBufferOptions {
12246 pub page: i32,
12249 pub n: i32,
12252 pub thumbnail: bool,
12255 pub unlimited: bool,
12258 pub flags: ForeignFlags,
12265 pub memory: bool,
12268 pub access: Access,
12274 pub fail_on: FailOn,
12281 pub revalidate: bool,
12284}
12285
12286impl std::default::Default for HeifloadBufferOptions {
12287 fn default() -> Self {
12288 HeifloadBufferOptions {
12289 page: i32::from(0),
12290 n: i32::from(1),
12291 thumbnail: false,
12292 unlimited: false,
12293 flags: ForeignFlags::None,
12294 memory: false,
12295 access: Access::Random,
12296 fail_on: FailOn::None,
12297 revalidate: false,
12298 }
12299 }
12300}
12301
12302pub fn heifload_buffer_with_opts(
12307 buffer: &[u8],
12308 heifload_buffer_options: &HeifloadBufferOptions,
12309) -> Result<VipsImage> {
12310 unsafe {
12311 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
12312 let mut out_out: *mut bindings::VipsImage = null_mut();
12313
12314 let page_in: i32 = heifload_buffer_options.page;
12315 let page_in_name = utils::new_c_string("page")?;
12316
12317 let n_in: i32 = heifload_buffer_options.n;
12318 let n_in_name = utils::new_c_string("n")?;
12319
12320 let thumbnail_in: i32 = if heifload_buffer_options.thumbnail {
12321 1
12322 } else {
12323 0
12324 };
12325 let thumbnail_in_name = utils::new_c_string("thumbnail")?;
12326
12327 let unlimited_in: i32 = if heifload_buffer_options.unlimited {
12328 1
12329 } else {
12330 0
12331 };
12332 let unlimited_in_name = utils::new_c_string("unlimited")?;
12333
12334 let flags_in: i32 = heifload_buffer_options.flags as i32;
12335 let flags_in_name = utils::new_c_string("flags")?;
12336
12337 let memory_in: i32 = if heifload_buffer_options.memory { 1 } else { 0 };
12338 let memory_in_name = utils::new_c_string("memory")?;
12339
12340 let access_in: i32 = heifload_buffer_options.access as i32;
12341 let access_in_name = utils::new_c_string("access")?;
12342
12343 let fail_on_in: i32 = heifload_buffer_options.fail_on as i32;
12344 let fail_on_in_name = utils::new_c_string("fail-on")?;
12345
12346 let revalidate_in: i32 = if heifload_buffer_options.revalidate {
12347 1
12348 } else {
12349 0
12350 };
12351 let revalidate_in_name = utils::new_c_string("revalidate")?;
12352
12353 let vips_op_response = bindings::vips_heifload_buffer(
12354 buffer_in,
12355 buffer.len() as u64,
12356 &mut out_out,
12357 page_in_name.as_ptr(),
12358 page_in,
12359 n_in_name.as_ptr(),
12360 n_in,
12361 thumbnail_in_name.as_ptr(),
12362 thumbnail_in,
12363 unlimited_in_name.as_ptr(),
12364 unlimited_in,
12365 flags_in_name.as_ptr(),
12366 flags_in,
12367 memory_in_name.as_ptr(),
12368 memory_in,
12369 access_in_name.as_ptr(),
12370 access_in,
12371 fail_on_in_name.as_ptr(),
12372 fail_on_in,
12373 revalidate_in_name.as_ptr(),
12374 revalidate_in,
12375 NULL,
12376 );
12377 utils::result(
12378 vips_op_response,
12379 VipsImage { ctx: out_out },
12380 Error::HeifloadBufferError,
12381 )
12382 }
12383}
12384
12385pub fn heifload_source(source: &VipsSource) -> Result<VipsImage> {
12389 unsafe {
12390 let source_in: *mut bindings::VipsSource = source.ctx;
12391 let mut out_out: *mut bindings::VipsImage = null_mut();
12392
12393 let vips_op_response = bindings::vips_heifload_source(source_in, &mut out_out, NULL);
12394 utils::result(
12395 vips_op_response,
12396 VipsImage { ctx: out_out },
12397 Error::HeifloadSourceError,
12398 )
12399 }
12400}
12401
12402#[derive(Clone, Debug)]
12404pub struct HeifloadSourceOptions {
12405 pub page: i32,
12408 pub n: i32,
12411 pub thumbnail: bool,
12414 pub unlimited: bool,
12417 pub flags: ForeignFlags,
12424 pub memory: bool,
12427 pub access: Access,
12433 pub fail_on: FailOn,
12440 pub revalidate: bool,
12443}
12444
12445impl std::default::Default for HeifloadSourceOptions {
12446 fn default() -> Self {
12447 HeifloadSourceOptions {
12448 page: i32::from(0),
12449 n: i32::from(1),
12450 thumbnail: false,
12451 unlimited: false,
12452 flags: ForeignFlags::None,
12453 memory: false,
12454 access: Access::Random,
12455 fail_on: FailOn::None,
12456 revalidate: false,
12457 }
12458 }
12459}
12460
12461pub fn heifload_source_with_opts(
12466 source: &VipsSource,
12467 heifload_source_options: &HeifloadSourceOptions,
12468) -> Result<VipsImage> {
12469 unsafe {
12470 let source_in: *mut bindings::VipsSource = source.ctx;
12471 let mut out_out: *mut bindings::VipsImage = null_mut();
12472
12473 let page_in: i32 = heifload_source_options.page;
12474 let page_in_name = utils::new_c_string("page")?;
12475
12476 let n_in: i32 = heifload_source_options.n;
12477 let n_in_name = utils::new_c_string("n")?;
12478
12479 let thumbnail_in: i32 = if heifload_source_options.thumbnail {
12480 1
12481 } else {
12482 0
12483 };
12484 let thumbnail_in_name = utils::new_c_string("thumbnail")?;
12485
12486 let unlimited_in: i32 = if heifload_source_options.unlimited {
12487 1
12488 } else {
12489 0
12490 };
12491 let unlimited_in_name = utils::new_c_string("unlimited")?;
12492
12493 let flags_in: i32 = heifload_source_options.flags as i32;
12494 let flags_in_name = utils::new_c_string("flags")?;
12495
12496 let memory_in: i32 = if heifload_source_options.memory { 1 } else { 0 };
12497 let memory_in_name = utils::new_c_string("memory")?;
12498
12499 let access_in: i32 = heifload_source_options.access as i32;
12500 let access_in_name = utils::new_c_string("access")?;
12501
12502 let fail_on_in: i32 = heifload_source_options.fail_on as i32;
12503 let fail_on_in_name = utils::new_c_string("fail-on")?;
12504
12505 let revalidate_in: i32 = if heifload_source_options.revalidate {
12506 1
12507 } else {
12508 0
12509 };
12510 let revalidate_in_name = utils::new_c_string("revalidate")?;
12511
12512 let vips_op_response = bindings::vips_heifload_source(
12513 source_in,
12514 &mut out_out,
12515 page_in_name.as_ptr(),
12516 page_in,
12517 n_in_name.as_ptr(),
12518 n_in,
12519 thumbnail_in_name.as_ptr(),
12520 thumbnail_in,
12521 unlimited_in_name.as_ptr(),
12522 unlimited_in,
12523 flags_in_name.as_ptr(),
12524 flags_in,
12525 memory_in_name.as_ptr(),
12526 memory_in,
12527 access_in_name.as_ptr(),
12528 access_in,
12529 fail_on_in_name.as_ptr(),
12530 fail_on_in,
12531 revalidate_in_name.as_ptr(),
12532 revalidate_in,
12533 NULL,
12534 );
12535 utils::result(
12536 vips_op_response,
12537 VipsImage { ctx: out_out },
12538 Error::HeifloadSourceError,
12539 )
12540 }
12541}
12542
12543pub fn csvsave(inp: &VipsImage, filename: &str) -> Result<()> {
12548 unsafe {
12549 let inp_in: *mut bindings::VipsImage = inp.ctx;
12550 let filename_in: CString = utils::new_c_string(filename)?;
12551
12552 let vips_op_response = bindings::vips_csvsave(inp_in, filename_in.as_ptr(), NULL);
12553 utils::result(vips_op_response, (), Error::CsvsaveError)
12554 }
12555}
12556
12557#[derive(Clone, Debug)]
12559pub struct CsvsaveOptions {
12560 pub separator: String,
12562 pub keep: ForeignKeep,
12571 pub background: Vec<f64>,
12573 pub page_height: i32,
12576 pub profile: String,
12578}
12579
12580impl std::default::Default for CsvsaveOptions {
12581 fn default() -> Self {
12582 CsvsaveOptions {
12583 separator: String::new(),
12584 keep: ForeignKeep::All,
12585 background: Vec::new(),
12586 page_height: i32::from(0),
12587 profile: String::from("sRGB"),
12588 }
12589 }
12590}
12591
12592pub fn csvsave_with_opts(
12598 inp: &VipsImage,
12599 filename: &str,
12600 csvsave_options: &CsvsaveOptions,
12601) -> Result<()> {
12602 unsafe {
12603 let inp_in: *mut bindings::VipsImage = inp.ctx;
12604 let filename_in: CString = utils::new_c_string(filename)?;
12605
12606 let separator_in: CString = utils::new_c_string(&csvsave_options.separator)?;
12607 let separator_in_name = utils::new_c_string("separator")?;
12608
12609 let keep_in: i32 = csvsave_options.keep as i32;
12610 let keep_in_name = utils::new_c_string("keep")?;
12611
12612 let background_wrapper =
12613 utils::VipsArrayDoubleWrapper::from(&csvsave_options.background[..]);
12614 let background_in = background_wrapper.ctx;
12615 let background_in_name = utils::new_c_string("background")?;
12616
12617 let page_height_in: i32 = csvsave_options.page_height;
12618 let page_height_in_name = utils::new_c_string("page-height")?;
12619
12620 let profile_in: CString = utils::new_c_string(&csvsave_options.profile)?;
12621 let profile_in_name = utils::new_c_string("profile")?;
12622
12623 let vips_op_response = bindings::vips_csvsave(
12624 inp_in,
12625 filename_in.as_ptr(),
12626 separator_in_name.as_ptr(),
12627 separator_in.as_ptr(),
12628 keep_in_name.as_ptr(),
12629 keep_in,
12630 background_in_name.as_ptr(),
12631 background_in,
12632 page_height_in_name.as_ptr(),
12633 page_height_in,
12634 profile_in_name.as_ptr(),
12635 profile_in.as_ptr(),
12636 NULL,
12637 );
12638 utils::result(vips_op_response, (), Error::CsvsaveError)
12639 }
12640}
12641
12642pub fn csvsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
12647 unsafe {
12648 let inp_in: *mut bindings::VipsImage = inp.ctx;
12649 let target_in: *mut bindings::VipsTarget = target.ctx;
12650
12651 let vips_op_response = bindings::vips_csvsave_target(inp_in, target_in, NULL);
12652 utils::result(vips_op_response, (), Error::CsvsaveTargetError)
12653 }
12654}
12655
12656#[derive(Clone, Debug)]
12658pub struct CsvsaveTargetOptions {
12659 pub separator: String,
12661 pub keep: ForeignKeep,
12670 pub background: Vec<f64>,
12672 pub page_height: i32,
12675 pub profile: String,
12677}
12678
12679impl std::default::Default for CsvsaveTargetOptions {
12680 fn default() -> Self {
12681 CsvsaveTargetOptions {
12682 separator: String::new(),
12683 keep: ForeignKeep::All,
12684 background: Vec::new(),
12685 page_height: i32::from(0),
12686 profile: String::from("sRGB"),
12687 }
12688 }
12689}
12690
12691pub fn csvsave_target_with_opts(
12697 inp: &VipsImage,
12698 target: &VipsTarget,
12699 csvsave_target_options: &CsvsaveTargetOptions,
12700) -> Result<()> {
12701 unsafe {
12702 let inp_in: *mut bindings::VipsImage = inp.ctx;
12703 let target_in: *mut bindings::VipsTarget = target.ctx;
12704
12705 let separator_in: CString = utils::new_c_string(&csvsave_target_options.separator)?;
12706 let separator_in_name = utils::new_c_string("separator")?;
12707
12708 let keep_in: i32 = csvsave_target_options.keep as i32;
12709 let keep_in_name = utils::new_c_string("keep")?;
12710
12711 let background_wrapper =
12712 utils::VipsArrayDoubleWrapper::from(&csvsave_target_options.background[..]);
12713 let background_in = background_wrapper.ctx;
12714 let background_in_name = utils::new_c_string("background")?;
12715
12716 let page_height_in: i32 = csvsave_target_options.page_height;
12717 let page_height_in_name = utils::new_c_string("page-height")?;
12718
12719 let profile_in: CString = utils::new_c_string(&csvsave_target_options.profile)?;
12720 let profile_in_name = utils::new_c_string("profile")?;
12721
12722 let vips_op_response = bindings::vips_csvsave_target(
12723 inp_in,
12724 target_in,
12725 separator_in_name.as_ptr(),
12726 separator_in.as_ptr(),
12727 keep_in_name.as_ptr(),
12728 keep_in,
12729 background_in_name.as_ptr(),
12730 background_in,
12731 page_height_in_name.as_ptr(),
12732 page_height_in,
12733 profile_in_name.as_ptr(),
12734 profile_in.as_ptr(),
12735 NULL,
12736 );
12737 utils::result(vips_op_response, (), Error::CsvsaveTargetError)
12738 }
12739}
12740
12741pub fn matrixsave(inp: &VipsImage, filename: &str) -> Result<()> {
12746 unsafe {
12747 let inp_in: *mut bindings::VipsImage = inp.ctx;
12748 let filename_in: CString = utils::new_c_string(filename)?;
12749
12750 let vips_op_response = bindings::vips_matrixsave(inp_in, filename_in.as_ptr(), NULL);
12751 utils::result(vips_op_response, (), Error::MatrixsaveError)
12752 }
12753}
12754
12755#[derive(Clone, Debug)]
12757pub struct MatrixsaveOptions {
12758 pub keep: ForeignKeep,
12767 pub background: Vec<f64>,
12769 pub page_height: i32,
12772 pub profile: String,
12774}
12775
12776impl std::default::Default for MatrixsaveOptions {
12777 fn default() -> Self {
12778 MatrixsaveOptions {
12779 keep: ForeignKeep::All,
12780 background: Vec::new(),
12781 page_height: i32::from(0),
12782 profile: String::from("sRGB"),
12783 }
12784 }
12785}
12786
12787pub fn matrixsave_with_opts(
12793 inp: &VipsImage,
12794 filename: &str,
12795 matrixsave_options: &MatrixsaveOptions,
12796) -> Result<()> {
12797 unsafe {
12798 let inp_in: *mut bindings::VipsImage = inp.ctx;
12799 let filename_in: CString = utils::new_c_string(filename)?;
12800
12801 let keep_in: i32 = matrixsave_options.keep as i32;
12802 let keep_in_name = utils::new_c_string("keep")?;
12803
12804 let background_wrapper =
12805 utils::VipsArrayDoubleWrapper::from(&matrixsave_options.background[..]);
12806 let background_in = background_wrapper.ctx;
12807 let background_in_name = utils::new_c_string("background")?;
12808
12809 let page_height_in: i32 = matrixsave_options.page_height;
12810 let page_height_in_name = utils::new_c_string("page-height")?;
12811
12812 let profile_in: CString = utils::new_c_string(&matrixsave_options.profile)?;
12813 let profile_in_name = utils::new_c_string("profile")?;
12814
12815 let vips_op_response = bindings::vips_matrixsave(
12816 inp_in,
12817 filename_in.as_ptr(),
12818 keep_in_name.as_ptr(),
12819 keep_in,
12820 background_in_name.as_ptr(),
12821 background_in,
12822 page_height_in_name.as_ptr(),
12823 page_height_in,
12824 profile_in_name.as_ptr(),
12825 profile_in.as_ptr(),
12826 NULL,
12827 );
12828 utils::result(vips_op_response, (), Error::MatrixsaveError)
12829 }
12830}
12831
12832pub fn matrixsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
12837 unsafe {
12838 let inp_in: *mut bindings::VipsImage = inp.ctx;
12839 let target_in: *mut bindings::VipsTarget = target.ctx;
12840
12841 let vips_op_response = bindings::vips_matrixsave_target(inp_in, target_in, NULL);
12842 utils::result(vips_op_response, (), Error::MatrixsaveTargetError)
12843 }
12844}
12845
12846#[derive(Clone, Debug)]
12848pub struct MatrixsaveTargetOptions {
12849 pub keep: ForeignKeep,
12858 pub background: Vec<f64>,
12860 pub page_height: i32,
12863 pub profile: String,
12865}
12866
12867impl std::default::Default for MatrixsaveTargetOptions {
12868 fn default() -> Self {
12869 MatrixsaveTargetOptions {
12870 keep: ForeignKeep::All,
12871 background: Vec::new(),
12872 page_height: i32::from(0),
12873 profile: String::from("sRGB"),
12874 }
12875 }
12876}
12877
12878pub fn matrixsave_target_with_opts(
12884 inp: &VipsImage,
12885 target: &VipsTarget,
12886 matrixsave_target_options: &MatrixsaveTargetOptions,
12887) -> Result<()> {
12888 unsafe {
12889 let inp_in: *mut bindings::VipsImage = inp.ctx;
12890 let target_in: *mut bindings::VipsTarget = target.ctx;
12891
12892 let keep_in: i32 = matrixsave_target_options.keep as i32;
12893 let keep_in_name = utils::new_c_string("keep")?;
12894
12895 let background_wrapper =
12896 utils::VipsArrayDoubleWrapper::from(&matrixsave_target_options.background[..]);
12897 let background_in = background_wrapper.ctx;
12898 let background_in_name = utils::new_c_string("background")?;
12899
12900 let page_height_in: i32 = matrixsave_target_options.page_height;
12901 let page_height_in_name = utils::new_c_string("page-height")?;
12902
12903 let profile_in: CString = utils::new_c_string(&matrixsave_target_options.profile)?;
12904 let profile_in_name = utils::new_c_string("profile")?;
12905
12906 let vips_op_response = bindings::vips_matrixsave_target(
12907 inp_in,
12908 target_in,
12909 keep_in_name.as_ptr(),
12910 keep_in,
12911 background_in_name.as_ptr(),
12912 background_in,
12913 page_height_in_name.as_ptr(),
12914 page_height_in,
12915 profile_in_name.as_ptr(),
12916 profile_in.as_ptr(),
12917 NULL,
12918 );
12919 utils::result(vips_op_response, (), Error::MatrixsaveTargetError)
12920 }
12921}
12922
12923pub fn matrixprint(inp: &VipsImage) -> Result<()> {
12927 unsafe {
12928 let inp_in: *mut bindings::VipsImage = inp.ctx;
12929
12930 let vips_op_response = bindings::vips_matrixprint(inp_in, NULL);
12931 utils::result(vips_op_response, (), Error::MatrixprintError)
12932 }
12933}
12934
12935#[derive(Clone, Debug)]
12937pub struct MatrixprintOptions {
12938 pub keep: ForeignKeep,
12947 pub background: Vec<f64>,
12949 pub page_height: i32,
12952 pub profile: String,
12954}
12955
12956impl std::default::Default for MatrixprintOptions {
12957 fn default() -> Self {
12958 MatrixprintOptions {
12959 keep: ForeignKeep::All,
12960 background: Vec::new(),
12961 page_height: i32::from(0),
12962 profile: String::from("sRGB"),
12963 }
12964 }
12965}
12966
12967pub fn matrixprint_with_opts(
12972 inp: &VipsImage,
12973 matrixprint_options: &MatrixprintOptions,
12974) -> Result<()> {
12975 unsafe {
12976 let inp_in: *mut bindings::VipsImage = inp.ctx;
12977
12978 let keep_in: i32 = matrixprint_options.keep as i32;
12979 let keep_in_name = utils::new_c_string("keep")?;
12980
12981 let background_wrapper =
12982 utils::VipsArrayDoubleWrapper::from(&matrixprint_options.background[..]);
12983 let background_in = background_wrapper.ctx;
12984 let background_in_name = utils::new_c_string("background")?;
12985
12986 let page_height_in: i32 = matrixprint_options.page_height;
12987 let page_height_in_name = utils::new_c_string("page-height")?;
12988
12989 let profile_in: CString = utils::new_c_string(&matrixprint_options.profile)?;
12990 let profile_in_name = utils::new_c_string("profile")?;
12991
12992 let vips_op_response = bindings::vips_matrixprint(
12993 inp_in,
12994 keep_in_name.as_ptr(),
12995 keep_in,
12996 background_in_name.as_ptr(),
12997 background_in,
12998 page_height_in_name.as_ptr(),
12999 page_height_in,
13000 profile_in_name.as_ptr(),
13001 profile_in.as_ptr(),
13002 NULL,
13003 );
13004 utils::result(vips_op_response, (), Error::MatrixprintError)
13005 }
13006}
13007
13008pub fn rawsave(inp: &VipsImage, filename: &str) -> Result<()> {
13013 unsafe {
13014 let inp_in: *mut bindings::VipsImage = inp.ctx;
13015 let filename_in: CString = utils::new_c_string(filename)?;
13016
13017 let vips_op_response = bindings::vips_rawsave(inp_in, filename_in.as_ptr(), NULL);
13018 utils::result(vips_op_response, (), Error::RawsaveError)
13019 }
13020}
13021
13022#[derive(Clone, Debug)]
13024pub struct RawsaveOptions {
13025 pub keep: ForeignKeep,
13034 pub background: Vec<f64>,
13036 pub page_height: i32,
13039 pub profile: String,
13041}
13042
13043impl std::default::Default for RawsaveOptions {
13044 fn default() -> Self {
13045 RawsaveOptions {
13046 keep: ForeignKeep::All,
13047 background: Vec::new(),
13048 page_height: i32::from(0),
13049 profile: String::from("sRGB"),
13050 }
13051 }
13052}
13053
13054pub fn rawsave_with_opts(
13060 inp: &VipsImage,
13061 filename: &str,
13062 rawsave_options: &RawsaveOptions,
13063) -> Result<()> {
13064 unsafe {
13065 let inp_in: *mut bindings::VipsImage = inp.ctx;
13066 let filename_in: CString = utils::new_c_string(filename)?;
13067
13068 let keep_in: i32 = rawsave_options.keep as i32;
13069 let keep_in_name = utils::new_c_string("keep")?;
13070
13071 let background_wrapper =
13072 utils::VipsArrayDoubleWrapper::from(&rawsave_options.background[..]);
13073 let background_in = background_wrapper.ctx;
13074 let background_in_name = utils::new_c_string("background")?;
13075
13076 let page_height_in: i32 = rawsave_options.page_height;
13077 let page_height_in_name = utils::new_c_string("page-height")?;
13078
13079 let profile_in: CString = utils::new_c_string(&rawsave_options.profile)?;
13080 let profile_in_name = utils::new_c_string("profile")?;
13081
13082 let vips_op_response = bindings::vips_rawsave(
13083 inp_in,
13084 filename_in.as_ptr(),
13085 keep_in_name.as_ptr(),
13086 keep_in,
13087 background_in_name.as_ptr(),
13088 background_in,
13089 page_height_in_name.as_ptr(),
13090 page_height_in,
13091 profile_in_name.as_ptr(),
13092 profile_in.as_ptr(),
13093 NULL,
13094 );
13095 utils::result(vips_op_response, (), Error::RawsaveError)
13096 }
13097}
13098
13099pub fn rawsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
13103 unsafe {
13104 let inp_in: *mut bindings::VipsImage = inp.ctx;
13105 let mut buffer_buf_size: u64 = 0;
13106 let mut buffer_out: *mut c_void = null_mut();
13107
13108 let vips_op_response =
13109 bindings::vips_rawsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
13110 utils::result(
13111 vips_op_response,
13112 utils::new_byte_array(buffer_out, buffer_buf_size),
13113 Error::RawsaveBufferError,
13114 )
13115 }
13116}
13117
13118#[derive(Clone, Debug)]
13120pub struct RawsaveBufferOptions {
13121 pub keep: ForeignKeep,
13130 pub background: Vec<f64>,
13132 pub page_height: i32,
13135 pub profile: String,
13137}
13138
13139impl std::default::Default for RawsaveBufferOptions {
13140 fn default() -> Self {
13141 RawsaveBufferOptions {
13142 keep: ForeignKeep::All,
13143 background: Vec::new(),
13144 page_height: i32::from(0),
13145 profile: String::from("sRGB"),
13146 }
13147 }
13148}
13149
13150pub fn rawsave_buffer_with_opts(
13155 inp: &VipsImage,
13156 rawsave_buffer_options: &RawsaveBufferOptions,
13157) -> Result<Vec<u8>> {
13158 unsafe {
13159 let inp_in: *mut bindings::VipsImage = inp.ctx;
13160 let mut buffer_buf_size: u64 = 0;
13161 let mut buffer_out: *mut c_void = null_mut();
13162
13163 let keep_in: i32 = rawsave_buffer_options.keep as i32;
13164 let keep_in_name = utils::new_c_string("keep")?;
13165
13166 let background_wrapper =
13167 utils::VipsArrayDoubleWrapper::from(&rawsave_buffer_options.background[..]);
13168 let background_in = background_wrapper.ctx;
13169 let background_in_name = utils::new_c_string("background")?;
13170
13171 let page_height_in: i32 = rawsave_buffer_options.page_height;
13172 let page_height_in_name = utils::new_c_string("page-height")?;
13173
13174 let profile_in: CString = utils::new_c_string(&rawsave_buffer_options.profile)?;
13175 let profile_in_name = utils::new_c_string("profile")?;
13176
13177 let vips_op_response = bindings::vips_rawsave_buffer(
13178 inp_in,
13179 &mut buffer_out,
13180 &mut buffer_buf_size,
13181 keep_in_name.as_ptr(),
13182 keep_in,
13183 background_in_name.as_ptr(),
13184 background_in,
13185 page_height_in_name.as_ptr(),
13186 page_height_in,
13187 profile_in_name.as_ptr(),
13188 profile_in.as_ptr(),
13189 NULL,
13190 );
13191 utils::result(
13192 vips_op_response,
13193 utils::new_byte_array(buffer_out, buffer_buf_size),
13194 Error::RawsaveBufferError,
13195 )
13196 }
13197}
13198
13199pub fn rawsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13204 unsafe {
13205 let inp_in: *mut bindings::VipsImage = inp.ctx;
13206 let target_in: *mut bindings::VipsTarget = target.ctx;
13207
13208 let vips_op_response = bindings::vips_rawsave_target(inp_in, target_in, NULL);
13209 utils::result(vips_op_response, (), Error::RawsaveTargetError)
13210 }
13211}
13212
13213#[derive(Clone, Debug)]
13215pub struct RawsaveTargetOptions {
13216 pub keep: ForeignKeep,
13225 pub background: Vec<f64>,
13227 pub page_height: i32,
13230 pub profile: String,
13232}
13233
13234impl std::default::Default for RawsaveTargetOptions {
13235 fn default() -> Self {
13236 RawsaveTargetOptions {
13237 keep: ForeignKeep::All,
13238 background: Vec::new(),
13239 page_height: i32::from(0),
13240 profile: String::from("sRGB"),
13241 }
13242 }
13243}
13244
13245pub fn rawsave_target_with_opts(
13251 inp: &VipsImage,
13252 target: &VipsTarget,
13253 rawsave_target_options: &RawsaveTargetOptions,
13254) -> Result<()> {
13255 unsafe {
13256 let inp_in: *mut bindings::VipsImage = inp.ctx;
13257 let target_in: *mut bindings::VipsTarget = target.ctx;
13258
13259 let keep_in: i32 = rawsave_target_options.keep as i32;
13260 let keep_in_name = utils::new_c_string("keep")?;
13261
13262 let background_wrapper =
13263 utils::VipsArrayDoubleWrapper::from(&rawsave_target_options.background[..]);
13264 let background_in = background_wrapper.ctx;
13265 let background_in_name = utils::new_c_string("background")?;
13266
13267 let page_height_in: i32 = rawsave_target_options.page_height;
13268 let page_height_in_name = utils::new_c_string("page-height")?;
13269
13270 let profile_in: CString = utils::new_c_string(&rawsave_target_options.profile)?;
13271 let profile_in_name = utils::new_c_string("profile")?;
13272
13273 let vips_op_response = bindings::vips_rawsave_target(
13274 inp_in,
13275 target_in,
13276 keep_in_name.as_ptr(),
13277 keep_in,
13278 background_in_name.as_ptr(),
13279 background_in,
13280 page_height_in_name.as_ptr(),
13281 page_height_in,
13282 profile_in_name.as_ptr(),
13283 profile_in.as_ptr(),
13284 NULL,
13285 );
13286 utils::result(vips_op_response, (), Error::RawsaveTargetError)
13287 }
13288}
13289
13290pub fn vipssave(inp: &VipsImage, filename: &str) -> Result<()> {
13295 unsafe {
13296 let inp_in: *mut bindings::VipsImage = inp.ctx;
13297 let filename_in: CString = utils::new_c_string(filename)?;
13298
13299 let vips_op_response = bindings::vips_vipssave(inp_in, filename_in.as_ptr(), NULL);
13300 utils::result(vips_op_response, (), Error::VipssaveError)
13301 }
13302}
13303
13304#[derive(Clone, Debug)]
13306pub struct VipssaveOptions {
13307 pub keep: ForeignKeep,
13316 pub background: Vec<f64>,
13318 pub page_height: i32,
13321 pub profile: String,
13323}
13324
13325impl std::default::Default for VipssaveOptions {
13326 fn default() -> Self {
13327 VipssaveOptions {
13328 keep: ForeignKeep::All,
13329 background: Vec::new(),
13330 page_height: i32::from(0),
13331 profile: String::from("sRGB"),
13332 }
13333 }
13334}
13335
13336pub fn vipssave_with_opts(
13342 inp: &VipsImage,
13343 filename: &str,
13344 vipssave_options: &VipssaveOptions,
13345) -> Result<()> {
13346 unsafe {
13347 let inp_in: *mut bindings::VipsImage = inp.ctx;
13348 let filename_in: CString = utils::new_c_string(filename)?;
13349
13350 let keep_in: i32 = vipssave_options.keep as i32;
13351 let keep_in_name = utils::new_c_string("keep")?;
13352
13353 let background_wrapper =
13354 utils::VipsArrayDoubleWrapper::from(&vipssave_options.background[..]);
13355 let background_in = background_wrapper.ctx;
13356 let background_in_name = utils::new_c_string("background")?;
13357
13358 let page_height_in: i32 = vipssave_options.page_height;
13359 let page_height_in_name = utils::new_c_string("page-height")?;
13360
13361 let profile_in: CString = utils::new_c_string(&vipssave_options.profile)?;
13362 let profile_in_name = utils::new_c_string("profile")?;
13363
13364 let vips_op_response = bindings::vips_vipssave(
13365 inp_in,
13366 filename_in.as_ptr(),
13367 keep_in_name.as_ptr(),
13368 keep_in,
13369 background_in_name.as_ptr(),
13370 background_in,
13371 page_height_in_name.as_ptr(),
13372 page_height_in,
13373 profile_in_name.as_ptr(),
13374 profile_in.as_ptr(),
13375 NULL,
13376 );
13377 utils::result(vips_op_response, (), Error::VipssaveError)
13378 }
13379}
13380
13381pub fn vipssave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13386 unsafe {
13387 let inp_in: *mut bindings::VipsImage = inp.ctx;
13388 let target_in: *mut bindings::VipsTarget = target.ctx;
13389
13390 let vips_op_response = bindings::vips_vipssave_target(inp_in, target_in, NULL);
13391 utils::result(vips_op_response, (), Error::VipssaveTargetError)
13392 }
13393}
13394
13395#[derive(Clone, Debug)]
13397pub struct VipssaveTargetOptions {
13398 pub keep: ForeignKeep,
13407 pub background: Vec<f64>,
13409 pub page_height: i32,
13412 pub profile: String,
13414}
13415
13416impl std::default::Default for VipssaveTargetOptions {
13417 fn default() -> Self {
13418 VipssaveTargetOptions {
13419 keep: ForeignKeep::All,
13420 background: Vec::new(),
13421 page_height: i32::from(0),
13422 profile: String::from("sRGB"),
13423 }
13424 }
13425}
13426
13427pub fn vipssave_target_with_opts(
13433 inp: &VipsImage,
13434 target: &VipsTarget,
13435 vipssave_target_options: &VipssaveTargetOptions,
13436) -> Result<()> {
13437 unsafe {
13438 let inp_in: *mut bindings::VipsImage = inp.ctx;
13439 let target_in: *mut bindings::VipsTarget = target.ctx;
13440
13441 let keep_in: i32 = vipssave_target_options.keep as i32;
13442 let keep_in_name = utils::new_c_string("keep")?;
13443
13444 let background_wrapper =
13445 utils::VipsArrayDoubleWrapper::from(&vipssave_target_options.background[..]);
13446 let background_in = background_wrapper.ctx;
13447 let background_in_name = utils::new_c_string("background")?;
13448
13449 let page_height_in: i32 = vipssave_target_options.page_height;
13450 let page_height_in_name = utils::new_c_string("page-height")?;
13451
13452 let profile_in: CString = utils::new_c_string(&vipssave_target_options.profile)?;
13453 let profile_in_name = utils::new_c_string("profile")?;
13454
13455 let vips_op_response = bindings::vips_vipssave_target(
13456 inp_in,
13457 target_in,
13458 keep_in_name.as_ptr(),
13459 keep_in,
13460 background_in_name.as_ptr(),
13461 background_in,
13462 page_height_in_name.as_ptr(),
13463 page_height_in,
13464 profile_in_name.as_ptr(),
13465 profile_in.as_ptr(),
13466 NULL,
13467 );
13468 utils::result(vips_op_response, (), Error::VipssaveTargetError)
13469 }
13470}
13471
13472pub fn ppmsave(inp: &VipsImage, filename: &str) -> Result<()> {
13477 unsafe {
13478 let inp_in: *mut bindings::VipsImage = inp.ctx;
13479 let filename_in: CString = utils::new_c_string(filename)?;
13480
13481 let vips_op_response = bindings::vips_ppmsave(inp_in, filename_in.as_ptr(), NULL);
13482 utils::result(vips_op_response, (), Error::PpmsaveError)
13483 }
13484}
13485
13486#[derive(Clone, Debug)]
13488pub struct PpmsaveOptions {
13489 pub format: ForeignPpmFormat,
13497 pub ascii: bool,
13500 pub bitdepth: i32,
13503 pub keep: ForeignKeep,
13512 pub background: Vec<f64>,
13514 pub page_height: i32,
13517 pub profile: String,
13519}
13520
13521impl std::default::Default for PpmsaveOptions {
13522 fn default() -> Self {
13523 PpmsaveOptions {
13524 format: ForeignPpmFormat::Ppm,
13525 ascii: false,
13526 bitdepth: i32::from(0),
13527 keep: ForeignKeep::All,
13528 background: Vec::new(),
13529 page_height: i32::from(0),
13530 profile: String::from("sRGB"),
13531 }
13532 }
13533}
13534
13535pub fn ppmsave_with_opts(
13541 inp: &VipsImage,
13542 filename: &str,
13543 ppmsave_options: &PpmsaveOptions,
13544) -> Result<()> {
13545 unsafe {
13546 let inp_in: *mut bindings::VipsImage = inp.ctx;
13547 let filename_in: CString = utils::new_c_string(filename)?;
13548
13549 let format_in: i32 = ppmsave_options.format as i32;
13550 let format_in_name = utils::new_c_string("format")?;
13551
13552 let ascii_in: i32 = if ppmsave_options.ascii { 1 } else { 0 };
13553 let ascii_in_name = utils::new_c_string("ascii")?;
13554
13555 let bitdepth_in: i32 = ppmsave_options.bitdepth;
13556 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
13557
13558 let keep_in: i32 = ppmsave_options.keep as i32;
13559 let keep_in_name = utils::new_c_string("keep")?;
13560
13561 let background_wrapper =
13562 utils::VipsArrayDoubleWrapper::from(&ppmsave_options.background[..]);
13563 let background_in = background_wrapper.ctx;
13564 let background_in_name = utils::new_c_string("background")?;
13565
13566 let page_height_in: i32 = ppmsave_options.page_height;
13567 let page_height_in_name = utils::new_c_string("page-height")?;
13568
13569 let profile_in: CString = utils::new_c_string(&ppmsave_options.profile)?;
13570 let profile_in_name = utils::new_c_string("profile")?;
13571
13572 let vips_op_response = bindings::vips_ppmsave(
13573 inp_in,
13574 filename_in.as_ptr(),
13575 format_in_name.as_ptr(),
13576 format_in,
13577 ascii_in_name.as_ptr(),
13578 ascii_in,
13579 bitdepth_in_name.as_ptr(),
13580 bitdepth_in,
13581 keep_in_name.as_ptr(),
13582 keep_in,
13583 background_in_name.as_ptr(),
13584 background_in,
13585 page_height_in_name.as_ptr(),
13586 page_height_in,
13587 profile_in_name.as_ptr(),
13588 profile_in.as_ptr(),
13589 NULL,
13590 );
13591 utils::result(vips_op_response, (), Error::PpmsaveError)
13592 }
13593}
13594
13595pub fn ppmsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13600 unsafe {
13601 let inp_in: *mut bindings::VipsImage = inp.ctx;
13602 let target_in: *mut bindings::VipsTarget = target.ctx;
13603
13604 let vips_op_response = bindings::vips_ppmsave_target(inp_in, target_in, NULL);
13605 utils::result(vips_op_response, (), Error::PpmsaveTargetError)
13606 }
13607}
13608
13609#[derive(Clone, Debug)]
13611pub struct PpmsaveTargetOptions {
13612 pub format: ForeignPpmFormat,
13620 pub ascii: bool,
13623 pub bitdepth: i32,
13626 pub keep: ForeignKeep,
13635 pub background: Vec<f64>,
13637 pub page_height: i32,
13640 pub profile: String,
13642}
13643
13644impl std::default::Default for PpmsaveTargetOptions {
13645 fn default() -> Self {
13646 PpmsaveTargetOptions {
13647 format: ForeignPpmFormat::Ppm,
13648 ascii: false,
13649 bitdepth: i32::from(0),
13650 keep: ForeignKeep::All,
13651 background: Vec::new(),
13652 page_height: i32::from(0),
13653 profile: String::from("sRGB"),
13654 }
13655 }
13656}
13657
13658pub fn ppmsave_target_with_opts(
13664 inp: &VipsImage,
13665 target: &VipsTarget,
13666 ppmsave_target_options: &PpmsaveTargetOptions,
13667) -> Result<()> {
13668 unsafe {
13669 let inp_in: *mut bindings::VipsImage = inp.ctx;
13670 let target_in: *mut bindings::VipsTarget = target.ctx;
13671
13672 let format_in: i32 = ppmsave_target_options.format as i32;
13673 let format_in_name = utils::new_c_string("format")?;
13674
13675 let ascii_in: i32 = if ppmsave_target_options.ascii { 1 } else { 0 };
13676 let ascii_in_name = utils::new_c_string("ascii")?;
13677
13678 let bitdepth_in: i32 = ppmsave_target_options.bitdepth;
13679 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
13680
13681 let keep_in: i32 = ppmsave_target_options.keep as i32;
13682 let keep_in_name = utils::new_c_string("keep")?;
13683
13684 let background_wrapper =
13685 utils::VipsArrayDoubleWrapper::from(&ppmsave_target_options.background[..]);
13686 let background_in = background_wrapper.ctx;
13687 let background_in_name = utils::new_c_string("background")?;
13688
13689 let page_height_in: i32 = ppmsave_target_options.page_height;
13690 let page_height_in_name = utils::new_c_string("page-height")?;
13691
13692 let profile_in: CString = utils::new_c_string(&ppmsave_target_options.profile)?;
13693 let profile_in_name = utils::new_c_string("profile")?;
13694
13695 let vips_op_response = bindings::vips_ppmsave_target(
13696 inp_in,
13697 target_in,
13698 format_in_name.as_ptr(),
13699 format_in,
13700 ascii_in_name.as_ptr(),
13701 ascii_in,
13702 bitdepth_in_name.as_ptr(),
13703 bitdepth_in,
13704 keep_in_name.as_ptr(),
13705 keep_in,
13706 background_in_name.as_ptr(),
13707 background_in,
13708 page_height_in_name.as_ptr(),
13709 page_height_in,
13710 profile_in_name.as_ptr(),
13711 profile_in.as_ptr(),
13712 NULL,
13713 );
13714 utils::result(vips_op_response, (), Error::PpmsaveTargetError)
13715 }
13716}
13717
13718pub fn radsave(inp: &VipsImage, filename: &str) -> Result<()> {
13723 unsafe {
13724 let inp_in: *mut bindings::VipsImage = inp.ctx;
13725 let filename_in: CString = utils::new_c_string(filename)?;
13726
13727 let vips_op_response = bindings::vips_radsave(inp_in, filename_in.as_ptr(), NULL);
13728 utils::result(vips_op_response, (), Error::RadsaveError)
13729 }
13730}
13731
13732#[derive(Clone, Debug)]
13734pub struct RadsaveOptions {
13735 pub keep: ForeignKeep,
13744 pub background: Vec<f64>,
13746 pub page_height: i32,
13749 pub profile: String,
13751}
13752
13753impl std::default::Default for RadsaveOptions {
13754 fn default() -> Self {
13755 RadsaveOptions {
13756 keep: ForeignKeep::All,
13757 background: Vec::new(),
13758 page_height: i32::from(0),
13759 profile: String::from("sRGB"),
13760 }
13761 }
13762}
13763
13764pub fn radsave_with_opts(
13770 inp: &VipsImage,
13771 filename: &str,
13772 radsave_options: &RadsaveOptions,
13773) -> Result<()> {
13774 unsafe {
13775 let inp_in: *mut bindings::VipsImage = inp.ctx;
13776 let filename_in: CString = utils::new_c_string(filename)?;
13777
13778 let keep_in: i32 = radsave_options.keep as i32;
13779 let keep_in_name = utils::new_c_string("keep")?;
13780
13781 let background_wrapper =
13782 utils::VipsArrayDoubleWrapper::from(&radsave_options.background[..]);
13783 let background_in = background_wrapper.ctx;
13784 let background_in_name = utils::new_c_string("background")?;
13785
13786 let page_height_in: i32 = radsave_options.page_height;
13787 let page_height_in_name = utils::new_c_string("page-height")?;
13788
13789 let profile_in: CString = utils::new_c_string(&radsave_options.profile)?;
13790 let profile_in_name = utils::new_c_string("profile")?;
13791
13792 let vips_op_response = bindings::vips_radsave(
13793 inp_in,
13794 filename_in.as_ptr(),
13795 keep_in_name.as_ptr(),
13796 keep_in,
13797 background_in_name.as_ptr(),
13798 background_in,
13799 page_height_in_name.as_ptr(),
13800 page_height_in,
13801 profile_in_name.as_ptr(),
13802 profile_in.as_ptr(),
13803 NULL,
13804 );
13805 utils::result(vips_op_response, (), Error::RadsaveError)
13806 }
13807}
13808
13809pub fn radsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
13813 unsafe {
13814 let inp_in: *mut bindings::VipsImage = inp.ctx;
13815 let mut buffer_buf_size: u64 = 0;
13816 let mut buffer_out: *mut c_void = null_mut();
13817
13818 let vips_op_response =
13819 bindings::vips_radsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
13820 utils::result(
13821 vips_op_response,
13822 utils::new_byte_array(buffer_out, buffer_buf_size),
13823 Error::RadsaveBufferError,
13824 )
13825 }
13826}
13827
13828#[derive(Clone, Debug)]
13830pub struct RadsaveBufferOptions {
13831 pub keep: ForeignKeep,
13840 pub background: Vec<f64>,
13842 pub page_height: i32,
13845 pub profile: String,
13847}
13848
13849impl std::default::Default for RadsaveBufferOptions {
13850 fn default() -> Self {
13851 RadsaveBufferOptions {
13852 keep: ForeignKeep::All,
13853 background: Vec::new(),
13854 page_height: i32::from(0),
13855 profile: String::from("sRGB"),
13856 }
13857 }
13858}
13859
13860pub fn radsave_buffer_with_opts(
13865 inp: &VipsImage,
13866 radsave_buffer_options: &RadsaveBufferOptions,
13867) -> Result<Vec<u8>> {
13868 unsafe {
13869 let inp_in: *mut bindings::VipsImage = inp.ctx;
13870 let mut buffer_buf_size: u64 = 0;
13871 let mut buffer_out: *mut c_void = null_mut();
13872
13873 let keep_in: i32 = radsave_buffer_options.keep as i32;
13874 let keep_in_name = utils::new_c_string("keep")?;
13875
13876 let background_wrapper =
13877 utils::VipsArrayDoubleWrapper::from(&radsave_buffer_options.background[..]);
13878 let background_in = background_wrapper.ctx;
13879 let background_in_name = utils::new_c_string("background")?;
13880
13881 let page_height_in: i32 = radsave_buffer_options.page_height;
13882 let page_height_in_name = utils::new_c_string("page-height")?;
13883
13884 let profile_in: CString = utils::new_c_string(&radsave_buffer_options.profile)?;
13885 let profile_in_name = utils::new_c_string("profile")?;
13886
13887 let vips_op_response = bindings::vips_radsave_buffer(
13888 inp_in,
13889 &mut buffer_out,
13890 &mut buffer_buf_size,
13891 keep_in_name.as_ptr(),
13892 keep_in,
13893 background_in_name.as_ptr(),
13894 background_in,
13895 page_height_in_name.as_ptr(),
13896 page_height_in,
13897 profile_in_name.as_ptr(),
13898 profile_in.as_ptr(),
13899 NULL,
13900 );
13901 utils::result(
13902 vips_op_response,
13903 utils::new_byte_array(buffer_out, buffer_buf_size),
13904 Error::RadsaveBufferError,
13905 )
13906 }
13907}
13908
13909pub fn radsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
13914 unsafe {
13915 let inp_in: *mut bindings::VipsImage = inp.ctx;
13916 let target_in: *mut bindings::VipsTarget = target.ctx;
13917
13918 let vips_op_response = bindings::vips_radsave_target(inp_in, target_in, NULL);
13919 utils::result(vips_op_response, (), Error::RadsaveTargetError)
13920 }
13921}
13922
13923#[derive(Clone, Debug)]
13925pub struct RadsaveTargetOptions {
13926 pub keep: ForeignKeep,
13935 pub background: Vec<f64>,
13937 pub page_height: i32,
13940 pub profile: String,
13942}
13943
13944impl std::default::Default for RadsaveTargetOptions {
13945 fn default() -> Self {
13946 RadsaveTargetOptions {
13947 keep: ForeignKeep::All,
13948 background: Vec::new(),
13949 page_height: i32::from(0),
13950 profile: String::from("sRGB"),
13951 }
13952 }
13953}
13954
13955pub fn radsave_target_with_opts(
13961 inp: &VipsImage,
13962 target: &VipsTarget,
13963 radsave_target_options: &RadsaveTargetOptions,
13964) -> Result<()> {
13965 unsafe {
13966 let inp_in: *mut bindings::VipsImage = inp.ctx;
13967 let target_in: *mut bindings::VipsTarget = target.ctx;
13968
13969 let keep_in: i32 = radsave_target_options.keep as i32;
13970 let keep_in_name = utils::new_c_string("keep")?;
13971
13972 let background_wrapper =
13973 utils::VipsArrayDoubleWrapper::from(&radsave_target_options.background[..]);
13974 let background_in = background_wrapper.ctx;
13975 let background_in_name = utils::new_c_string("background")?;
13976
13977 let page_height_in: i32 = radsave_target_options.page_height;
13978 let page_height_in_name = utils::new_c_string("page-height")?;
13979
13980 let profile_in: CString = utils::new_c_string(&radsave_target_options.profile)?;
13981 let profile_in_name = utils::new_c_string("profile")?;
13982
13983 let vips_op_response = bindings::vips_radsave_target(
13984 inp_in,
13985 target_in,
13986 keep_in_name.as_ptr(),
13987 keep_in,
13988 background_in_name.as_ptr(),
13989 background_in,
13990 page_height_in_name.as_ptr(),
13991 page_height_in,
13992 profile_in_name.as_ptr(),
13993 profile_in.as_ptr(),
13994 NULL,
13995 );
13996 utils::result(vips_op_response, (), Error::RadsaveTargetError)
13997 }
13998}
13999
14000pub fn gifsave(inp: &VipsImage, filename: &str) -> Result<()> {
14005 unsafe {
14006 let inp_in: *mut bindings::VipsImage = inp.ctx;
14007 let filename_in: CString = utils::new_c_string(filename)?;
14008
14009 let vips_op_response = bindings::vips_gifsave(inp_in, filename_in.as_ptr(), NULL);
14010 utils::result(vips_op_response, (), Error::GifsaveError)
14011 }
14012}
14013
14014#[derive(Clone, Debug)]
14016pub struct GifsaveOptions {
14017 pub dither: f64,
14020 pub effort: i32,
14023 pub bitdepth: i32,
14026 pub interframe_maxerror: f64,
14029 pub reuse: bool,
14032 pub interpalette_maxerror: f64,
14035 pub interlace: bool,
14038 pub keep: ForeignKeep,
14047 pub background: Vec<f64>,
14049 pub page_height: i32,
14052 pub profile: String,
14054}
14055
14056impl std::default::Default for GifsaveOptions {
14057 fn default() -> Self {
14058 GifsaveOptions {
14059 dither: f64::from(1),
14060 effort: i32::from(7),
14061 bitdepth: i32::from(8),
14062 interframe_maxerror: f64::from(0),
14063 reuse: false,
14064 interpalette_maxerror: f64::from(3),
14065 interlace: false,
14066 keep: ForeignKeep::All,
14067 background: Vec::new(),
14068 page_height: i32::from(0),
14069 profile: String::from("sRGB"),
14070 }
14071 }
14072}
14073
14074pub fn gifsave_with_opts(
14080 inp: &VipsImage,
14081 filename: &str,
14082 gifsave_options: &GifsaveOptions,
14083) -> Result<()> {
14084 unsafe {
14085 let inp_in: *mut bindings::VipsImage = inp.ctx;
14086 let filename_in: CString = utils::new_c_string(filename)?;
14087
14088 let dither_in: f64 = gifsave_options.dither;
14089 let dither_in_name = utils::new_c_string("dither")?;
14090
14091 let effort_in: i32 = gifsave_options.effort;
14092 let effort_in_name = utils::new_c_string("effort")?;
14093
14094 let bitdepth_in: i32 = gifsave_options.bitdepth;
14095 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14096
14097 let interframe_maxerror_in: f64 = gifsave_options.interframe_maxerror;
14098 let interframe_maxerror_in_name = utils::new_c_string("interframe-maxerror")?;
14099
14100 let reuse_in: i32 = if gifsave_options.reuse { 1 } else { 0 };
14101 let reuse_in_name = utils::new_c_string("reuse")?;
14102
14103 let interpalette_maxerror_in: f64 = gifsave_options.interpalette_maxerror;
14104 let interpalette_maxerror_in_name = utils::new_c_string("interpalette-maxerror")?;
14105
14106 let interlace_in: i32 = if gifsave_options.interlace { 1 } else { 0 };
14107 let interlace_in_name = utils::new_c_string("interlace")?;
14108
14109 let keep_in: i32 = gifsave_options.keep as i32;
14110 let keep_in_name = utils::new_c_string("keep")?;
14111
14112 let background_wrapper =
14113 utils::VipsArrayDoubleWrapper::from(&gifsave_options.background[..]);
14114 let background_in = background_wrapper.ctx;
14115 let background_in_name = utils::new_c_string("background")?;
14116
14117 let page_height_in: i32 = gifsave_options.page_height;
14118 let page_height_in_name = utils::new_c_string("page-height")?;
14119
14120 let profile_in: CString = utils::new_c_string(&gifsave_options.profile)?;
14121 let profile_in_name = utils::new_c_string("profile")?;
14122
14123 let vips_op_response = bindings::vips_gifsave(
14124 inp_in,
14125 filename_in.as_ptr(),
14126 dither_in_name.as_ptr(),
14127 dither_in,
14128 effort_in_name.as_ptr(),
14129 effort_in,
14130 bitdepth_in_name.as_ptr(),
14131 bitdepth_in,
14132 interframe_maxerror_in_name.as_ptr(),
14133 interframe_maxerror_in,
14134 reuse_in_name.as_ptr(),
14135 reuse_in,
14136 interpalette_maxerror_in_name.as_ptr(),
14137 interpalette_maxerror_in,
14138 interlace_in_name.as_ptr(),
14139 interlace_in,
14140 keep_in_name.as_ptr(),
14141 keep_in,
14142 background_in_name.as_ptr(),
14143 background_in,
14144 page_height_in_name.as_ptr(),
14145 page_height_in,
14146 profile_in_name.as_ptr(),
14147 profile_in.as_ptr(),
14148 NULL,
14149 );
14150 utils::result(vips_op_response, (), Error::GifsaveError)
14151 }
14152}
14153
14154pub fn gifsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
14158 unsafe {
14159 let inp_in: *mut bindings::VipsImage = inp.ctx;
14160 let mut buffer_buf_size: u64 = 0;
14161 let mut buffer_out: *mut c_void = null_mut();
14162
14163 let vips_op_response =
14164 bindings::vips_gifsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
14165 utils::result(
14166 vips_op_response,
14167 utils::new_byte_array(buffer_out, buffer_buf_size),
14168 Error::GifsaveBufferError,
14169 )
14170 }
14171}
14172
14173#[derive(Clone, Debug)]
14175pub struct GifsaveBufferOptions {
14176 pub dither: f64,
14179 pub effort: i32,
14182 pub bitdepth: i32,
14185 pub interframe_maxerror: f64,
14188 pub reuse: bool,
14191 pub interpalette_maxerror: f64,
14194 pub interlace: bool,
14197 pub keep: ForeignKeep,
14206 pub background: Vec<f64>,
14208 pub page_height: i32,
14211 pub profile: String,
14213}
14214
14215impl std::default::Default for GifsaveBufferOptions {
14216 fn default() -> Self {
14217 GifsaveBufferOptions {
14218 dither: f64::from(1),
14219 effort: i32::from(7),
14220 bitdepth: i32::from(8),
14221 interframe_maxerror: f64::from(0),
14222 reuse: false,
14223 interpalette_maxerror: f64::from(3),
14224 interlace: false,
14225 keep: ForeignKeep::All,
14226 background: Vec::new(),
14227 page_height: i32::from(0),
14228 profile: String::from("sRGB"),
14229 }
14230 }
14231}
14232
14233pub fn gifsave_buffer_with_opts(
14238 inp: &VipsImage,
14239 gifsave_buffer_options: &GifsaveBufferOptions,
14240) -> Result<Vec<u8>> {
14241 unsafe {
14242 let inp_in: *mut bindings::VipsImage = inp.ctx;
14243 let mut buffer_buf_size: u64 = 0;
14244 let mut buffer_out: *mut c_void = null_mut();
14245
14246 let dither_in: f64 = gifsave_buffer_options.dither;
14247 let dither_in_name = utils::new_c_string("dither")?;
14248
14249 let effort_in: i32 = gifsave_buffer_options.effort;
14250 let effort_in_name = utils::new_c_string("effort")?;
14251
14252 let bitdepth_in: i32 = gifsave_buffer_options.bitdepth;
14253 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14254
14255 let interframe_maxerror_in: f64 = gifsave_buffer_options.interframe_maxerror;
14256 let interframe_maxerror_in_name = utils::new_c_string("interframe-maxerror")?;
14257
14258 let reuse_in: i32 = if gifsave_buffer_options.reuse { 1 } else { 0 };
14259 let reuse_in_name = utils::new_c_string("reuse")?;
14260
14261 let interpalette_maxerror_in: f64 = gifsave_buffer_options.interpalette_maxerror;
14262 let interpalette_maxerror_in_name = utils::new_c_string("interpalette-maxerror")?;
14263
14264 let interlace_in: i32 = if gifsave_buffer_options.interlace {
14265 1
14266 } else {
14267 0
14268 };
14269 let interlace_in_name = utils::new_c_string("interlace")?;
14270
14271 let keep_in: i32 = gifsave_buffer_options.keep as i32;
14272 let keep_in_name = utils::new_c_string("keep")?;
14273
14274 let background_wrapper =
14275 utils::VipsArrayDoubleWrapper::from(&gifsave_buffer_options.background[..]);
14276 let background_in = background_wrapper.ctx;
14277 let background_in_name = utils::new_c_string("background")?;
14278
14279 let page_height_in: i32 = gifsave_buffer_options.page_height;
14280 let page_height_in_name = utils::new_c_string("page-height")?;
14281
14282 let profile_in: CString = utils::new_c_string(&gifsave_buffer_options.profile)?;
14283 let profile_in_name = utils::new_c_string("profile")?;
14284
14285 let vips_op_response = bindings::vips_gifsave_buffer(
14286 inp_in,
14287 &mut buffer_out,
14288 &mut buffer_buf_size,
14289 dither_in_name.as_ptr(),
14290 dither_in,
14291 effort_in_name.as_ptr(),
14292 effort_in,
14293 bitdepth_in_name.as_ptr(),
14294 bitdepth_in,
14295 interframe_maxerror_in_name.as_ptr(),
14296 interframe_maxerror_in,
14297 reuse_in_name.as_ptr(),
14298 reuse_in,
14299 interpalette_maxerror_in_name.as_ptr(),
14300 interpalette_maxerror_in,
14301 interlace_in_name.as_ptr(),
14302 interlace_in,
14303 keep_in_name.as_ptr(),
14304 keep_in,
14305 background_in_name.as_ptr(),
14306 background_in,
14307 page_height_in_name.as_ptr(),
14308 page_height_in,
14309 profile_in_name.as_ptr(),
14310 profile_in.as_ptr(),
14311 NULL,
14312 );
14313 utils::result(
14314 vips_op_response,
14315 utils::new_byte_array(buffer_out, buffer_buf_size),
14316 Error::GifsaveBufferError,
14317 )
14318 }
14319}
14320
14321pub fn gifsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
14326 unsafe {
14327 let inp_in: *mut bindings::VipsImage = inp.ctx;
14328 let target_in: *mut bindings::VipsTarget = target.ctx;
14329
14330 let vips_op_response = bindings::vips_gifsave_target(inp_in, target_in, NULL);
14331 utils::result(vips_op_response, (), Error::GifsaveTargetError)
14332 }
14333}
14334
14335#[derive(Clone, Debug)]
14337pub struct GifsaveTargetOptions {
14338 pub dither: f64,
14341 pub effort: i32,
14344 pub bitdepth: i32,
14347 pub interframe_maxerror: f64,
14350 pub reuse: bool,
14353 pub interpalette_maxerror: f64,
14356 pub interlace: bool,
14359 pub keep: ForeignKeep,
14368 pub background: Vec<f64>,
14370 pub page_height: i32,
14373 pub profile: String,
14375}
14376
14377impl std::default::Default for GifsaveTargetOptions {
14378 fn default() -> Self {
14379 GifsaveTargetOptions {
14380 dither: f64::from(1),
14381 effort: i32::from(7),
14382 bitdepth: i32::from(8),
14383 interframe_maxerror: f64::from(0),
14384 reuse: false,
14385 interpalette_maxerror: f64::from(3),
14386 interlace: false,
14387 keep: ForeignKeep::All,
14388 background: Vec::new(),
14389 page_height: i32::from(0),
14390 profile: String::from("sRGB"),
14391 }
14392 }
14393}
14394
14395pub fn gifsave_target_with_opts(
14401 inp: &VipsImage,
14402 target: &VipsTarget,
14403 gifsave_target_options: &GifsaveTargetOptions,
14404) -> Result<()> {
14405 unsafe {
14406 let inp_in: *mut bindings::VipsImage = inp.ctx;
14407 let target_in: *mut bindings::VipsTarget = target.ctx;
14408
14409 let dither_in: f64 = gifsave_target_options.dither;
14410 let dither_in_name = utils::new_c_string("dither")?;
14411
14412 let effort_in: i32 = gifsave_target_options.effort;
14413 let effort_in_name = utils::new_c_string("effort")?;
14414
14415 let bitdepth_in: i32 = gifsave_target_options.bitdepth;
14416 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14417
14418 let interframe_maxerror_in: f64 = gifsave_target_options.interframe_maxerror;
14419 let interframe_maxerror_in_name = utils::new_c_string("interframe-maxerror")?;
14420
14421 let reuse_in: i32 = if gifsave_target_options.reuse { 1 } else { 0 };
14422 let reuse_in_name = utils::new_c_string("reuse")?;
14423
14424 let interpalette_maxerror_in: f64 = gifsave_target_options.interpalette_maxerror;
14425 let interpalette_maxerror_in_name = utils::new_c_string("interpalette-maxerror")?;
14426
14427 let interlace_in: i32 = if gifsave_target_options.interlace {
14428 1
14429 } else {
14430 0
14431 };
14432 let interlace_in_name = utils::new_c_string("interlace")?;
14433
14434 let keep_in: i32 = gifsave_target_options.keep as i32;
14435 let keep_in_name = utils::new_c_string("keep")?;
14436
14437 let background_wrapper =
14438 utils::VipsArrayDoubleWrapper::from(&gifsave_target_options.background[..]);
14439 let background_in = background_wrapper.ctx;
14440 let background_in_name = utils::new_c_string("background")?;
14441
14442 let page_height_in: i32 = gifsave_target_options.page_height;
14443 let page_height_in_name = utils::new_c_string("page-height")?;
14444
14445 let profile_in: CString = utils::new_c_string(&gifsave_target_options.profile)?;
14446 let profile_in_name = utils::new_c_string("profile")?;
14447
14448 let vips_op_response = bindings::vips_gifsave_target(
14449 inp_in,
14450 target_in,
14451 dither_in_name.as_ptr(),
14452 dither_in,
14453 effort_in_name.as_ptr(),
14454 effort_in,
14455 bitdepth_in_name.as_ptr(),
14456 bitdepth_in,
14457 interframe_maxerror_in_name.as_ptr(),
14458 interframe_maxerror_in,
14459 reuse_in_name.as_ptr(),
14460 reuse_in,
14461 interpalette_maxerror_in_name.as_ptr(),
14462 interpalette_maxerror_in,
14463 interlace_in_name.as_ptr(),
14464 interlace_in,
14465 keep_in_name.as_ptr(),
14466 keep_in,
14467 background_in_name.as_ptr(),
14468 background_in,
14469 page_height_in_name.as_ptr(),
14470 page_height_in,
14471 profile_in_name.as_ptr(),
14472 profile_in.as_ptr(),
14473 NULL,
14474 );
14475 utils::result(vips_op_response, (), Error::GifsaveTargetError)
14476 }
14477}
14478
14479pub fn pngsave(inp: &VipsImage, filename: &str) -> Result<()> {
14484 unsafe {
14485 let inp_in: *mut bindings::VipsImage = inp.ctx;
14486 let filename_in: CString = utils::new_c_string(filename)?;
14487
14488 let vips_op_response = bindings::vips_pngsave(inp_in, filename_in.as_ptr(), NULL);
14489 utils::result(vips_op_response, (), Error::PngsaveError)
14490 }
14491}
14492
14493#[derive(Clone, Debug)]
14495pub struct PngsaveOptions {
14496 pub compression: i32,
14499 pub interlace: bool,
14502 pub filter: ForeignPngFilter,
14510 pub palette: bool,
14513 pub q: i32,
14516 pub dither: f64,
14519 pub bitdepth: i32,
14522 pub effort: i32,
14525 pub keep: ForeignKeep,
14534 pub background: Vec<f64>,
14536 pub page_height: i32,
14539 pub profile: String,
14541}
14542
14543impl std::default::Default for PngsaveOptions {
14544 fn default() -> Self {
14545 PngsaveOptions {
14546 compression: i32::from(6),
14547 interlace: false,
14548 filter: ForeignPngFilter::None,
14549 palette: false,
14550 q: i32::from(100),
14551 dither: f64::from(1),
14552 bitdepth: i32::from(8),
14553 effort: i32::from(7),
14554 keep: ForeignKeep::All,
14555 background: Vec::new(),
14556 page_height: i32::from(0),
14557 profile: String::from("sRGB"),
14558 }
14559 }
14560}
14561
14562pub fn pngsave_with_opts(
14568 inp: &VipsImage,
14569 filename: &str,
14570 pngsave_options: &PngsaveOptions,
14571) -> Result<()> {
14572 unsafe {
14573 let inp_in: *mut bindings::VipsImage = inp.ctx;
14574 let filename_in: CString = utils::new_c_string(filename)?;
14575
14576 let compression_in: i32 = pngsave_options.compression;
14577 let compression_in_name = utils::new_c_string("compression")?;
14578
14579 let interlace_in: i32 = if pngsave_options.interlace { 1 } else { 0 };
14580 let interlace_in_name = utils::new_c_string("interlace")?;
14581
14582 let filter_in: i32 = pngsave_options.filter as i32;
14583 let filter_in_name = utils::new_c_string("filter")?;
14584
14585 let palette_in: i32 = if pngsave_options.palette { 1 } else { 0 };
14586 let palette_in_name = utils::new_c_string("palette")?;
14587
14588 let q_in: i32 = pngsave_options.q;
14589 let q_in_name = utils::new_c_string("Q")?;
14590
14591 let dither_in: f64 = pngsave_options.dither;
14592 let dither_in_name = utils::new_c_string("dither")?;
14593
14594 let bitdepth_in: i32 = pngsave_options.bitdepth;
14595 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14596
14597 let effort_in: i32 = pngsave_options.effort;
14598 let effort_in_name = utils::new_c_string("effort")?;
14599
14600 let keep_in: i32 = pngsave_options.keep as i32;
14601 let keep_in_name = utils::new_c_string("keep")?;
14602
14603 let background_wrapper =
14604 utils::VipsArrayDoubleWrapper::from(&pngsave_options.background[..]);
14605 let background_in = background_wrapper.ctx;
14606 let background_in_name = utils::new_c_string("background")?;
14607
14608 let page_height_in: i32 = pngsave_options.page_height;
14609 let page_height_in_name = utils::new_c_string("page-height")?;
14610
14611 let profile_in: CString = utils::new_c_string(&pngsave_options.profile)?;
14612 let profile_in_name = utils::new_c_string("profile")?;
14613
14614 let vips_op_response = bindings::vips_pngsave(
14615 inp_in,
14616 filename_in.as_ptr(),
14617 compression_in_name.as_ptr(),
14618 compression_in,
14619 interlace_in_name.as_ptr(),
14620 interlace_in,
14621 filter_in_name.as_ptr(),
14622 filter_in,
14623 palette_in_name.as_ptr(),
14624 palette_in,
14625 q_in_name.as_ptr(),
14626 q_in,
14627 dither_in_name.as_ptr(),
14628 dither_in,
14629 bitdepth_in_name.as_ptr(),
14630 bitdepth_in,
14631 effort_in_name.as_ptr(),
14632 effort_in,
14633 keep_in_name.as_ptr(),
14634 keep_in,
14635 background_in_name.as_ptr(),
14636 background_in,
14637 page_height_in_name.as_ptr(),
14638 page_height_in,
14639 profile_in_name.as_ptr(),
14640 profile_in.as_ptr(),
14641 NULL,
14642 );
14643 utils::result(vips_op_response, (), Error::PngsaveError)
14644 }
14645}
14646
14647pub fn pngsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
14651 unsafe {
14652 let inp_in: *mut bindings::VipsImage = inp.ctx;
14653 let mut buffer_buf_size: u64 = 0;
14654 let mut buffer_out: *mut c_void = null_mut();
14655
14656 let vips_op_response =
14657 bindings::vips_pngsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
14658 utils::result(
14659 vips_op_response,
14660 utils::new_byte_array(buffer_out, buffer_buf_size),
14661 Error::PngsaveBufferError,
14662 )
14663 }
14664}
14665
14666#[derive(Clone, Debug)]
14668pub struct PngsaveBufferOptions {
14669 pub compression: i32,
14672 pub interlace: bool,
14675 pub filter: ForeignPngFilter,
14683 pub palette: bool,
14686 pub q: i32,
14689 pub dither: f64,
14692 pub bitdepth: i32,
14695 pub effort: i32,
14698 pub keep: ForeignKeep,
14707 pub background: Vec<f64>,
14709 pub page_height: i32,
14712 pub profile: String,
14714}
14715
14716impl std::default::Default for PngsaveBufferOptions {
14717 fn default() -> Self {
14718 PngsaveBufferOptions {
14719 compression: i32::from(6),
14720 interlace: false,
14721 filter: ForeignPngFilter::None,
14722 palette: false,
14723 q: i32::from(100),
14724 dither: f64::from(1),
14725 bitdepth: i32::from(8),
14726 effort: i32::from(7),
14727 keep: ForeignKeep::All,
14728 background: Vec::new(),
14729 page_height: i32::from(0),
14730 profile: String::from("sRGB"),
14731 }
14732 }
14733}
14734
14735pub fn pngsave_buffer_with_opts(
14740 inp: &VipsImage,
14741 pngsave_buffer_options: &PngsaveBufferOptions,
14742) -> Result<Vec<u8>> {
14743 unsafe {
14744 let inp_in: *mut bindings::VipsImage = inp.ctx;
14745 let mut buffer_buf_size: u64 = 0;
14746 let mut buffer_out: *mut c_void = null_mut();
14747
14748 let compression_in: i32 = pngsave_buffer_options.compression;
14749 let compression_in_name = utils::new_c_string("compression")?;
14750
14751 let interlace_in: i32 = if pngsave_buffer_options.interlace {
14752 1
14753 } else {
14754 0
14755 };
14756 let interlace_in_name = utils::new_c_string("interlace")?;
14757
14758 let filter_in: i32 = pngsave_buffer_options.filter as i32;
14759 let filter_in_name = utils::new_c_string("filter")?;
14760
14761 let palette_in: i32 = if pngsave_buffer_options.palette { 1 } else { 0 };
14762 let palette_in_name = utils::new_c_string("palette")?;
14763
14764 let q_in: i32 = pngsave_buffer_options.q;
14765 let q_in_name = utils::new_c_string("Q")?;
14766
14767 let dither_in: f64 = pngsave_buffer_options.dither;
14768 let dither_in_name = utils::new_c_string("dither")?;
14769
14770 let bitdepth_in: i32 = pngsave_buffer_options.bitdepth;
14771 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14772
14773 let effort_in: i32 = pngsave_buffer_options.effort;
14774 let effort_in_name = utils::new_c_string("effort")?;
14775
14776 let keep_in: i32 = pngsave_buffer_options.keep as i32;
14777 let keep_in_name = utils::new_c_string("keep")?;
14778
14779 let background_wrapper =
14780 utils::VipsArrayDoubleWrapper::from(&pngsave_buffer_options.background[..]);
14781 let background_in = background_wrapper.ctx;
14782 let background_in_name = utils::new_c_string("background")?;
14783
14784 let page_height_in: i32 = pngsave_buffer_options.page_height;
14785 let page_height_in_name = utils::new_c_string("page-height")?;
14786
14787 let profile_in: CString = utils::new_c_string(&pngsave_buffer_options.profile)?;
14788 let profile_in_name = utils::new_c_string("profile")?;
14789
14790 let vips_op_response = bindings::vips_pngsave_buffer(
14791 inp_in,
14792 &mut buffer_out,
14793 &mut buffer_buf_size,
14794 compression_in_name.as_ptr(),
14795 compression_in,
14796 interlace_in_name.as_ptr(),
14797 interlace_in,
14798 filter_in_name.as_ptr(),
14799 filter_in,
14800 palette_in_name.as_ptr(),
14801 palette_in,
14802 q_in_name.as_ptr(),
14803 q_in,
14804 dither_in_name.as_ptr(),
14805 dither_in,
14806 bitdepth_in_name.as_ptr(),
14807 bitdepth_in,
14808 effort_in_name.as_ptr(),
14809 effort_in,
14810 keep_in_name.as_ptr(),
14811 keep_in,
14812 background_in_name.as_ptr(),
14813 background_in,
14814 page_height_in_name.as_ptr(),
14815 page_height_in,
14816 profile_in_name.as_ptr(),
14817 profile_in.as_ptr(),
14818 NULL,
14819 );
14820 utils::result(
14821 vips_op_response,
14822 utils::new_byte_array(buffer_out, buffer_buf_size),
14823 Error::PngsaveBufferError,
14824 )
14825 }
14826}
14827
14828pub fn pngsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
14833 unsafe {
14834 let inp_in: *mut bindings::VipsImage = inp.ctx;
14835 let target_in: *mut bindings::VipsTarget = target.ctx;
14836
14837 let vips_op_response = bindings::vips_pngsave_target(inp_in, target_in, NULL);
14838 utils::result(vips_op_response, (), Error::PngsaveTargetError)
14839 }
14840}
14841
14842#[derive(Clone, Debug)]
14844pub struct PngsaveTargetOptions {
14845 pub compression: i32,
14848 pub interlace: bool,
14851 pub filter: ForeignPngFilter,
14859 pub palette: bool,
14862 pub q: i32,
14865 pub dither: f64,
14868 pub bitdepth: i32,
14871 pub effort: i32,
14874 pub keep: ForeignKeep,
14883 pub background: Vec<f64>,
14885 pub page_height: i32,
14888 pub profile: String,
14890}
14891
14892impl std::default::Default for PngsaveTargetOptions {
14893 fn default() -> Self {
14894 PngsaveTargetOptions {
14895 compression: i32::from(6),
14896 interlace: false,
14897 filter: ForeignPngFilter::None,
14898 palette: false,
14899 q: i32::from(100),
14900 dither: f64::from(1),
14901 bitdepth: i32::from(8),
14902 effort: i32::from(7),
14903 keep: ForeignKeep::All,
14904 background: Vec::new(),
14905 page_height: i32::from(0),
14906 profile: String::from("sRGB"),
14907 }
14908 }
14909}
14910
14911pub fn pngsave_target_with_opts(
14917 inp: &VipsImage,
14918 target: &VipsTarget,
14919 pngsave_target_options: &PngsaveTargetOptions,
14920) -> Result<()> {
14921 unsafe {
14922 let inp_in: *mut bindings::VipsImage = inp.ctx;
14923 let target_in: *mut bindings::VipsTarget = target.ctx;
14924
14925 let compression_in: i32 = pngsave_target_options.compression;
14926 let compression_in_name = utils::new_c_string("compression")?;
14927
14928 let interlace_in: i32 = if pngsave_target_options.interlace {
14929 1
14930 } else {
14931 0
14932 };
14933 let interlace_in_name = utils::new_c_string("interlace")?;
14934
14935 let filter_in: i32 = pngsave_target_options.filter as i32;
14936 let filter_in_name = utils::new_c_string("filter")?;
14937
14938 let palette_in: i32 = if pngsave_target_options.palette { 1 } else { 0 };
14939 let palette_in_name = utils::new_c_string("palette")?;
14940
14941 let q_in: i32 = pngsave_target_options.q;
14942 let q_in_name = utils::new_c_string("Q")?;
14943
14944 let dither_in: f64 = pngsave_target_options.dither;
14945 let dither_in_name = utils::new_c_string("dither")?;
14946
14947 let bitdepth_in: i32 = pngsave_target_options.bitdepth;
14948 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
14949
14950 let effort_in: i32 = pngsave_target_options.effort;
14951 let effort_in_name = utils::new_c_string("effort")?;
14952
14953 let keep_in: i32 = pngsave_target_options.keep as i32;
14954 let keep_in_name = utils::new_c_string("keep")?;
14955
14956 let background_wrapper =
14957 utils::VipsArrayDoubleWrapper::from(&pngsave_target_options.background[..]);
14958 let background_in = background_wrapper.ctx;
14959 let background_in_name = utils::new_c_string("background")?;
14960
14961 let page_height_in: i32 = pngsave_target_options.page_height;
14962 let page_height_in_name = utils::new_c_string("page-height")?;
14963
14964 let profile_in: CString = utils::new_c_string(&pngsave_target_options.profile)?;
14965 let profile_in_name = utils::new_c_string("profile")?;
14966
14967 let vips_op_response = bindings::vips_pngsave_target(
14968 inp_in,
14969 target_in,
14970 compression_in_name.as_ptr(),
14971 compression_in,
14972 interlace_in_name.as_ptr(),
14973 interlace_in,
14974 filter_in_name.as_ptr(),
14975 filter_in,
14976 palette_in_name.as_ptr(),
14977 palette_in,
14978 q_in_name.as_ptr(),
14979 q_in,
14980 dither_in_name.as_ptr(),
14981 dither_in,
14982 bitdepth_in_name.as_ptr(),
14983 bitdepth_in,
14984 effort_in_name.as_ptr(),
14985 effort_in,
14986 keep_in_name.as_ptr(),
14987 keep_in,
14988 background_in_name.as_ptr(),
14989 background_in,
14990 page_height_in_name.as_ptr(),
14991 page_height_in,
14992 profile_in_name.as_ptr(),
14993 profile_in.as_ptr(),
14994 NULL,
14995 );
14996 utils::result(vips_op_response, (), Error::PngsaveTargetError)
14997 }
14998}
14999
15000pub fn jpegsave(inp: &VipsImage, filename: &str) -> Result<()> {
15005 unsafe {
15006 let inp_in: *mut bindings::VipsImage = inp.ctx;
15007 let filename_in: CString = utils::new_c_string(filename)?;
15008
15009 let vips_op_response = bindings::vips_jpegsave(inp_in, filename_in.as_ptr(), NULL);
15010 utils::result(vips_op_response, (), Error::JpegsaveError)
15011 }
15012}
15013
15014#[derive(Clone, Debug)]
15016pub struct JpegsaveOptions {
15017 pub q: i32,
15020 pub optimize_coding: bool,
15023 pub interlace: bool,
15026 pub trellis_quant: bool,
15029 pub overshoot_deringing: bool,
15032 pub optimize_scans: bool,
15035 pub quant_table: i32,
15038 pub subsample_mode: ForeignSubsample,
15044 pub restart_interval: i32,
15047 pub keep: ForeignKeep,
15056 pub background: Vec<f64>,
15058 pub page_height: i32,
15061 pub profile: String,
15063}
15064
15065impl std::default::Default for JpegsaveOptions {
15066 fn default() -> Self {
15067 JpegsaveOptions {
15068 q: i32::from(75),
15069 optimize_coding: false,
15070 interlace: false,
15071 trellis_quant: false,
15072 overshoot_deringing: false,
15073 optimize_scans: false,
15074 quant_table: i32::from(0),
15075 subsample_mode: ForeignSubsample::Auto,
15076 restart_interval: i32::from(0),
15077 keep: ForeignKeep::All,
15078 background: Vec::new(),
15079 page_height: i32::from(0),
15080 profile: String::from("sRGB"),
15081 }
15082 }
15083}
15084
15085pub fn jpegsave_with_opts(
15091 inp: &VipsImage,
15092 filename: &str,
15093 jpegsave_options: &JpegsaveOptions,
15094) -> Result<()> {
15095 unsafe {
15096 let inp_in: *mut bindings::VipsImage = inp.ctx;
15097 let filename_in: CString = utils::new_c_string(filename)?;
15098
15099 let q_in: i32 = jpegsave_options.q;
15100 let q_in_name = utils::new_c_string("Q")?;
15101
15102 let optimize_coding_in: i32 = if jpegsave_options.optimize_coding {
15103 1
15104 } else {
15105 0
15106 };
15107 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15108
15109 let interlace_in: i32 = if jpegsave_options.interlace { 1 } else { 0 };
15110 let interlace_in_name = utils::new_c_string("interlace")?;
15111
15112 let trellis_quant_in: i32 = if jpegsave_options.trellis_quant { 1 } else { 0 };
15113 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15114
15115 let overshoot_deringing_in: i32 = if jpegsave_options.overshoot_deringing {
15116 1
15117 } else {
15118 0
15119 };
15120 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15121
15122 let optimize_scans_in: i32 = if jpegsave_options.optimize_scans {
15123 1
15124 } else {
15125 0
15126 };
15127 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15128
15129 let quant_table_in: i32 = jpegsave_options.quant_table;
15130 let quant_table_in_name = utils::new_c_string("quant-table")?;
15131
15132 let subsample_mode_in: i32 = jpegsave_options.subsample_mode as i32;
15133 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15134
15135 let restart_interval_in: i32 = jpegsave_options.restart_interval;
15136 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15137
15138 let keep_in: i32 = jpegsave_options.keep as i32;
15139 let keep_in_name = utils::new_c_string("keep")?;
15140
15141 let background_wrapper =
15142 utils::VipsArrayDoubleWrapper::from(&jpegsave_options.background[..]);
15143 let background_in = background_wrapper.ctx;
15144 let background_in_name = utils::new_c_string("background")?;
15145
15146 let page_height_in: i32 = jpegsave_options.page_height;
15147 let page_height_in_name = utils::new_c_string("page-height")?;
15148
15149 let profile_in: CString = utils::new_c_string(&jpegsave_options.profile)?;
15150 let profile_in_name = utils::new_c_string("profile")?;
15151
15152 let vips_op_response = bindings::vips_jpegsave(
15153 inp_in,
15154 filename_in.as_ptr(),
15155 q_in_name.as_ptr(),
15156 q_in,
15157 optimize_coding_in_name.as_ptr(),
15158 optimize_coding_in,
15159 interlace_in_name.as_ptr(),
15160 interlace_in,
15161 trellis_quant_in_name.as_ptr(),
15162 trellis_quant_in,
15163 overshoot_deringing_in_name.as_ptr(),
15164 overshoot_deringing_in,
15165 optimize_scans_in_name.as_ptr(),
15166 optimize_scans_in,
15167 quant_table_in_name.as_ptr(),
15168 quant_table_in,
15169 subsample_mode_in_name.as_ptr(),
15170 subsample_mode_in,
15171 restart_interval_in_name.as_ptr(),
15172 restart_interval_in,
15173 keep_in_name.as_ptr(),
15174 keep_in,
15175 background_in_name.as_ptr(),
15176 background_in,
15177 page_height_in_name.as_ptr(),
15178 page_height_in,
15179 profile_in_name.as_ptr(),
15180 profile_in.as_ptr(),
15181 NULL,
15182 );
15183 utils::result(vips_op_response, (), Error::JpegsaveError)
15184 }
15185}
15186
15187pub fn jpegsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
15191 unsafe {
15192 let inp_in: *mut bindings::VipsImage = inp.ctx;
15193 let mut buffer_buf_size: u64 = 0;
15194 let mut buffer_out: *mut c_void = null_mut();
15195
15196 let vips_op_response =
15197 bindings::vips_jpegsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
15198 utils::result(
15199 vips_op_response,
15200 utils::new_byte_array(buffer_out, buffer_buf_size),
15201 Error::JpegsaveBufferError,
15202 )
15203 }
15204}
15205
15206#[derive(Clone, Debug)]
15208pub struct JpegsaveBufferOptions {
15209 pub q: i32,
15212 pub optimize_coding: bool,
15215 pub interlace: bool,
15218 pub trellis_quant: bool,
15221 pub overshoot_deringing: bool,
15224 pub optimize_scans: bool,
15227 pub quant_table: i32,
15230 pub subsample_mode: ForeignSubsample,
15236 pub restart_interval: i32,
15239 pub keep: ForeignKeep,
15248 pub background: Vec<f64>,
15250 pub page_height: i32,
15253 pub profile: String,
15255}
15256
15257impl std::default::Default for JpegsaveBufferOptions {
15258 fn default() -> Self {
15259 JpegsaveBufferOptions {
15260 q: i32::from(75),
15261 optimize_coding: false,
15262 interlace: false,
15263 trellis_quant: false,
15264 overshoot_deringing: false,
15265 optimize_scans: false,
15266 quant_table: i32::from(0),
15267 subsample_mode: ForeignSubsample::Auto,
15268 restart_interval: i32::from(0),
15269 keep: ForeignKeep::All,
15270 background: Vec::new(),
15271 page_height: i32::from(0),
15272 profile: String::from("sRGB"),
15273 }
15274 }
15275}
15276
15277pub fn jpegsave_buffer_with_opts(
15282 inp: &VipsImage,
15283 jpegsave_buffer_options: &JpegsaveBufferOptions,
15284) -> Result<Vec<u8>> {
15285 unsafe {
15286 let inp_in: *mut bindings::VipsImage = inp.ctx;
15287 let mut buffer_buf_size: u64 = 0;
15288 let mut buffer_out: *mut c_void = null_mut();
15289
15290 let q_in: i32 = jpegsave_buffer_options.q;
15291 let q_in_name = utils::new_c_string("Q")?;
15292
15293 let optimize_coding_in: i32 = if jpegsave_buffer_options.optimize_coding {
15294 1
15295 } else {
15296 0
15297 };
15298 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15299
15300 let interlace_in: i32 = if jpegsave_buffer_options.interlace {
15301 1
15302 } else {
15303 0
15304 };
15305 let interlace_in_name = utils::new_c_string("interlace")?;
15306
15307 let trellis_quant_in: i32 = if jpegsave_buffer_options.trellis_quant {
15308 1
15309 } else {
15310 0
15311 };
15312 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15313
15314 let overshoot_deringing_in: i32 = if jpegsave_buffer_options.overshoot_deringing {
15315 1
15316 } else {
15317 0
15318 };
15319 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15320
15321 let optimize_scans_in: i32 = if jpegsave_buffer_options.optimize_scans {
15322 1
15323 } else {
15324 0
15325 };
15326 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15327
15328 let quant_table_in: i32 = jpegsave_buffer_options.quant_table;
15329 let quant_table_in_name = utils::new_c_string("quant-table")?;
15330
15331 let subsample_mode_in: i32 = jpegsave_buffer_options.subsample_mode as i32;
15332 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15333
15334 let restart_interval_in: i32 = jpegsave_buffer_options.restart_interval;
15335 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15336
15337 let keep_in: i32 = jpegsave_buffer_options.keep as i32;
15338 let keep_in_name = utils::new_c_string("keep")?;
15339
15340 let background_wrapper =
15341 utils::VipsArrayDoubleWrapper::from(&jpegsave_buffer_options.background[..]);
15342 let background_in = background_wrapper.ctx;
15343 let background_in_name = utils::new_c_string("background")?;
15344
15345 let page_height_in: i32 = jpegsave_buffer_options.page_height;
15346 let page_height_in_name = utils::new_c_string("page-height")?;
15347
15348 let profile_in: CString = utils::new_c_string(&jpegsave_buffer_options.profile)?;
15349 let profile_in_name = utils::new_c_string("profile")?;
15350
15351 let vips_op_response = bindings::vips_jpegsave_buffer(
15352 inp_in,
15353 &mut buffer_out,
15354 &mut buffer_buf_size,
15355 q_in_name.as_ptr(),
15356 q_in,
15357 optimize_coding_in_name.as_ptr(),
15358 optimize_coding_in,
15359 interlace_in_name.as_ptr(),
15360 interlace_in,
15361 trellis_quant_in_name.as_ptr(),
15362 trellis_quant_in,
15363 overshoot_deringing_in_name.as_ptr(),
15364 overshoot_deringing_in,
15365 optimize_scans_in_name.as_ptr(),
15366 optimize_scans_in,
15367 quant_table_in_name.as_ptr(),
15368 quant_table_in,
15369 subsample_mode_in_name.as_ptr(),
15370 subsample_mode_in,
15371 restart_interval_in_name.as_ptr(),
15372 restart_interval_in,
15373 keep_in_name.as_ptr(),
15374 keep_in,
15375 background_in_name.as_ptr(),
15376 background_in,
15377 page_height_in_name.as_ptr(),
15378 page_height_in,
15379 profile_in_name.as_ptr(),
15380 profile_in.as_ptr(),
15381 NULL,
15382 );
15383 utils::result(
15384 vips_op_response,
15385 utils::new_byte_array(buffer_out, buffer_buf_size),
15386 Error::JpegsaveBufferError,
15387 )
15388 }
15389}
15390
15391pub fn jpegsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
15396 unsafe {
15397 let inp_in: *mut bindings::VipsImage = inp.ctx;
15398 let target_in: *mut bindings::VipsTarget = target.ctx;
15399
15400 let vips_op_response = bindings::vips_jpegsave_target(inp_in, target_in, NULL);
15401 utils::result(vips_op_response, (), Error::JpegsaveTargetError)
15402 }
15403}
15404
15405#[derive(Clone, Debug)]
15407pub struct JpegsaveTargetOptions {
15408 pub q: i32,
15411 pub optimize_coding: bool,
15414 pub interlace: bool,
15417 pub trellis_quant: bool,
15420 pub overshoot_deringing: bool,
15423 pub optimize_scans: bool,
15426 pub quant_table: i32,
15429 pub subsample_mode: ForeignSubsample,
15435 pub restart_interval: i32,
15438 pub keep: ForeignKeep,
15447 pub background: Vec<f64>,
15449 pub page_height: i32,
15452 pub profile: String,
15454}
15455
15456impl std::default::Default for JpegsaveTargetOptions {
15457 fn default() -> Self {
15458 JpegsaveTargetOptions {
15459 q: i32::from(75),
15460 optimize_coding: false,
15461 interlace: false,
15462 trellis_quant: false,
15463 overshoot_deringing: false,
15464 optimize_scans: false,
15465 quant_table: i32::from(0),
15466 subsample_mode: ForeignSubsample::Auto,
15467 restart_interval: i32::from(0),
15468 keep: ForeignKeep::All,
15469 background: Vec::new(),
15470 page_height: i32::from(0),
15471 profile: String::from("sRGB"),
15472 }
15473 }
15474}
15475
15476pub fn jpegsave_target_with_opts(
15482 inp: &VipsImage,
15483 target: &VipsTarget,
15484 jpegsave_target_options: &JpegsaveTargetOptions,
15485) -> Result<()> {
15486 unsafe {
15487 let inp_in: *mut bindings::VipsImage = inp.ctx;
15488 let target_in: *mut bindings::VipsTarget = target.ctx;
15489
15490 let q_in: i32 = jpegsave_target_options.q;
15491 let q_in_name = utils::new_c_string("Q")?;
15492
15493 let optimize_coding_in: i32 = if jpegsave_target_options.optimize_coding {
15494 1
15495 } else {
15496 0
15497 };
15498 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15499
15500 let interlace_in: i32 = if jpegsave_target_options.interlace {
15501 1
15502 } else {
15503 0
15504 };
15505 let interlace_in_name = utils::new_c_string("interlace")?;
15506
15507 let trellis_quant_in: i32 = if jpegsave_target_options.trellis_quant {
15508 1
15509 } else {
15510 0
15511 };
15512 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15513
15514 let overshoot_deringing_in: i32 = if jpegsave_target_options.overshoot_deringing {
15515 1
15516 } else {
15517 0
15518 };
15519 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15520
15521 let optimize_scans_in: i32 = if jpegsave_target_options.optimize_scans {
15522 1
15523 } else {
15524 0
15525 };
15526 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15527
15528 let quant_table_in: i32 = jpegsave_target_options.quant_table;
15529 let quant_table_in_name = utils::new_c_string("quant-table")?;
15530
15531 let subsample_mode_in: i32 = jpegsave_target_options.subsample_mode as i32;
15532 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15533
15534 let restart_interval_in: i32 = jpegsave_target_options.restart_interval;
15535 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15536
15537 let keep_in: i32 = jpegsave_target_options.keep as i32;
15538 let keep_in_name = utils::new_c_string("keep")?;
15539
15540 let background_wrapper =
15541 utils::VipsArrayDoubleWrapper::from(&jpegsave_target_options.background[..]);
15542 let background_in = background_wrapper.ctx;
15543 let background_in_name = utils::new_c_string("background")?;
15544
15545 let page_height_in: i32 = jpegsave_target_options.page_height;
15546 let page_height_in_name = utils::new_c_string("page-height")?;
15547
15548 let profile_in: CString = utils::new_c_string(&jpegsave_target_options.profile)?;
15549 let profile_in_name = utils::new_c_string("profile")?;
15550
15551 let vips_op_response = bindings::vips_jpegsave_target(
15552 inp_in,
15553 target_in,
15554 q_in_name.as_ptr(),
15555 q_in,
15556 optimize_coding_in_name.as_ptr(),
15557 optimize_coding_in,
15558 interlace_in_name.as_ptr(),
15559 interlace_in,
15560 trellis_quant_in_name.as_ptr(),
15561 trellis_quant_in,
15562 overshoot_deringing_in_name.as_ptr(),
15563 overshoot_deringing_in,
15564 optimize_scans_in_name.as_ptr(),
15565 optimize_scans_in,
15566 quant_table_in_name.as_ptr(),
15567 quant_table_in,
15568 subsample_mode_in_name.as_ptr(),
15569 subsample_mode_in,
15570 restart_interval_in_name.as_ptr(),
15571 restart_interval_in,
15572 keep_in_name.as_ptr(),
15573 keep_in,
15574 background_in_name.as_ptr(),
15575 background_in,
15576 page_height_in_name.as_ptr(),
15577 page_height_in,
15578 profile_in_name.as_ptr(),
15579 profile_in.as_ptr(),
15580 NULL,
15581 );
15582 utils::result(vips_op_response, (), Error::JpegsaveTargetError)
15583 }
15584}
15585
15586pub fn jpegsave_mime(inp: &VipsImage) -> Result<()> {
15590 unsafe {
15591 let inp_in: *mut bindings::VipsImage = inp.ctx;
15592
15593 let vips_op_response = bindings::vips_jpegsave_mime(inp_in, NULL);
15594 utils::result(vips_op_response, (), Error::JpegsaveMimeError)
15595 }
15596}
15597
15598#[derive(Clone, Debug)]
15600pub struct JpegsaveMimeOptions {
15601 pub q: i32,
15604 pub optimize_coding: bool,
15607 pub interlace: bool,
15610 pub trellis_quant: bool,
15613 pub overshoot_deringing: bool,
15616 pub optimize_scans: bool,
15619 pub quant_table: i32,
15622 pub subsample_mode: ForeignSubsample,
15628 pub restart_interval: i32,
15631 pub keep: ForeignKeep,
15640 pub background: Vec<f64>,
15642 pub page_height: i32,
15645 pub profile: String,
15647}
15648
15649impl std::default::Default for JpegsaveMimeOptions {
15650 fn default() -> Self {
15651 JpegsaveMimeOptions {
15652 q: i32::from(75),
15653 optimize_coding: false,
15654 interlace: false,
15655 trellis_quant: false,
15656 overshoot_deringing: false,
15657 optimize_scans: false,
15658 quant_table: i32::from(0),
15659 subsample_mode: ForeignSubsample::Auto,
15660 restart_interval: i32::from(0),
15661 keep: ForeignKeep::All,
15662 background: Vec::new(),
15663 page_height: i32::from(0),
15664 profile: String::from("sRGB"),
15665 }
15666 }
15667}
15668
15669pub fn jpegsave_mime_with_opts(
15674 inp: &VipsImage,
15675 jpegsave_mime_options: &JpegsaveMimeOptions,
15676) -> Result<()> {
15677 unsafe {
15678 let inp_in: *mut bindings::VipsImage = inp.ctx;
15679
15680 let q_in: i32 = jpegsave_mime_options.q;
15681 let q_in_name = utils::new_c_string("Q")?;
15682
15683 let optimize_coding_in: i32 = if jpegsave_mime_options.optimize_coding {
15684 1
15685 } else {
15686 0
15687 };
15688 let optimize_coding_in_name = utils::new_c_string("optimize-coding")?;
15689
15690 let interlace_in: i32 = if jpegsave_mime_options.interlace {
15691 1
15692 } else {
15693 0
15694 };
15695 let interlace_in_name = utils::new_c_string("interlace")?;
15696
15697 let trellis_quant_in: i32 = if jpegsave_mime_options.trellis_quant {
15698 1
15699 } else {
15700 0
15701 };
15702 let trellis_quant_in_name = utils::new_c_string("trellis-quant")?;
15703
15704 let overshoot_deringing_in: i32 = if jpegsave_mime_options.overshoot_deringing {
15705 1
15706 } else {
15707 0
15708 };
15709 let overshoot_deringing_in_name = utils::new_c_string("overshoot-deringing")?;
15710
15711 let optimize_scans_in: i32 = if jpegsave_mime_options.optimize_scans {
15712 1
15713 } else {
15714 0
15715 };
15716 let optimize_scans_in_name = utils::new_c_string("optimize-scans")?;
15717
15718 let quant_table_in: i32 = jpegsave_mime_options.quant_table;
15719 let quant_table_in_name = utils::new_c_string("quant-table")?;
15720
15721 let subsample_mode_in: i32 = jpegsave_mime_options.subsample_mode as i32;
15722 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
15723
15724 let restart_interval_in: i32 = jpegsave_mime_options.restart_interval;
15725 let restart_interval_in_name = utils::new_c_string("restart-interval")?;
15726
15727 let keep_in: i32 = jpegsave_mime_options.keep as i32;
15728 let keep_in_name = utils::new_c_string("keep")?;
15729
15730 let background_wrapper =
15731 utils::VipsArrayDoubleWrapper::from(&jpegsave_mime_options.background[..]);
15732 let background_in = background_wrapper.ctx;
15733 let background_in_name = utils::new_c_string("background")?;
15734
15735 let page_height_in: i32 = jpegsave_mime_options.page_height;
15736 let page_height_in_name = utils::new_c_string("page-height")?;
15737
15738 let profile_in: CString = utils::new_c_string(&jpegsave_mime_options.profile)?;
15739 let profile_in_name = utils::new_c_string("profile")?;
15740
15741 let vips_op_response = bindings::vips_jpegsave_mime(
15742 inp_in,
15743 q_in_name.as_ptr(),
15744 q_in,
15745 optimize_coding_in_name.as_ptr(),
15746 optimize_coding_in,
15747 interlace_in_name.as_ptr(),
15748 interlace_in,
15749 trellis_quant_in_name.as_ptr(),
15750 trellis_quant_in,
15751 overshoot_deringing_in_name.as_ptr(),
15752 overshoot_deringing_in,
15753 optimize_scans_in_name.as_ptr(),
15754 optimize_scans_in,
15755 quant_table_in_name.as_ptr(),
15756 quant_table_in,
15757 subsample_mode_in_name.as_ptr(),
15758 subsample_mode_in,
15759 restart_interval_in_name.as_ptr(),
15760 restart_interval_in,
15761 keep_in_name.as_ptr(),
15762 keep_in,
15763 background_in_name.as_ptr(),
15764 background_in,
15765 page_height_in_name.as_ptr(),
15766 page_height_in,
15767 profile_in_name.as_ptr(),
15768 profile_in.as_ptr(),
15769 NULL,
15770 );
15771 utils::result(vips_op_response, (), Error::JpegsaveMimeError)
15772 }
15773}
15774
15775pub fn webpsave(inp: &VipsImage, filename: &str) -> Result<()> {
15780 unsafe {
15781 let inp_in: *mut bindings::VipsImage = inp.ctx;
15782 let filename_in: CString = utils::new_c_string(filename)?;
15783
15784 let vips_op_response = bindings::vips_webpsave(inp_in, filename_in.as_ptr(), NULL);
15785 utils::result(vips_op_response, (), Error::WebpsaveError)
15786 }
15787}
15788
15789#[derive(Clone, Debug)]
15791pub struct WebpsaveOptions {
15792 pub q: i32,
15795 pub lossless: bool,
15798 pub preset: ForeignWebpPreset,
15807 pub smart_subsample: bool,
15810 pub near_lossless: bool,
15813 pub alpha_q: i32,
15816 pub min_size: bool,
15819 pub kmin: i32,
15822 pub kmax: i32,
15825 pub effort: i32,
15828 pub target_size: i32,
15831 pub mixed: bool,
15834 pub smart_deblock: bool,
15837 pub passes: i32,
15840 pub keep: ForeignKeep,
15849 pub background: Vec<f64>,
15851 pub page_height: i32,
15854 pub profile: String,
15856}
15857
15858impl std::default::Default for WebpsaveOptions {
15859 fn default() -> Self {
15860 WebpsaveOptions {
15861 q: i32::from(75),
15862 lossless: false,
15863 preset: ForeignWebpPreset::Default,
15864 smart_subsample: false,
15865 near_lossless: false,
15866 alpha_q: i32::from(100),
15867 min_size: false,
15868 kmin: i32::from(2147483646),
15869 kmax: i32::from(2147483647),
15870 effort: i32::from(4),
15871 target_size: i32::from(0),
15872 mixed: false,
15873 smart_deblock: false,
15874 passes: i32::from(1),
15875 keep: ForeignKeep::All,
15876 background: Vec::new(),
15877 page_height: i32::from(0),
15878 profile: String::from("sRGB"),
15879 }
15880 }
15881}
15882
15883pub fn webpsave_with_opts(
15889 inp: &VipsImage,
15890 filename: &str,
15891 webpsave_options: &WebpsaveOptions,
15892) -> Result<()> {
15893 unsafe {
15894 let inp_in: *mut bindings::VipsImage = inp.ctx;
15895 let filename_in: CString = utils::new_c_string(filename)?;
15896
15897 let q_in: i32 = webpsave_options.q;
15898 let q_in_name = utils::new_c_string("Q")?;
15899
15900 let lossless_in: i32 = if webpsave_options.lossless { 1 } else { 0 };
15901 let lossless_in_name = utils::new_c_string("lossless")?;
15902
15903 let preset_in: i32 = webpsave_options.preset as i32;
15904 let preset_in_name = utils::new_c_string("preset")?;
15905
15906 let smart_subsample_in: i32 = if webpsave_options.smart_subsample {
15907 1
15908 } else {
15909 0
15910 };
15911 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
15912
15913 let near_lossless_in: i32 = if webpsave_options.near_lossless { 1 } else { 0 };
15914 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
15915
15916 let alpha_q_in: i32 = webpsave_options.alpha_q;
15917 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
15918
15919 let min_size_in: i32 = if webpsave_options.min_size { 1 } else { 0 };
15920 let min_size_in_name = utils::new_c_string("min-size")?;
15921
15922 let kmin_in: i32 = webpsave_options.kmin;
15923 let kmin_in_name = utils::new_c_string("kmin")?;
15924
15925 let kmax_in: i32 = webpsave_options.kmax;
15926 let kmax_in_name = utils::new_c_string("kmax")?;
15927
15928 let effort_in: i32 = webpsave_options.effort;
15929 let effort_in_name = utils::new_c_string("effort")?;
15930
15931 let target_size_in: i32 = webpsave_options.target_size;
15932 let target_size_in_name = utils::new_c_string("target-size")?;
15933
15934 let mixed_in: i32 = if webpsave_options.mixed { 1 } else { 0 };
15935 let mixed_in_name = utils::new_c_string("mixed")?;
15936
15937 let smart_deblock_in: i32 = if webpsave_options.smart_deblock { 1 } else { 0 };
15938 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
15939
15940 let passes_in: i32 = webpsave_options.passes;
15941 let passes_in_name = utils::new_c_string("passes")?;
15942
15943 let keep_in: i32 = webpsave_options.keep as i32;
15944 let keep_in_name = utils::new_c_string("keep")?;
15945
15946 let background_wrapper =
15947 utils::VipsArrayDoubleWrapper::from(&webpsave_options.background[..]);
15948 let background_in = background_wrapper.ctx;
15949 let background_in_name = utils::new_c_string("background")?;
15950
15951 let page_height_in: i32 = webpsave_options.page_height;
15952 let page_height_in_name = utils::new_c_string("page-height")?;
15953
15954 let profile_in: CString = utils::new_c_string(&webpsave_options.profile)?;
15955 let profile_in_name = utils::new_c_string("profile")?;
15956
15957 let vips_op_response = bindings::vips_webpsave(
15958 inp_in,
15959 filename_in.as_ptr(),
15960 q_in_name.as_ptr(),
15961 q_in,
15962 lossless_in_name.as_ptr(),
15963 lossless_in,
15964 preset_in_name.as_ptr(),
15965 preset_in,
15966 smart_subsample_in_name.as_ptr(),
15967 smart_subsample_in,
15968 near_lossless_in_name.as_ptr(),
15969 near_lossless_in,
15970 alpha_q_in_name.as_ptr(),
15971 alpha_q_in,
15972 min_size_in_name.as_ptr(),
15973 min_size_in,
15974 kmin_in_name.as_ptr(),
15975 kmin_in,
15976 kmax_in_name.as_ptr(),
15977 kmax_in,
15978 effort_in_name.as_ptr(),
15979 effort_in,
15980 target_size_in_name.as_ptr(),
15981 target_size_in,
15982 mixed_in_name.as_ptr(),
15983 mixed_in,
15984 smart_deblock_in_name.as_ptr(),
15985 smart_deblock_in,
15986 passes_in_name.as_ptr(),
15987 passes_in,
15988 keep_in_name.as_ptr(),
15989 keep_in,
15990 background_in_name.as_ptr(),
15991 background_in,
15992 page_height_in_name.as_ptr(),
15993 page_height_in,
15994 profile_in_name.as_ptr(),
15995 profile_in.as_ptr(),
15996 NULL,
15997 );
15998 utils::result(vips_op_response, (), Error::WebpsaveError)
15999 }
16000}
16001
16002pub fn webpsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
16006 unsafe {
16007 let inp_in: *mut bindings::VipsImage = inp.ctx;
16008 let mut buffer_buf_size: u64 = 0;
16009 let mut buffer_out: *mut c_void = null_mut();
16010
16011 let vips_op_response =
16012 bindings::vips_webpsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
16013 utils::result(
16014 vips_op_response,
16015 utils::new_byte_array(buffer_out, buffer_buf_size),
16016 Error::WebpsaveBufferError,
16017 )
16018 }
16019}
16020
16021#[derive(Clone, Debug)]
16023pub struct WebpsaveBufferOptions {
16024 pub q: i32,
16027 pub lossless: bool,
16030 pub preset: ForeignWebpPreset,
16039 pub smart_subsample: bool,
16042 pub near_lossless: bool,
16045 pub alpha_q: i32,
16048 pub min_size: bool,
16051 pub kmin: i32,
16054 pub kmax: i32,
16057 pub effort: i32,
16060 pub target_size: i32,
16063 pub mixed: bool,
16066 pub smart_deblock: bool,
16069 pub passes: i32,
16072 pub keep: ForeignKeep,
16081 pub background: Vec<f64>,
16083 pub page_height: i32,
16086 pub profile: String,
16088}
16089
16090impl std::default::Default for WebpsaveBufferOptions {
16091 fn default() -> Self {
16092 WebpsaveBufferOptions {
16093 q: i32::from(75),
16094 lossless: false,
16095 preset: ForeignWebpPreset::Default,
16096 smart_subsample: false,
16097 near_lossless: false,
16098 alpha_q: i32::from(100),
16099 min_size: false,
16100 kmin: i32::from(2147483646),
16101 kmax: i32::from(2147483647),
16102 effort: i32::from(4),
16103 target_size: i32::from(0),
16104 mixed: false,
16105 smart_deblock: false,
16106 passes: i32::from(1),
16107 keep: ForeignKeep::All,
16108 background: Vec::new(),
16109 page_height: i32::from(0),
16110 profile: String::from("sRGB"),
16111 }
16112 }
16113}
16114
16115pub fn webpsave_buffer_with_opts(
16120 inp: &VipsImage,
16121 webpsave_buffer_options: &WebpsaveBufferOptions,
16122) -> Result<Vec<u8>> {
16123 unsafe {
16124 let inp_in: *mut bindings::VipsImage = inp.ctx;
16125 let mut buffer_buf_size: u64 = 0;
16126 let mut buffer_out: *mut c_void = null_mut();
16127
16128 let q_in: i32 = webpsave_buffer_options.q;
16129 let q_in_name = utils::new_c_string("Q")?;
16130
16131 let lossless_in: i32 = if webpsave_buffer_options.lossless {
16132 1
16133 } else {
16134 0
16135 };
16136 let lossless_in_name = utils::new_c_string("lossless")?;
16137
16138 let preset_in: i32 = webpsave_buffer_options.preset as i32;
16139 let preset_in_name = utils::new_c_string("preset")?;
16140
16141 let smart_subsample_in: i32 = if webpsave_buffer_options.smart_subsample {
16142 1
16143 } else {
16144 0
16145 };
16146 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16147
16148 let near_lossless_in: i32 = if webpsave_buffer_options.near_lossless {
16149 1
16150 } else {
16151 0
16152 };
16153 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16154
16155 let alpha_q_in: i32 = webpsave_buffer_options.alpha_q;
16156 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16157
16158 let min_size_in: i32 = if webpsave_buffer_options.min_size {
16159 1
16160 } else {
16161 0
16162 };
16163 let min_size_in_name = utils::new_c_string("min-size")?;
16164
16165 let kmin_in: i32 = webpsave_buffer_options.kmin;
16166 let kmin_in_name = utils::new_c_string("kmin")?;
16167
16168 let kmax_in: i32 = webpsave_buffer_options.kmax;
16169 let kmax_in_name = utils::new_c_string("kmax")?;
16170
16171 let effort_in: i32 = webpsave_buffer_options.effort;
16172 let effort_in_name = utils::new_c_string("effort")?;
16173
16174 let target_size_in: i32 = webpsave_buffer_options.target_size;
16175 let target_size_in_name = utils::new_c_string("target-size")?;
16176
16177 let mixed_in: i32 = if webpsave_buffer_options.mixed { 1 } else { 0 };
16178 let mixed_in_name = utils::new_c_string("mixed")?;
16179
16180 let smart_deblock_in: i32 = if webpsave_buffer_options.smart_deblock {
16181 1
16182 } else {
16183 0
16184 };
16185 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16186
16187 let passes_in: i32 = webpsave_buffer_options.passes;
16188 let passes_in_name = utils::new_c_string("passes")?;
16189
16190 let keep_in: i32 = webpsave_buffer_options.keep as i32;
16191 let keep_in_name = utils::new_c_string("keep")?;
16192
16193 let background_wrapper =
16194 utils::VipsArrayDoubleWrapper::from(&webpsave_buffer_options.background[..]);
16195 let background_in = background_wrapper.ctx;
16196 let background_in_name = utils::new_c_string("background")?;
16197
16198 let page_height_in: i32 = webpsave_buffer_options.page_height;
16199 let page_height_in_name = utils::new_c_string("page-height")?;
16200
16201 let profile_in: CString = utils::new_c_string(&webpsave_buffer_options.profile)?;
16202 let profile_in_name = utils::new_c_string("profile")?;
16203
16204 let vips_op_response = bindings::vips_webpsave_buffer(
16205 inp_in,
16206 &mut buffer_out,
16207 &mut buffer_buf_size,
16208 q_in_name.as_ptr(),
16209 q_in,
16210 lossless_in_name.as_ptr(),
16211 lossless_in,
16212 preset_in_name.as_ptr(),
16213 preset_in,
16214 smart_subsample_in_name.as_ptr(),
16215 smart_subsample_in,
16216 near_lossless_in_name.as_ptr(),
16217 near_lossless_in,
16218 alpha_q_in_name.as_ptr(),
16219 alpha_q_in,
16220 min_size_in_name.as_ptr(),
16221 min_size_in,
16222 kmin_in_name.as_ptr(),
16223 kmin_in,
16224 kmax_in_name.as_ptr(),
16225 kmax_in,
16226 effort_in_name.as_ptr(),
16227 effort_in,
16228 target_size_in_name.as_ptr(),
16229 target_size_in,
16230 mixed_in_name.as_ptr(),
16231 mixed_in,
16232 smart_deblock_in_name.as_ptr(),
16233 smart_deblock_in,
16234 passes_in_name.as_ptr(),
16235 passes_in,
16236 keep_in_name.as_ptr(),
16237 keep_in,
16238 background_in_name.as_ptr(),
16239 background_in,
16240 page_height_in_name.as_ptr(),
16241 page_height_in,
16242 profile_in_name.as_ptr(),
16243 profile_in.as_ptr(),
16244 NULL,
16245 );
16246 utils::result(
16247 vips_op_response,
16248 utils::new_byte_array(buffer_out, buffer_buf_size),
16249 Error::WebpsaveBufferError,
16250 )
16251 }
16252}
16253
16254pub fn webpsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
16259 unsafe {
16260 let inp_in: *mut bindings::VipsImage = inp.ctx;
16261 let target_in: *mut bindings::VipsTarget = target.ctx;
16262
16263 let vips_op_response = bindings::vips_webpsave_target(inp_in, target_in, NULL);
16264 utils::result(vips_op_response, (), Error::WebpsaveTargetError)
16265 }
16266}
16267
16268#[derive(Clone, Debug)]
16270pub struct WebpsaveTargetOptions {
16271 pub q: i32,
16274 pub lossless: bool,
16277 pub preset: ForeignWebpPreset,
16286 pub smart_subsample: bool,
16289 pub near_lossless: bool,
16292 pub alpha_q: i32,
16295 pub min_size: bool,
16298 pub kmin: i32,
16301 pub kmax: i32,
16304 pub effort: i32,
16307 pub target_size: i32,
16310 pub mixed: bool,
16313 pub smart_deblock: bool,
16316 pub passes: i32,
16319 pub keep: ForeignKeep,
16328 pub background: Vec<f64>,
16330 pub page_height: i32,
16333 pub profile: String,
16335}
16336
16337impl std::default::Default for WebpsaveTargetOptions {
16338 fn default() -> Self {
16339 WebpsaveTargetOptions {
16340 q: i32::from(75),
16341 lossless: false,
16342 preset: ForeignWebpPreset::Default,
16343 smart_subsample: false,
16344 near_lossless: false,
16345 alpha_q: i32::from(100),
16346 min_size: false,
16347 kmin: i32::from(2147483646),
16348 kmax: i32::from(2147483647),
16349 effort: i32::from(4),
16350 target_size: i32::from(0),
16351 mixed: false,
16352 smart_deblock: false,
16353 passes: i32::from(1),
16354 keep: ForeignKeep::All,
16355 background: Vec::new(),
16356 page_height: i32::from(0),
16357 profile: String::from("sRGB"),
16358 }
16359 }
16360}
16361
16362pub fn webpsave_target_with_opts(
16368 inp: &VipsImage,
16369 target: &VipsTarget,
16370 webpsave_target_options: &WebpsaveTargetOptions,
16371) -> Result<()> {
16372 unsafe {
16373 let inp_in: *mut bindings::VipsImage = inp.ctx;
16374 let target_in: *mut bindings::VipsTarget = target.ctx;
16375
16376 let q_in: i32 = webpsave_target_options.q;
16377 let q_in_name = utils::new_c_string("Q")?;
16378
16379 let lossless_in: i32 = if webpsave_target_options.lossless {
16380 1
16381 } else {
16382 0
16383 };
16384 let lossless_in_name = utils::new_c_string("lossless")?;
16385
16386 let preset_in: i32 = webpsave_target_options.preset as i32;
16387 let preset_in_name = utils::new_c_string("preset")?;
16388
16389 let smart_subsample_in: i32 = if webpsave_target_options.smart_subsample {
16390 1
16391 } else {
16392 0
16393 };
16394 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16395
16396 let near_lossless_in: i32 = if webpsave_target_options.near_lossless {
16397 1
16398 } else {
16399 0
16400 };
16401 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16402
16403 let alpha_q_in: i32 = webpsave_target_options.alpha_q;
16404 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16405
16406 let min_size_in: i32 = if webpsave_target_options.min_size {
16407 1
16408 } else {
16409 0
16410 };
16411 let min_size_in_name = utils::new_c_string("min-size")?;
16412
16413 let kmin_in: i32 = webpsave_target_options.kmin;
16414 let kmin_in_name = utils::new_c_string("kmin")?;
16415
16416 let kmax_in: i32 = webpsave_target_options.kmax;
16417 let kmax_in_name = utils::new_c_string("kmax")?;
16418
16419 let effort_in: i32 = webpsave_target_options.effort;
16420 let effort_in_name = utils::new_c_string("effort")?;
16421
16422 let target_size_in: i32 = webpsave_target_options.target_size;
16423 let target_size_in_name = utils::new_c_string("target-size")?;
16424
16425 let mixed_in: i32 = if webpsave_target_options.mixed { 1 } else { 0 };
16426 let mixed_in_name = utils::new_c_string("mixed")?;
16427
16428 let smart_deblock_in: i32 = if webpsave_target_options.smart_deblock {
16429 1
16430 } else {
16431 0
16432 };
16433 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16434
16435 let passes_in: i32 = webpsave_target_options.passes;
16436 let passes_in_name = utils::new_c_string("passes")?;
16437
16438 let keep_in: i32 = webpsave_target_options.keep as i32;
16439 let keep_in_name = utils::new_c_string("keep")?;
16440
16441 let background_wrapper =
16442 utils::VipsArrayDoubleWrapper::from(&webpsave_target_options.background[..]);
16443 let background_in = background_wrapper.ctx;
16444 let background_in_name = utils::new_c_string("background")?;
16445
16446 let page_height_in: i32 = webpsave_target_options.page_height;
16447 let page_height_in_name = utils::new_c_string("page-height")?;
16448
16449 let profile_in: CString = utils::new_c_string(&webpsave_target_options.profile)?;
16450 let profile_in_name = utils::new_c_string("profile")?;
16451
16452 let vips_op_response = bindings::vips_webpsave_target(
16453 inp_in,
16454 target_in,
16455 q_in_name.as_ptr(),
16456 q_in,
16457 lossless_in_name.as_ptr(),
16458 lossless_in,
16459 preset_in_name.as_ptr(),
16460 preset_in,
16461 smart_subsample_in_name.as_ptr(),
16462 smart_subsample_in,
16463 near_lossless_in_name.as_ptr(),
16464 near_lossless_in,
16465 alpha_q_in_name.as_ptr(),
16466 alpha_q_in,
16467 min_size_in_name.as_ptr(),
16468 min_size_in,
16469 kmin_in_name.as_ptr(),
16470 kmin_in,
16471 kmax_in_name.as_ptr(),
16472 kmax_in,
16473 effort_in_name.as_ptr(),
16474 effort_in,
16475 target_size_in_name.as_ptr(),
16476 target_size_in,
16477 mixed_in_name.as_ptr(),
16478 mixed_in,
16479 smart_deblock_in_name.as_ptr(),
16480 smart_deblock_in,
16481 passes_in_name.as_ptr(),
16482 passes_in,
16483 keep_in_name.as_ptr(),
16484 keep_in,
16485 background_in_name.as_ptr(),
16486 background_in,
16487 page_height_in_name.as_ptr(),
16488 page_height_in,
16489 profile_in_name.as_ptr(),
16490 profile_in.as_ptr(),
16491 NULL,
16492 );
16493 utils::result(vips_op_response, (), Error::WebpsaveTargetError)
16494 }
16495}
16496
16497pub fn webpsave_mime(inp: &VipsImage) -> Result<()> {
16501 unsafe {
16502 let inp_in: *mut bindings::VipsImage = inp.ctx;
16503
16504 let vips_op_response = bindings::vips_webpsave_mime(inp_in, NULL);
16505 utils::result(vips_op_response, (), Error::WebpsaveMimeError)
16506 }
16507}
16508
16509#[derive(Clone, Debug)]
16511pub struct WebpsaveMimeOptions {
16512 pub q: i32,
16515 pub lossless: bool,
16518 pub preset: ForeignWebpPreset,
16527 pub smart_subsample: bool,
16530 pub near_lossless: bool,
16533 pub alpha_q: i32,
16536 pub min_size: bool,
16539 pub kmin: i32,
16542 pub kmax: i32,
16545 pub effort: i32,
16548 pub target_size: i32,
16551 pub mixed: bool,
16554 pub smart_deblock: bool,
16557 pub passes: i32,
16560 pub keep: ForeignKeep,
16569 pub background: Vec<f64>,
16571 pub page_height: i32,
16574 pub profile: String,
16576}
16577
16578impl std::default::Default for WebpsaveMimeOptions {
16579 fn default() -> Self {
16580 WebpsaveMimeOptions {
16581 q: i32::from(75),
16582 lossless: false,
16583 preset: ForeignWebpPreset::Default,
16584 smart_subsample: false,
16585 near_lossless: false,
16586 alpha_q: i32::from(100),
16587 min_size: false,
16588 kmin: i32::from(2147483646),
16589 kmax: i32::from(2147483647),
16590 effort: i32::from(4),
16591 target_size: i32::from(0),
16592 mixed: false,
16593 smart_deblock: false,
16594 passes: i32::from(1),
16595 keep: ForeignKeep::All,
16596 background: Vec::new(),
16597 page_height: i32::from(0),
16598 profile: String::from("sRGB"),
16599 }
16600 }
16601}
16602
16603pub fn webpsave_mime_with_opts(
16608 inp: &VipsImage,
16609 webpsave_mime_options: &WebpsaveMimeOptions,
16610) -> Result<()> {
16611 unsafe {
16612 let inp_in: *mut bindings::VipsImage = inp.ctx;
16613
16614 let q_in: i32 = webpsave_mime_options.q;
16615 let q_in_name = utils::new_c_string("Q")?;
16616
16617 let lossless_in: i32 = if webpsave_mime_options.lossless { 1 } else { 0 };
16618 let lossless_in_name = utils::new_c_string("lossless")?;
16619
16620 let preset_in: i32 = webpsave_mime_options.preset as i32;
16621 let preset_in_name = utils::new_c_string("preset")?;
16622
16623 let smart_subsample_in: i32 = if webpsave_mime_options.smart_subsample {
16624 1
16625 } else {
16626 0
16627 };
16628 let smart_subsample_in_name = utils::new_c_string("smart-subsample")?;
16629
16630 let near_lossless_in: i32 = if webpsave_mime_options.near_lossless {
16631 1
16632 } else {
16633 0
16634 };
16635 let near_lossless_in_name = utils::new_c_string("near-lossless")?;
16636
16637 let alpha_q_in: i32 = webpsave_mime_options.alpha_q;
16638 let alpha_q_in_name = utils::new_c_string("alpha-q")?;
16639
16640 let min_size_in: i32 = if webpsave_mime_options.min_size { 1 } else { 0 };
16641 let min_size_in_name = utils::new_c_string("min-size")?;
16642
16643 let kmin_in: i32 = webpsave_mime_options.kmin;
16644 let kmin_in_name = utils::new_c_string("kmin")?;
16645
16646 let kmax_in: i32 = webpsave_mime_options.kmax;
16647 let kmax_in_name = utils::new_c_string("kmax")?;
16648
16649 let effort_in: i32 = webpsave_mime_options.effort;
16650 let effort_in_name = utils::new_c_string("effort")?;
16651
16652 let target_size_in: i32 = webpsave_mime_options.target_size;
16653 let target_size_in_name = utils::new_c_string("target-size")?;
16654
16655 let mixed_in: i32 = if webpsave_mime_options.mixed { 1 } else { 0 };
16656 let mixed_in_name = utils::new_c_string("mixed")?;
16657
16658 let smart_deblock_in: i32 = if webpsave_mime_options.smart_deblock {
16659 1
16660 } else {
16661 0
16662 };
16663 let smart_deblock_in_name = utils::new_c_string("smart-deblock")?;
16664
16665 let passes_in: i32 = webpsave_mime_options.passes;
16666 let passes_in_name = utils::new_c_string("passes")?;
16667
16668 let keep_in: i32 = webpsave_mime_options.keep as i32;
16669 let keep_in_name = utils::new_c_string("keep")?;
16670
16671 let background_wrapper =
16672 utils::VipsArrayDoubleWrapper::from(&webpsave_mime_options.background[..]);
16673 let background_in = background_wrapper.ctx;
16674 let background_in_name = utils::new_c_string("background")?;
16675
16676 let page_height_in: i32 = webpsave_mime_options.page_height;
16677 let page_height_in_name = utils::new_c_string("page-height")?;
16678
16679 let profile_in: CString = utils::new_c_string(&webpsave_mime_options.profile)?;
16680 let profile_in_name = utils::new_c_string("profile")?;
16681
16682 let vips_op_response = bindings::vips_webpsave_mime(
16683 inp_in,
16684 q_in_name.as_ptr(),
16685 q_in,
16686 lossless_in_name.as_ptr(),
16687 lossless_in,
16688 preset_in_name.as_ptr(),
16689 preset_in,
16690 smart_subsample_in_name.as_ptr(),
16691 smart_subsample_in,
16692 near_lossless_in_name.as_ptr(),
16693 near_lossless_in,
16694 alpha_q_in_name.as_ptr(),
16695 alpha_q_in,
16696 min_size_in_name.as_ptr(),
16697 min_size_in,
16698 kmin_in_name.as_ptr(),
16699 kmin_in,
16700 kmax_in_name.as_ptr(),
16701 kmax_in,
16702 effort_in_name.as_ptr(),
16703 effort_in,
16704 target_size_in_name.as_ptr(),
16705 target_size_in,
16706 mixed_in_name.as_ptr(),
16707 mixed_in,
16708 smart_deblock_in_name.as_ptr(),
16709 smart_deblock_in,
16710 passes_in_name.as_ptr(),
16711 passes_in,
16712 keep_in_name.as_ptr(),
16713 keep_in,
16714 background_in_name.as_ptr(),
16715 background_in,
16716 page_height_in_name.as_ptr(),
16717 page_height_in,
16718 profile_in_name.as_ptr(),
16719 profile_in.as_ptr(),
16720 NULL,
16721 );
16722 utils::result(vips_op_response, (), Error::WebpsaveMimeError)
16723 }
16724}
16725
16726pub fn tiffsave(inp: &VipsImage, filename: &str) -> Result<()> {
16731 unsafe {
16732 let inp_in: *mut bindings::VipsImage = inp.ctx;
16733 let filename_in: CString = utils::new_c_string(filename)?;
16734
16735 let vips_op_response = bindings::vips_tiffsave(inp_in, filename_in.as_ptr(), NULL);
16736 utils::result(vips_op_response, (), Error::TiffsaveError)
16737 }
16738}
16739
16740#[derive(Clone, Debug)]
16742pub struct TiffsaveOptions {
16743 pub compression: ForeignTiffCompression,
16755 pub q: i32,
16758 pub predictor: ForeignTiffPredictor,
16764 pub tile: bool,
16767 pub tile_width: i32,
16770 pub tile_height: i32,
16773 pub pyramid: bool,
16776 pub miniswhite: bool,
16779 pub bitdepth: i32,
16782 pub resunit: ForeignTiffResunit,
16787 pub xres: f64,
16790 pub yres: f64,
16793 pub bigtiff: bool,
16796 pub properties: bool,
16799 pub region_shrink: RegionShrink,
16808 pub level: i32,
16811 pub lossless: bool,
16814 pub depth: ForeignDzDepth,
16820 pub subifd: bool,
16823 pub premultiply: bool,
16826 pub keep: ForeignKeep,
16835 pub background: Vec<f64>,
16837 pub page_height: i32,
16840 pub profile: String,
16842}
16843
16844impl std::default::Default for TiffsaveOptions {
16845 fn default() -> Self {
16846 TiffsaveOptions {
16847 compression: ForeignTiffCompression::None,
16848 q: i32::from(75),
16849 predictor: ForeignTiffPredictor::Horizontal,
16850 tile: false,
16851 tile_width: i32::from(128),
16852 tile_height: i32::from(128),
16853 pyramid: false,
16854 miniswhite: false,
16855 bitdepth: i32::from(0),
16856 resunit: ForeignTiffResunit::Cm,
16857 xres: f64::from(1),
16858 yres: f64::from(1),
16859 bigtiff: false,
16860 properties: false,
16861 region_shrink: RegionShrink::Mean,
16862 level: i32::from(6),
16863 lossless: false,
16864 depth: ForeignDzDepth::Onetile,
16865 subifd: false,
16866 premultiply: false,
16867 keep: ForeignKeep::All,
16868 background: Vec::new(),
16869 page_height: i32::from(0),
16870 profile: String::from("sRGB"),
16871 }
16872 }
16873}
16874
16875pub fn tiffsave_with_opts(
16881 inp: &VipsImage,
16882 filename: &str,
16883 tiffsave_options: &TiffsaveOptions,
16884) -> Result<()> {
16885 unsafe {
16886 let inp_in: *mut bindings::VipsImage = inp.ctx;
16887 let filename_in: CString = utils::new_c_string(filename)?;
16888
16889 let compression_in: i32 = tiffsave_options.compression as i32;
16890 let compression_in_name = utils::new_c_string("compression")?;
16891
16892 let q_in: i32 = tiffsave_options.q;
16893 let q_in_name = utils::new_c_string("Q")?;
16894
16895 let predictor_in: i32 = tiffsave_options.predictor as i32;
16896 let predictor_in_name = utils::new_c_string("predictor")?;
16897
16898 let tile_in: i32 = if tiffsave_options.tile { 1 } else { 0 };
16899 let tile_in_name = utils::new_c_string("tile")?;
16900
16901 let tile_width_in: i32 = tiffsave_options.tile_width;
16902 let tile_width_in_name = utils::new_c_string("tile-width")?;
16903
16904 let tile_height_in: i32 = tiffsave_options.tile_height;
16905 let tile_height_in_name = utils::new_c_string("tile-height")?;
16906
16907 let pyramid_in: i32 = if tiffsave_options.pyramid { 1 } else { 0 };
16908 let pyramid_in_name = utils::new_c_string("pyramid")?;
16909
16910 let miniswhite_in: i32 = if tiffsave_options.miniswhite { 1 } else { 0 };
16911 let miniswhite_in_name = utils::new_c_string("miniswhite")?;
16912
16913 let bitdepth_in: i32 = tiffsave_options.bitdepth;
16914 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
16915
16916 let resunit_in: i32 = tiffsave_options.resunit as i32;
16917 let resunit_in_name = utils::new_c_string("resunit")?;
16918
16919 let xres_in: f64 = tiffsave_options.xres;
16920 let xres_in_name = utils::new_c_string("xres")?;
16921
16922 let yres_in: f64 = tiffsave_options.yres;
16923 let yres_in_name = utils::new_c_string("yres")?;
16924
16925 let bigtiff_in: i32 = if tiffsave_options.bigtiff { 1 } else { 0 };
16926 let bigtiff_in_name = utils::new_c_string("bigtiff")?;
16927
16928 let properties_in: i32 = if tiffsave_options.properties { 1 } else { 0 };
16929 let properties_in_name = utils::new_c_string("properties")?;
16930
16931 let region_shrink_in: i32 = tiffsave_options.region_shrink as i32;
16932 let region_shrink_in_name = utils::new_c_string("region-shrink")?;
16933
16934 let level_in: i32 = tiffsave_options.level;
16935 let level_in_name = utils::new_c_string("level")?;
16936
16937 let lossless_in: i32 = if tiffsave_options.lossless { 1 } else { 0 };
16938 let lossless_in_name = utils::new_c_string("lossless")?;
16939
16940 let depth_in: i32 = tiffsave_options.depth as i32;
16941 let depth_in_name = utils::new_c_string("depth")?;
16942
16943 let subifd_in: i32 = if tiffsave_options.subifd { 1 } else { 0 };
16944 let subifd_in_name = utils::new_c_string("subifd")?;
16945
16946 let premultiply_in: i32 = if tiffsave_options.premultiply { 1 } else { 0 };
16947 let premultiply_in_name = utils::new_c_string("premultiply")?;
16948
16949 let keep_in: i32 = tiffsave_options.keep as i32;
16950 let keep_in_name = utils::new_c_string("keep")?;
16951
16952 let background_wrapper =
16953 utils::VipsArrayDoubleWrapper::from(&tiffsave_options.background[..]);
16954 let background_in = background_wrapper.ctx;
16955 let background_in_name = utils::new_c_string("background")?;
16956
16957 let page_height_in: i32 = tiffsave_options.page_height;
16958 let page_height_in_name = utils::new_c_string("page-height")?;
16959
16960 let profile_in: CString = utils::new_c_string(&tiffsave_options.profile)?;
16961 let profile_in_name = utils::new_c_string("profile")?;
16962
16963 let vips_op_response = bindings::vips_tiffsave(
16964 inp_in,
16965 filename_in.as_ptr(),
16966 compression_in_name.as_ptr(),
16967 compression_in,
16968 q_in_name.as_ptr(),
16969 q_in,
16970 predictor_in_name.as_ptr(),
16971 predictor_in,
16972 tile_in_name.as_ptr(),
16973 tile_in,
16974 tile_width_in_name.as_ptr(),
16975 tile_width_in,
16976 tile_height_in_name.as_ptr(),
16977 tile_height_in,
16978 pyramid_in_name.as_ptr(),
16979 pyramid_in,
16980 miniswhite_in_name.as_ptr(),
16981 miniswhite_in,
16982 bitdepth_in_name.as_ptr(),
16983 bitdepth_in,
16984 resunit_in_name.as_ptr(),
16985 resunit_in,
16986 xres_in_name.as_ptr(),
16987 xres_in,
16988 yres_in_name.as_ptr(),
16989 yres_in,
16990 bigtiff_in_name.as_ptr(),
16991 bigtiff_in,
16992 properties_in_name.as_ptr(),
16993 properties_in,
16994 region_shrink_in_name.as_ptr(),
16995 region_shrink_in,
16996 level_in_name.as_ptr(),
16997 level_in,
16998 lossless_in_name.as_ptr(),
16999 lossless_in,
17000 depth_in_name.as_ptr(),
17001 depth_in,
17002 subifd_in_name.as_ptr(),
17003 subifd_in,
17004 premultiply_in_name.as_ptr(),
17005 premultiply_in,
17006 keep_in_name.as_ptr(),
17007 keep_in,
17008 background_in_name.as_ptr(),
17009 background_in,
17010 page_height_in_name.as_ptr(),
17011 page_height_in,
17012 profile_in_name.as_ptr(),
17013 profile_in.as_ptr(),
17014 NULL,
17015 );
17016 utils::result(vips_op_response, (), Error::TiffsaveError)
17017 }
17018}
17019
17020pub fn tiffsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
17024 unsafe {
17025 let inp_in: *mut bindings::VipsImage = inp.ctx;
17026 let mut buffer_buf_size: u64 = 0;
17027 let mut buffer_out: *mut c_void = null_mut();
17028
17029 let vips_op_response =
17030 bindings::vips_tiffsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
17031 utils::result(
17032 vips_op_response,
17033 utils::new_byte_array(buffer_out, buffer_buf_size),
17034 Error::TiffsaveBufferError,
17035 )
17036 }
17037}
17038
17039#[derive(Clone, Debug)]
17041pub struct TiffsaveBufferOptions {
17042 pub compression: ForeignTiffCompression,
17054 pub q: i32,
17057 pub predictor: ForeignTiffPredictor,
17063 pub tile: bool,
17066 pub tile_width: i32,
17069 pub tile_height: i32,
17072 pub pyramid: bool,
17075 pub miniswhite: bool,
17078 pub bitdepth: i32,
17081 pub resunit: ForeignTiffResunit,
17086 pub xres: f64,
17089 pub yres: f64,
17092 pub bigtiff: bool,
17095 pub properties: bool,
17098 pub region_shrink: RegionShrink,
17107 pub level: i32,
17110 pub lossless: bool,
17113 pub depth: ForeignDzDepth,
17119 pub subifd: bool,
17122 pub premultiply: bool,
17125 pub keep: ForeignKeep,
17134 pub background: Vec<f64>,
17136 pub page_height: i32,
17139 pub profile: String,
17141}
17142
17143impl std::default::Default for TiffsaveBufferOptions {
17144 fn default() -> Self {
17145 TiffsaveBufferOptions {
17146 compression: ForeignTiffCompression::None,
17147 q: i32::from(75),
17148 predictor: ForeignTiffPredictor::Horizontal,
17149 tile: false,
17150 tile_width: i32::from(128),
17151 tile_height: i32::from(128),
17152 pyramid: false,
17153 miniswhite: false,
17154 bitdepth: i32::from(0),
17155 resunit: ForeignTiffResunit::Cm,
17156 xres: f64::from(1),
17157 yres: f64::from(1),
17158 bigtiff: false,
17159 properties: false,
17160 region_shrink: RegionShrink::Mean,
17161 level: i32::from(6),
17162 lossless: false,
17163 depth: ForeignDzDepth::Onetile,
17164 subifd: false,
17165 premultiply: false,
17166 keep: ForeignKeep::All,
17167 background: Vec::new(),
17168 page_height: i32::from(0),
17169 profile: String::from("sRGB"),
17170 }
17171 }
17172}
17173
17174pub fn tiffsave_buffer_with_opts(
17179 inp: &VipsImage,
17180 tiffsave_buffer_options: &TiffsaveBufferOptions,
17181) -> Result<Vec<u8>> {
17182 unsafe {
17183 let inp_in: *mut bindings::VipsImage = inp.ctx;
17184 let mut buffer_buf_size: u64 = 0;
17185 let mut buffer_out: *mut c_void = null_mut();
17186
17187 let compression_in: i32 = tiffsave_buffer_options.compression as i32;
17188 let compression_in_name = utils::new_c_string("compression")?;
17189
17190 let q_in: i32 = tiffsave_buffer_options.q;
17191 let q_in_name = utils::new_c_string("Q")?;
17192
17193 let predictor_in: i32 = tiffsave_buffer_options.predictor as i32;
17194 let predictor_in_name = utils::new_c_string("predictor")?;
17195
17196 let tile_in: i32 = if tiffsave_buffer_options.tile { 1 } else { 0 };
17197 let tile_in_name = utils::new_c_string("tile")?;
17198
17199 let tile_width_in: i32 = tiffsave_buffer_options.tile_width;
17200 let tile_width_in_name = utils::new_c_string("tile-width")?;
17201
17202 let tile_height_in: i32 = tiffsave_buffer_options.tile_height;
17203 let tile_height_in_name = utils::new_c_string("tile-height")?;
17204
17205 let pyramid_in: i32 = if tiffsave_buffer_options.pyramid {
17206 1
17207 } else {
17208 0
17209 };
17210 let pyramid_in_name = utils::new_c_string("pyramid")?;
17211
17212 let miniswhite_in: i32 = if tiffsave_buffer_options.miniswhite {
17213 1
17214 } else {
17215 0
17216 };
17217 let miniswhite_in_name = utils::new_c_string("miniswhite")?;
17218
17219 let bitdepth_in: i32 = tiffsave_buffer_options.bitdepth;
17220 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17221
17222 let resunit_in: i32 = tiffsave_buffer_options.resunit as i32;
17223 let resunit_in_name = utils::new_c_string("resunit")?;
17224
17225 let xres_in: f64 = tiffsave_buffer_options.xres;
17226 let xres_in_name = utils::new_c_string("xres")?;
17227
17228 let yres_in: f64 = tiffsave_buffer_options.yres;
17229 let yres_in_name = utils::new_c_string("yres")?;
17230
17231 let bigtiff_in: i32 = if tiffsave_buffer_options.bigtiff {
17232 1
17233 } else {
17234 0
17235 };
17236 let bigtiff_in_name = utils::new_c_string("bigtiff")?;
17237
17238 let properties_in: i32 = if tiffsave_buffer_options.properties {
17239 1
17240 } else {
17241 0
17242 };
17243 let properties_in_name = utils::new_c_string("properties")?;
17244
17245 let region_shrink_in: i32 = tiffsave_buffer_options.region_shrink as i32;
17246 let region_shrink_in_name = utils::new_c_string("region-shrink")?;
17247
17248 let level_in: i32 = tiffsave_buffer_options.level;
17249 let level_in_name = utils::new_c_string("level")?;
17250
17251 let lossless_in: i32 = if tiffsave_buffer_options.lossless {
17252 1
17253 } else {
17254 0
17255 };
17256 let lossless_in_name = utils::new_c_string("lossless")?;
17257
17258 let depth_in: i32 = tiffsave_buffer_options.depth as i32;
17259 let depth_in_name = utils::new_c_string("depth")?;
17260
17261 let subifd_in: i32 = if tiffsave_buffer_options.subifd { 1 } else { 0 };
17262 let subifd_in_name = utils::new_c_string("subifd")?;
17263
17264 let premultiply_in: i32 = if tiffsave_buffer_options.premultiply {
17265 1
17266 } else {
17267 0
17268 };
17269 let premultiply_in_name = utils::new_c_string("premultiply")?;
17270
17271 let keep_in: i32 = tiffsave_buffer_options.keep as i32;
17272 let keep_in_name = utils::new_c_string("keep")?;
17273
17274 let background_wrapper =
17275 utils::VipsArrayDoubleWrapper::from(&tiffsave_buffer_options.background[..]);
17276 let background_in = background_wrapper.ctx;
17277 let background_in_name = utils::new_c_string("background")?;
17278
17279 let page_height_in: i32 = tiffsave_buffer_options.page_height;
17280 let page_height_in_name = utils::new_c_string("page-height")?;
17281
17282 let profile_in: CString = utils::new_c_string(&tiffsave_buffer_options.profile)?;
17283 let profile_in_name = utils::new_c_string("profile")?;
17284
17285 let vips_op_response = bindings::vips_tiffsave_buffer(
17286 inp_in,
17287 &mut buffer_out,
17288 &mut buffer_buf_size,
17289 compression_in_name.as_ptr(),
17290 compression_in,
17291 q_in_name.as_ptr(),
17292 q_in,
17293 predictor_in_name.as_ptr(),
17294 predictor_in,
17295 tile_in_name.as_ptr(),
17296 tile_in,
17297 tile_width_in_name.as_ptr(),
17298 tile_width_in,
17299 tile_height_in_name.as_ptr(),
17300 tile_height_in,
17301 pyramid_in_name.as_ptr(),
17302 pyramid_in,
17303 miniswhite_in_name.as_ptr(),
17304 miniswhite_in,
17305 bitdepth_in_name.as_ptr(),
17306 bitdepth_in,
17307 resunit_in_name.as_ptr(),
17308 resunit_in,
17309 xres_in_name.as_ptr(),
17310 xres_in,
17311 yres_in_name.as_ptr(),
17312 yres_in,
17313 bigtiff_in_name.as_ptr(),
17314 bigtiff_in,
17315 properties_in_name.as_ptr(),
17316 properties_in,
17317 region_shrink_in_name.as_ptr(),
17318 region_shrink_in,
17319 level_in_name.as_ptr(),
17320 level_in,
17321 lossless_in_name.as_ptr(),
17322 lossless_in,
17323 depth_in_name.as_ptr(),
17324 depth_in,
17325 subifd_in_name.as_ptr(),
17326 subifd_in,
17327 premultiply_in_name.as_ptr(),
17328 premultiply_in,
17329 keep_in_name.as_ptr(),
17330 keep_in,
17331 background_in_name.as_ptr(),
17332 background_in,
17333 page_height_in_name.as_ptr(),
17334 page_height_in,
17335 profile_in_name.as_ptr(),
17336 profile_in.as_ptr(),
17337 NULL,
17338 );
17339 utils::result(
17340 vips_op_response,
17341 utils::new_byte_array(buffer_out, buffer_buf_size),
17342 Error::TiffsaveBufferError,
17343 )
17344 }
17345}
17346
17347pub fn tiffsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
17352 unsafe {
17353 let inp_in: *mut bindings::VipsImage = inp.ctx;
17354 let target_in: *mut bindings::VipsTarget = target.ctx;
17355
17356 let vips_op_response = bindings::vips_tiffsave_target(inp_in, target_in, NULL);
17357 utils::result(vips_op_response, (), Error::TiffsaveTargetError)
17358 }
17359}
17360
17361#[derive(Clone, Debug)]
17363pub struct TiffsaveTargetOptions {
17364 pub compression: ForeignTiffCompression,
17376 pub q: i32,
17379 pub predictor: ForeignTiffPredictor,
17385 pub tile: bool,
17388 pub tile_width: i32,
17391 pub tile_height: i32,
17394 pub pyramid: bool,
17397 pub miniswhite: bool,
17400 pub bitdepth: i32,
17403 pub resunit: ForeignTiffResunit,
17408 pub xres: f64,
17411 pub yres: f64,
17414 pub bigtiff: bool,
17417 pub properties: bool,
17420 pub region_shrink: RegionShrink,
17429 pub level: i32,
17432 pub lossless: bool,
17435 pub depth: ForeignDzDepth,
17441 pub subifd: bool,
17444 pub premultiply: bool,
17447 pub keep: ForeignKeep,
17456 pub background: Vec<f64>,
17458 pub page_height: i32,
17461 pub profile: String,
17463}
17464
17465impl std::default::Default for TiffsaveTargetOptions {
17466 fn default() -> Self {
17467 TiffsaveTargetOptions {
17468 compression: ForeignTiffCompression::None,
17469 q: i32::from(75),
17470 predictor: ForeignTiffPredictor::Horizontal,
17471 tile: false,
17472 tile_width: i32::from(128),
17473 tile_height: i32::from(128),
17474 pyramid: false,
17475 miniswhite: false,
17476 bitdepth: i32::from(0),
17477 resunit: ForeignTiffResunit::Cm,
17478 xres: f64::from(1),
17479 yres: f64::from(1),
17480 bigtiff: false,
17481 properties: false,
17482 region_shrink: RegionShrink::Mean,
17483 level: i32::from(6),
17484 lossless: false,
17485 depth: ForeignDzDepth::Onetile,
17486 subifd: false,
17487 premultiply: false,
17488 keep: ForeignKeep::All,
17489 background: Vec::new(),
17490 page_height: i32::from(0),
17491 profile: String::from("sRGB"),
17492 }
17493 }
17494}
17495
17496pub fn tiffsave_target_with_opts(
17502 inp: &VipsImage,
17503 target: &VipsTarget,
17504 tiffsave_target_options: &TiffsaveTargetOptions,
17505) -> Result<()> {
17506 unsafe {
17507 let inp_in: *mut bindings::VipsImage = inp.ctx;
17508 let target_in: *mut bindings::VipsTarget = target.ctx;
17509
17510 let compression_in: i32 = tiffsave_target_options.compression as i32;
17511 let compression_in_name = utils::new_c_string("compression")?;
17512
17513 let q_in: i32 = tiffsave_target_options.q;
17514 let q_in_name = utils::new_c_string("Q")?;
17515
17516 let predictor_in: i32 = tiffsave_target_options.predictor as i32;
17517 let predictor_in_name = utils::new_c_string("predictor")?;
17518
17519 let tile_in: i32 = if tiffsave_target_options.tile { 1 } else { 0 };
17520 let tile_in_name = utils::new_c_string("tile")?;
17521
17522 let tile_width_in: i32 = tiffsave_target_options.tile_width;
17523 let tile_width_in_name = utils::new_c_string("tile-width")?;
17524
17525 let tile_height_in: i32 = tiffsave_target_options.tile_height;
17526 let tile_height_in_name = utils::new_c_string("tile-height")?;
17527
17528 let pyramid_in: i32 = if tiffsave_target_options.pyramid {
17529 1
17530 } else {
17531 0
17532 };
17533 let pyramid_in_name = utils::new_c_string("pyramid")?;
17534
17535 let miniswhite_in: i32 = if tiffsave_target_options.miniswhite {
17536 1
17537 } else {
17538 0
17539 };
17540 let miniswhite_in_name = utils::new_c_string("miniswhite")?;
17541
17542 let bitdepth_in: i32 = tiffsave_target_options.bitdepth;
17543 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17544
17545 let resunit_in: i32 = tiffsave_target_options.resunit as i32;
17546 let resunit_in_name = utils::new_c_string("resunit")?;
17547
17548 let xres_in: f64 = tiffsave_target_options.xres;
17549 let xres_in_name = utils::new_c_string("xres")?;
17550
17551 let yres_in: f64 = tiffsave_target_options.yres;
17552 let yres_in_name = utils::new_c_string("yres")?;
17553
17554 let bigtiff_in: i32 = if tiffsave_target_options.bigtiff {
17555 1
17556 } else {
17557 0
17558 };
17559 let bigtiff_in_name = utils::new_c_string("bigtiff")?;
17560
17561 let properties_in: i32 = if tiffsave_target_options.properties {
17562 1
17563 } else {
17564 0
17565 };
17566 let properties_in_name = utils::new_c_string("properties")?;
17567
17568 let region_shrink_in: i32 = tiffsave_target_options.region_shrink as i32;
17569 let region_shrink_in_name = utils::new_c_string("region-shrink")?;
17570
17571 let level_in: i32 = tiffsave_target_options.level;
17572 let level_in_name = utils::new_c_string("level")?;
17573
17574 let lossless_in: i32 = if tiffsave_target_options.lossless {
17575 1
17576 } else {
17577 0
17578 };
17579 let lossless_in_name = utils::new_c_string("lossless")?;
17580
17581 let depth_in: i32 = tiffsave_target_options.depth as i32;
17582 let depth_in_name = utils::new_c_string("depth")?;
17583
17584 let subifd_in: i32 = if tiffsave_target_options.subifd { 1 } else { 0 };
17585 let subifd_in_name = utils::new_c_string("subifd")?;
17586
17587 let premultiply_in: i32 = if tiffsave_target_options.premultiply {
17588 1
17589 } else {
17590 0
17591 };
17592 let premultiply_in_name = utils::new_c_string("premultiply")?;
17593
17594 let keep_in: i32 = tiffsave_target_options.keep as i32;
17595 let keep_in_name = utils::new_c_string("keep")?;
17596
17597 let background_wrapper =
17598 utils::VipsArrayDoubleWrapper::from(&tiffsave_target_options.background[..]);
17599 let background_in = background_wrapper.ctx;
17600 let background_in_name = utils::new_c_string("background")?;
17601
17602 let page_height_in: i32 = tiffsave_target_options.page_height;
17603 let page_height_in_name = utils::new_c_string("page-height")?;
17604
17605 let profile_in: CString = utils::new_c_string(&tiffsave_target_options.profile)?;
17606 let profile_in_name = utils::new_c_string("profile")?;
17607
17608 let vips_op_response = bindings::vips_tiffsave_target(
17609 inp_in,
17610 target_in,
17611 compression_in_name.as_ptr(),
17612 compression_in,
17613 q_in_name.as_ptr(),
17614 q_in,
17615 predictor_in_name.as_ptr(),
17616 predictor_in,
17617 tile_in_name.as_ptr(),
17618 tile_in,
17619 tile_width_in_name.as_ptr(),
17620 tile_width_in,
17621 tile_height_in_name.as_ptr(),
17622 tile_height_in,
17623 pyramid_in_name.as_ptr(),
17624 pyramid_in,
17625 miniswhite_in_name.as_ptr(),
17626 miniswhite_in,
17627 bitdepth_in_name.as_ptr(),
17628 bitdepth_in,
17629 resunit_in_name.as_ptr(),
17630 resunit_in,
17631 xres_in_name.as_ptr(),
17632 xres_in,
17633 yres_in_name.as_ptr(),
17634 yres_in,
17635 bigtiff_in_name.as_ptr(),
17636 bigtiff_in,
17637 properties_in_name.as_ptr(),
17638 properties_in,
17639 region_shrink_in_name.as_ptr(),
17640 region_shrink_in,
17641 level_in_name.as_ptr(),
17642 level_in,
17643 lossless_in_name.as_ptr(),
17644 lossless_in,
17645 depth_in_name.as_ptr(),
17646 depth_in,
17647 subifd_in_name.as_ptr(),
17648 subifd_in,
17649 premultiply_in_name.as_ptr(),
17650 premultiply_in,
17651 keep_in_name.as_ptr(),
17652 keep_in,
17653 background_in_name.as_ptr(),
17654 background_in,
17655 page_height_in_name.as_ptr(),
17656 page_height_in,
17657 profile_in_name.as_ptr(),
17658 profile_in.as_ptr(),
17659 NULL,
17660 );
17661 utils::result(vips_op_response, (), Error::TiffsaveTargetError)
17662 }
17663}
17664
17665pub fn heifsave(inp: &VipsImage, filename: &str) -> Result<()> {
17670 unsafe {
17671 let inp_in: *mut bindings::VipsImage = inp.ctx;
17672 let filename_in: CString = utils::new_c_string(filename)?;
17673
17674 let vips_op_response = bindings::vips_heifsave(inp_in, filename_in.as_ptr(), NULL);
17675 utils::result(vips_op_response, (), Error::HeifsaveError)
17676 }
17677}
17678
17679#[derive(Clone, Debug)]
17681pub struct HeifsaveOptions {
17682 pub q: i32,
17685 pub bitdepth: i32,
17688 pub lossless: bool,
17691 pub compression: ForeignHeifCompression,
17698 pub effort: i32,
17701 pub subsample_mode: ForeignSubsample,
17707 pub encoder: ForeignHeifEncoder,
17715 pub keep: ForeignKeep,
17724 pub background: Vec<f64>,
17726 pub page_height: i32,
17729 pub profile: String,
17731}
17732
17733impl std::default::Default for HeifsaveOptions {
17734 fn default() -> Self {
17735 HeifsaveOptions {
17736 q: i32::from(50),
17737 bitdepth: i32::from(12),
17738 lossless: false,
17739 compression: ForeignHeifCompression::Hevc,
17740 effort: i32::from(4),
17741 subsample_mode: ForeignSubsample::Auto,
17742 encoder: ForeignHeifEncoder::Auto,
17743 keep: ForeignKeep::All,
17744 background: Vec::new(),
17745 page_height: i32::from(0),
17746 profile: String::from("sRGB"),
17747 }
17748 }
17749}
17750
17751pub fn heifsave_with_opts(
17757 inp: &VipsImage,
17758 filename: &str,
17759 heifsave_options: &HeifsaveOptions,
17760) -> Result<()> {
17761 unsafe {
17762 let inp_in: *mut bindings::VipsImage = inp.ctx;
17763 let filename_in: CString = utils::new_c_string(filename)?;
17764
17765 let q_in: i32 = heifsave_options.q;
17766 let q_in_name = utils::new_c_string("Q")?;
17767
17768 let bitdepth_in: i32 = heifsave_options.bitdepth;
17769 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17770
17771 let lossless_in: i32 = if heifsave_options.lossless { 1 } else { 0 };
17772 let lossless_in_name = utils::new_c_string("lossless")?;
17773
17774 let compression_in: i32 = heifsave_options.compression as i32;
17775 let compression_in_name = utils::new_c_string("compression")?;
17776
17777 let effort_in: i32 = heifsave_options.effort;
17778 let effort_in_name = utils::new_c_string("effort")?;
17779
17780 let subsample_mode_in: i32 = heifsave_options.subsample_mode as i32;
17781 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
17782
17783 let encoder_in: i32 = heifsave_options.encoder as i32;
17784 let encoder_in_name = utils::new_c_string("encoder")?;
17785
17786 let keep_in: i32 = heifsave_options.keep as i32;
17787 let keep_in_name = utils::new_c_string("keep")?;
17788
17789 let background_wrapper =
17790 utils::VipsArrayDoubleWrapper::from(&heifsave_options.background[..]);
17791 let background_in = background_wrapper.ctx;
17792 let background_in_name = utils::new_c_string("background")?;
17793
17794 let page_height_in: i32 = heifsave_options.page_height;
17795 let page_height_in_name = utils::new_c_string("page-height")?;
17796
17797 let profile_in: CString = utils::new_c_string(&heifsave_options.profile)?;
17798 let profile_in_name = utils::new_c_string("profile")?;
17799
17800 let vips_op_response = bindings::vips_heifsave(
17801 inp_in,
17802 filename_in.as_ptr(),
17803 q_in_name.as_ptr(),
17804 q_in,
17805 bitdepth_in_name.as_ptr(),
17806 bitdepth_in,
17807 lossless_in_name.as_ptr(),
17808 lossless_in,
17809 compression_in_name.as_ptr(),
17810 compression_in,
17811 effort_in_name.as_ptr(),
17812 effort_in,
17813 subsample_mode_in_name.as_ptr(),
17814 subsample_mode_in,
17815 encoder_in_name.as_ptr(),
17816 encoder_in,
17817 keep_in_name.as_ptr(),
17818 keep_in,
17819 background_in_name.as_ptr(),
17820 background_in,
17821 page_height_in_name.as_ptr(),
17822 page_height_in,
17823 profile_in_name.as_ptr(),
17824 profile_in.as_ptr(),
17825 NULL,
17826 );
17827 utils::result(vips_op_response, (), Error::HeifsaveError)
17828 }
17829}
17830
17831pub fn heifsave_buffer(inp: &VipsImage) -> Result<Vec<u8>> {
17835 unsafe {
17836 let inp_in: *mut bindings::VipsImage = inp.ctx;
17837 let mut buffer_buf_size: u64 = 0;
17838 let mut buffer_out: *mut c_void = null_mut();
17839
17840 let vips_op_response =
17841 bindings::vips_heifsave_buffer(inp_in, &mut buffer_out, &mut buffer_buf_size, NULL);
17842 utils::result(
17843 vips_op_response,
17844 utils::new_byte_array(buffer_out, buffer_buf_size),
17845 Error::HeifsaveBufferError,
17846 )
17847 }
17848}
17849
17850#[derive(Clone, Debug)]
17852pub struct HeifsaveBufferOptions {
17853 pub q: i32,
17856 pub bitdepth: i32,
17859 pub lossless: bool,
17862 pub compression: ForeignHeifCompression,
17869 pub effort: i32,
17872 pub subsample_mode: ForeignSubsample,
17878 pub encoder: ForeignHeifEncoder,
17886 pub keep: ForeignKeep,
17895 pub background: Vec<f64>,
17897 pub page_height: i32,
17900 pub profile: String,
17902}
17903
17904impl std::default::Default for HeifsaveBufferOptions {
17905 fn default() -> Self {
17906 HeifsaveBufferOptions {
17907 q: i32::from(50),
17908 bitdepth: i32::from(12),
17909 lossless: false,
17910 compression: ForeignHeifCompression::Hevc,
17911 effort: i32::from(4),
17912 subsample_mode: ForeignSubsample::Auto,
17913 encoder: ForeignHeifEncoder::Auto,
17914 keep: ForeignKeep::All,
17915 background: Vec::new(),
17916 page_height: i32::from(0),
17917 profile: String::from("sRGB"),
17918 }
17919 }
17920}
17921
17922pub fn heifsave_buffer_with_opts(
17927 inp: &VipsImage,
17928 heifsave_buffer_options: &HeifsaveBufferOptions,
17929) -> Result<Vec<u8>> {
17930 unsafe {
17931 let inp_in: *mut bindings::VipsImage = inp.ctx;
17932 let mut buffer_buf_size: u64 = 0;
17933 let mut buffer_out: *mut c_void = null_mut();
17934
17935 let q_in: i32 = heifsave_buffer_options.q;
17936 let q_in_name = utils::new_c_string("Q")?;
17937
17938 let bitdepth_in: i32 = heifsave_buffer_options.bitdepth;
17939 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
17940
17941 let lossless_in: i32 = if heifsave_buffer_options.lossless {
17942 1
17943 } else {
17944 0
17945 };
17946 let lossless_in_name = utils::new_c_string("lossless")?;
17947
17948 let compression_in: i32 = heifsave_buffer_options.compression as i32;
17949 let compression_in_name = utils::new_c_string("compression")?;
17950
17951 let effort_in: i32 = heifsave_buffer_options.effort;
17952 let effort_in_name = utils::new_c_string("effort")?;
17953
17954 let subsample_mode_in: i32 = heifsave_buffer_options.subsample_mode as i32;
17955 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
17956
17957 let encoder_in: i32 = heifsave_buffer_options.encoder as i32;
17958 let encoder_in_name = utils::new_c_string("encoder")?;
17959
17960 let keep_in: i32 = heifsave_buffer_options.keep as i32;
17961 let keep_in_name = utils::new_c_string("keep")?;
17962
17963 let background_wrapper =
17964 utils::VipsArrayDoubleWrapper::from(&heifsave_buffer_options.background[..]);
17965 let background_in = background_wrapper.ctx;
17966 let background_in_name = utils::new_c_string("background")?;
17967
17968 let page_height_in: i32 = heifsave_buffer_options.page_height;
17969 let page_height_in_name = utils::new_c_string("page-height")?;
17970
17971 let profile_in: CString = utils::new_c_string(&heifsave_buffer_options.profile)?;
17972 let profile_in_name = utils::new_c_string("profile")?;
17973
17974 let vips_op_response = bindings::vips_heifsave_buffer(
17975 inp_in,
17976 &mut buffer_out,
17977 &mut buffer_buf_size,
17978 q_in_name.as_ptr(),
17979 q_in,
17980 bitdepth_in_name.as_ptr(),
17981 bitdepth_in,
17982 lossless_in_name.as_ptr(),
17983 lossless_in,
17984 compression_in_name.as_ptr(),
17985 compression_in,
17986 effort_in_name.as_ptr(),
17987 effort_in,
17988 subsample_mode_in_name.as_ptr(),
17989 subsample_mode_in,
17990 encoder_in_name.as_ptr(),
17991 encoder_in,
17992 keep_in_name.as_ptr(),
17993 keep_in,
17994 background_in_name.as_ptr(),
17995 background_in,
17996 page_height_in_name.as_ptr(),
17997 page_height_in,
17998 profile_in_name.as_ptr(),
17999 profile_in.as_ptr(),
18000 NULL,
18001 );
18002 utils::result(
18003 vips_op_response,
18004 utils::new_byte_array(buffer_out, buffer_buf_size),
18005 Error::HeifsaveBufferError,
18006 )
18007 }
18008}
18009
18010pub fn heifsave_target(inp: &VipsImage, target: &VipsTarget) -> Result<()> {
18015 unsafe {
18016 let inp_in: *mut bindings::VipsImage = inp.ctx;
18017 let target_in: *mut bindings::VipsTarget = target.ctx;
18018
18019 let vips_op_response = bindings::vips_heifsave_target(inp_in, target_in, NULL);
18020 utils::result(vips_op_response, (), Error::HeifsaveTargetError)
18021 }
18022}
18023
18024#[derive(Clone, Debug)]
18026pub struct HeifsaveTargetOptions {
18027 pub q: i32,
18030 pub bitdepth: i32,
18033 pub lossless: bool,
18036 pub compression: ForeignHeifCompression,
18043 pub effort: i32,
18046 pub subsample_mode: ForeignSubsample,
18052 pub encoder: ForeignHeifEncoder,
18060 pub keep: ForeignKeep,
18069 pub background: Vec<f64>,
18071 pub page_height: i32,
18074 pub profile: String,
18076}
18077
18078impl std::default::Default for HeifsaveTargetOptions {
18079 fn default() -> Self {
18080 HeifsaveTargetOptions {
18081 q: i32::from(50),
18082 bitdepth: i32::from(12),
18083 lossless: false,
18084 compression: ForeignHeifCompression::Hevc,
18085 effort: i32::from(4),
18086 subsample_mode: ForeignSubsample::Auto,
18087 encoder: ForeignHeifEncoder::Auto,
18088 keep: ForeignKeep::All,
18089 background: Vec::new(),
18090 page_height: i32::from(0),
18091 profile: String::from("sRGB"),
18092 }
18093 }
18094}
18095
18096pub fn heifsave_target_with_opts(
18102 inp: &VipsImage,
18103 target: &VipsTarget,
18104 heifsave_target_options: &HeifsaveTargetOptions,
18105) -> Result<()> {
18106 unsafe {
18107 let inp_in: *mut bindings::VipsImage = inp.ctx;
18108 let target_in: *mut bindings::VipsTarget = target.ctx;
18109
18110 let q_in: i32 = heifsave_target_options.q;
18111 let q_in_name = utils::new_c_string("Q")?;
18112
18113 let bitdepth_in: i32 = heifsave_target_options.bitdepth;
18114 let bitdepth_in_name = utils::new_c_string("bitdepth")?;
18115
18116 let lossless_in: i32 = if heifsave_target_options.lossless {
18117 1
18118 } else {
18119 0
18120 };
18121 let lossless_in_name = utils::new_c_string("lossless")?;
18122
18123 let compression_in: i32 = heifsave_target_options.compression as i32;
18124 let compression_in_name = utils::new_c_string("compression")?;
18125
18126 let effort_in: i32 = heifsave_target_options.effort;
18127 let effort_in_name = utils::new_c_string("effort")?;
18128
18129 let subsample_mode_in: i32 = heifsave_target_options.subsample_mode as i32;
18130 let subsample_mode_in_name = utils::new_c_string("subsample-mode")?;
18131
18132 let encoder_in: i32 = heifsave_target_options.encoder as i32;
18133 let encoder_in_name = utils::new_c_string("encoder")?;
18134
18135 let keep_in: i32 = heifsave_target_options.keep as i32;
18136 let keep_in_name = utils::new_c_string("keep")?;
18137
18138 let background_wrapper =
18139 utils::VipsArrayDoubleWrapper::from(&heifsave_target_options.background[..]);
18140 let background_in = background_wrapper.ctx;
18141 let background_in_name = utils::new_c_string("background")?;
18142
18143 let page_height_in: i32 = heifsave_target_options.page_height;
18144 let page_height_in_name = utils::new_c_string("page-height")?;
18145
18146 let profile_in: CString = utils::new_c_string(&heifsave_target_options.profile)?;
18147 let profile_in_name = utils::new_c_string("profile")?;
18148
18149 let vips_op_response = bindings::vips_heifsave_target(
18150 inp_in,
18151 target_in,
18152 q_in_name.as_ptr(),
18153 q_in,
18154 bitdepth_in_name.as_ptr(),
18155 bitdepth_in,
18156 lossless_in_name.as_ptr(),
18157 lossless_in,
18158 compression_in_name.as_ptr(),
18159 compression_in,
18160 effort_in_name.as_ptr(),
18161 effort_in,
18162 subsample_mode_in_name.as_ptr(),
18163 subsample_mode_in,
18164 encoder_in_name.as_ptr(),
18165 encoder_in,
18166 keep_in_name.as_ptr(),
18167 keep_in,
18168 background_in_name.as_ptr(),
18169 background_in,
18170 page_height_in_name.as_ptr(),
18171 page_height_in,
18172 profile_in_name.as_ptr(),
18173 profile_in.as_ptr(),
18174 NULL,
18175 );
18176 utils::result(vips_op_response, (), Error::HeifsaveTargetError)
18177 }
18178}
18179
18180pub fn thumbnail(filename: &str, width: i32) -> Result<VipsImage> {
18186 unsafe {
18187 let filename_in: CString = utils::new_c_string(filename)?;
18188 let width_in: i32 = width;
18189 let mut out_out: *mut bindings::VipsImage = null_mut();
18190
18191 let vips_op_response =
18192 bindings::vips_thumbnail(filename_in.as_ptr(), &mut out_out, width_in, NULL);
18193 utils::result(
18194 vips_op_response,
18195 VipsImage { ctx: out_out },
18196 Error::ThumbnailError,
18197 )
18198 }
18199}
18200
18201#[derive(Clone, Debug)]
18203pub struct ThumbnailOptions {
18204 pub height: i32,
18207 pub size: Size,
18214 pub no_rotate: bool,
18217 pub crop: Interesting,
18227 pub linear: bool,
18230 pub import_profile: String,
18232 pub export_profile: String,
18234 pub intent: Intent,
18241 pub fail_on: FailOn,
18248}
18249
18250impl std::default::Default for ThumbnailOptions {
18251 fn default() -> Self {
18252 ThumbnailOptions {
18253 height: i32::from(1),
18254 size: Size::Both,
18255 no_rotate: false,
18256 crop: Interesting::None,
18257 linear: false,
18258 import_profile: String::new(),
18259 export_profile: String::new(),
18260 intent: Intent::Relative,
18261 fail_on: FailOn::None,
18262 }
18263 }
18264}
18265
18266pub fn thumbnail_with_opts(
18273 filename: &str,
18274 width: i32,
18275 thumbnail_options: &ThumbnailOptions,
18276) -> Result<VipsImage> {
18277 unsafe {
18278 let filename_in: CString = utils::new_c_string(filename)?;
18279 let width_in: i32 = width;
18280 let mut out_out: *mut bindings::VipsImage = null_mut();
18281
18282 let height_in: i32 = thumbnail_options.height;
18283 let height_in_name = utils::new_c_string("height")?;
18284
18285 let size_in: i32 = thumbnail_options.size as i32;
18286 let size_in_name = utils::new_c_string("size")?;
18287
18288 let no_rotate_in: i32 = if thumbnail_options.no_rotate { 1 } else { 0 };
18289 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18290
18291 let crop_in: i32 = thumbnail_options.crop as i32;
18292 let crop_in_name = utils::new_c_string("crop")?;
18293
18294 let linear_in: i32 = if thumbnail_options.linear { 1 } else { 0 };
18295 let linear_in_name = utils::new_c_string("linear")?;
18296
18297 let import_profile_in: CString = utils::new_c_string(&thumbnail_options.import_profile)?;
18298 let import_profile_in_name = utils::new_c_string("import-profile")?;
18299
18300 let export_profile_in: CString = utils::new_c_string(&thumbnail_options.export_profile)?;
18301 let export_profile_in_name = utils::new_c_string("export-profile")?;
18302
18303 let intent_in: i32 = thumbnail_options.intent as i32;
18304 let intent_in_name = utils::new_c_string("intent")?;
18305
18306 let fail_on_in: i32 = thumbnail_options.fail_on as i32;
18307 let fail_on_in_name = utils::new_c_string("fail-on")?;
18308
18309 let vips_op_response = bindings::vips_thumbnail(
18310 filename_in.as_ptr(),
18311 &mut out_out,
18312 width_in,
18313 height_in_name.as_ptr(),
18314 height_in,
18315 size_in_name.as_ptr(),
18316 size_in,
18317 no_rotate_in_name.as_ptr(),
18318 no_rotate_in,
18319 crop_in_name.as_ptr(),
18320 crop_in,
18321 linear_in_name.as_ptr(),
18322 linear_in,
18323 import_profile_in_name.as_ptr(),
18324 import_profile_in.as_ptr(),
18325 export_profile_in_name.as_ptr(),
18326 export_profile_in.as_ptr(),
18327 intent_in_name.as_ptr(),
18328 intent_in,
18329 fail_on_in_name.as_ptr(),
18330 fail_on_in,
18331 NULL,
18332 );
18333 utils::result(
18334 vips_op_response,
18335 VipsImage { ctx: out_out },
18336 Error::ThumbnailError,
18337 )
18338 }
18339}
18340
18341pub fn thumbnail_buffer(buffer: &[u8], width: i32) -> Result<VipsImage> {
18347 unsafe {
18348 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
18349 let width_in: i32 = width;
18350 let mut out_out: *mut bindings::VipsImage = null_mut();
18351
18352 let vips_op_response = bindings::vips_thumbnail_buffer(
18353 buffer_in,
18354 buffer.len() as u64,
18355 &mut out_out,
18356 width_in,
18357 NULL,
18358 );
18359 utils::result(
18360 vips_op_response,
18361 VipsImage { ctx: out_out },
18362 Error::ThumbnailBufferError,
18363 )
18364 }
18365}
18366
18367#[derive(Clone, Debug)]
18369pub struct ThumbnailBufferOptions {
18370 pub option_string: String,
18372 pub height: i32,
18375 pub size: Size,
18382 pub no_rotate: bool,
18385 pub crop: Interesting,
18395 pub linear: bool,
18398 pub import_profile: String,
18400 pub export_profile: String,
18402 pub intent: Intent,
18409 pub fail_on: FailOn,
18416}
18417
18418impl std::default::Default for ThumbnailBufferOptions {
18419 fn default() -> Self {
18420 ThumbnailBufferOptions {
18421 option_string: String::new(),
18422 height: i32::from(1),
18423 size: Size::Both,
18424 no_rotate: false,
18425 crop: Interesting::None,
18426 linear: false,
18427 import_profile: String::new(),
18428 export_profile: String::new(),
18429 intent: Intent::Relative,
18430 fail_on: FailOn::None,
18431 }
18432 }
18433}
18434
18435pub fn thumbnail_buffer_with_opts(
18442 buffer: &[u8],
18443 width: i32,
18444 thumbnail_buffer_options: &ThumbnailBufferOptions,
18445) -> Result<VipsImage> {
18446 unsafe {
18447 let buffer_in: *mut c_void = buffer.as_ptr() as *mut c_void;
18448 let width_in: i32 = width;
18449 let mut out_out: *mut bindings::VipsImage = null_mut();
18450
18451 let option_string_in: CString =
18452 utils::new_c_string(&thumbnail_buffer_options.option_string)?;
18453 let option_string_in_name = utils::new_c_string("option-string")?;
18454
18455 let height_in: i32 = thumbnail_buffer_options.height;
18456 let height_in_name = utils::new_c_string("height")?;
18457
18458 let size_in: i32 = thumbnail_buffer_options.size as i32;
18459 let size_in_name = utils::new_c_string("size")?;
18460
18461 let no_rotate_in: i32 = if thumbnail_buffer_options.no_rotate {
18462 1
18463 } else {
18464 0
18465 };
18466 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18467
18468 let crop_in: i32 = thumbnail_buffer_options.crop as i32;
18469 let crop_in_name = utils::new_c_string("crop")?;
18470
18471 let linear_in: i32 = if thumbnail_buffer_options.linear {
18472 1
18473 } else {
18474 0
18475 };
18476 let linear_in_name = utils::new_c_string("linear")?;
18477
18478 let import_profile_in: CString =
18479 utils::new_c_string(&thumbnail_buffer_options.import_profile)?;
18480 let import_profile_in_name = utils::new_c_string("import-profile")?;
18481
18482 let export_profile_in: CString =
18483 utils::new_c_string(&thumbnail_buffer_options.export_profile)?;
18484 let export_profile_in_name = utils::new_c_string("export-profile")?;
18485
18486 let intent_in: i32 = thumbnail_buffer_options.intent as i32;
18487 let intent_in_name = utils::new_c_string("intent")?;
18488
18489 let fail_on_in: i32 = thumbnail_buffer_options.fail_on as i32;
18490 let fail_on_in_name = utils::new_c_string("fail-on")?;
18491
18492 let vips_op_response = bindings::vips_thumbnail_buffer(
18493 buffer_in,
18494 buffer.len() as u64,
18495 &mut out_out,
18496 width_in,
18497 option_string_in_name.as_ptr(),
18498 option_string_in.as_ptr(),
18499 height_in_name.as_ptr(),
18500 height_in,
18501 size_in_name.as_ptr(),
18502 size_in,
18503 no_rotate_in_name.as_ptr(),
18504 no_rotate_in,
18505 crop_in_name.as_ptr(),
18506 crop_in,
18507 linear_in_name.as_ptr(),
18508 linear_in,
18509 import_profile_in_name.as_ptr(),
18510 import_profile_in.as_ptr(),
18511 export_profile_in_name.as_ptr(),
18512 export_profile_in.as_ptr(),
18513 intent_in_name.as_ptr(),
18514 intent_in,
18515 fail_on_in_name.as_ptr(),
18516 fail_on_in,
18517 NULL,
18518 );
18519 utils::result(
18520 vips_op_response,
18521 VipsImage { ctx: out_out },
18522 Error::ThumbnailBufferError,
18523 )
18524 }
18525}
18526
18527pub fn thumbnail_image(inp: &VipsImage, width: i32) -> Result<VipsImage> {
18533 unsafe {
18534 let inp_in: *mut bindings::VipsImage = inp.ctx;
18535 let width_in: i32 = width;
18536 let mut out_out: *mut bindings::VipsImage = null_mut();
18537
18538 let vips_op_response = bindings::vips_thumbnail_image(inp_in, &mut out_out, width_in, NULL);
18539 utils::result(
18540 vips_op_response,
18541 VipsImage { ctx: out_out },
18542 Error::ThumbnailImageError,
18543 )
18544 }
18545}
18546
18547#[derive(Clone, Debug)]
18549pub struct ThumbnailImageOptions {
18550 pub height: i32,
18553 pub size: Size,
18560 pub no_rotate: bool,
18563 pub crop: Interesting,
18573 pub linear: bool,
18576 pub import_profile: String,
18578 pub export_profile: String,
18580 pub intent: Intent,
18587 pub fail_on: FailOn,
18594}
18595
18596impl std::default::Default for ThumbnailImageOptions {
18597 fn default() -> Self {
18598 ThumbnailImageOptions {
18599 height: i32::from(1),
18600 size: Size::Both,
18601 no_rotate: false,
18602 crop: Interesting::None,
18603 linear: false,
18604 import_profile: String::new(),
18605 export_profile: String::new(),
18606 intent: Intent::Relative,
18607 fail_on: FailOn::None,
18608 }
18609 }
18610}
18611
18612pub fn thumbnail_image_with_opts(
18619 inp: &VipsImage,
18620 width: i32,
18621 thumbnail_image_options: &ThumbnailImageOptions,
18622) -> Result<VipsImage> {
18623 unsafe {
18624 let inp_in: *mut bindings::VipsImage = inp.ctx;
18625 let width_in: i32 = width;
18626 let mut out_out: *mut bindings::VipsImage = null_mut();
18627
18628 let height_in: i32 = thumbnail_image_options.height;
18629 let height_in_name = utils::new_c_string("height")?;
18630
18631 let size_in: i32 = thumbnail_image_options.size as i32;
18632 let size_in_name = utils::new_c_string("size")?;
18633
18634 let no_rotate_in: i32 = if thumbnail_image_options.no_rotate {
18635 1
18636 } else {
18637 0
18638 };
18639 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18640
18641 let crop_in: i32 = thumbnail_image_options.crop as i32;
18642 let crop_in_name = utils::new_c_string("crop")?;
18643
18644 let linear_in: i32 = if thumbnail_image_options.linear { 1 } else { 0 };
18645 let linear_in_name = utils::new_c_string("linear")?;
18646
18647 let import_profile_in: CString =
18648 utils::new_c_string(&thumbnail_image_options.import_profile)?;
18649 let import_profile_in_name = utils::new_c_string("import-profile")?;
18650
18651 let export_profile_in: CString =
18652 utils::new_c_string(&thumbnail_image_options.export_profile)?;
18653 let export_profile_in_name = utils::new_c_string("export-profile")?;
18654
18655 let intent_in: i32 = thumbnail_image_options.intent as i32;
18656 let intent_in_name = utils::new_c_string("intent")?;
18657
18658 let fail_on_in: i32 = thumbnail_image_options.fail_on as i32;
18659 let fail_on_in_name = utils::new_c_string("fail-on")?;
18660
18661 let vips_op_response = bindings::vips_thumbnail_image(
18662 inp_in,
18663 &mut out_out,
18664 width_in,
18665 height_in_name.as_ptr(),
18666 height_in,
18667 size_in_name.as_ptr(),
18668 size_in,
18669 no_rotate_in_name.as_ptr(),
18670 no_rotate_in,
18671 crop_in_name.as_ptr(),
18672 crop_in,
18673 linear_in_name.as_ptr(),
18674 linear_in,
18675 import_profile_in_name.as_ptr(),
18676 import_profile_in.as_ptr(),
18677 export_profile_in_name.as_ptr(),
18678 export_profile_in.as_ptr(),
18679 intent_in_name.as_ptr(),
18680 intent_in,
18681 fail_on_in_name.as_ptr(),
18682 fail_on_in,
18683 NULL,
18684 );
18685 utils::result(
18686 vips_op_response,
18687 VipsImage { ctx: out_out },
18688 Error::ThumbnailImageError,
18689 )
18690 }
18691}
18692
18693pub fn thumbnail_source(source: &VipsSource, width: i32) -> Result<VipsImage> {
18699 unsafe {
18700 let source_in: *mut bindings::VipsSource = source.ctx;
18701 let width_in: i32 = width;
18702 let mut out_out: *mut bindings::VipsImage = null_mut();
18703
18704 let vips_op_response =
18705 bindings::vips_thumbnail_source(source_in, &mut out_out, width_in, NULL);
18706 utils::result(
18707 vips_op_response,
18708 VipsImage { ctx: out_out },
18709 Error::ThumbnailSourceError,
18710 )
18711 }
18712}
18713
18714#[derive(Clone, Debug)]
18716pub struct ThumbnailSourceOptions {
18717 pub option_string: String,
18719 pub height: i32,
18722 pub size: Size,
18729 pub no_rotate: bool,
18732 pub crop: Interesting,
18742 pub linear: bool,
18745 pub import_profile: String,
18747 pub export_profile: String,
18749 pub intent: Intent,
18756 pub fail_on: FailOn,
18763}
18764
18765impl std::default::Default for ThumbnailSourceOptions {
18766 fn default() -> Self {
18767 ThumbnailSourceOptions {
18768 option_string: String::new(),
18769 height: i32::from(1),
18770 size: Size::Both,
18771 no_rotate: false,
18772 crop: Interesting::None,
18773 linear: false,
18774 import_profile: String::new(),
18775 export_profile: String::new(),
18776 intent: Intent::Relative,
18777 fail_on: FailOn::None,
18778 }
18779 }
18780}
18781
18782pub fn thumbnail_source_with_opts(
18789 source: &VipsSource,
18790 width: i32,
18791 thumbnail_source_options: &ThumbnailSourceOptions,
18792) -> Result<VipsImage> {
18793 unsafe {
18794 let source_in: *mut bindings::VipsSource = source.ctx;
18795 let width_in: i32 = width;
18796 let mut out_out: *mut bindings::VipsImage = null_mut();
18797
18798 let option_string_in: CString =
18799 utils::new_c_string(&thumbnail_source_options.option_string)?;
18800 let option_string_in_name = utils::new_c_string("option-string")?;
18801
18802 let height_in: i32 = thumbnail_source_options.height;
18803 let height_in_name = utils::new_c_string("height")?;
18804
18805 let size_in: i32 = thumbnail_source_options.size as i32;
18806 let size_in_name = utils::new_c_string("size")?;
18807
18808 let no_rotate_in: i32 = if thumbnail_source_options.no_rotate {
18809 1
18810 } else {
18811 0
18812 };
18813 let no_rotate_in_name = utils::new_c_string("no-rotate")?;
18814
18815 let crop_in: i32 = thumbnail_source_options.crop as i32;
18816 let crop_in_name = utils::new_c_string("crop")?;
18817
18818 let linear_in: i32 = if thumbnail_source_options.linear {
18819 1
18820 } else {
18821 0
18822 };
18823 let linear_in_name = utils::new_c_string("linear")?;
18824
18825 let import_profile_in: CString =
18826 utils::new_c_string(&thumbnail_source_options.import_profile)?;
18827 let import_profile_in_name = utils::new_c_string("import-profile")?;
18828
18829 let export_profile_in: CString =
18830 utils::new_c_string(&thumbnail_source_options.export_profile)?;
18831 let export_profile_in_name = utils::new_c_string("export-profile")?;
18832
18833 let intent_in: i32 = thumbnail_source_options.intent as i32;
18834 let intent_in_name = utils::new_c_string("intent")?;
18835
18836 let fail_on_in: i32 = thumbnail_source_options.fail_on as i32;
18837 let fail_on_in_name = utils::new_c_string("fail-on")?;
18838
18839 let vips_op_response = bindings::vips_thumbnail_source(
18840 source_in,
18841 &mut out_out,
18842 width_in,
18843 option_string_in_name.as_ptr(),
18844 option_string_in.as_ptr(),
18845 height_in_name.as_ptr(),
18846 height_in,
18847 size_in_name.as_ptr(),
18848 size_in,
18849 no_rotate_in_name.as_ptr(),
18850 no_rotate_in,
18851 crop_in_name.as_ptr(),
18852 crop_in,
18853 linear_in_name.as_ptr(),
18854 linear_in,
18855 import_profile_in_name.as_ptr(),
18856 import_profile_in.as_ptr(),
18857 export_profile_in_name.as_ptr(),
18858 export_profile_in.as_ptr(),
18859 intent_in_name.as_ptr(),
18860 intent_in,
18861 fail_on_in_name.as_ptr(),
18862 fail_on_in,
18863 NULL,
18864 );
18865 utils::result(
18866 vips_op_response,
18867 VipsImage { ctx: out_out },
18868 Error::ThumbnailSourceError,
18869 )
18870 }
18871}
18872
18873pub fn mapim(inp: &VipsImage, index: &VipsImage) -> Result<VipsImage> {
18878 unsafe {
18879 let inp_in: *mut bindings::VipsImage = inp.ctx;
18880 let index_in: *mut bindings::VipsImage = index.ctx;
18881 let mut out_out: *mut bindings::VipsImage = null_mut();
18882
18883 let vips_op_response = bindings::vips_mapim(inp_in, &mut out_out, index_in, NULL);
18884 utils::result(
18885 vips_op_response,
18886 VipsImage { ctx: out_out },
18887 Error::MapimError,
18888 )
18889 }
18890}
18891
18892#[derive(Clone, Debug)]
18894pub struct MapimOptions {
18895 pub interpolate: VipsInterpolate,
18897 pub background: Vec<f64>,
18899 pub premultiplied: bool,
18902 pub extend: Extend,
18911}
18912
18913impl std::default::Default for MapimOptions {
18914 fn default() -> Self {
18915 MapimOptions {
18916 interpolate: VipsInterpolate::new(),
18917 background: Vec::new(),
18918 premultiplied: false,
18919 extend: Extend::Background,
18920 }
18921 }
18922}
18923
18924pub fn mapim_with_opts(
18930 inp: &VipsImage,
18931 index: &VipsImage,
18932 mapim_options: &MapimOptions,
18933) -> Result<VipsImage> {
18934 unsafe {
18935 let inp_in: *mut bindings::VipsImage = inp.ctx;
18936 let index_in: *mut bindings::VipsImage = index.ctx;
18937 let mut out_out: *mut bindings::VipsImage = null_mut();
18938
18939 let interpolate_in: *mut bindings::VipsInterpolate = mapim_options.interpolate.ctx;
18940 let interpolate_in_name = utils::new_c_string("interpolate")?;
18941
18942 let background_wrapper = utils::VipsArrayDoubleWrapper::from(&mapim_options.background[..]);
18943 let background_in = background_wrapper.ctx;
18944 let background_in_name = utils::new_c_string("background")?;
18945
18946 let premultiplied_in: i32 = if mapim_options.premultiplied { 1 } else { 0 };
18947 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
18948
18949 let extend_in: i32 = mapim_options.extend as i32;
18950 let extend_in_name = utils::new_c_string("extend")?;
18951
18952 let vips_op_response = bindings::vips_mapim(
18953 inp_in,
18954 &mut out_out,
18955 index_in,
18956 interpolate_in_name.as_ptr(),
18957 interpolate_in,
18958 background_in_name.as_ptr(),
18959 background_in,
18960 premultiplied_in_name.as_ptr(),
18961 premultiplied_in,
18962 extend_in_name.as_ptr(),
18963 extend_in,
18964 NULL,
18965 );
18966 utils::result(
18967 vips_op_response,
18968 VipsImage { ctx: out_out },
18969 Error::MapimError,
18970 )
18971 }
18972}
18973
18974pub fn shrink(inp: &VipsImage, hshrink: f64, vshrink: f64) -> Result<VipsImage> {
18982 unsafe {
18983 let inp_in: *mut bindings::VipsImage = inp.ctx;
18984 let hshrink_in: f64 = hshrink;
18985 let vshrink_in: f64 = vshrink;
18986 let mut out_out: *mut bindings::VipsImage = null_mut();
18987
18988 let vips_op_response =
18989 bindings::vips_shrink(inp_in, &mut out_out, hshrink_in, vshrink_in, NULL);
18990 utils::result(
18991 vips_op_response,
18992 VipsImage { ctx: out_out },
18993 Error::ShrinkError,
18994 )
18995 }
18996}
18997
18998#[derive(Clone, Debug)]
19000pub struct ShrinkOptions {
19001 pub ceil: bool,
19004}
19005
19006impl std::default::Default for ShrinkOptions {
19007 fn default() -> Self {
19008 ShrinkOptions { ceil: false }
19009 }
19010}
19011
19012pub fn shrink_with_opts(
19021 inp: &VipsImage,
19022 hshrink: f64,
19023 vshrink: f64,
19024 shrink_options: &ShrinkOptions,
19025) -> Result<VipsImage> {
19026 unsafe {
19027 let inp_in: *mut bindings::VipsImage = inp.ctx;
19028 let hshrink_in: f64 = hshrink;
19029 let vshrink_in: f64 = vshrink;
19030 let mut out_out: *mut bindings::VipsImage = null_mut();
19031
19032 let ceil_in: i32 = if shrink_options.ceil { 1 } else { 0 };
19033 let ceil_in_name = utils::new_c_string("ceil")?;
19034
19035 let vips_op_response = bindings::vips_shrink(
19036 inp_in,
19037 &mut out_out,
19038 hshrink_in,
19039 vshrink_in,
19040 ceil_in_name.as_ptr(),
19041 ceil_in,
19042 NULL,
19043 );
19044 utils::result(
19045 vips_op_response,
19046 VipsImage { ctx: out_out },
19047 Error::ShrinkError,
19048 )
19049 }
19050}
19051
19052pub fn shrinkh(inp: &VipsImage, hshrink: i32) -> Result<VipsImage> {
19058 unsafe {
19059 let inp_in: *mut bindings::VipsImage = inp.ctx;
19060 let hshrink_in: i32 = hshrink;
19061 let mut out_out: *mut bindings::VipsImage = null_mut();
19062
19063 let vips_op_response = bindings::vips_shrinkh(inp_in, &mut out_out, hshrink_in, NULL);
19064 utils::result(
19065 vips_op_response,
19066 VipsImage { ctx: out_out },
19067 Error::ShrinkhError,
19068 )
19069 }
19070}
19071
19072#[derive(Clone, Debug)]
19074pub struct ShrinkhOptions {
19075 pub ceil: bool,
19078}
19079
19080impl std::default::Default for ShrinkhOptions {
19081 fn default() -> Self {
19082 ShrinkhOptions { ceil: false }
19083 }
19084}
19085
19086pub fn shrinkh_with_opts(
19093 inp: &VipsImage,
19094 hshrink: i32,
19095 shrinkh_options: &ShrinkhOptions,
19096) -> Result<VipsImage> {
19097 unsafe {
19098 let inp_in: *mut bindings::VipsImage = inp.ctx;
19099 let hshrink_in: i32 = hshrink;
19100 let mut out_out: *mut bindings::VipsImage = null_mut();
19101
19102 let ceil_in: i32 = if shrinkh_options.ceil { 1 } else { 0 };
19103 let ceil_in_name = utils::new_c_string("ceil")?;
19104
19105 let vips_op_response = bindings::vips_shrinkh(
19106 inp_in,
19107 &mut out_out,
19108 hshrink_in,
19109 ceil_in_name.as_ptr(),
19110 ceil_in,
19111 NULL,
19112 );
19113 utils::result(
19114 vips_op_response,
19115 VipsImage { ctx: out_out },
19116 Error::ShrinkhError,
19117 )
19118 }
19119}
19120
19121pub fn shrinkv(inp: &VipsImage, vshrink: i32) -> Result<VipsImage> {
19127 unsafe {
19128 let inp_in: *mut bindings::VipsImage = inp.ctx;
19129 let vshrink_in: i32 = vshrink;
19130 let mut out_out: *mut bindings::VipsImage = null_mut();
19131
19132 let vips_op_response = bindings::vips_shrinkv(inp_in, &mut out_out, vshrink_in, NULL);
19133 utils::result(
19134 vips_op_response,
19135 VipsImage { ctx: out_out },
19136 Error::ShrinkvError,
19137 )
19138 }
19139}
19140
19141#[derive(Clone, Debug)]
19143pub struct ShrinkvOptions {
19144 pub ceil: bool,
19147}
19148
19149impl std::default::Default for ShrinkvOptions {
19150 fn default() -> Self {
19151 ShrinkvOptions { ceil: false }
19152 }
19153}
19154
19155pub fn shrinkv_with_opts(
19162 inp: &VipsImage,
19163 vshrink: i32,
19164 shrinkv_options: &ShrinkvOptions,
19165) -> Result<VipsImage> {
19166 unsafe {
19167 let inp_in: *mut bindings::VipsImage = inp.ctx;
19168 let vshrink_in: i32 = vshrink;
19169 let mut out_out: *mut bindings::VipsImage = null_mut();
19170
19171 let ceil_in: i32 = if shrinkv_options.ceil { 1 } else { 0 };
19172 let ceil_in_name = utils::new_c_string("ceil")?;
19173
19174 let vips_op_response = bindings::vips_shrinkv(
19175 inp_in,
19176 &mut out_out,
19177 vshrink_in,
19178 ceil_in_name.as_ptr(),
19179 ceil_in,
19180 NULL,
19181 );
19182 utils::result(
19183 vips_op_response,
19184 VipsImage { ctx: out_out },
19185 Error::ShrinkvError,
19186 )
19187 }
19188}
19189
19190pub fn reduceh(inp: &VipsImage, hshrink: f64) -> Result<VipsImage> {
19196 unsafe {
19197 let inp_in: *mut bindings::VipsImage = inp.ctx;
19198 let hshrink_in: f64 = hshrink;
19199 let mut out_out: *mut bindings::VipsImage = null_mut();
19200
19201 let vips_op_response = bindings::vips_reduceh(inp_in, &mut out_out, hshrink_in, NULL);
19202 utils::result(
19203 vips_op_response,
19204 VipsImage { ctx: out_out },
19205 Error::ReducehError,
19206 )
19207 }
19208}
19209
19210#[derive(Clone, Debug)]
19212pub struct ReducehOptions {
19213 pub kernel: Kernel,
19222 pub gap: f64,
19225}
19226
19227impl std::default::Default for ReducehOptions {
19228 fn default() -> Self {
19229 ReducehOptions {
19230 kernel: Kernel::Lanczos3,
19231 gap: f64::from(0),
19232 }
19233 }
19234}
19235
19236pub fn reduceh_with_opts(
19243 inp: &VipsImage,
19244 hshrink: f64,
19245 reduceh_options: &ReducehOptions,
19246) -> Result<VipsImage> {
19247 unsafe {
19248 let inp_in: *mut bindings::VipsImage = inp.ctx;
19249 let hshrink_in: f64 = hshrink;
19250 let mut out_out: *mut bindings::VipsImage = null_mut();
19251
19252 let kernel_in: i32 = reduceh_options.kernel as i32;
19253 let kernel_in_name = utils::new_c_string("kernel")?;
19254
19255 let gap_in: f64 = reduceh_options.gap;
19256 let gap_in_name = utils::new_c_string("gap")?;
19257
19258 let vips_op_response = bindings::vips_reduceh(
19259 inp_in,
19260 &mut out_out,
19261 hshrink_in,
19262 kernel_in_name.as_ptr(),
19263 kernel_in,
19264 gap_in_name.as_ptr(),
19265 gap_in,
19266 NULL,
19267 );
19268 utils::result(
19269 vips_op_response,
19270 VipsImage { ctx: out_out },
19271 Error::ReducehError,
19272 )
19273 }
19274}
19275
19276pub fn reducev(inp: &VipsImage, vshrink: f64) -> Result<VipsImage> {
19282 unsafe {
19283 let inp_in: *mut bindings::VipsImage = inp.ctx;
19284 let vshrink_in: f64 = vshrink;
19285 let mut out_out: *mut bindings::VipsImage = null_mut();
19286
19287 let vips_op_response = bindings::vips_reducev(inp_in, &mut out_out, vshrink_in, NULL);
19288 utils::result(
19289 vips_op_response,
19290 VipsImage { ctx: out_out },
19291 Error::ReducevError,
19292 )
19293 }
19294}
19295
19296#[derive(Clone, Debug)]
19298pub struct ReducevOptions {
19299 pub kernel: Kernel,
19308 pub gap: f64,
19311}
19312
19313impl std::default::Default for ReducevOptions {
19314 fn default() -> Self {
19315 ReducevOptions {
19316 kernel: Kernel::Lanczos3,
19317 gap: f64::from(0),
19318 }
19319 }
19320}
19321
19322pub fn reducev_with_opts(
19329 inp: &VipsImage,
19330 vshrink: f64,
19331 reducev_options: &ReducevOptions,
19332) -> Result<VipsImage> {
19333 unsafe {
19334 let inp_in: *mut bindings::VipsImage = inp.ctx;
19335 let vshrink_in: f64 = vshrink;
19336 let mut out_out: *mut bindings::VipsImage = null_mut();
19337
19338 let kernel_in: i32 = reducev_options.kernel as i32;
19339 let kernel_in_name = utils::new_c_string("kernel")?;
19340
19341 let gap_in: f64 = reducev_options.gap;
19342 let gap_in_name = utils::new_c_string("gap")?;
19343
19344 let vips_op_response = bindings::vips_reducev(
19345 inp_in,
19346 &mut out_out,
19347 vshrink_in,
19348 kernel_in_name.as_ptr(),
19349 kernel_in,
19350 gap_in_name.as_ptr(),
19351 gap_in,
19352 NULL,
19353 );
19354 utils::result(
19355 vips_op_response,
19356 VipsImage { ctx: out_out },
19357 Error::ReducevError,
19358 )
19359 }
19360}
19361
19362pub fn reduce(inp: &VipsImage, hshrink: f64, vshrink: f64) -> Result<VipsImage> {
19370 unsafe {
19371 let inp_in: *mut bindings::VipsImage = inp.ctx;
19372 let hshrink_in: f64 = hshrink;
19373 let vshrink_in: f64 = vshrink;
19374 let mut out_out: *mut bindings::VipsImage = null_mut();
19375
19376 let vips_op_response =
19377 bindings::vips_reduce(inp_in, &mut out_out, hshrink_in, vshrink_in, NULL);
19378 utils::result(
19379 vips_op_response,
19380 VipsImage { ctx: out_out },
19381 Error::ReduceError,
19382 )
19383 }
19384}
19385
19386#[derive(Clone, Debug)]
19388pub struct ReduceOptions {
19389 pub kernel: Kernel,
19398 pub gap: f64,
19401}
19402
19403impl std::default::Default for ReduceOptions {
19404 fn default() -> Self {
19405 ReduceOptions {
19406 kernel: Kernel::Lanczos3,
19407 gap: f64::from(0),
19408 }
19409 }
19410}
19411
19412pub fn reduce_with_opts(
19421 inp: &VipsImage,
19422 hshrink: f64,
19423 vshrink: f64,
19424 reduce_options: &ReduceOptions,
19425) -> Result<VipsImage> {
19426 unsafe {
19427 let inp_in: *mut bindings::VipsImage = inp.ctx;
19428 let hshrink_in: f64 = hshrink;
19429 let vshrink_in: f64 = vshrink;
19430 let mut out_out: *mut bindings::VipsImage = null_mut();
19431
19432 let kernel_in: i32 = reduce_options.kernel as i32;
19433 let kernel_in_name = utils::new_c_string("kernel")?;
19434
19435 let gap_in: f64 = reduce_options.gap;
19436 let gap_in_name = utils::new_c_string("gap")?;
19437
19438 let vips_op_response = bindings::vips_reduce(
19439 inp_in,
19440 &mut out_out,
19441 hshrink_in,
19442 vshrink_in,
19443 kernel_in_name.as_ptr(),
19444 kernel_in,
19445 gap_in_name.as_ptr(),
19446 gap_in,
19447 NULL,
19448 );
19449 utils::result(
19450 vips_op_response,
19451 VipsImage { ctx: out_out },
19452 Error::ReduceError,
19453 )
19454 }
19455}
19456
19457pub fn quadratic(inp: &VipsImage, coeff: &VipsImage) -> Result<VipsImage> {
19462 unsafe {
19463 let inp_in: *mut bindings::VipsImage = inp.ctx;
19464 let coeff_in: *mut bindings::VipsImage = coeff.ctx;
19465 let mut out_out: *mut bindings::VipsImage = null_mut();
19466
19467 let vips_op_response = bindings::vips_quadratic(inp_in, &mut out_out, coeff_in, NULL);
19468 utils::result(
19469 vips_op_response,
19470 VipsImage { ctx: out_out },
19471 Error::QuadraticError,
19472 )
19473 }
19474}
19475
19476#[derive(Clone, Debug)]
19478pub struct QuadraticOptions {
19479 pub interpolate: VipsInterpolate,
19481}
19482
19483impl std::default::Default for QuadraticOptions {
19484 fn default() -> Self {
19485 QuadraticOptions {
19486 interpolate: VipsInterpolate::new(),
19487 }
19488 }
19489}
19490
19491pub fn quadratic_with_opts(
19497 inp: &VipsImage,
19498 coeff: &VipsImage,
19499 quadratic_options: &QuadraticOptions,
19500) -> Result<VipsImage> {
19501 unsafe {
19502 let inp_in: *mut bindings::VipsImage = inp.ctx;
19503 let coeff_in: *mut bindings::VipsImage = coeff.ctx;
19504 let mut out_out: *mut bindings::VipsImage = null_mut();
19505
19506 let interpolate_in: *mut bindings::VipsInterpolate = quadratic_options.interpolate.ctx;
19507 let interpolate_in_name = utils::new_c_string("interpolate")?;
19508
19509 let vips_op_response = bindings::vips_quadratic(
19510 inp_in,
19511 &mut out_out,
19512 coeff_in,
19513 interpolate_in_name.as_ptr(),
19514 interpolate_in,
19515 NULL,
19516 );
19517 utils::result(
19518 vips_op_response,
19519 VipsImage { ctx: out_out },
19520 Error::QuadraticError,
19521 )
19522 }
19523}
19524
19525pub fn affine(inp: &VipsImage, a: f64, b: f64, c: f64, d: f64) -> Result<VipsImage> {
19537 unsafe {
19538 let inp_in: *mut bindings::VipsImage = inp.ctx;
19539 let a_in: f64 = a;
19540 let b_in: f64 = b;
19541 let c_in: f64 = c;
19542 let d_in: f64 = d;
19543 let mut out_out: *mut bindings::VipsImage = null_mut();
19544
19545 let vips_op_response =
19546 bindings::vips_affine(inp_in, &mut out_out, a_in, b_in, c_in, d_in, NULL);
19547 utils::result(
19548 vips_op_response,
19549 VipsImage { ctx: out_out },
19550 Error::AffineError,
19551 )
19552 }
19553}
19554
19555#[derive(Clone, Debug)]
19557pub struct AffineOptions {
19558 pub interpolate: VipsInterpolate,
19560 pub oarea: Vec<i32>,
19562 pub odx: f64,
19565 pub ody: f64,
19568 pub idx: f64,
19571 pub idy: f64,
19574 pub background: Vec<f64>,
19576 pub premultiplied: bool,
19579 pub extend: Extend,
19588}
19589
19590impl std::default::Default for AffineOptions {
19591 fn default() -> Self {
19592 AffineOptions {
19593 interpolate: VipsInterpolate::new(),
19594 oarea: Vec::new(),
19595 odx: f64::from(0),
19596 ody: f64::from(0),
19597 idx: f64::from(0),
19598 idy: f64::from(0),
19599 background: Vec::new(),
19600 premultiplied: false,
19601 extend: Extend::Background,
19602 }
19603 }
19604}
19605
19606pub fn affine_with_opts(
19619 inp: &VipsImage,
19620 a: f64,
19621 b: f64,
19622 c: f64,
19623 d: f64,
19624 affine_options: &AffineOptions,
19625) -> Result<VipsImage> {
19626 unsafe {
19627 let inp_in: *mut bindings::VipsImage = inp.ctx;
19628 let a_in: f64 = a;
19629 let b_in: f64 = b;
19630 let c_in: f64 = c;
19631 let d_in: f64 = d;
19632 let mut out_out: *mut bindings::VipsImage = null_mut();
19633
19634 let interpolate_in: *mut bindings::VipsInterpolate = affine_options.interpolate.ctx;
19635 let interpolate_in_name = utils::new_c_string("interpolate")?;
19636
19637 let oarea_wrapper = utils::VipsArrayIntWrapper::from(&affine_options.oarea[..]);
19638 let oarea_in = oarea_wrapper.ctx;
19639 let oarea_in_name = utils::new_c_string("oarea")?;
19640
19641 let odx_in: f64 = affine_options.odx;
19642 let odx_in_name = utils::new_c_string("odx")?;
19643
19644 let ody_in: f64 = affine_options.ody;
19645 let ody_in_name = utils::new_c_string("ody")?;
19646
19647 let idx_in: f64 = affine_options.idx;
19648 let idx_in_name = utils::new_c_string("idx")?;
19649
19650 let idy_in: f64 = affine_options.idy;
19651 let idy_in_name = utils::new_c_string("idy")?;
19652
19653 let background_wrapper =
19654 utils::VipsArrayDoubleWrapper::from(&affine_options.background[..]);
19655 let background_in = background_wrapper.ctx;
19656 let background_in_name = utils::new_c_string("background")?;
19657
19658 let premultiplied_in: i32 = if affine_options.premultiplied { 1 } else { 0 };
19659 let premultiplied_in_name = utils::new_c_string("premultiplied")?;
19660
19661 let extend_in: i32 = affine_options.extend as i32;
19662 let extend_in_name = utils::new_c_string("extend")?;
19663
19664 let vips_op_response = bindings::vips_affine(
19665 inp_in,
19666 &mut out_out,
19667 a_in,
19668 b_in,
19669 c_in,
19670 d_in,
19671 interpolate_in_name.as_ptr(),
19672 interpolate_in,
19673 oarea_in_name.as_ptr(),
19674 oarea_in,
19675 odx_in_name.as_ptr(),
19676 odx_in,
19677 ody_in_name.as_ptr(),
19678 ody_in,
19679 idx_in_name.as_ptr(),
19680 idx_in,
19681 idy_in_name.as_ptr(),
19682 idy_in,
19683 background_in_name.as_ptr(),
19684 background_in,
19685 premultiplied_in_name.as_ptr(),
19686 premultiplied_in,
19687 extend_in_name.as_ptr(),
19688 extend_in,
19689 NULL,
19690 );
19691 utils::result(
19692 vips_op_response,
19693 VipsImage { ctx: out_out },
19694 Error::AffineError,
19695 )
19696 }
19697}
19698
19699pub fn similarity(inp: &VipsImage) -> Result<VipsImage> {
19703 unsafe {
19704 let inp_in: *mut bindings::VipsImage = inp.ctx;
19705 let mut out_out: *mut bindings::VipsImage = null_mut();
19706
19707 let vips_op_response = bindings::vips_similarity(inp_in, &mut out_out, NULL);
19708 utils::result(
19709 vips_op_response,
19710 VipsImage { ctx: out_out },
19711 Error::SimilarityError,
19712 )
19713 }
19714}
19715
19716#[derive(Clone, Debug)]
19718pub struct SimilarityOptions {
19719 pub scale: f64,
19722 pub angle: f64,
19725 pub interpolate: VipsInterpolate,
19727 pub background: Vec<f64>,
19729 pub odx: f64,
19732 pub ody: f64,
19735 pub idx: f64,
19738 pub idy: f64,
19741}
19742
19743impl std::default::Default for SimilarityOptions {
19744 fn default() -> Self {
19745 SimilarityOptions {
19746 scale: f64::from(1),
19747 angle: f64::from(0),
19748 interpolate: VipsInterpolate::new(),
19749 background: Vec::new(),
19750 odx: f64::from(0),
19751 ody: f64::from(0),
19752 idx: f64::from(0),
19753 idy: f64::from(0),
19754 }
19755 }
19756}
19757
19758pub fn similarity_with_opts(
19763 inp: &VipsImage,
19764 similarity_options: &SimilarityOptions,
19765) -> Result<VipsImage> {
19766 unsafe {
19767 let inp_in: *mut bindings::VipsImage = inp.ctx;
19768 let mut out_out: *mut bindings::VipsImage = null_mut();
19769
19770 let scale_in: f64 = similarity_options.scale;
19771 let scale_in_name = utils::new_c_string("scale")?;
19772
19773 let angle_in: f64 = similarity_options.angle;
19774 let angle_in_name = utils::new_c_string("angle")?;
19775
19776 let interpolate_in: *mut bindings::VipsInterpolate = similarity_options.interpolate.ctx;
19777 let interpolate_in_name = utils::new_c_string("interpolate")?;
19778
19779 let background_wrapper =
19780 utils::VipsArrayDoubleWrapper::from(&similarity_options.background[..]);
19781 let background_in = background_wrapper.ctx;
19782 let background_in_name = utils::new_c_string("background")?;
19783
19784 let odx_in: f64 = similarity_options.odx;
19785 let odx_in_name = utils::new_c_string("odx")?;
19786
19787 let ody_in: f64 = similarity_options.ody;
19788 let ody_in_name = utils::new_c_string("ody")?;
19789
19790 let idx_in: f64 = similarity_options.idx;
19791 let idx_in_name = utils::new_c_string("idx")?;
19792
19793 let idy_in: f64 = similarity_options.idy;
19794 let idy_in_name = utils::new_c_string("idy")?;
19795
19796 let vips_op_response = bindings::vips_similarity(
19797 inp_in,
19798 &mut out_out,
19799 scale_in_name.as_ptr(),
19800 scale_in,
19801 angle_in_name.as_ptr(),
19802 angle_in,
19803 interpolate_in_name.as_ptr(),
19804 interpolate_in,
19805 background_in_name.as_ptr(),
19806 background_in,
19807 odx_in_name.as_ptr(),
19808 odx_in,
19809 ody_in_name.as_ptr(),
19810 ody_in,
19811 idx_in_name.as_ptr(),
19812 idx_in,
19813 idy_in_name.as_ptr(),
19814 idy_in,
19815 NULL,
19816 );
19817 utils::result(
19818 vips_op_response,
19819 VipsImage { ctx: out_out },
19820 Error::SimilarityError,
19821 )
19822 }
19823}
19824
19825pub fn rotate(inp: &VipsImage, angle: f64) -> Result<VipsImage> {
19831 unsafe {
19832 let inp_in: *mut bindings::VipsImage = inp.ctx;
19833 let angle_in: f64 = angle;
19834 let mut out_out: *mut bindings::VipsImage = null_mut();
19835
19836 let vips_op_response = bindings::vips_rotate(inp_in, &mut out_out, angle_in, NULL);
19837 utils::result(
19838 vips_op_response,
19839 VipsImage { ctx: out_out },
19840 Error::RotateError,
19841 )
19842 }
19843}
19844
19845#[derive(Clone, Debug)]
19847pub struct RotateOptions {
19848 pub interpolate: VipsInterpolate,
19850 pub background: Vec<f64>,
19852 pub odx: f64,
19855 pub ody: f64,
19858 pub idx: f64,
19861 pub idy: f64,
19864}
19865
19866impl std::default::Default for RotateOptions {
19867 fn default() -> Self {
19868 RotateOptions {
19869 interpolate: VipsInterpolate::new(),
19870 background: Vec::new(),
19871 odx: f64::from(0),
19872 ody: f64::from(0),
19873 idx: f64::from(0),
19874 idy: f64::from(0),
19875 }
19876 }
19877}
19878
19879pub fn rotate_with_opts(
19886 inp: &VipsImage,
19887 angle: f64,
19888 rotate_options: &RotateOptions,
19889) -> Result<VipsImage> {
19890 unsafe {
19891 let inp_in: *mut bindings::VipsImage = inp.ctx;
19892 let angle_in: f64 = angle;
19893 let mut out_out: *mut bindings::VipsImage = null_mut();
19894
19895 let interpolate_in: *mut bindings::VipsInterpolate = rotate_options.interpolate.ctx;
19896 let interpolate_in_name = utils::new_c_string("interpolate")?;
19897
19898 let background_wrapper =
19899 utils::VipsArrayDoubleWrapper::from(&rotate_options.background[..]);
19900 let background_in = background_wrapper.ctx;
19901 let background_in_name = utils::new_c_string("background")?;
19902
19903 let odx_in: f64 = rotate_options.odx;
19904 let odx_in_name = utils::new_c_string("odx")?;
19905
19906 let ody_in: f64 = rotate_options.ody;
19907 let ody_in_name = utils::new_c_string("ody")?;
19908
19909 let idx_in: f64 = rotate_options.idx;
19910 let idx_in_name = utils::new_c_string("idx")?;
19911
19912 let idy_in: f64 = rotate_options.idy;
19913 let idy_in_name = utils::new_c_string("idy")?;
19914
19915 let vips_op_response = bindings::vips_rotate(
19916 inp_in,
19917 &mut out_out,
19918 angle_in,
19919 interpolate_in_name.as_ptr(),
19920 interpolate_in,
19921 background_in_name.as_ptr(),
19922 background_in,
19923 odx_in_name.as_ptr(),
19924 odx_in,
19925 ody_in_name.as_ptr(),
19926 ody_in,
19927 idx_in_name.as_ptr(),
19928 idx_in,
19929 idy_in_name.as_ptr(),
19930 idy_in,
19931 NULL,
19932 );
19933 utils::result(
19934 vips_op_response,
19935 VipsImage { ctx: out_out },
19936 Error::RotateError,
19937 )
19938 }
19939}
19940
19941pub fn resize(inp: &VipsImage, scale: f64) -> Result<VipsImage> {
19947 unsafe {
19948 let inp_in: *mut bindings::VipsImage = inp.ctx;
19949 let scale_in: f64 = scale;
19950 let mut out_out: *mut bindings::VipsImage = null_mut();
19951
19952 let vips_op_response = bindings::vips_resize(inp_in, &mut out_out, scale_in, NULL);
19953 utils::result(
19954 vips_op_response,
19955 VipsImage { ctx: out_out },
19956 Error::ResizeError,
19957 )
19958 }
19959}
19960
19961#[derive(Clone, Debug)]
19963pub struct ResizeOptions {
19964 pub kernel: Kernel,
19973 pub gap: f64,
19976 pub vscale: f64,
19979}
19980
19981impl std::default::Default for ResizeOptions {
19982 fn default() -> Self {
19983 ResizeOptions {
19984 kernel: Kernel::Lanczos3,
19985 gap: f64::from(2),
19986 vscale: f64::from(0),
19987 }
19988 }
19989}
19990
19991pub fn resize_with_opts(
19998 inp: &VipsImage,
19999 scale: f64,
20000 resize_options: &ResizeOptions,
20001) -> Result<VipsImage> {
20002 unsafe {
20003 let inp_in: *mut bindings::VipsImage = inp.ctx;
20004 let scale_in: f64 = scale;
20005 let mut out_out: *mut bindings::VipsImage = null_mut();
20006
20007 let kernel_in: i32 = resize_options.kernel as i32;
20008 let kernel_in_name = utils::new_c_string("kernel")?;
20009
20010 let gap_in: f64 = resize_options.gap;
20011 let gap_in_name = utils::new_c_string("gap")?;
20012
20013 let vscale_in: f64 = resize_options.vscale;
20014 let vscale_in_name = utils::new_c_string("vscale")?;
20015
20016 let vips_op_response = bindings::vips_resize(
20017 inp_in,
20018 &mut out_out,
20019 scale_in,
20020 kernel_in_name.as_ptr(),
20021 kernel_in,
20022 gap_in_name.as_ptr(),
20023 gap_in,
20024 vscale_in_name.as_ptr(),
20025 vscale_in,
20026 NULL,
20027 );
20028 utils::result(
20029 vips_op_response,
20030 VipsImage { ctx: out_out },
20031 Error::ResizeError,
20032 )
20033 }
20034}
20035
20036pub fn colourspace(inp: &VipsImage, space: Interpretation) -> Result<VipsImage> {
20062 unsafe {
20063 let inp_in: *mut bindings::VipsImage = inp.ctx;
20064 let space_in: i32 = space as i32;
20065 let mut out_out: *mut bindings::VipsImage = null_mut();
20066
20067 let vips_op_response =
20068 bindings::vips_colourspace(inp_in, &mut out_out, space_in.try_into().unwrap(), NULL);
20069 utils::result(
20070 vips_op_response,
20071 VipsImage { ctx: out_out },
20072 Error::ColourspaceError,
20073 )
20074 }
20075}
20076
20077#[derive(Clone, Debug)]
20079pub struct ColourspaceOptions {
20080 pub source_space: Interpretation,
20103}
20104
20105impl std::default::Default for ColourspaceOptions {
20106 fn default() -> Self {
20107 ColourspaceOptions {
20108 source_space: Interpretation::Srgb,
20109 }
20110 }
20111}
20112
20113pub fn colourspace_with_opts(
20140 inp: &VipsImage,
20141 space: Interpretation,
20142 colourspace_options: &ColourspaceOptions,
20143) -> Result<VipsImage> {
20144 unsafe {
20145 let inp_in: *mut bindings::VipsImage = inp.ctx;
20146 let space_in: i32 = space as i32;
20147 let mut out_out: *mut bindings::VipsImage = null_mut();
20148
20149 let source_space_in: i32 = colourspace_options.source_space as i32;
20150 let source_space_in_name = utils::new_c_string("source-space")?;
20151
20152 let vips_op_response = bindings::vips_colourspace(
20153 inp_in,
20154 &mut out_out,
20155 space_in.try_into().unwrap(),
20156 source_space_in_name.as_ptr(),
20157 source_space_in,
20158 NULL,
20159 );
20160 utils::result(
20161 vips_op_response,
20162 VipsImage { ctx: out_out },
20163 Error::ColourspaceError,
20164 )
20165 }
20166}
20167
20168pub fn lab_2xyz(inp: &VipsImage) -> Result<VipsImage> {
20172 unsafe {
20173 let inp_in: *mut bindings::VipsImage = inp.ctx;
20174 let mut out_out: *mut bindings::VipsImage = null_mut();
20175
20176 let vips_op_response = bindings::vips_Lab2XYZ(inp_in, &mut out_out, NULL);
20177 utils::result(
20178 vips_op_response,
20179 VipsImage { ctx: out_out },
20180 Error::Lab2XyzError,
20181 )
20182 }
20183}
20184
20185#[derive(Clone, Debug)]
20187pub struct Lab2XyzOptions {
20188 pub temp: Vec<f64>,
20190}
20191
20192impl std::default::Default for Lab2XyzOptions {
20193 fn default() -> Self {
20194 Lab2XyzOptions { temp: Vec::new() }
20195 }
20196}
20197
20198pub fn lab_2xyz_with_opts(inp: &VipsImage, lab_2xyz_options: &Lab2XyzOptions) -> Result<VipsImage> {
20203 unsafe {
20204 let inp_in: *mut bindings::VipsImage = inp.ctx;
20205 let mut out_out: *mut bindings::VipsImage = null_mut();
20206
20207 let temp_wrapper = utils::VipsArrayDoubleWrapper::from(&lab_2xyz_options.temp[..]);
20208 let temp_in = temp_wrapper.ctx;
20209 let temp_in_name = utils::new_c_string("temp")?;
20210
20211 let vips_op_response =
20212 bindings::vips_Lab2XYZ(inp_in, &mut out_out, temp_in_name.as_ptr(), temp_in, NULL);
20213 utils::result(
20214 vips_op_response,
20215 VipsImage { ctx: out_out },
20216 Error::Lab2XyzError,
20217 )
20218 }
20219}
20220
20221pub fn xyz2_lab(inp: &VipsImage) -> Result<VipsImage> {
20225 unsafe {
20226 let inp_in: *mut bindings::VipsImage = inp.ctx;
20227 let mut out_out: *mut bindings::VipsImage = null_mut();
20228
20229 let vips_op_response = bindings::vips_XYZ2Lab(inp_in, &mut out_out, NULL);
20230 utils::result(
20231 vips_op_response,
20232 VipsImage { ctx: out_out },
20233 Error::Xyz2LabError,
20234 )
20235 }
20236}
20237
20238#[derive(Clone, Debug)]
20240pub struct Xyz2LabOptions {
20241 pub temp: Vec<f64>,
20243}
20244
20245impl std::default::Default for Xyz2LabOptions {
20246 fn default() -> Self {
20247 Xyz2LabOptions { temp: Vec::new() }
20248 }
20249}
20250
20251pub fn xyz2_lab_with_opts(
20256 inp: &VipsImage,
20257 xyz_2_lab_options: &Xyz2LabOptions,
20258) -> Result<VipsImage> {
20259 unsafe {
20260 let inp_in: *mut bindings::VipsImage = inp.ctx;
20261 let mut out_out: *mut bindings::VipsImage = null_mut();
20262
20263 let temp_wrapper = utils::VipsArrayDoubleWrapper::from(&xyz_2_lab_options.temp[..]);
20264 let temp_in = temp_wrapper.ctx;
20265 let temp_in_name = utils::new_c_string("temp")?;
20266
20267 let vips_op_response =
20268 bindings::vips_XYZ2Lab(inp_in, &mut out_out, temp_in_name.as_ptr(), temp_in, NULL);
20269 utils::result(
20270 vips_op_response,
20271 VipsImage { ctx: out_out },
20272 Error::Xyz2LabError,
20273 )
20274 }
20275}
20276
20277pub fn lab_2l_ch(inp: &VipsImage) -> Result<VipsImage> {
20281 unsafe {
20282 let inp_in: *mut bindings::VipsImage = inp.ctx;
20283 let mut out_out: *mut bindings::VipsImage = null_mut();
20284
20285 let vips_op_response = bindings::vips_Lab2LCh(inp_in, &mut out_out, NULL);
20286 utils::result(
20287 vips_op_response,
20288 VipsImage { ctx: out_out },
20289 Error::Lab2LChError,
20290 )
20291 }
20292}
20293
20294pub fn l_ch_2_lab(inp: &VipsImage) -> Result<VipsImage> {
20298 unsafe {
20299 let inp_in: *mut bindings::VipsImage = inp.ctx;
20300 let mut out_out: *mut bindings::VipsImage = null_mut();
20301
20302 let vips_op_response = bindings::vips_LCh2Lab(inp_in, &mut out_out, NULL);
20303 utils::result(
20304 vips_op_response,
20305 VipsImage { ctx: out_out },
20306 Error::LCh2LabError,
20307 )
20308 }
20309}
20310
20311pub fn l_ch_2cmc(inp: &VipsImage) -> Result<VipsImage> {
20315 unsafe {
20316 let inp_in: *mut bindings::VipsImage = inp.ctx;
20317 let mut out_out: *mut bindings::VipsImage = null_mut();
20318
20319 let vips_op_response = bindings::vips_LCh2CMC(inp_in, &mut out_out, NULL);
20320 utils::result(
20321 vips_op_response,
20322 VipsImage { ctx: out_out },
20323 Error::LCh2CmcError,
20324 )
20325 }
20326}
20327
20328pub fn cmc2l_ch(inp: &VipsImage) -> Result<VipsImage> {
20332 unsafe {
20333 let inp_in: *mut bindings::VipsImage = inp.ctx;
20334 let mut out_out: *mut bindings::VipsImage = null_mut();
20335
20336 let vips_op_response = bindings::vips_CMC2LCh(inp_in, &mut out_out, NULL);
20337 utils::result(
20338 vips_op_response,
20339 VipsImage { ctx: out_out },
20340 Error::Cmc2LChError,
20341 )
20342 }
20343}
20344
20345pub fn xyz2_yxy(inp: &VipsImage) -> Result<VipsImage> {
20349 unsafe {
20350 let inp_in: *mut bindings::VipsImage = inp.ctx;
20351 let mut out_out: *mut bindings::VipsImage = null_mut();
20352
20353 let vips_op_response = bindings::vips_XYZ2Yxy(inp_in, &mut out_out, NULL);
20354 utils::result(
20355 vips_op_response,
20356 VipsImage { ctx: out_out },
20357 Error::Xyz2YxyError,
20358 )
20359 }
20360}
20361
20362pub fn yxy_2xyz(inp: &VipsImage) -> Result<VipsImage> {
20366 unsafe {
20367 let inp_in: *mut bindings::VipsImage = inp.ctx;
20368 let mut out_out: *mut bindings::VipsImage = null_mut();
20369
20370 let vips_op_response = bindings::vips_Yxy2XYZ(inp_in, &mut out_out, NULL);
20371 utils::result(
20372 vips_op_response,
20373 VipsImage { ctx: out_out },
20374 Error::Yxy2XyzError,
20375 )
20376 }
20377}
20378
20379pub fn lab_q2_lab(inp: &VipsImage) -> Result<VipsImage> {
20383 unsafe {
20384 let inp_in: *mut bindings::VipsImage = inp.ctx;
20385 let mut out_out: *mut bindings::VipsImage = null_mut();
20386
20387 let vips_op_response = bindings::vips_LabQ2Lab(inp_in, &mut out_out, NULL);
20388 utils::result(
20389 vips_op_response,
20390 VipsImage { ctx: out_out },
20391 Error::LabQ2LabError,
20392 )
20393 }
20394}
20395
20396pub fn lab_2_lab_q(inp: &VipsImage) -> Result<VipsImage> {
20400 unsafe {
20401 let inp_in: *mut bindings::VipsImage = inp.ctx;
20402 let mut out_out: *mut bindings::VipsImage = null_mut();
20403
20404 let vips_op_response = bindings::vips_Lab2LabQ(inp_in, &mut out_out, NULL);
20405 utils::result(
20406 vips_op_response,
20407 VipsImage { ctx: out_out },
20408 Error::Lab2LabQError,
20409 )
20410 }
20411}
20412
20413pub fn lab_q2_lab_s(inp: &VipsImage) -> Result<VipsImage> {
20417 unsafe {
20418 let inp_in: *mut bindings::VipsImage = inp.ctx;
20419 let mut out_out: *mut bindings::VipsImage = null_mut();
20420
20421 let vips_op_response = bindings::vips_LabQ2LabS(inp_in, &mut out_out, NULL);
20422 utils::result(
20423 vips_op_response,
20424 VipsImage { ctx: out_out },
20425 Error::LabQ2LabSError,
20426 )
20427 }
20428}
20429
20430pub fn lab_s2_lab_q(inp: &VipsImage) -> Result<VipsImage> {
20434 unsafe {
20435 let inp_in: *mut bindings::VipsImage = inp.ctx;
20436 let mut out_out: *mut bindings::VipsImage = null_mut();
20437
20438 let vips_op_response = bindings::vips_LabS2LabQ(inp_in, &mut out_out, NULL);
20439 utils::result(
20440 vips_op_response,
20441 VipsImage { ctx: out_out },
20442 Error::LabS2LabQError,
20443 )
20444 }
20445}
20446
20447pub fn lab_s2_lab(inp: &VipsImage) -> Result<VipsImage> {
20451 unsafe {
20452 let inp_in: *mut bindings::VipsImage = inp.ctx;
20453 let mut out_out: *mut bindings::VipsImage = null_mut();
20454
20455 let vips_op_response = bindings::vips_LabS2Lab(inp_in, &mut out_out, NULL);
20456 utils::result(
20457 vips_op_response,
20458 VipsImage { ctx: out_out },
20459 Error::LabS2LabError,
20460 )
20461 }
20462}
20463
20464pub fn lab_2_lab_s(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_Lab2LabS(inp_in, &mut out_out, NULL);
20473 utils::result(
20474 vips_op_response,
20475 VipsImage { ctx: out_out },
20476 Error::Lab2LabSError,
20477 )
20478 }
20479}
20480
20481pub fn rad_2float(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_rad2float(inp_in, &mut out_out, NULL);
20490 utils::result(
20491 vips_op_response,
20492 VipsImage { ctx: out_out },
20493 Error::Rad2FloatError,
20494 )
20495 }
20496}
20497
20498pub fn float_2rad(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_float2rad(inp_in, &mut out_out, NULL);
20507 utils::result(
20508 vips_op_response,
20509 VipsImage { ctx: out_out },
20510 Error::Float2RadError,
20511 )
20512 }
20513}
20514
20515pub fn lab_q_2s_rgb(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_LabQ2sRGB(inp_in, &mut out_out, NULL);
20524 utils::result(
20525 vips_op_response,
20526 VipsImage { ctx: out_out },
20527 Error::LabQ2SRgbError,
20528 )
20529 }
20530}
20531
20532pub fn s_rgb2hsv(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_sRGB2HSV(inp_in, &mut out_out, NULL);
20541 utils::result(
20542 vips_op_response,
20543 VipsImage { ctx: out_out },
20544 Error::SRgb2HsvError,
20545 )
20546 }
20547}
20548
20549pub fn hsv_2s_rgb(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_HSV2sRGB(inp_in, &mut out_out, NULL);
20558 utils::result(
20559 vips_op_response,
20560 VipsImage { ctx: out_out },
20561 Error::Hsv2SRgbError,
20562 )
20563 }
20564}
20565
20566pub fn icc_import(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_icc_import(inp_in, &mut out_out, NULL);
20575 utils::result(
20576 vips_op_response,
20577 VipsImage { ctx: out_out },
20578 Error::IccImportError,
20579 )
20580 }
20581}
20582
20583#[derive(Clone, Debug)]
20585pub struct IccImportOptions {
20586 pub pcs: PCS,
20591 pub intent: Intent,
20598 pub black_point_compensation: bool,
20601 pub embedded: bool,
20604 pub input_profile: String,
20606}
20607
20608impl std::default::Default for IccImportOptions {
20609 fn default() -> Self {
20610 IccImportOptions {
20611 pcs: PCS::Lab,
20612 intent: Intent::Relative,
20613 black_point_compensation: false,
20614 embedded: false,
20615 input_profile: String::new(),
20616 }
20617 }
20618}
20619
20620pub fn icc_import_with_opts(
20625 inp: &VipsImage,
20626 icc_import_options: &IccImportOptions,
20627) -> Result<VipsImage> {
20628 unsafe {
20629 let inp_in: *mut bindings::VipsImage = inp.ctx;
20630 let mut out_out: *mut bindings::VipsImage = null_mut();
20631
20632 let pcs_in: i32 = icc_import_options.pcs as i32;
20633 let pcs_in_name = utils::new_c_string("pcs")?;
20634
20635 let intent_in: i32 = icc_import_options.intent as i32;
20636 let intent_in_name = utils::new_c_string("intent")?;
20637
20638 let black_point_compensation_in: i32 = if icc_import_options.black_point_compensation {
20639 1
20640 } else {
20641 0
20642 };
20643 let black_point_compensation_in_name = utils::new_c_string("black-point-compensation")?;
20644
20645 let embedded_in: i32 = if icc_import_options.embedded { 1 } else { 0 };
20646 let embedded_in_name = utils::new_c_string("embedded")?;
20647
20648 let input_profile_in: CString = utils::new_c_string(&icc_import_options.input_profile)?;
20649 let input_profile_in_name = utils::new_c_string("input-profile")?;
20650
20651 let vips_op_response = bindings::vips_icc_import(
20652 inp_in,
20653 &mut out_out,
20654 pcs_in_name.as_ptr(),
20655 pcs_in,
20656 intent_in_name.as_ptr(),
20657 intent_in,
20658 black_point_compensation_in_name.as_ptr(),
20659 black_point_compensation_in,
20660 embedded_in_name.as_ptr(),
20661 embedded_in,
20662 input_profile_in_name.as_ptr(),
20663 input_profile_in.as_ptr(),
20664 NULL,
20665 );
20666 utils::result(
20667 vips_op_response,
20668 VipsImage { ctx: out_out },
20669 Error::IccImportError,
20670 )
20671 }
20672}
20673
20674pub fn icc_export(inp: &VipsImage) -> Result<VipsImage> {
20678 unsafe {
20679 let inp_in: *mut bindings::VipsImage = inp.ctx;
20680 let mut out_out: *mut bindings::VipsImage = null_mut();
20681
20682 let vips_op_response = bindings::vips_icc_export(inp_in, &mut out_out, NULL);
20683 utils::result(
20684 vips_op_response,
20685 VipsImage { ctx: out_out },
20686 Error::IccExportError,
20687 )
20688 }
20689}
20690
20691#[derive(Clone, Debug)]
20693pub struct IccExportOptions {
20694 pub pcs: PCS,
20699 pub intent: Intent,
20706 pub black_point_compensation: bool,
20709 pub output_profile: String,
20711 pub depth: i32,
20714}
20715
20716impl std::default::Default for IccExportOptions {
20717 fn default() -> Self {
20718 IccExportOptions {
20719 pcs: PCS::Lab,
20720 intent: Intent::Relative,
20721 black_point_compensation: false,
20722 output_profile: String::new(),
20723 depth: i32::from(8),
20724 }
20725 }
20726}
20727
20728pub fn icc_export_with_opts(
20733 inp: &VipsImage,
20734 icc_export_options: &IccExportOptions,
20735) -> Result<VipsImage> {
20736 unsafe {
20737 let inp_in: *mut bindings::VipsImage = inp.ctx;
20738 let mut out_out: *mut bindings::VipsImage = null_mut();
20739
20740 let pcs_in: i32 = icc_export_options.pcs as i32;
20741 let pcs_in_name = utils::new_c_string("pcs")?;
20742
20743 let intent_in: i32 = icc_export_options.intent as i32;
20744 let intent_in_name = utils::new_c_string("intent")?;
20745
20746 let black_point_compensation_in: i32 = if icc_export_options.black_point_compensation {
20747 1
20748 } else {
20749 0
20750 };
20751 let black_point_compensation_in_name = utils::new_c_string("black-point-compensation")?;
20752
20753 let output_profile_in: CString = utils::new_c_string(&icc_export_options.output_profile)?;
20754 let output_profile_in_name = utils::new_c_string("output-profile")?;
20755
20756 let depth_in: i32 = icc_export_options.depth;
20757 let depth_in_name = utils::new_c_string("depth")?;
20758
20759 let vips_op_response = bindings::vips_icc_export(
20760 inp_in,
20761 &mut out_out,
20762 pcs_in_name.as_ptr(),
20763 pcs_in,
20764 intent_in_name.as_ptr(),
20765 intent_in,
20766 black_point_compensation_in_name.as_ptr(),
20767 black_point_compensation_in,
20768 output_profile_in_name.as_ptr(),
20769 output_profile_in.as_ptr(),
20770 depth_in_name.as_ptr(),
20771 depth_in,
20772 NULL,
20773 );
20774 utils::result(
20775 vips_op_response,
20776 VipsImage { ctx: out_out },
20777 Error::IccExportError,
20778 )
20779 }
20780}
20781
20782pub fn icc_transform(inp: &VipsImage, output_profile: &str) -> Result<VipsImage> {
20787 unsafe {
20788 let inp_in: *mut bindings::VipsImage = inp.ctx;
20789 let output_profile_in: CString = utils::new_c_string(output_profile)?;
20790 let mut out_out: *mut bindings::VipsImage = null_mut();
20791
20792 let vips_op_response =
20793 bindings::vips_icc_transform(inp_in, &mut out_out, output_profile_in.as_ptr(), NULL);
20794 utils::result(
20795 vips_op_response,
20796 VipsImage { ctx: out_out },
20797 Error::IccTransformError,
20798 )
20799 }
20800}
20801
20802#[derive(Clone, Debug)]
20804pub struct IccTransformOptions {
20805 pub pcs: PCS,
20810 pub intent: Intent,
20817 pub black_point_compensation: bool,
20820 pub embedded: bool,
20823 pub input_profile: String,
20825 pub depth: i32,
20828}
20829
20830impl std::default::Default for IccTransformOptions {
20831 fn default() -> Self {
20832 IccTransformOptions {
20833 pcs: PCS::Lab,
20834 intent: Intent::Relative,
20835 black_point_compensation: false,
20836 embedded: false,
20837 input_profile: String::new(),
20838 depth: i32::from(8),
20839 }
20840 }
20841}
20842
20843pub fn icc_transform_with_opts(
20849 inp: &VipsImage,
20850 output_profile: &str,
20851 icc_transform_options: &IccTransformOptions,
20852) -> Result<VipsImage> {
20853 unsafe {
20854 let inp_in: *mut bindings::VipsImage = inp.ctx;
20855 let output_profile_in: CString = utils::new_c_string(output_profile)?;
20856 let mut out_out: *mut bindings::VipsImage = null_mut();
20857
20858 let pcs_in: i32 = icc_transform_options.pcs as i32;
20859 let pcs_in_name = utils::new_c_string("pcs")?;
20860
20861 let intent_in: i32 = icc_transform_options.intent as i32;
20862 let intent_in_name = utils::new_c_string("intent")?;
20863
20864 let black_point_compensation_in: i32 = if icc_transform_options.black_point_compensation {
20865 1
20866 } else {
20867 0
20868 };
20869 let black_point_compensation_in_name = utils::new_c_string("black-point-compensation")?;
20870
20871 let embedded_in: i32 = if icc_transform_options.embedded { 1 } else { 0 };
20872 let embedded_in_name = utils::new_c_string("embedded")?;
20873
20874 let input_profile_in: CString = utils::new_c_string(&icc_transform_options.input_profile)?;
20875 let input_profile_in_name = utils::new_c_string("input-profile")?;
20876
20877 let depth_in: i32 = icc_transform_options.depth;
20878 let depth_in_name = utils::new_c_string("depth")?;
20879
20880 let vips_op_response = bindings::vips_icc_transform(
20881 inp_in,
20882 &mut out_out,
20883 output_profile_in.as_ptr(),
20884 pcs_in_name.as_ptr(),
20885 pcs_in,
20886 intent_in_name.as_ptr(),
20887 intent_in,
20888 black_point_compensation_in_name.as_ptr(),
20889 black_point_compensation_in,
20890 embedded_in_name.as_ptr(),
20891 embedded_in,
20892 input_profile_in_name.as_ptr(),
20893 input_profile_in.as_ptr(),
20894 depth_in_name.as_ptr(),
20895 depth_in,
20896 NULL,
20897 );
20898 utils::result(
20899 vips_op_response,
20900 VipsImage { ctx: out_out },
20901 Error::IccTransformError,
20902 )
20903 }
20904}
20905
20906pub fn d_e76(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
20911 unsafe {
20912 let left_in: *mut bindings::VipsImage = left.ctx;
20913 let right_in: *mut bindings::VipsImage = right.ctx;
20914 let mut out_out: *mut bindings::VipsImage = null_mut();
20915
20916 let vips_op_response = bindings::vips_dE76(left_in, right_in, &mut out_out, NULL);
20917 utils::result(
20918 vips_op_response,
20919 VipsImage { ctx: out_out },
20920 Error::DE76Error,
20921 )
20922 }
20923}
20924
20925pub fn d_e00(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
20930 unsafe {
20931 let left_in: *mut bindings::VipsImage = left.ctx;
20932 let right_in: *mut bindings::VipsImage = right.ctx;
20933 let mut out_out: *mut bindings::VipsImage = null_mut();
20934
20935 let vips_op_response = bindings::vips_dE00(left_in, right_in, &mut out_out, NULL);
20936 utils::result(
20937 vips_op_response,
20938 VipsImage { ctx: out_out },
20939 Error::DE00Error,
20940 )
20941 }
20942}
20943
20944pub fn d_ecmc(left: &VipsImage, right: &VipsImage) -> Result<VipsImage> {
20949 unsafe {
20950 let left_in: *mut bindings::VipsImage = left.ctx;
20951 let right_in: *mut bindings::VipsImage = right.ctx;
20952 let mut out_out: *mut bindings::VipsImage = null_mut();
20953
20954 let vips_op_response = bindings::vips_dECMC(left_in, right_in, &mut out_out, NULL);
20955 utils::result(
20956 vips_op_response,
20957 VipsImage { ctx: out_out },
20958 Error::DEcmcError,
20959 )
20960 }
20961}
20962
20963pub fn s_rgb_2sc_rgb(inp: &VipsImage) -> Result<VipsImage> {
20967 unsafe {
20968 let inp_in: *mut bindings::VipsImage = inp.ctx;
20969 let mut out_out: *mut bindings::VipsImage = null_mut();
20970
20971 let vips_op_response = bindings::vips_sRGB2scRGB(inp_in, &mut out_out, NULL);
20972 utils::result(
20973 vips_op_response,
20974 VipsImage { ctx: out_out },
20975 Error::SRgb2ScRgbError,
20976 )
20977 }
20978}
20979
20980pub fn sc_rgb2xyz(inp: &VipsImage) -> Result<VipsImage> {
20984 unsafe {
20985 let inp_in: *mut bindings::VipsImage = inp.ctx;
20986 let mut out_out: *mut bindings::VipsImage = null_mut();
20987
20988 let vips_op_response = bindings::vips_scRGB2XYZ(inp_in, &mut out_out, NULL);
20989 utils::result(
20990 vips_op_response,
20991 VipsImage { ctx: out_out },
20992 Error::ScRgb2XyzError,
20993 )
20994 }
20995}
20996
20997pub fn sc_rgb2bw(inp: &VipsImage) -> Result<VipsImage> {
21001 unsafe {
21002 let inp_in: *mut bindings::VipsImage = inp.ctx;
21003 let mut out_out: *mut bindings::VipsImage = null_mut();
21004
21005 let vips_op_response = bindings::vips_scRGB2BW(inp_in, &mut out_out, NULL);
21006 utils::result(
21007 vips_op_response,
21008 VipsImage { ctx: out_out },
21009 Error::ScRgb2BwError,
21010 )
21011 }
21012}
21013
21014#[derive(Clone, Debug)]
21016pub struct ScRgb2BwOptions {
21017 pub depth: i32,
21020}
21021
21022impl std::default::Default for ScRgb2BwOptions {
21023 fn default() -> Self {
21024 ScRgb2BwOptions {
21025 depth: i32::from(8),
21026 }
21027 }
21028}
21029
21030pub fn sc_rgb2bw_with_opts(
21035 inp: &VipsImage,
21036 sc_rgb_2bw_options: &ScRgb2BwOptions,
21037) -> Result<VipsImage> {
21038 unsafe {
21039 let inp_in: *mut bindings::VipsImage = inp.ctx;
21040 let mut out_out: *mut bindings::VipsImage = null_mut();
21041
21042 let depth_in: i32 = sc_rgb_2bw_options.depth;
21043 let depth_in_name = utils::new_c_string("depth")?;
21044
21045 let vips_op_response =
21046 bindings::vips_scRGB2BW(inp_in, &mut out_out, depth_in_name.as_ptr(), depth_in, NULL);
21047 utils::result(
21048 vips_op_response,
21049 VipsImage { ctx: out_out },
21050 Error::ScRgb2BwError,
21051 )
21052 }
21053}
21054
21055pub fn xyz_2sc_rgb(inp: &VipsImage) -> Result<VipsImage> {
21059 unsafe {
21060 let inp_in: *mut bindings::VipsImage = inp.ctx;
21061 let mut out_out: *mut bindings::VipsImage = null_mut();
21062
21063 let vips_op_response = bindings::vips_XYZ2scRGB(inp_in, &mut out_out, NULL);
21064 utils::result(
21065 vips_op_response,
21066 VipsImage { ctx: out_out },
21067 Error::Xyz2ScRgbError,
21068 )
21069 }
21070}
21071
21072pub fn sc_rgb_2s_rgb(inp: &VipsImage) -> Result<VipsImage> {
21076 unsafe {
21077 let inp_in: *mut bindings::VipsImage = inp.ctx;
21078 let mut out_out: *mut bindings::VipsImage = null_mut();
21079
21080 let vips_op_response = bindings::vips_scRGB2sRGB(inp_in, &mut out_out, NULL);
21081 utils::result(
21082 vips_op_response,
21083 VipsImage { ctx: out_out },
21084 Error::ScRgb2SRgbError,
21085 )
21086 }
21087}
21088
21089#[derive(Clone, Debug)]
21091pub struct ScRgb2SRgbOptions {
21092 pub depth: i32,
21095}
21096
21097impl std::default::Default for ScRgb2SRgbOptions {
21098 fn default() -> Self {
21099 ScRgb2SRgbOptions {
21100 depth: i32::from(8),
21101 }
21102 }
21103}
21104
21105pub fn sc_rgb_2s_rgb_with_opts(
21110 inp: &VipsImage,
21111 sc_rgb_2s_rgb_options: &ScRgb2SRgbOptions,
21112) -> Result<VipsImage> {
21113 unsafe {
21114 let inp_in: *mut bindings::VipsImage = inp.ctx;
21115 let mut out_out: *mut bindings::VipsImage = null_mut();
21116
21117 let depth_in: i32 = sc_rgb_2s_rgb_options.depth;
21118 let depth_in_name = utils::new_c_string("depth")?;
21119
21120 let vips_op_response =
21121 bindings::vips_scRGB2sRGB(inp_in, &mut out_out, depth_in_name.as_ptr(), depth_in, NULL);
21122 utils::result(
21123 vips_op_response,
21124 VipsImage { ctx: out_out },
21125 Error::ScRgb2SRgbError,
21126 )
21127 }
21128}
21129
21130pub fn cmyk2xyz(inp: &VipsImage) -> Result<VipsImage> {
21134 unsafe {
21135 let inp_in: *mut bindings::VipsImage = inp.ctx;
21136 let mut out_out: *mut bindings::VipsImage = null_mut();
21137
21138 let vips_op_response = bindings::vips_CMYK2XYZ(inp_in, &mut out_out, NULL);
21139 utils::result(
21140 vips_op_response,
21141 VipsImage { ctx: out_out },
21142 Error::Cmyk2XyzError,
21143 )
21144 }
21145}
21146
21147pub fn xyz2cmyk(inp: &VipsImage) -> Result<VipsImage> {
21151 unsafe {
21152 let inp_in: *mut bindings::VipsImage = inp.ctx;
21153 let mut out_out: *mut bindings::VipsImage = null_mut();
21154
21155 let vips_op_response = bindings::vips_XYZ2CMYK(inp_in, &mut out_out, NULL);
21156 utils::result(
21157 vips_op_response,
21158 VipsImage { ctx: out_out },
21159 Error::Xyz2CmykError,
21160 )
21161 }
21162}
21163
21164pub fn profile_load(name: &str) -> Result<Vec<u8>> {
21168 unsafe {
21169 let name_in: CString = utils::new_c_string(name)?;
21170 let mut profile_out: *mut bindings::VipsBlob = null_mut();
21171
21172 let vips_op_response =
21173 bindings::vips_profile_load(name_in.as_ptr(), &mut profile_out, NULL);
21174 utils::result(
21175 vips_op_response,
21176 VipsBlob { ctx: profile_out }.into(),
21177 Error::ProfileLoadError,
21178 )
21179 }
21180}
21181
21182pub fn maplut(inp: &VipsImage, lut: &VipsImage) -> Result<VipsImage> {
21187 unsafe {
21188 let inp_in: *mut bindings::VipsImage = inp.ctx;
21189 let lut_in: *mut bindings::VipsImage = lut.ctx;
21190 let mut out_out: *mut bindings::VipsImage = null_mut();
21191
21192 let vips_op_response = bindings::vips_maplut(inp_in, &mut out_out, lut_in, NULL);
21193 utils::result(
21194 vips_op_response,
21195 VipsImage { ctx: out_out },
21196 Error::MaplutError,
21197 )
21198 }
21199}
21200
21201#[derive(Clone, Debug)]
21203pub struct MaplutOptions {
21204 pub band: i32,
21207}
21208
21209impl std::default::Default for MaplutOptions {
21210 fn default() -> Self {
21211 MaplutOptions {
21212 band: i32::from(-1),
21213 }
21214 }
21215}
21216
21217pub fn maplut_with_opts(
21223 inp: &VipsImage,
21224 lut: &VipsImage,
21225 maplut_options: &MaplutOptions,
21226) -> Result<VipsImage> {
21227 unsafe {
21228 let inp_in: *mut bindings::VipsImage = inp.ctx;
21229 let lut_in: *mut bindings::VipsImage = lut.ctx;
21230 let mut out_out: *mut bindings::VipsImage = null_mut();
21231
21232 let band_in: i32 = maplut_options.band;
21233 let band_in_name = utils::new_c_string("band")?;
21234
21235 let vips_op_response = bindings::vips_maplut(
21236 inp_in,
21237 &mut out_out,
21238 lut_in,
21239 band_in_name.as_ptr(),
21240 band_in,
21241 NULL,
21242 );
21243 utils::result(
21244 vips_op_response,
21245 VipsImage { ctx: out_out },
21246 Error::MaplutError,
21247 )
21248 }
21249}
21250
21251pub fn percent(inp: &VipsImage, percent: f64) -> Result<i32> {
21257 unsafe {
21258 let inp_in: *mut bindings::VipsImage = inp.ctx;
21259 let percent_in: f64 = percent;
21260 let mut threshold_out: i32 = i32::from(0);
21261
21262 let vips_op_response = bindings::vips_percent(inp_in, percent_in, &mut threshold_out, NULL);
21263 utils::result(vips_op_response, threshold_out, Error::PercentError)
21264 }
21265}
21266
21267pub fn stdif(inp: &VipsImage, width: i32, height: i32) -> Result<VipsImage> {
21275 unsafe {
21276 let inp_in: *mut bindings::VipsImage = inp.ctx;
21277 let width_in: i32 = width;
21278 let height_in: i32 = height;
21279 let mut out_out: *mut bindings::VipsImage = null_mut();
21280
21281 let vips_op_response =
21282 bindings::vips_stdif(inp_in, &mut out_out, width_in, height_in, NULL);
21283 utils::result(
21284 vips_op_response,
21285 VipsImage { ctx: out_out },
21286 Error::StdifError,
21287 )
21288 }
21289}
21290
21291#[derive(Clone, Debug)]
21293pub struct StdifOptions {
21294 pub s_0: f64,
21297 pub b: f64,
21300 pub m_0: f64,
21303 pub a: f64,
21306}
21307
21308impl std::default::Default for StdifOptions {
21309 fn default() -> Self {
21310 StdifOptions {
21311 s_0: f64::from(50),
21312 b: f64::from(0.5),
21313 m_0: f64::from(128),
21314 a: f64::from(0.5),
21315 }
21316 }
21317}
21318
21319pub fn stdif_with_opts(
21328 inp: &VipsImage,
21329 width: i32,
21330 height: i32,
21331 stdif_options: &StdifOptions,
21332) -> Result<VipsImage> {
21333 unsafe {
21334 let inp_in: *mut bindings::VipsImage = inp.ctx;
21335 let width_in: i32 = width;
21336 let height_in: i32 = height;
21337 let mut out_out: *mut bindings::VipsImage = null_mut();
21338
21339 let s_0_in: f64 = stdif_options.s_0;
21340 let s_0_in_name = utils::new_c_string("s0")?;
21341
21342 let b_in: f64 = stdif_options.b;
21343 let b_in_name = utils::new_c_string("b")?;
21344
21345 let m_0_in: f64 = stdif_options.m_0;
21346 let m_0_in_name = utils::new_c_string("m0")?;
21347
21348 let a_in: f64 = stdif_options.a;
21349 let a_in_name = utils::new_c_string("a")?;
21350
21351 let vips_op_response = bindings::vips_stdif(
21352 inp_in,
21353 &mut out_out,
21354 width_in,
21355 height_in,
21356 s_0_in_name.as_ptr(),
21357 s_0_in,
21358 b_in_name.as_ptr(),
21359 b_in,
21360 m_0_in_name.as_ptr(),
21361 m_0_in,
21362 a_in_name.as_ptr(),
21363 a_in,
21364 NULL,
21365 );
21366 utils::result(
21367 vips_op_response,
21368 VipsImage { ctx: out_out },
21369 Error::StdifError,
21370 )
21371 }
21372}
21373
21374pub fn hist_cum(inp: &VipsImage) -> Result<VipsImage> {
21378 unsafe {
21379 let inp_in: *mut bindings::VipsImage = inp.ctx;
21380 let mut out_out: *mut bindings::VipsImage = null_mut();
21381
21382 let vips_op_response = bindings::vips_hist_cum(inp_in, &mut out_out, NULL);
21383 utils::result(
21384 vips_op_response,
21385 VipsImage { ctx: out_out },
21386 Error::HistCumError,
21387 )
21388 }
21389}
21390
21391pub fn hist_match(inp: &VipsImage, refp: &VipsImage) -> Result<VipsImage> {
21396 unsafe {
21397 let inp_in: *mut bindings::VipsImage = inp.ctx;
21398 let refp_in: *mut bindings::VipsImage = refp.ctx;
21399 let mut out_out: *mut bindings::VipsImage = null_mut();
21400
21401 let vips_op_response = bindings::vips_hist_match(inp_in, refp_in, &mut out_out, NULL);
21402 utils::result(
21403 vips_op_response,
21404 VipsImage { ctx: out_out },
21405 Error::HistMatchError,
21406 )
21407 }
21408}
21409
21410pub fn hist_norm(inp: &VipsImage) -> Result<VipsImage> {
21414 unsafe {
21415 let inp_in: *mut bindings::VipsImage = inp.ctx;
21416 let mut out_out: *mut bindings::VipsImage = null_mut();
21417
21418 let vips_op_response = bindings::vips_hist_norm(inp_in, &mut out_out, NULL);
21419 utils::result(
21420 vips_op_response,
21421 VipsImage { ctx: out_out },
21422 Error::HistNormError,
21423 )
21424 }
21425}
21426
21427pub fn hist_equal(inp: &VipsImage) -> Result<VipsImage> {
21431 unsafe {
21432 let inp_in: *mut bindings::VipsImage = inp.ctx;
21433 let mut out_out: *mut bindings::VipsImage = null_mut();
21434
21435 let vips_op_response = bindings::vips_hist_equal(inp_in, &mut out_out, NULL);
21436 utils::result(
21437 vips_op_response,
21438 VipsImage { ctx: out_out },
21439 Error::HistEqualError,
21440 )
21441 }
21442}
21443
21444#[derive(Clone, Debug)]
21446pub struct HistEqualOptions {
21447 pub band: i32,
21450}
21451
21452impl std::default::Default for HistEqualOptions {
21453 fn default() -> Self {
21454 HistEqualOptions {
21455 band: i32::from(-1),
21456 }
21457 }
21458}
21459
21460pub fn hist_equal_with_opts(
21465 inp: &VipsImage,
21466 hist_equal_options: &HistEqualOptions,
21467) -> Result<VipsImage> {
21468 unsafe {
21469 let inp_in: *mut bindings::VipsImage = inp.ctx;
21470 let mut out_out: *mut bindings::VipsImage = null_mut();
21471
21472 let band_in: i32 = hist_equal_options.band;
21473 let band_in_name = utils::new_c_string("band")?;
21474
21475 let vips_op_response =
21476 bindings::vips_hist_equal(inp_in, &mut out_out, band_in_name.as_ptr(), band_in, NULL);
21477 utils::result(
21478 vips_op_response,
21479 VipsImage { ctx: out_out },
21480 Error::HistEqualError,
21481 )
21482 }
21483}
21484
21485pub fn hist_plot(inp: &VipsImage) -> Result<VipsImage> {
21489 unsafe {
21490 let inp_in: *mut bindings::VipsImage = inp.ctx;
21491 let mut out_out: *mut bindings::VipsImage = null_mut();
21492
21493 let vips_op_response = bindings::vips_hist_plot(inp_in, &mut out_out, NULL);
21494 utils::result(
21495 vips_op_response,
21496 VipsImage { ctx: out_out },
21497 Error::HistPlotError,
21498 )
21499 }
21500}
21501
21502pub fn hist_local(inp: &VipsImage, width: i32, height: i32) -> Result<VipsImage> {
21510 unsafe {
21511 let inp_in: *mut bindings::VipsImage = inp.ctx;
21512 let width_in: i32 = width;
21513 let height_in: i32 = height;
21514 let mut out_out: *mut bindings::VipsImage = null_mut();
21515
21516 let vips_op_response =
21517 bindings::vips_hist_local(inp_in, &mut out_out, width_in, height_in, NULL);
21518 utils::result(
21519 vips_op_response,
21520 VipsImage { ctx: out_out },
21521 Error::HistLocalError,
21522 )
21523 }
21524}
21525
21526#[derive(Clone, Debug)]
21528pub struct HistLocalOptions {
21529 pub max_slope: i32,
21532}
21533
21534impl std::default::Default for HistLocalOptions {
21535 fn default() -> Self {
21536 HistLocalOptions {
21537 max_slope: i32::from(0),
21538 }
21539 }
21540}
21541
21542pub fn hist_local_with_opts(
21551 inp: &VipsImage,
21552 width: i32,
21553 height: i32,
21554 hist_local_options: &HistLocalOptions,
21555) -> Result<VipsImage> {
21556 unsafe {
21557 let inp_in: *mut bindings::VipsImage = inp.ctx;
21558 let width_in: i32 = width;
21559 let height_in: i32 = height;
21560 let mut out_out: *mut bindings::VipsImage = null_mut();
21561
21562 let max_slope_in: i32 = hist_local_options.max_slope;
21563 let max_slope_in_name = utils::new_c_string("max-slope")?;
21564
21565 let vips_op_response = bindings::vips_hist_local(
21566 inp_in,
21567 &mut out_out,
21568 width_in,
21569 height_in,
21570 max_slope_in_name.as_ptr(),
21571 max_slope_in,
21572 NULL,
21573 );
21574 utils::result(
21575 vips_op_response,
21576 VipsImage { ctx: out_out },
21577 Error::HistLocalError,
21578 )
21579 }
21580}
21581
21582pub fn hist_ismonotonic(inp: &VipsImage) -> Result<bool> {
21586 unsafe {
21587 let inp_in: *mut bindings::VipsImage = inp.ctx;
21588 let mut monotonic_out: i32 = 0;
21589
21590 let vips_op_response = bindings::vips_hist_ismonotonic(inp_in, &mut monotonic_out, NULL);
21591 utils::result(
21592 vips_op_response,
21593 monotonic_out != 0,
21594 Error::HistIsmonotonicError,
21595 )
21596 }
21597}
21598
21599pub fn hist_entropy(inp: &VipsImage) -> Result<f64> {
21603 unsafe {
21604 let inp_in: *mut bindings::VipsImage = inp.ctx;
21605 let mut out_out: f64 = f64::from(0);
21606
21607 let vips_op_response = bindings::vips_hist_entropy(inp_in, &mut out_out, NULL);
21608 utils::result(vips_op_response, out_out, Error::HistEntropyError)
21609 }
21610}
21611
21612pub fn conv(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21617 unsafe {
21618 let inp_in: *mut bindings::VipsImage = inp.ctx;
21619 let mask_in: *mut bindings::VipsImage = mask.ctx;
21620 let mut out_out: *mut bindings::VipsImage = null_mut();
21621
21622 let vips_op_response = bindings::vips_conv(inp_in, &mut out_out, mask_in, NULL);
21623 utils::result(
21624 vips_op_response,
21625 VipsImage { ctx: out_out },
21626 Error::ConvError,
21627 )
21628 }
21629}
21630
21631#[derive(Clone, Debug)]
21633pub struct ConvOptions {
21634 pub precision: Precision,
21640 pub layers: i32,
21643 pub cluster: i32,
21646}
21647
21648impl std::default::Default for ConvOptions {
21649 fn default() -> Self {
21650 ConvOptions {
21651 precision: Precision::Float,
21652 layers: i32::from(5),
21653 cluster: i32::from(1),
21654 }
21655 }
21656}
21657
21658pub fn conv_with_opts(
21664 inp: &VipsImage,
21665 mask: &VipsImage,
21666 conv_options: &ConvOptions,
21667) -> Result<VipsImage> {
21668 unsafe {
21669 let inp_in: *mut bindings::VipsImage = inp.ctx;
21670 let mask_in: *mut bindings::VipsImage = mask.ctx;
21671 let mut out_out: *mut bindings::VipsImage = null_mut();
21672
21673 let precision_in: i32 = conv_options.precision as i32;
21674 let precision_in_name = utils::new_c_string("precision")?;
21675
21676 let layers_in: i32 = conv_options.layers;
21677 let layers_in_name = utils::new_c_string("layers")?;
21678
21679 let cluster_in: i32 = conv_options.cluster;
21680 let cluster_in_name = utils::new_c_string("cluster")?;
21681
21682 let vips_op_response = bindings::vips_conv(
21683 inp_in,
21684 &mut out_out,
21685 mask_in,
21686 precision_in_name.as_ptr(),
21687 precision_in,
21688 layers_in_name.as_ptr(),
21689 layers_in,
21690 cluster_in_name.as_ptr(),
21691 cluster_in,
21692 NULL,
21693 );
21694 utils::result(
21695 vips_op_response,
21696 VipsImage { ctx: out_out },
21697 Error::ConvError,
21698 )
21699 }
21700}
21701
21702pub fn conva(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21707 unsafe {
21708 let inp_in: *mut bindings::VipsImage = inp.ctx;
21709 let mask_in: *mut bindings::VipsImage = mask.ctx;
21710 let mut out_out: *mut bindings::VipsImage = null_mut();
21711
21712 let vips_op_response = bindings::vips_conva(inp_in, &mut out_out, mask_in, NULL);
21713 utils::result(
21714 vips_op_response,
21715 VipsImage { ctx: out_out },
21716 Error::ConvaError,
21717 )
21718 }
21719}
21720
21721#[derive(Clone, Debug)]
21723pub struct ConvaOptions {
21724 pub layers: i32,
21727 pub cluster: i32,
21730}
21731
21732impl std::default::Default for ConvaOptions {
21733 fn default() -> Self {
21734 ConvaOptions {
21735 layers: i32::from(5),
21736 cluster: i32::from(1),
21737 }
21738 }
21739}
21740
21741pub fn conva_with_opts(
21747 inp: &VipsImage,
21748 mask: &VipsImage,
21749 conva_options: &ConvaOptions,
21750) -> Result<VipsImage> {
21751 unsafe {
21752 let inp_in: *mut bindings::VipsImage = inp.ctx;
21753 let mask_in: *mut bindings::VipsImage = mask.ctx;
21754 let mut out_out: *mut bindings::VipsImage = null_mut();
21755
21756 let layers_in: i32 = conva_options.layers;
21757 let layers_in_name = utils::new_c_string("layers")?;
21758
21759 let cluster_in: i32 = conva_options.cluster;
21760 let cluster_in_name = utils::new_c_string("cluster")?;
21761
21762 let vips_op_response = bindings::vips_conva(
21763 inp_in,
21764 &mut out_out,
21765 mask_in,
21766 layers_in_name.as_ptr(),
21767 layers_in,
21768 cluster_in_name.as_ptr(),
21769 cluster_in,
21770 NULL,
21771 );
21772 utils::result(
21773 vips_op_response,
21774 VipsImage { ctx: out_out },
21775 Error::ConvaError,
21776 )
21777 }
21778}
21779
21780pub fn convf(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21785 unsafe {
21786 let inp_in: *mut bindings::VipsImage = inp.ctx;
21787 let mask_in: *mut bindings::VipsImage = mask.ctx;
21788 let mut out_out: *mut bindings::VipsImage = null_mut();
21789
21790 let vips_op_response = bindings::vips_convf(inp_in, &mut out_out, mask_in, NULL);
21791 utils::result(
21792 vips_op_response,
21793 VipsImage { ctx: out_out },
21794 Error::ConvfError,
21795 )
21796 }
21797}
21798
21799pub fn convi(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21804 unsafe {
21805 let inp_in: *mut bindings::VipsImage = inp.ctx;
21806 let mask_in: *mut bindings::VipsImage = mask.ctx;
21807 let mut out_out: *mut bindings::VipsImage = null_mut();
21808
21809 let vips_op_response = bindings::vips_convi(inp_in, &mut out_out, mask_in, NULL);
21810 utils::result(
21811 vips_op_response,
21812 VipsImage { ctx: out_out },
21813 Error::ConviError,
21814 )
21815 }
21816}
21817
21818pub fn compass(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
21823 unsafe {
21824 let inp_in: *mut bindings::VipsImage = inp.ctx;
21825 let mask_in: *mut bindings::VipsImage = mask.ctx;
21826 let mut out_out: *mut bindings::VipsImage = null_mut();
21827
21828 let vips_op_response = bindings::vips_compass(inp_in, &mut out_out, mask_in, NULL);
21829 utils::result(
21830 vips_op_response,
21831 VipsImage { ctx: out_out },
21832 Error::CompassError,
21833 )
21834 }
21835}
21836
21837#[derive(Clone, Debug)]
21839pub struct CompassOptions {
21840 pub times: i32,
21843 pub angle: Angle45,
21854 pub combine: Combine,
21860 pub precision: Precision,
21866 pub layers: i32,
21869 pub cluster: i32,
21872}
21873
21874impl std::default::Default for CompassOptions {
21875 fn default() -> Self {
21876 CompassOptions {
21877 times: i32::from(2),
21878 angle: Angle45::D90,
21879 combine: Combine::Max,
21880 precision: Precision::Float,
21881 layers: i32::from(5),
21882 cluster: i32::from(1),
21883 }
21884 }
21885}
21886
21887pub fn compass_with_opts(
21893 inp: &VipsImage,
21894 mask: &VipsImage,
21895 compass_options: &CompassOptions,
21896) -> Result<VipsImage> {
21897 unsafe {
21898 let inp_in: *mut bindings::VipsImage = inp.ctx;
21899 let mask_in: *mut bindings::VipsImage = mask.ctx;
21900 let mut out_out: *mut bindings::VipsImage = null_mut();
21901
21902 let times_in: i32 = compass_options.times;
21903 let times_in_name = utils::new_c_string("times")?;
21904
21905 let angle_in: i32 = compass_options.angle as i32;
21906 let angle_in_name = utils::new_c_string("angle")?;
21907
21908 let combine_in: i32 = compass_options.combine as i32;
21909 let combine_in_name = utils::new_c_string("combine")?;
21910
21911 let precision_in: i32 = compass_options.precision as i32;
21912 let precision_in_name = utils::new_c_string("precision")?;
21913
21914 let layers_in: i32 = compass_options.layers;
21915 let layers_in_name = utils::new_c_string("layers")?;
21916
21917 let cluster_in: i32 = compass_options.cluster;
21918 let cluster_in_name = utils::new_c_string("cluster")?;
21919
21920 let vips_op_response = bindings::vips_compass(
21921 inp_in,
21922 &mut out_out,
21923 mask_in,
21924 times_in_name.as_ptr(),
21925 times_in,
21926 angle_in_name.as_ptr(),
21927 angle_in,
21928 combine_in_name.as_ptr(),
21929 combine_in,
21930 precision_in_name.as_ptr(),
21931 precision_in,
21932 layers_in_name.as_ptr(),
21933 layers_in,
21934 cluster_in_name.as_ptr(),
21935 cluster_in,
21936 NULL,
21937 );
21938 utils::result(
21939 vips_op_response,
21940 VipsImage { ctx: out_out },
21941 Error::CompassError,
21942 )
21943 }
21944}
21945
21946pub fn convsep(inp: &VipsImage, mask: &VipsImage) -> 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 vips_op_response = bindings::vips_convsep(inp_in, &mut out_out, mask_in, NULL);
21957 utils::result(
21958 vips_op_response,
21959 VipsImage { ctx: out_out },
21960 Error::ConvsepError,
21961 )
21962 }
21963}
21964
21965#[derive(Clone, Debug)]
21967pub struct ConvsepOptions {
21968 pub precision: Precision,
21974 pub layers: i32,
21977 pub cluster: i32,
21980}
21981
21982impl std::default::Default for ConvsepOptions {
21983 fn default() -> Self {
21984 ConvsepOptions {
21985 precision: Precision::Float,
21986 layers: i32::from(5),
21987 cluster: i32::from(1),
21988 }
21989 }
21990}
21991
21992pub fn convsep_with_opts(
21998 inp: &VipsImage,
21999 mask: &VipsImage,
22000 convsep_options: &ConvsepOptions,
22001) -> Result<VipsImage> {
22002 unsafe {
22003 let inp_in: *mut bindings::VipsImage = inp.ctx;
22004 let mask_in: *mut bindings::VipsImage = mask.ctx;
22005 let mut out_out: *mut bindings::VipsImage = null_mut();
22006
22007 let precision_in: i32 = convsep_options.precision as i32;
22008 let precision_in_name = utils::new_c_string("precision")?;
22009
22010 let layers_in: i32 = convsep_options.layers;
22011 let layers_in_name = utils::new_c_string("layers")?;
22012
22013 let cluster_in: i32 = convsep_options.cluster;
22014 let cluster_in_name = utils::new_c_string("cluster")?;
22015
22016 let vips_op_response = bindings::vips_convsep(
22017 inp_in,
22018 &mut out_out,
22019 mask_in,
22020 precision_in_name.as_ptr(),
22021 precision_in,
22022 layers_in_name.as_ptr(),
22023 layers_in,
22024 cluster_in_name.as_ptr(),
22025 cluster_in,
22026 NULL,
22027 );
22028 utils::result(
22029 vips_op_response,
22030 VipsImage { ctx: out_out },
22031 Error::ConvsepError,
22032 )
22033 }
22034}
22035
22036pub fn convasep(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22041 unsafe {
22042 let inp_in: *mut bindings::VipsImage = inp.ctx;
22043 let mask_in: *mut bindings::VipsImage = mask.ctx;
22044 let mut out_out: *mut bindings::VipsImage = null_mut();
22045
22046 let vips_op_response = bindings::vips_convasep(inp_in, &mut out_out, mask_in, NULL);
22047 utils::result(
22048 vips_op_response,
22049 VipsImage { ctx: out_out },
22050 Error::ConvasepError,
22051 )
22052 }
22053}
22054
22055#[derive(Clone, Debug)]
22057pub struct ConvasepOptions {
22058 pub layers: i32,
22061}
22062
22063impl std::default::Default for ConvasepOptions {
22064 fn default() -> Self {
22065 ConvasepOptions {
22066 layers: i32::from(5),
22067 }
22068 }
22069}
22070
22071pub fn convasep_with_opts(
22077 inp: &VipsImage,
22078 mask: &VipsImage,
22079 convasep_options: &ConvasepOptions,
22080) -> Result<VipsImage> {
22081 unsafe {
22082 let inp_in: *mut bindings::VipsImage = inp.ctx;
22083 let mask_in: *mut bindings::VipsImage = mask.ctx;
22084 let mut out_out: *mut bindings::VipsImage = null_mut();
22085
22086 let layers_in: i32 = convasep_options.layers;
22087 let layers_in_name = utils::new_c_string("layers")?;
22088
22089 let vips_op_response = bindings::vips_convasep(
22090 inp_in,
22091 &mut out_out,
22092 mask_in,
22093 layers_in_name.as_ptr(),
22094 layers_in,
22095 NULL,
22096 );
22097 utils::result(
22098 vips_op_response,
22099 VipsImage { ctx: out_out },
22100 Error::ConvasepError,
22101 )
22102 }
22103}
22104
22105pub fn fastcor(inp: &VipsImage, refp: &VipsImage) -> Result<VipsImage> {
22110 unsafe {
22111 let inp_in: *mut bindings::VipsImage = inp.ctx;
22112 let refp_in: *mut bindings::VipsImage = refp.ctx;
22113 let mut out_out: *mut bindings::VipsImage = null_mut();
22114
22115 let vips_op_response = bindings::vips_fastcor(inp_in, refp_in, &mut out_out, NULL);
22116 utils::result(
22117 vips_op_response,
22118 VipsImage { ctx: out_out },
22119 Error::FastcorError,
22120 )
22121 }
22122}
22123
22124pub fn spcor(inp: &VipsImage, refp: &VipsImage) -> Result<VipsImage> {
22129 unsafe {
22130 let inp_in: *mut bindings::VipsImage = inp.ctx;
22131 let refp_in: *mut bindings::VipsImage = refp.ctx;
22132 let mut out_out: *mut bindings::VipsImage = null_mut();
22133
22134 let vips_op_response = bindings::vips_spcor(inp_in, refp_in, &mut out_out, NULL);
22135 utils::result(
22136 vips_op_response,
22137 VipsImage { ctx: out_out },
22138 Error::SpcorError,
22139 )
22140 }
22141}
22142
22143pub fn sharpen(inp: &VipsImage) -> Result<VipsImage> {
22147 unsafe {
22148 let inp_in: *mut bindings::VipsImage = inp.ctx;
22149 let mut out_out: *mut bindings::VipsImage = null_mut();
22150
22151 let vips_op_response = bindings::vips_sharpen(inp_in, &mut out_out, NULL);
22152 utils::result(
22153 vips_op_response,
22154 VipsImage { ctx: out_out },
22155 Error::SharpenError,
22156 )
22157 }
22158}
22159
22160#[derive(Clone, Debug)]
22162pub struct SharpenOptions {
22163 pub sigma: f64,
22166 pub x_1: f64,
22169 pub y_2: f64,
22172 pub y_3: f64,
22175 pub m_1: f64,
22178 pub m_2: f64,
22181}
22182
22183impl std::default::Default for SharpenOptions {
22184 fn default() -> Self {
22185 SharpenOptions {
22186 sigma: f64::from(0.5),
22187 x_1: f64::from(2),
22188 y_2: f64::from(10),
22189 y_3: f64::from(20),
22190 m_1: f64::from(0),
22191 m_2: f64::from(3),
22192 }
22193 }
22194}
22195
22196pub fn sharpen_with_opts(inp: &VipsImage, sharpen_options: &SharpenOptions) -> Result<VipsImage> {
22201 unsafe {
22202 let inp_in: *mut bindings::VipsImage = inp.ctx;
22203 let mut out_out: *mut bindings::VipsImage = null_mut();
22204
22205 let sigma_in: f64 = sharpen_options.sigma;
22206 let sigma_in_name = utils::new_c_string("sigma")?;
22207
22208 let x_1_in: f64 = sharpen_options.x_1;
22209 let x_1_in_name = utils::new_c_string("x1")?;
22210
22211 let y_2_in: f64 = sharpen_options.y_2;
22212 let y_2_in_name = utils::new_c_string("y2")?;
22213
22214 let y_3_in: f64 = sharpen_options.y_3;
22215 let y_3_in_name = utils::new_c_string("y3")?;
22216
22217 let m_1_in: f64 = sharpen_options.m_1;
22218 let m_1_in_name = utils::new_c_string("m1")?;
22219
22220 let m_2_in: f64 = sharpen_options.m_2;
22221 let m_2_in_name = utils::new_c_string("m2")?;
22222
22223 let vips_op_response = bindings::vips_sharpen(
22224 inp_in,
22225 &mut out_out,
22226 sigma_in_name.as_ptr(),
22227 sigma_in,
22228 x_1_in_name.as_ptr(),
22229 x_1_in,
22230 y_2_in_name.as_ptr(),
22231 y_2_in,
22232 y_3_in_name.as_ptr(),
22233 y_3_in,
22234 m_1_in_name.as_ptr(),
22235 m_1_in,
22236 m_2_in_name.as_ptr(),
22237 m_2_in,
22238 NULL,
22239 );
22240 utils::result(
22241 vips_op_response,
22242 VipsImage { ctx: out_out },
22243 Error::SharpenError,
22244 )
22245 }
22246}
22247
22248pub fn gaussblur(inp: &VipsImage, sigma: f64) -> Result<VipsImage> {
22254 unsafe {
22255 let inp_in: *mut bindings::VipsImage = inp.ctx;
22256 let sigma_in: f64 = sigma;
22257 let mut out_out: *mut bindings::VipsImage = null_mut();
22258
22259 let vips_op_response = bindings::vips_gaussblur(inp_in, &mut out_out, sigma_in, NULL);
22260 utils::result(
22261 vips_op_response,
22262 VipsImage { ctx: out_out },
22263 Error::GaussblurError,
22264 )
22265 }
22266}
22267
22268#[derive(Clone, Debug)]
22270pub struct GaussblurOptions {
22271 pub min_ampl: f64,
22274 pub precision: Precision,
22280}
22281
22282impl std::default::Default for GaussblurOptions {
22283 fn default() -> Self {
22284 GaussblurOptions {
22285 min_ampl: f64::from(0.2),
22286 precision: Precision::Integer,
22287 }
22288 }
22289}
22290
22291pub fn gaussblur_with_opts(
22298 inp: &VipsImage,
22299 sigma: f64,
22300 gaussblur_options: &GaussblurOptions,
22301) -> Result<VipsImage> {
22302 unsafe {
22303 let inp_in: *mut bindings::VipsImage = inp.ctx;
22304 let sigma_in: f64 = sigma;
22305 let mut out_out: *mut bindings::VipsImage = null_mut();
22306
22307 let min_ampl_in: f64 = gaussblur_options.min_ampl;
22308 let min_ampl_in_name = utils::new_c_string("min-ampl")?;
22309
22310 let precision_in: i32 = gaussblur_options.precision as i32;
22311 let precision_in_name = utils::new_c_string("precision")?;
22312
22313 let vips_op_response = bindings::vips_gaussblur(
22314 inp_in,
22315 &mut out_out,
22316 sigma_in,
22317 min_ampl_in_name.as_ptr(),
22318 min_ampl_in,
22319 precision_in_name.as_ptr(),
22320 precision_in,
22321 NULL,
22322 );
22323 utils::result(
22324 vips_op_response,
22325 VipsImage { ctx: out_out },
22326 Error::GaussblurError,
22327 )
22328 }
22329}
22330
22331pub fn sobel(inp: &VipsImage) -> Result<VipsImage> {
22335 unsafe {
22336 let inp_in: *mut bindings::VipsImage = inp.ctx;
22337 let mut out_out: *mut bindings::VipsImage = null_mut();
22338
22339 let vips_op_response = bindings::vips_sobel(inp_in, &mut out_out, NULL);
22340 utils::result(
22341 vips_op_response,
22342 VipsImage { ctx: out_out },
22343 Error::SobelError,
22344 )
22345 }
22346}
22347
22348pub fn scharr(inp: &VipsImage) -> Result<VipsImage> {
22352 unsafe {
22353 let inp_in: *mut bindings::VipsImage = inp.ctx;
22354 let mut out_out: *mut bindings::VipsImage = null_mut();
22355
22356 let vips_op_response = bindings::vips_scharr(inp_in, &mut out_out, NULL);
22357 utils::result(
22358 vips_op_response,
22359 VipsImage { ctx: out_out },
22360 Error::ScharrError,
22361 )
22362 }
22363}
22364
22365pub fn prewitt(inp: &VipsImage) -> Result<VipsImage> {
22369 unsafe {
22370 let inp_in: *mut bindings::VipsImage = inp.ctx;
22371 let mut out_out: *mut bindings::VipsImage = null_mut();
22372
22373 let vips_op_response = bindings::vips_prewitt(inp_in, &mut out_out, NULL);
22374 utils::result(
22375 vips_op_response,
22376 VipsImage { ctx: out_out },
22377 Error::PrewittError,
22378 )
22379 }
22380}
22381
22382pub fn canny(inp: &VipsImage) -> Result<VipsImage> {
22386 unsafe {
22387 let inp_in: *mut bindings::VipsImage = inp.ctx;
22388 let mut out_out: *mut bindings::VipsImage = null_mut();
22389
22390 let vips_op_response = bindings::vips_canny(inp_in, &mut out_out, NULL);
22391 utils::result(
22392 vips_op_response,
22393 VipsImage { ctx: out_out },
22394 Error::CannyError,
22395 )
22396 }
22397}
22398
22399#[derive(Clone, Debug)]
22401pub struct CannyOptions {
22402 pub sigma: f64,
22405 pub precision: Precision,
22411}
22412
22413impl std::default::Default for CannyOptions {
22414 fn default() -> Self {
22415 CannyOptions {
22416 sigma: f64::from(1.4),
22417 precision: Precision::Float,
22418 }
22419 }
22420}
22421
22422pub fn canny_with_opts(inp: &VipsImage, canny_options: &CannyOptions) -> Result<VipsImage> {
22427 unsafe {
22428 let inp_in: *mut bindings::VipsImage = inp.ctx;
22429 let mut out_out: *mut bindings::VipsImage = null_mut();
22430
22431 let sigma_in: f64 = canny_options.sigma;
22432 let sigma_in_name = utils::new_c_string("sigma")?;
22433
22434 let precision_in: i32 = canny_options.precision as i32;
22435 let precision_in_name = utils::new_c_string("precision")?;
22436
22437 let vips_op_response = bindings::vips_canny(
22438 inp_in,
22439 &mut out_out,
22440 sigma_in_name.as_ptr(),
22441 sigma_in,
22442 precision_in_name.as_ptr(),
22443 precision_in,
22444 NULL,
22445 );
22446 utils::result(
22447 vips_op_response,
22448 VipsImage { ctx: out_out },
22449 Error::CannyError,
22450 )
22451 }
22452}
22453
22454pub fn fwfft(inp: &VipsImage) -> Result<VipsImage> {
22458 unsafe {
22459 let inp_in: *mut bindings::VipsImage = inp.ctx;
22460 let mut out_out: *mut bindings::VipsImage = null_mut();
22461
22462 let vips_op_response = bindings::vips_fwfft(inp_in, &mut out_out, NULL);
22463 utils::result(
22464 vips_op_response,
22465 VipsImage { ctx: out_out },
22466 Error::FwfftError,
22467 )
22468 }
22469}
22470
22471pub fn invfft(inp: &VipsImage) -> Result<VipsImage> {
22475 unsafe {
22476 let inp_in: *mut bindings::VipsImage = inp.ctx;
22477 let mut out_out: *mut bindings::VipsImage = null_mut();
22478
22479 let vips_op_response = bindings::vips_invfft(inp_in, &mut out_out, NULL);
22480 utils::result(
22481 vips_op_response,
22482 VipsImage { ctx: out_out },
22483 Error::InvfftError,
22484 )
22485 }
22486}
22487
22488#[derive(Clone, Debug)]
22490pub struct InvfftOptions {
22491 pub real: bool,
22494}
22495
22496impl std::default::Default for InvfftOptions {
22497 fn default() -> Self {
22498 InvfftOptions { real: false }
22499 }
22500}
22501
22502pub fn invfft_with_opts(inp: &VipsImage, invfft_options: &InvfftOptions) -> Result<VipsImage> {
22507 unsafe {
22508 let inp_in: *mut bindings::VipsImage = inp.ctx;
22509 let mut out_out: *mut bindings::VipsImage = null_mut();
22510
22511 let real_in: i32 = if invfft_options.real { 1 } else { 0 };
22512 let real_in_name = utils::new_c_string("real")?;
22513
22514 let vips_op_response =
22515 bindings::vips_invfft(inp_in, &mut out_out, real_in_name.as_ptr(), real_in, NULL);
22516 utils::result(
22517 vips_op_response,
22518 VipsImage { ctx: out_out },
22519 Error::InvfftError,
22520 )
22521 }
22522}
22523
22524pub fn freqmult(inp: &VipsImage, mask: &VipsImage) -> Result<VipsImage> {
22529 unsafe {
22530 let inp_in: *mut bindings::VipsImage = inp.ctx;
22531 let mask_in: *mut bindings::VipsImage = mask.ctx;
22532 let mut out_out: *mut bindings::VipsImage = null_mut();
22533
22534 let vips_op_response = bindings::vips_freqmult(inp_in, mask_in, &mut out_out, NULL);
22535 utils::result(
22536 vips_op_response,
22537 VipsImage { ctx: out_out },
22538 Error::FreqmultError,
22539 )
22540 }
22541}
22542
22543pub fn spectrum(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_spectrum(inp_in, &mut out_out, NULL);
22552 utils::result(
22553 vips_op_response,
22554 VipsImage { ctx: out_out },
22555 Error::SpectrumError,
22556 )
22557 }
22558}
22559
22560pub fn phasecor(inp: &VipsImage, in_2: &VipsImage) -> Result<VipsImage> {
22565 unsafe {
22566 let inp_in: *mut bindings::VipsImage = inp.ctx;
22567 let in_2_in: *mut bindings::VipsImage = in_2.ctx;
22568 let mut out_out: *mut bindings::VipsImage = null_mut();
22569
22570 let vips_op_response = bindings::vips_phasecor(inp_in, in_2_in, &mut out_out, NULL);
22571 utils::result(
22572 vips_op_response,
22573 VipsImage { ctx: out_out },
22574 Error::PhasecorError,
22575 )
22576 }
22577}
22578
22579pub fn morph(inp: &VipsImage, mask: &VipsImage, morph: OperationMorphology) -> Result<VipsImage> {
22588 unsafe {
22589 let inp_in: *mut bindings::VipsImage = inp.ctx;
22590 let mask_in: *mut bindings::VipsImage = mask.ctx;
22591 let morph_in: i32 = morph as i32;
22592 let mut out_out: *mut bindings::VipsImage = null_mut();
22593
22594 let vips_op_response = bindings::vips_morph(
22595 inp_in,
22596 &mut out_out,
22597 mask_in,
22598 morph_in.try_into().unwrap(),
22599 NULL,
22600 );
22601 utils::result(
22602 vips_op_response,
22603 VipsImage { ctx: out_out },
22604 Error::MorphError,
22605 )
22606 }
22607}
22608
22609pub fn rank(inp: &VipsImage, width: i32, height: i32, index: i32) -> Result<VipsImage> {
22619 unsafe {
22620 let inp_in: *mut bindings::VipsImage = inp.ctx;
22621 let width_in: i32 = width;
22622 let height_in: i32 = height;
22623 let index_in: i32 = index;
22624 let mut out_out: *mut bindings::VipsImage = null_mut();
22625
22626 let vips_op_response =
22627 bindings::vips_rank(inp_in, &mut out_out, width_in, height_in, index_in, NULL);
22628 utils::result(
22629 vips_op_response,
22630 VipsImage { ctx: out_out },
22631 Error::RankError,
22632 )
22633 }
22634}
22635
22636pub fn countlines(inp: &VipsImage, direction: Direction) -> Result<f64> {
22644 unsafe {
22645 let inp_in: *mut bindings::VipsImage = inp.ctx;
22646 let direction_in: i32 = direction as i32;
22647 let mut nolines_out: f64 = f64::from(0);
22648
22649 let vips_op_response = bindings::vips_countlines(
22650 inp_in,
22651 &mut nolines_out,
22652 direction_in.try_into().unwrap(),
22653 NULL,
22654 );
22655 utils::result(vips_op_response, nolines_out, Error::CountlineError)
22656 }
22657}
22658
22659pub fn labelregions(inp: &VipsImage) -> Result<VipsImage> {
22663 unsafe {
22664 let inp_in: *mut bindings::VipsImage = inp.ctx;
22665 let mut mask_out: *mut bindings::VipsImage = null_mut();
22666
22667 let vips_op_response = bindings::vips_labelregions(inp_in, &mut mask_out, NULL);
22668 utils::result(
22669 vips_op_response,
22670 VipsImage { ctx: mask_out },
22671 Error::LabelregionError,
22672 )
22673 }
22674}
22675
22676#[derive(Clone, Debug)]
22678pub struct LabelregionOptions {
22679 pub segments: i32,
22682}
22683
22684impl std::default::Default for LabelregionOptions {
22685 fn default() -> Self {
22686 LabelregionOptions {
22687 segments: i32::from(0),
22688 }
22689 }
22690}
22691
22692pub fn labelregions_with_opts(
22697 inp: &VipsImage,
22698 labelregions_options: &LabelregionOptions,
22699) -> Result<VipsImage> {
22700 unsafe {
22701 let inp_in: *mut bindings::VipsImage = inp.ctx;
22702 let mut mask_out: *mut bindings::VipsImage = null_mut();
22703
22704 let segments_in: i32 = labelregions_options.segments;
22705 let segments_in_name = utils::new_c_string("segments")?;
22706
22707 let vips_op_response = bindings::vips_labelregions(
22708 inp_in,
22709 &mut mask_out,
22710 segments_in_name.as_ptr(),
22711 segments_in,
22712 NULL,
22713 );
22714 utils::result(
22715 vips_op_response,
22716 VipsImage { ctx: mask_out },
22717 Error::LabelregionError,
22718 )
22719 }
22720}
22721
22722pub fn fill_nearest(inp: &VipsImage) -> Result<VipsImage> {
22726 unsafe {
22727 let inp_in: *mut bindings::VipsImage = inp.ctx;
22728 let mut out_out: *mut bindings::VipsImage = null_mut();
22729
22730 let vips_op_response = bindings::vips_fill_nearest(inp_in, &mut out_out, NULL);
22731 utils::result(
22732 vips_op_response,
22733 VipsImage { ctx: out_out },
22734 Error::FillNearestError,
22735 )
22736 }
22737}
22738
22739#[derive(Clone, Debug)]
22741pub struct FillNearestOptions {
22742 pub distance: VipsImage,
22744}
22745
22746impl std::default::Default for FillNearestOptions {
22747 fn default() -> Self {
22748 FillNearestOptions {
22749 distance: VipsImage::new(),
22750 }
22751 }
22752}
22753
22754pub fn fill_nearest_with_opts(
22759 inp: &VipsImage,
22760 fill_nearest_options: &FillNearestOptions,
22761) -> Result<VipsImage> {
22762 unsafe {
22763 let inp_in: *mut bindings::VipsImage = inp.ctx;
22764 let mut out_out: *mut bindings::VipsImage = null_mut();
22765
22766 let distance_in: *mut bindings::VipsImage = fill_nearest_options.distance.ctx;
22767 let distance_in_name = utils::new_c_string("distance")?;
22768
22769 let vips_op_response = bindings::vips_fill_nearest(
22770 inp_in,
22771 &mut out_out,
22772 distance_in_name.as_ptr(),
22773 distance_in,
22774 NULL,
22775 );
22776 utils::result(
22777 vips_op_response,
22778 VipsImage { ctx: out_out },
22779 Error::FillNearestError,
22780 )
22781 }
22782}
22783
22784pub fn draw_rect(
22797 image: &VipsImage,
22798 ink: &mut [f64],
22799 left: i32,
22800 top: i32,
22801 width: i32,
22802 height: i32,
22803) -> Result<()> {
22804 unsafe {
22805 let image_in: *mut bindings::VipsImage = image.ctx;
22806 let ink_in: *mut f64 = ink.as_mut_ptr();
22807 let left_in: i32 = left;
22808 let top_in: i32 = top;
22809 let width_in: i32 = width;
22810 let height_in: i32 = height;
22811
22812 let vips_op_response = bindings::vips_draw_rect(
22813 image_in,
22814 ink_in,
22815 ink.len() as i32,
22816 left_in,
22817 top_in,
22818 width_in,
22819 height_in,
22820 NULL,
22821 );
22822 utils::result(vips_op_response, (), Error::DrawRectError)
22823 }
22824}
22825
22826#[derive(Clone, Debug)]
22828pub struct DrawRectOptions {
22829 pub fill: bool,
22832}
22833
22834impl std::default::Default for DrawRectOptions {
22835 fn default() -> Self {
22836 DrawRectOptions { fill: false }
22837 }
22838}
22839
22840pub fn draw_rect_with_opts(
22854 image: &VipsImage,
22855 ink: &mut [f64],
22856 left: i32,
22857 top: i32,
22858 width: i32,
22859 height: i32,
22860 draw_rect_options: &DrawRectOptions,
22861) -> Result<()> {
22862 unsafe {
22863 let image_in: *mut bindings::VipsImage = image.ctx;
22864 let ink_in: *mut f64 = ink.as_mut_ptr();
22865 let left_in: i32 = left;
22866 let top_in: i32 = top;
22867 let width_in: i32 = width;
22868 let height_in: i32 = height;
22869
22870 let fill_in: i32 = if draw_rect_options.fill { 1 } else { 0 };
22871 let fill_in_name = utils::new_c_string("fill")?;
22872
22873 let vips_op_response = bindings::vips_draw_rect(
22874 image_in,
22875 ink_in,
22876 ink.len() as i32,
22877 left_in,
22878 top_in,
22879 width_in,
22880 height_in,
22881 fill_in_name.as_ptr(),
22882 fill_in,
22883 NULL,
22884 );
22885 utils::result(vips_op_response, (), Error::DrawRectError)
22886 }
22887}
22888
22889pub fn draw_mask(
22899 image: &VipsImage,
22900 ink: &mut [f64],
22901 mask: &VipsImage,
22902 x: i32,
22903 y: i32,
22904) -> Result<()> {
22905 unsafe {
22906 let image_in: *mut bindings::VipsImage = image.ctx;
22907 let ink_in: *mut f64 = ink.as_mut_ptr();
22908 let mask_in: *mut bindings::VipsImage = mask.ctx;
22909 let x_in: i32 = x;
22910 let y_in: i32 = y;
22911
22912 let vips_op_response = bindings::vips_draw_mask(
22913 image_in,
22914 ink_in,
22915 ink.len() as i32,
22916 mask_in,
22917 x_in,
22918 y_in,
22919 NULL,
22920 );
22921 utils::result(vips_op_response, (), Error::DrawMaskError)
22922 }
22923}
22924
22925pub fn draw_line(
22938 image: &VipsImage,
22939 ink: &mut [f64],
22940 x_1: i32,
22941 y_1: i32,
22942 x_2: i32,
22943 y_2: i32,
22944) -> Result<()> {
22945 unsafe {
22946 let image_in: *mut bindings::VipsImage = image.ctx;
22947 let ink_in: *mut f64 = ink.as_mut_ptr();
22948 let x_1_in: i32 = x_1;
22949 let y_1_in: i32 = y_1;
22950 let x_2_in: i32 = x_2;
22951 let y_2_in: i32 = y_2;
22952
22953 let vips_op_response = bindings::vips_draw_line(
22954 image_in,
22955 ink_in,
22956 ink.len() as i32,
22957 x_1_in,
22958 y_1_in,
22959 x_2_in,
22960 y_2_in,
22961 NULL,
22962 );
22963 utils::result(vips_op_response, (), Error::DrawLineError)
22964 }
22965}
22966
22967pub fn draw_circle(
22978 image: &VipsImage,
22979 ink: &mut [f64],
22980 cx: i32,
22981 cy: i32,
22982 radius: i32,
22983) -> Result<()> {
22984 unsafe {
22985 let image_in: *mut bindings::VipsImage = image.ctx;
22986 let ink_in: *mut f64 = ink.as_mut_ptr();
22987 let cx_in: i32 = cx;
22988 let cy_in: i32 = cy;
22989 let radius_in: i32 = radius;
22990
22991 let vips_op_response = bindings::vips_draw_circle(
22992 image_in,
22993 ink_in,
22994 ink.len() as i32,
22995 cx_in,
22996 cy_in,
22997 radius_in,
22998 NULL,
22999 );
23000 utils::result(vips_op_response, (), Error::DrawCircleError)
23001 }
23002}
23003
23004#[derive(Clone, Debug)]
23006pub struct DrawCircleOptions {
23007 pub fill: bool,
23010}
23011
23012impl std::default::Default for DrawCircleOptions {
23013 fn default() -> Self {
23014 DrawCircleOptions { fill: false }
23015 }
23016}
23017
23018pub fn draw_circle_with_opts(
23030 image: &VipsImage,
23031 ink: &mut [f64],
23032 cx: i32,
23033 cy: i32,
23034 radius: i32,
23035 draw_circle_options: &DrawCircleOptions,
23036) -> Result<()> {
23037 unsafe {
23038 let image_in: *mut bindings::VipsImage = image.ctx;
23039 let ink_in: *mut f64 = ink.as_mut_ptr();
23040 let cx_in: i32 = cx;
23041 let cy_in: i32 = cy;
23042 let radius_in: i32 = radius;
23043
23044 let fill_in: i32 = if draw_circle_options.fill { 1 } else { 0 };
23045 let fill_in_name = utils::new_c_string("fill")?;
23046
23047 let vips_op_response = bindings::vips_draw_circle(
23048 image_in,
23049 ink_in,
23050 ink.len() as i32,
23051 cx_in,
23052 cy_in,
23053 radius_in,
23054 fill_in_name.as_ptr(),
23055 fill_in,
23056 NULL,
23057 );
23058 utils::result(vips_op_response, (), Error::DrawCircleError)
23059 }
23060}
23061
23062pub fn draw_flood(image: &VipsImage, ink: &mut [f64], x: i32, y: i32) -> Result<()> {
23071 unsafe {
23072 let image_in: *mut bindings::VipsImage = image.ctx;
23073 let ink_in: *mut f64 = ink.as_mut_ptr();
23074 let x_in: i32 = x;
23075 let y_in: i32 = y;
23076
23077 let vips_op_response =
23078 bindings::vips_draw_flood(image_in, ink_in, ink.len() as i32, x_in, y_in, NULL);
23079 utils::result(vips_op_response, (), Error::DrawFloodError)
23080 }
23081}
23082
23083#[derive(Clone, Debug)]
23085pub struct DrawFloodOptions {
23086 pub test: VipsImage,
23088 pub equal: bool,
23091 pub left: i32,
23094 pub top: i32,
23097 pub width: i32,
23100 pub height: i32,
23103}
23104
23105impl std::default::Default for DrawFloodOptions {
23106 fn default() -> Self {
23107 DrawFloodOptions {
23108 test: VipsImage::new(),
23109 equal: false,
23110 left: i32::from(0),
23111 top: i32::from(0),
23112 width: i32::from(0),
23113 height: i32::from(0),
23114 }
23115 }
23116}
23117
23118pub fn draw_flood_with_opts(
23128 image: &VipsImage,
23129 ink: &mut [f64],
23130 x: i32,
23131 y: i32,
23132 draw_flood_options: &DrawFloodOptions,
23133) -> Result<()> {
23134 unsafe {
23135 let image_in: *mut bindings::VipsImage = image.ctx;
23136 let ink_in: *mut f64 = ink.as_mut_ptr();
23137 let x_in: i32 = x;
23138 let y_in: i32 = y;
23139
23140 let test_in: *mut bindings::VipsImage = draw_flood_options.test.ctx;
23141 let test_in_name = utils::new_c_string("test")?;
23142
23143 let equal_in: i32 = if draw_flood_options.equal { 1 } else { 0 };
23144 let equal_in_name = utils::new_c_string("equal")?;
23145
23146 let left_in: i32 = draw_flood_options.left;
23147 let left_in_name = utils::new_c_string("left")?;
23148
23149 let top_in: i32 = draw_flood_options.top;
23150 let top_in_name = utils::new_c_string("top")?;
23151
23152 let width_in: i32 = draw_flood_options.width;
23153 let width_in_name = utils::new_c_string("width")?;
23154
23155 let height_in: i32 = draw_flood_options.height;
23156 let height_in_name = utils::new_c_string("height")?;
23157
23158 let vips_op_response = bindings::vips_draw_flood(
23159 image_in,
23160 ink_in,
23161 ink.len() as i32,
23162 x_in,
23163 y_in,
23164 test_in_name.as_ptr(),
23165 test_in,
23166 equal_in_name.as_ptr(),
23167 equal_in,
23168 left_in_name.as_ptr(),
23169 left_in,
23170 top_in_name.as_ptr(),
23171 top_in,
23172 width_in_name.as_ptr(),
23173 width_in,
23174 height_in_name.as_ptr(),
23175 height_in,
23176 NULL,
23177 );
23178 utils::result(vips_op_response, (), Error::DrawFloodError)
23179 }
23180}
23181
23182pub fn draw_image(image: &VipsImage, sub: &VipsImage, x: i32, y: i32) -> Result<()> {
23191 unsafe {
23192 let image_in: *mut bindings::VipsImage = image.ctx;
23193 let sub_in: *mut bindings::VipsImage = sub.ctx;
23194 let x_in: i32 = x;
23195 let y_in: i32 = y;
23196
23197 let vips_op_response = bindings::vips_draw_image(image_in, sub_in, x_in, y_in, NULL);
23198 utils::result(vips_op_response, (), Error::DrawImageError)
23199 }
23200}
23201
23202#[derive(Clone, Debug)]
23204pub struct DrawImageOptions {
23205 pub mode: CombineMode,
23210}
23211
23212impl std::default::Default for DrawImageOptions {
23213 fn default() -> Self {
23214 DrawImageOptions {
23215 mode: CombineMode::Set,
23216 }
23217 }
23218}
23219
23220pub fn draw_image_with_opts(
23230 image: &VipsImage,
23231 sub: &VipsImage,
23232 x: i32,
23233 y: i32,
23234 draw_image_options: &DrawImageOptions,
23235) -> Result<()> {
23236 unsafe {
23237 let image_in: *mut bindings::VipsImage = image.ctx;
23238 let sub_in: *mut bindings::VipsImage = sub.ctx;
23239 let x_in: i32 = x;
23240 let y_in: i32 = y;
23241
23242 let mode_in: i32 = draw_image_options.mode as i32;
23243 let mode_in_name = utils::new_c_string("mode")?;
23244
23245 let vips_op_response = bindings::vips_draw_image(
23246 image_in,
23247 sub_in,
23248 x_in,
23249 y_in,
23250 mode_in_name.as_ptr(),
23251 mode_in,
23252 NULL,
23253 );
23254 utils::result(vips_op_response, (), Error::DrawImageError)
23255 }
23256}
23257
23258pub fn draw_smudge(image: &VipsImage, left: i32, top: i32, width: i32, height: i32) -> Result<()> {
23270 unsafe {
23271 let image_in: *mut bindings::VipsImage = image.ctx;
23272 let left_in: i32 = left;
23273 let top_in: i32 = top;
23274 let width_in: i32 = width;
23275 let height_in: i32 = height;
23276
23277 let vips_op_response =
23278 bindings::vips_draw_smudge(image_in, left_in, top_in, width_in, height_in, NULL);
23279 utils::result(vips_op_response, (), Error::DrawSmudgeError)
23280 }
23281}
23282
23283pub fn merge(
23296 refp: &VipsImage,
23297 sec: &VipsImage,
23298 direction: Direction,
23299 dx: i32,
23300 dy: i32,
23301) -> Result<VipsImage> {
23302 unsafe {
23303 let refp_in: *mut bindings::VipsImage = refp.ctx;
23304 let sec_in: *mut bindings::VipsImage = sec.ctx;
23305 let direction_in: i32 = direction as i32;
23306 let dx_in: i32 = dx;
23307 let dy_in: i32 = dy;
23308 let mut out_out: *mut bindings::VipsImage = null_mut();
23309
23310 let vips_op_response = bindings::vips_merge(
23311 refp_in,
23312 sec_in,
23313 &mut out_out,
23314 direction_in.try_into().unwrap(),
23315 dx_in,
23316 dy_in,
23317 NULL,
23318 );
23319 utils::result(
23320 vips_op_response,
23321 VipsImage { ctx: out_out },
23322 Error::MergeError,
23323 )
23324 }
23325}
23326
23327#[derive(Clone, Debug)]
23329pub struct MergeOptions {
23330 pub mblend: i32,
23333}
23334
23335impl std::default::Default for MergeOptions {
23336 fn default() -> Self {
23337 MergeOptions {
23338 mblend: i32::from(10),
23339 }
23340 }
23341}
23342
23343pub fn merge_with_opts(
23357 refp: &VipsImage,
23358 sec: &VipsImage,
23359 direction: Direction,
23360 dx: i32,
23361 dy: i32,
23362 merge_options: &MergeOptions,
23363) -> Result<VipsImage> {
23364 unsafe {
23365 let refp_in: *mut bindings::VipsImage = refp.ctx;
23366 let sec_in: *mut bindings::VipsImage = sec.ctx;
23367 let direction_in: i32 = direction as i32;
23368 let dx_in: i32 = dx;
23369 let dy_in: i32 = dy;
23370 let mut out_out: *mut bindings::VipsImage = null_mut();
23371
23372 let mblend_in: i32 = merge_options.mblend;
23373 let mblend_in_name = utils::new_c_string("mblend")?;
23374
23375 let vips_op_response = bindings::vips_merge(
23376 refp_in,
23377 sec_in,
23378 &mut out_out,
23379 direction_in.try_into().unwrap(),
23380 dx_in,
23381 dy_in,
23382 mblend_in_name.as_ptr(),
23383 mblend_in,
23384 NULL,
23385 );
23386 utils::result(
23387 vips_op_response,
23388 VipsImage { ctx: out_out },
23389 Error::MergeError,
23390 )
23391 }
23392}
23393
23394pub fn mosaic(
23411 refp: &VipsImage,
23412 sec: &VipsImage,
23413 direction: Direction,
23414 xref: i32,
23415 yref: i32,
23416 xsec: i32,
23417 ysec: i32,
23418) -> Result<VipsImage> {
23419 unsafe {
23420 let refp_in: *mut bindings::VipsImage = refp.ctx;
23421 let sec_in: *mut bindings::VipsImage = sec.ctx;
23422 let direction_in: i32 = direction as i32;
23423 let xref_in: i32 = xref;
23424 let yref_in: i32 = yref;
23425 let xsec_in: i32 = xsec;
23426 let ysec_in: i32 = ysec;
23427 let mut out_out: *mut bindings::VipsImage = null_mut();
23428
23429 let vips_op_response = bindings::vips_mosaic(
23430 refp_in,
23431 sec_in,
23432 &mut out_out,
23433 direction_in.try_into().unwrap(),
23434 xref_in,
23435 yref_in,
23436 xsec_in,
23437 ysec_in,
23438 NULL,
23439 );
23440 utils::result(
23441 vips_op_response,
23442 VipsImage { ctx: out_out },
23443 Error::MosaicError,
23444 )
23445 }
23446}
23447
23448#[derive(Clone, Debug)]
23450pub struct MosaicOptions {
23451 pub hwindow: i32,
23454 pub harea: i32,
23457 pub mblend: i32,
23460 pub bandno: i32,
23463 pub dx_0: i32,
23466 pub dy_0: i32,
23469 pub scale_1: f64,
23472 pub angle_1: f64,
23475 pub dy_1: f64,
23478 pub dx_1: f64,
23481}
23482
23483impl std::default::Default for MosaicOptions {
23484 fn default() -> Self {
23485 MosaicOptions {
23486 hwindow: i32::from(5),
23487 harea: i32::from(15),
23488 mblend: i32::from(10),
23489 bandno: i32::from(0),
23490 dx_0: i32::from(0),
23491 dy_0: i32::from(0),
23492 scale_1: f64::from(1),
23493 angle_1: f64::from(0),
23494 dy_1: f64::from(0),
23495 dx_1: f64::from(0),
23496 }
23497 }
23498}
23499
23500pub fn mosaic_with_opts(
23518 refp: &VipsImage,
23519 sec: &VipsImage,
23520 direction: Direction,
23521 xref: i32,
23522 yref: i32,
23523 xsec: i32,
23524 ysec: i32,
23525 mosaic_options: &MosaicOptions,
23526) -> Result<VipsImage> {
23527 unsafe {
23528 let refp_in: *mut bindings::VipsImage = refp.ctx;
23529 let sec_in: *mut bindings::VipsImage = sec.ctx;
23530 let direction_in: i32 = direction as i32;
23531 let xref_in: i32 = xref;
23532 let yref_in: i32 = yref;
23533 let xsec_in: i32 = xsec;
23534 let ysec_in: i32 = ysec;
23535 let mut out_out: *mut bindings::VipsImage = null_mut();
23536
23537 let hwindow_in: i32 = mosaic_options.hwindow;
23538 let hwindow_in_name = utils::new_c_string("hwindow")?;
23539
23540 let harea_in: i32 = mosaic_options.harea;
23541 let harea_in_name = utils::new_c_string("harea")?;
23542
23543 let mblend_in: i32 = mosaic_options.mblend;
23544 let mblend_in_name = utils::new_c_string("mblend")?;
23545
23546 let bandno_in: i32 = mosaic_options.bandno;
23547 let bandno_in_name = utils::new_c_string("bandno")?;
23548
23549 let dx_0_in: i32 = mosaic_options.dx_0;
23550 let dx_0_in_name = utils::new_c_string("dx0")?;
23551
23552 let dy_0_in: i32 = mosaic_options.dy_0;
23553 let dy_0_in_name = utils::new_c_string("dy0")?;
23554
23555 let scale_1_in: f64 = mosaic_options.scale_1;
23556 let scale_1_in_name = utils::new_c_string("scale1")?;
23557
23558 let angle_1_in: f64 = mosaic_options.angle_1;
23559 let angle_1_in_name = utils::new_c_string("angle1")?;
23560
23561 let dy_1_in: f64 = mosaic_options.dy_1;
23562 let dy_1_in_name = utils::new_c_string("dy1")?;
23563
23564 let dx_1_in: f64 = mosaic_options.dx_1;
23565 let dx_1_in_name = utils::new_c_string("dx1")?;
23566
23567 let vips_op_response = bindings::vips_mosaic(
23568 refp_in,
23569 sec_in,
23570 &mut out_out,
23571 direction_in.try_into().unwrap(),
23572 xref_in,
23573 yref_in,
23574 xsec_in,
23575 ysec_in,
23576 hwindow_in_name.as_ptr(),
23577 hwindow_in,
23578 harea_in_name.as_ptr(),
23579 harea_in,
23580 mblend_in_name.as_ptr(),
23581 mblend_in,
23582 bandno_in_name.as_ptr(),
23583 bandno_in,
23584 dx_0_in_name.as_ptr(),
23585 dx_0_in,
23586 dy_0_in_name.as_ptr(),
23587 dy_0_in,
23588 scale_1_in_name.as_ptr(),
23589 scale_1_in,
23590 angle_1_in_name.as_ptr(),
23591 angle_1_in,
23592 dy_1_in_name.as_ptr(),
23593 dy_1_in,
23594 dx_1_in_name.as_ptr(),
23595 dx_1_in,
23596 NULL,
23597 );
23598 utils::result(
23599 vips_op_response,
23600 VipsImage { ctx: out_out },
23601 Error::MosaicError,
23602 )
23603 }
23604}
23605
23606pub fn mosaic_1(
23631 refp: &VipsImage,
23632 sec: &VipsImage,
23633 direction: Direction,
23634 xr_1: i32,
23635 yr_1: i32,
23636 xs_1: i32,
23637 ys_1: i32,
23638 xr_2: i32,
23639 yr_2: i32,
23640 xs_2: i32,
23641 ys_2: i32,
23642) -> Result<VipsImage> {
23643 unsafe {
23644 let refp_in: *mut bindings::VipsImage = refp.ctx;
23645 let sec_in: *mut bindings::VipsImage = sec.ctx;
23646 let direction_in: i32 = direction as i32;
23647 let xr_1_in: i32 = xr_1;
23648 let yr_1_in: i32 = yr_1;
23649 let xs_1_in: i32 = xs_1;
23650 let ys_1_in: i32 = ys_1;
23651 let xr_2_in: i32 = xr_2;
23652 let yr_2_in: i32 = yr_2;
23653 let xs_2_in: i32 = xs_2;
23654 let ys_2_in: i32 = ys_2;
23655 let mut out_out: *mut bindings::VipsImage = null_mut();
23656
23657 let vips_op_response = bindings::vips_mosaic1(
23658 refp_in,
23659 sec_in,
23660 &mut out_out,
23661 direction_in.try_into().unwrap(),
23662 xr_1_in,
23663 yr_1_in,
23664 xs_1_in,
23665 ys_1_in,
23666 xr_2_in,
23667 yr_2_in,
23668 xs_2_in,
23669 ys_2_in,
23670 NULL,
23671 );
23672 utils::result(
23673 vips_op_response,
23674 VipsImage { ctx: out_out },
23675 Error::Mosaic1Error,
23676 )
23677 }
23678}
23679
23680#[derive(Clone, Debug)]
23682pub struct Mosaic1Options {
23683 pub hwindow: i32,
23686 pub harea: i32,
23689 pub search: bool,
23692 pub interpolate: VipsInterpolate,
23694 pub mblend: i32,
23697}
23698
23699impl std::default::Default for Mosaic1Options {
23700 fn default() -> Self {
23701 Mosaic1Options {
23702 hwindow: i32::from(5),
23703 harea: i32::from(15),
23704 search: false,
23705 interpolate: VipsInterpolate::new(),
23706 mblend: i32::from(10),
23707 }
23708 }
23709}
23710
23711pub fn mosaic_1_with_opts(
23737 refp: &VipsImage,
23738 sec: &VipsImage,
23739 direction: Direction,
23740 xr_1: i32,
23741 yr_1: i32,
23742 xs_1: i32,
23743 ys_1: i32,
23744 xr_2: i32,
23745 yr_2: i32,
23746 xs_2: i32,
23747 ys_2: i32,
23748 mosaic_1_options: &Mosaic1Options,
23749) -> Result<VipsImage> {
23750 unsafe {
23751 let refp_in: *mut bindings::VipsImage = refp.ctx;
23752 let sec_in: *mut bindings::VipsImage = sec.ctx;
23753 let direction_in: i32 = direction as i32;
23754 let xr_1_in: i32 = xr_1;
23755 let yr_1_in: i32 = yr_1;
23756 let xs_1_in: i32 = xs_1;
23757 let ys_1_in: i32 = ys_1;
23758 let xr_2_in: i32 = xr_2;
23759 let yr_2_in: i32 = yr_2;
23760 let xs_2_in: i32 = xs_2;
23761 let ys_2_in: i32 = ys_2;
23762 let mut out_out: *mut bindings::VipsImage = null_mut();
23763
23764 let hwindow_in: i32 = mosaic_1_options.hwindow;
23765 let hwindow_in_name = utils::new_c_string("hwindow")?;
23766
23767 let harea_in: i32 = mosaic_1_options.harea;
23768 let harea_in_name = utils::new_c_string("harea")?;
23769
23770 let search_in: i32 = if mosaic_1_options.search { 1 } else { 0 };
23771 let search_in_name = utils::new_c_string("search")?;
23772
23773 let interpolate_in: *mut bindings::VipsInterpolate = mosaic_1_options.interpolate.ctx;
23774 let interpolate_in_name = utils::new_c_string("interpolate")?;
23775
23776 let mblend_in: i32 = mosaic_1_options.mblend;
23777 let mblend_in_name = utils::new_c_string("mblend")?;
23778
23779 let vips_op_response = bindings::vips_mosaic1(
23780 refp_in,
23781 sec_in,
23782 &mut out_out,
23783 direction_in.try_into().unwrap(),
23784 xr_1_in,
23785 yr_1_in,
23786 xs_1_in,
23787 ys_1_in,
23788 xr_2_in,
23789 yr_2_in,
23790 xs_2_in,
23791 ys_2_in,
23792 hwindow_in_name.as_ptr(),
23793 hwindow_in,
23794 harea_in_name.as_ptr(),
23795 harea_in,
23796 search_in_name.as_ptr(),
23797 search_in,
23798 interpolate_in_name.as_ptr(),
23799 interpolate_in,
23800 mblend_in_name.as_ptr(),
23801 mblend_in,
23802 NULL,
23803 );
23804 utils::result(
23805 vips_op_response,
23806 VipsImage { ctx: out_out },
23807 Error::Mosaic1Error,
23808 )
23809 }
23810}
23811
23812pub fn matrixinvert(inp: &VipsImage) -> Result<VipsImage> {
23816 unsafe {
23817 let inp_in: *mut bindings::VipsImage = inp.ctx;
23818 let mut out_out: *mut bindings::VipsImage = null_mut();
23819
23820 let vips_op_response = bindings::vips_matrixinvert(inp_in, &mut out_out, NULL);
23821 utils::result(
23822 vips_op_response,
23823 VipsImage { ctx: out_out },
23824 Error::MatrixinvertError,
23825 )
23826 }
23827}
23828
23829pub fn matches(
23850 refp: &VipsImage,
23851 sec: &VipsImage,
23852 xr_1: i32,
23853 yr_1: i32,
23854 xs_1: i32,
23855 ys_1: i32,
23856 xr_2: i32,
23857 yr_2: i32,
23858 xs_2: i32,
23859 ys_2: i32,
23860) -> Result<VipsImage> {
23861 unsafe {
23862 let refp_in: *mut bindings::VipsImage = refp.ctx;
23863 let sec_in: *mut bindings::VipsImage = sec.ctx;
23864 let xr_1_in: i32 = xr_1;
23865 let yr_1_in: i32 = yr_1;
23866 let xs_1_in: i32 = xs_1;
23867 let ys_1_in: i32 = ys_1;
23868 let xr_2_in: i32 = xr_2;
23869 let yr_2_in: i32 = yr_2;
23870 let xs_2_in: i32 = xs_2;
23871 let ys_2_in: i32 = ys_2;
23872 let mut out_out: *mut bindings::VipsImage = null_mut();
23873
23874 let vips_op_response = bindings::vips_match(
23875 refp_in,
23876 sec_in,
23877 &mut out_out,
23878 xr_1_in,
23879 yr_1_in,
23880 xs_1_in,
23881 ys_1_in,
23882 xr_2_in,
23883 yr_2_in,
23884 xs_2_in,
23885 ys_2_in,
23886 NULL,
23887 );
23888 utils::result(
23889 vips_op_response,
23890 VipsImage { ctx: out_out },
23891 Error::MatchError,
23892 )
23893 }
23894}
23895
23896#[derive(Clone, Debug)]
23898pub struct MatchOptions {
23899 pub hwindow: i32,
23902 pub harea: i32,
23905 pub search: bool,
23908 pub interpolate: VipsInterpolate,
23910}
23911
23912impl std::default::Default for MatchOptions {
23913 fn default() -> Self {
23914 MatchOptions {
23915 hwindow: i32::from(1),
23916 harea: i32::from(1),
23917 search: false,
23918 interpolate: VipsInterpolate::new(),
23919 }
23920 }
23921}
23922
23923pub fn matches_with_opts(
23945 refp: &VipsImage,
23946 sec: &VipsImage,
23947 xr_1: i32,
23948 yr_1: i32,
23949 xs_1: i32,
23950 ys_1: i32,
23951 xr_2: i32,
23952 yr_2: i32,
23953 xs_2: i32,
23954 ys_2: i32,
23955 matches_options: &MatchOptions,
23956) -> Result<VipsImage> {
23957 unsafe {
23958 let refp_in: *mut bindings::VipsImage = refp.ctx;
23959 let sec_in: *mut bindings::VipsImage = sec.ctx;
23960 let xr_1_in: i32 = xr_1;
23961 let yr_1_in: i32 = yr_1;
23962 let xs_1_in: i32 = xs_1;
23963 let ys_1_in: i32 = ys_1;
23964 let xr_2_in: i32 = xr_2;
23965 let yr_2_in: i32 = yr_2;
23966 let xs_2_in: i32 = xs_2;
23967 let ys_2_in: i32 = ys_2;
23968 let mut out_out: *mut bindings::VipsImage = null_mut();
23969
23970 let hwindow_in: i32 = matches_options.hwindow;
23971 let hwindow_in_name = utils::new_c_string("hwindow")?;
23972
23973 let harea_in: i32 = matches_options.harea;
23974 let harea_in_name = utils::new_c_string("harea")?;
23975
23976 let search_in: i32 = if matches_options.search { 1 } else { 0 };
23977 let search_in_name = utils::new_c_string("search")?;
23978
23979 let interpolate_in: *mut bindings::VipsInterpolate = matches_options.interpolate.ctx;
23980 let interpolate_in_name = utils::new_c_string("interpolate")?;
23981
23982 let vips_op_response = bindings::vips_match(
23983 refp_in,
23984 sec_in,
23985 &mut out_out,
23986 xr_1_in,
23987 yr_1_in,
23988 xs_1_in,
23989 ys_1_in,
23990 xr_2_in,
23991 yr_2_in,
23992 xs_2_in,
23993 ys_2_in,
23994 hwindow_in_name.as_ptr(),
23995 hwindow_in,
23996 harea_in_name.as_ptr(),
23997 harea_in,
23998 search_in_name.as_ptr(),
23999 search_in,
24000 interpolate_in_name.as_ptr(),
24001 interpolate_in,
24002 NULL,
24003 );
24004 utils::result(
24005 vips_op_response,
24006 VipsImage { ctx: out_out },
24007 Error::MatchError,
24008 )
24009 }
24010}
24011
24012pub fn globalbalance(inp: &VipsImage) -> Result<VipsImage> {
24016 unsafe {
24017 let inp_in: *mut bindings::VipsImage = inp.ctx;
24018 let mut out_out: *mut bindings::VipsImage = null_mut();
24019
24020 let vips_op_response = bindings::vips_globalbalance(inp_in, &mut out_out, NULL);
24021 utils::result(
24022 vips_op_response,
24023 VipsImage { ctx: out_out },
24024 Error::GlobalbalanceError,
24025 )
24026 }
24027}
24028
24029#[derive(Clone, Debug)]
24031pub struct GlobalbalanceOptions {
24032 pub gamma: f64,
24035 pub int_output: bool,
24038}
24039
24040impl std::default::Default for GlobalbalanceOptions {
24041 fn default() -> Self {
24042 GlobalbalanceOptions {
24043 gamma: f64::from(1.6),
24044 int_output: false,
24045 }
24046 }
24047}
24048
24049pub fn globalbalance_with_opts(
24054 inp: &VipsImage,
24055 globalbalance_options: &GlobalbalanceOptions,
24056) -> Result<VipsImage> {
24057 unsafe {
24058 let inp_in: *mut bindings::VipsImage = inp.ctx;
24059 let mut out_out: *mut bindings::VipsImage = null_mut();
24060
24061 let gamma_in: f64 = globalbalance_options.gamma;
24062 let gamma_in_name = utils::new_c_string("gamma")?;
24063
24064 let int_output_in: i32 = if globalbalance_options.int_output {
24065 1
24066 } else {
24067 0
24068 };
24069 let int_output_in_name = utils::new_c_string("int-output")?;
24070
24071 let vips_op_response = bindings::vips_globalbalance(
24072 inp_in,
24073 &mut out_out,
24074 gamma_in_name.as_ptr(),
24075 gamma_in,
24076 int_output_in_name.as_ptr(),
24077 int_output_in,
24078 NULL,
24079 );
24080 utils::result(
24081 vips_op_response,
24082 VipsImage { ctx: out_out },
24083 Error::GlobalbalanceError,
24084 )
24085 }
24086}