Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default-features = false for image dependency #42

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Allow disabling image features
  • Loading branch information
SamWilsn committed Jan 11, 2024
commit 169f2f6073a8151b1281c8cf28c51f617b6ea7a0
25 changes: 22 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ urlencoding = "2.1.3"
uriparse = "0.6.4"
chrono = "0.4.31"
chrono-tz = "0.8"
image = {version = "0.24", optional = true}
image = {version = "0.24", optional = true, default-features = false}
imageproc = {version = "0.23", optional = true}
unicode-segmentation = "1.10"
codepage-437 = "0.1.0"
Expand All @@ -41,9 +41,28 @@ rand = "0.8.5"
criterion = "0.5"

[features]
default = ["image", "client_support"]
default = ["image", "client_support", "image-formats"]
#/// Enable features required for image manipulation and reading.
image = ["dep:image", "dep:imageproc"]
image-formats = [
"image",
"image/gif",
"image/jpeg",
"image/ico",
"image/png",
"image/pnm",
"image/tga",
"image/tiff",
"image/webp",
"image/bmp",
"image/hdr",
"image/dxt",
"image/dds",
"image/farbfeld",
"image/jpeg_rayon",
"image/openexr",
"image/qoi"
]

#/// Allows the ability to force ISO/IED 18004 compliance.
#/// Leave disabled unless specificially needed.
Expand Down Expand Up @@ -83,4 +102,4 @@ harness = false
[profile.release]
codegen-units = 1
lto = true
opt-level = 3
opt-level = 3
8 changes: 8 additions & 0 deletions src/maxicode/detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ mod detector_test {
Binarizer, BufferedImageLuminanceSource,
};

#[cfg(feature = "image-formats")]
#[test]
fn mode_1() {
finder_test(
Expand All @@ -1062,6 +1063,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mode_2() {
finder_test(
Expand All @@ -1070,6 +1072,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mode_2_rot90() {
finder_test(
Expand All @@ -1078,6 +1081,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mode3() {
finder_test(
Expand All @@ -1086,6 +1090,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mixed_sets() {
finder_test(
Expand All @@ -1094,6 +1099,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mode4() {
finder_test(
Expand All @@ -1102,6 +1108,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mode5() {
finder_test(
Expand All @@ -1110,6 +1117,7 @@ mod detector_test {
)
}

#[cfg(feature = "image-formats")]
#[test]
fn mode6() {
finder_test(
Expand Down
2 changes: 2 additions & 0 deletions src/multi/multi_test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use super::{GenericMultipleBarcodeReader, MultipleBarcodeReader};
* Tests {@link MultipleBarcodeReader}.
*/

#[cfg(feature = "image-formats")]
#[test]
fn testMulti() {
// Very basic test for now
Expand Down Expand Up @@ -54,6 +55,7 @@ fn testMulti() {
assert_eq!(&BarcodeFormat::QR_CODE, results[1].getBarcodeFormat());
}

#[cfg(feature = "image-formats")]
#[test]
fn testMultiQR() {
// Very basic test for now
Expand Down
1 change: 1 addition & 0 deletions src/multi/qrcode/qr_code_multi_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ mod multi_qr_code_test_case {
* Tests {@link QRCodeMultiReader}.
*/

#[cfg(feature = "image-formats")]
#[test]
fn testMultiQRCodes() {
// Very basic test for now
Expand Down
2 changes: 1 addition & 1 deletion src/oned/rss/expanded/expanded_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl ExpandedPair {
&self.finderPattern
}

#[cfg(test)]
#[cfg(all(test, feature = "image"))]
pub(crate) fn getFinderPatternMut(&mut self) -> &mut Option<FinderPattern> {
&mut self.finderPattern
}
Expand Down
2 changes: 1 addition & 1 deletion src/oned/rss/expanded/expanded_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ExpandedRow {
&self.pairs
}

#[cfg(test)]
#[cfg(all(test, feature = "image"))]
pub(crate) fn getPairsMut(&mut self) -> &mut [ExpandedPair] {
&mut self.pairs
}
Expand Down
18 changes: 18 additions & 0 deletions src/oned/rss/expanded/rss_expanded_image_2_binary_test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ use crate::{

use super::bit_array_builder;

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary1() {
// (11)100224(17)110224(3102)000100
assertCorrectImage2binary("1.png",
" ...X...X .X....X. .XX...X. X..X...X ...XX.X. ..X.X... ..X.X..X ...X..X. X.X....X .X....X. .....X.. X...X...");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary2() {
// (01)90012345678908(3103)001750
Expand All @@ -51,19 +53,22 @@ fn testDecodeRow2binary2() {
);
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary3() {
// (10)12A
assertCorrectImage2binary("3.png", " .......X ..XX..X. X.X....X .......X ....");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary4() {
// (01)98898765432106(3202)012345(15)991231
assertCorrectImage2binary(
"4.png", " ..XXXX.X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX..XX XX.X.XXX X..XX..X .X.XXXXX XXXX");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary5() {
// (01)90614141000015(3202)000150
Expand All @@ -73,20 +78,23 @@ fn testDecodeRow2binary5() {
);
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary10() {
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012
assertCorrectImage2binary("10.png",
" .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... XX.XX..X .X..X..X .X.X.X.X X.XX...X .XX.XXX. XXX.X.XX ..X.");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary11() {
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456
assertCorrectImage2binary("11.png",
" .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... ....");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary12() {
// (01)98898765432106(3103)001750
Expand All @@ -96,6 +104,7 @@ fn testDecodeRow2binary12() {
);
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary13() {
// (01)90012345678908(3922)795
Expand All @@ -105,62 +114,71 @@ fn testDecodeRow2binary13() {
);
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary14() {
// (01)90012345678908(3932)0401234
assertCorrectImage2binary(
"14.png", " ..XX.X.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.....X. X.....X. X.X.X.XX .X...... X...");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary15() {
// (01)90012345678908(3102)001750(11)100312
assertCorrectImage2binary(
"15.png", " ..XXX... ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary16() {
// (01)90012345678908(3202)001750(11)100312
assertCorrectImage2binary(
"16.png", " ..XXX..X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary17() {
// (01)90012345678908(3102)001750(13)100312
assertCorrectImage2binary(
"17.png", " ..XXX.X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary18() {
// (01)90012345678908(3202)001750(13)100312
assertCorrectImage2binary(
"18.png", " ..XXX.XX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary19() {
// (01)90012345678908(3102)001750(15)100312
assertCorrectImage2binary(
"19.png", " ..XXXX.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary20() {
// (01)90012345678908(3202)001750(15)100312
assertCorrectImage2binary(
"20.png", " ..XXXX.X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary21() {
// (01)90012345678908(3102)001750(17)100312
assertCorrectImage2binary(
"21.png", " ..XXXXX. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
}

#[cfg(feature = "image-formats")]
#[test]
fn testDecodeRow2binary22() {
// (01)90012345678908(3202)001750(17)100312
Expand Down
Loading