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

Promotes next to master branch #1132

Merged
merged 131 commits into from Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
b63680c
Remove bit depth parameter on colortypes
fintelia Feb 10, 2019
13600b3
ColorType::Palette -> ColorType::Unknown
fintelia Feb 11, 2019
0e848ea
16bit bitdepths for tiff
fintelia Feb 11, 2019
2dcf226
Make ColorType non-exaustive
fintelia Feb 14, 2019
34f97bc
Failing ColorType conversions now produce Unknown rather than panic
fintelia Jun 5, 2019
a14309a
Address review feedback
fintelia Jun 6, 2019
1f2156e
Don't implement From<ColorType> for (png::ColorType, png::BitDepth)
fintelia Jun 6, 2019
b2fa1aa
Merge pull request #865 from fintelia/colortype
fintelia Jul 23, 2019
f3d240d
Rename variants of ColorType
fintelia Jul 23, 2019
586e323
Remove ColorType::L1 and add ExtendedColorType enum
fintelia Jul 23, 2019
bf80bf5
Merge pull request #995 from fintelia/colortype2
fintelia Jul 24, 2019
20bb03e
'color type' is two words
fintelia Jul 24, 2019
3153f80
Remove ColorType::Unknown so all variants are an integer number of bytes
fintelia Jul 24, 2019
fae1d5b
Make copy_from return an ImageResult instead of a boolean
lovasoa Aug 9, 2019
022af2b
Remove commented code
fintelia Aug 18, 2019
4eb1431
Remove PNM encoder test for palette support
fintelia Aug 18, 2019
6d86e32
suggested edits
fintelia Aug 18, 2019
e762c55
Merge branch 'master' into colortype3
fintelia Aug 18, 2019
7d8efcb
Fix a bunch of clippy lints
fintelia Aug 18, 2019
aa267b8
Merge pull request #1012 from fintelia/colortype3
fintelia Aug 21, 2019
f405277
Fix invalid return type
lovasoa Aug 23, 2019
04dbe9c
Merge pull request #1004 from lovasoa/next
fintelia Aug 23, 2019
de1974d
Merge remote-tracking branch 'upstream/master' into next
HeroicKatora Oct 3, 2019
4c12b40
Merge pull request #1054 from HeroicKatora/next
HeroicKatora Oct 8, 2019
2c970cf
Convert ImageFormat variants to CamelCase
HeroicKatora Oct 3, 2019
5c92a3e
Change to proper WebP capitalization
HeroicKatora Oct 11, 2019
a2c96ca
Merge pull request #1056 from HeroicKatora/screamless
HeroicKatora Oct 12, 2019
45623c5
Proper capitalization for decoder struct names
fintelia Oct 18, 2019
8cb2233
Merge pull request #1061 from fintelia/decoder-rename
fintelia Oct 19, 2019
796266c
Tweak ImageDecoder trait
fintelia Sep 27, 2019
c6a5fe6
Document panic behavior
fintelia Sep 27, 2019
19373db
Apply suggestions from code review
fintelia Sep 29, 2019
cc2617d
Update src/image.rs
fintelia Sep 29, 2019
f56cf08
Update decoders and tests to use new interface
fintelia Oct 4, 2019
6e7bad0
Factor out decoder_to_vec() function
fintelia Oct 18, 2019
56e9814
Avoid usize 'as u64' casts
fintelia Oct 19, 2019
2e5fab4
Add comment explaining GIF decoding better
fintelia Oct 19, 2019
a1011f7
Make insuffient memory be a panic more consistently
fintelia Oct 19, 2019
65791e3
Fixes #1058. Migrated to ImageError from std::io::Error
Mike-Neto Oct 20, 2019
5f71068
Updated some error types as requested by review
Mike-Neto Oct 22, 2019
e445729
Removed impl for png encoding error.
Mike-Neto Oct 25, 2019
ac33478
Fix borrow checker issue for old rustc versions
fintelia Oct 25, 2019
2159b2f
Merge pull request #1044 from fintelia/image-decoder-tweak
fintelia Oct 25, 2019
945ae8b
Make read_rect take u32's
fintelia Oct 19, 2019
23f18a7
Merge pull request #1063 from fintelia/read-rect-u32
fintelia Oct 27, 2019
af2e4a3
Convert error with private methods, not From
HeroicKatora Oct 27, 2019
682cf78
Merge pull request #1068 from HeroicKatora/next
HeroicKatora Oct 27, 2019
926304c
Remove several re-exports from the crate root
fintelia Oct 18, 2019
51812bc
Merge pull request #1062 from fintelia/less-in-root
HeroicKatora Nov 11, 2019
1362d0d
Updated target branch to next & fixed conflicts
mmendesTillster Nov 19, 2019
27e3fa1
Merge pull request #1066 from Mike-Neto/master
HeroicKatora Nov 19, 2019
d5f0ac1
Allow setting a custom pixel density in the JPEG encoder
lovasoa Nov 23, 2019
76abfcf
Remove the ability to chain method calls in JpegDecoder::set_pixel_de…
lovasoa Nov 23, 2019
2e35996
Merge pull request #1078 from lovasoa/next
fintelia Nov 23, 2019
37bc410
Bump tiff version
HeroicKatora Nov 25, 2019
9342a0b
Merge pull request #1081 from HeroicKatora/next
fintelia Nov 25, 2019
bb5ebc2
Export public decoder relevant types
HeroicKatora Nov 27, 2019
da7827d
Replace Lenna test images
aschampion Nov 28, 2019
22365c5
Fix benchmarks and ensure compilation on Travis
aschampion Nov 28, 2019
87b04b7
Merge pull request #1086 from aschampion/issues/benchmarks-broken
HeroicKatora Nov 28, 2019
9a0dbab
Merge pull request #1087 from aschampion/replace-lenna-images
HeroicKatora Nov 28, 2019
e26f632
Add documentation on the new structures
HeroicKatora Nov 30, 2019
bb61bb7
Make Progress opaque but accessible
HeroicKatora Nov 30, 2019
6946691
Merge pull request #1089 from HeroicKatora/next
HeroicKatora Nov 30, 2019
d0f6d00
Update release and notes for 0.23 preview
HeroicKatora Dec 5, 2019
a247ba9
Apply change note wording suggestions
HeroicKatora Dec 5, 2019
f23f53a
Merge pull request #1091 from HeroicKatora/next
HeroicKatora Dec 6, 2019
64591f8
Make Cargo.toml a bit cleaner
fintelia Dec 7, 2019
c3de761
Update a few fields in Cargo.toml
fintelia Dec 7, 2019
e706bfb
Rename 'gif_codec' and 'png_codec' features to 'gif' and 'png'
fintelia Dec 7, 2019
2478a75
Use renaming trick to avoid having both jpeg and jpeg-decoder as "fea…
fintelia Dec 7, 2019
bf8e26b
Fix Travis config
fintelia Dec 7, 2019
3a7eb68
Merge pull request #1093 from fintelia/simplify-cargo-toml
fintelia Dec 8, 2019
67a327b
Support 16 bit per channel image buffers
aschampion Oct 31, 2019
4d776b7
Create common trait for all image format encoders
aschampion Nov 27, 2019
a32fd74
Bump png version
aschampion Dec 4, 2019
fe06c05
Make ChannelsType nonexhaustive
aschampion Dec 4, 2019
7b62a7b
Remove ColorType::bytes_per_channel
aschampion Dec 4, 2019
9de3e61
Note trait should be removed (minor)
aschampion Dec 4, 2019
a502bee
Restore as_flat_samples methods for DynamicImage
aschampion Dec 4, 2019
ed47a76
Remove zerocopy from public interface
aschampion Dec 4, 2019
c642686
Fix compilation on 1.34.2
aschampion Dec 4, 2019
e12da31
Hide 16bpc buffer aliases from public API
aschampion Dec 8, 2019
35ebf63
Remove ChannelsType
aschampion Dec 10, 2019
33cebef
Restore Pixel::COLOR_TYPE associated type
aschampion Dec 10, 2019
5dae1fd
Switch from zerocopy to bytemuck
aschampion Dec 12, 2019
d3b3133
Merge pull request #1085 from aschampion/features/16bpc-dynimage-squash
HeroicKatora Dec 12, 2019
133e1dd
Fixes #1090.
Mike-Neto Dec 13, 2019
577fa28
Refactored using ok_or.
Mike-Neto Dec 13, 2019
77bc941
Merge pull request #1097 from Mike-Neto/next
HeroicKatora Dec 15, 2019
38232ee
Fix potential overflow in GIF decoding
fintelia Sep 16, 2019
182de11
Merge pull request #1036 from fintelia/delay-overflow
fintelia Dec 20, 2019
af89715
Edition fix to 2018
HeroicKatora Dec 31, 2019
1ec46ba
Merge pull request #1106 from HeroicKatora/edition-2018
HeroicKatora Dec 31, 2019
612a116
Move error types to seperate module
birktj May 4, 2019
a1848da
Merge pull request #1110 from HeroicKatora/error-module
HeroicKatora Jan 9, 2020
1919d39
Update the quickcheck dev-dependency
HeroicKatora Jan 11, 2020
2902901
Merge pull request #1114 from HeroicKatora/update-quickcheck
HeroicKatora Jan 11, 2020
d3dd380
Merge remote-tracking branch 'upstream/master' into update-from-master
HeroicKatora Jan 21, 2020
e5ab3ba
Merge pull request #1117 from HeroicKatora/update-from-master
HeroicKatora Jan 21, 2020
35774bc
Add support for DDS files using DXT1, DXT3 or DXT5 compression
benoitryder Jan 26, 2020
cea55d5
Make ImageFormat related enums non-exhaustive
HeroicKatora Feb 1, 2020
9da5407
Merge pull request #1121 from benoitryder/master
HeroicKatora Feb 1, 2020
3afbdcb
Merge pull request #1123 from HeroicKatora/format-non-exhaustive
HeroicKatora Feb 1, 2020
495a470
Add missing feature requirement dxt for dds
HeroicKatora Feb 1, 2020
49d13fd
Merge pull request #1124 from HeroicKatora/dds-required-feature
HeroicKatora Feb 1, 2020
4d19e84
Add an opaque redesign for error type
HeroicKatora Jan 23, 2020
02bd05e
Add utility constructors for new error type
HeroicKatora Jan 25, 2020
73f8c1f
Switch error types with minimal cleanup
HeroicKatora Jan 26, 2020
52510ef
Remove the old error representation
HeroicKatora Jan 26, 2020
b8758ec
Map the PNG errors with underlying error
HeroicKatora Jan 28, 2020
d0d6e53
Add test/assertions for ImageError marker impls
HeroicKatora Jan 31, 2020
8980781
Do a documentation pass and improve naming
HeroicKatora Jan 31, 2020
ce79a34
Use boxed str instead of String for error message
HeroicKatora Feb 1, 2020
b98d3d4
Switch to marker based non-exhaustive
HeroicKatora Feb 1, 2020
a1ddcb3
Fix benchmarks to edition 2018
HeroicKatora Feb 1, 2020
c0b5d97
Merge pull request #1125 from HeroicKatora/benchmark-edition-2018
HeroicKatora Feb 1, 2020
312ec9a
Some last, minor documentation improvements.
HeroicKatora Feb 1, 2020
737a05d
Merge pull request #1119 from HeroicKatora/error-rework2
HeroicKatora Feb 1, 2020
875372e
Interface restrictions for gif and jpeg
HeroicKatora Feb 2, 2020
e69978c
Fixed animation::Frame and raw byte interfaces
HeroicKatora Feb 2, 2020
90a21f3
Merge pull request #1126 from HeroicKatora/remove-public-dependencies
HeroicKatora Feb 2, 2020
081dcc0
Add travis script and public dependency reference
HeroicKatora Feb 2, 2020
4c592d7
Merge pull request #1127 from HeroicKatora/public-private-dependencies
HeroicKatora Feb 2, 2020
22e1fe3
Encapsulate the delay ratio
HeroicKatora Feb 2, 2020
68ad0cc
Add conversion of Delay into time::Duration
HeroicKatora Feb 5, 2020
633f247
Align naming to ratio
HeroicKatora Feb 5, 2020
b6dacab
Add a saturating conversion from time::Duration
HeroicKatora Feb 5, 2020
9dd1c44
Merge pull request #1128 from HeroicKatora/hide-num-ratio
fintelia Feb 7, 2020
e3ab70d
Merge remote-tracking branch 'upstream/master' into upstream-master
HeroicKatora Feb 7, 2020
140f4ea
Merge pull request #1131 from HeroicKatora/upstream-master
HeroicKatora Feb 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions .travis.yml
Expand Up @@ -20,11 +20,12 @@ env:
matrix:
- DEFAULT_FEATURES='yes'
- FEATURES=''
- FEATURES='gif_codec'
- FEATURES='gif'
- FEATURES='jpeg'
- FEATURES='png_codec'
- FEATURES='png'
- FEATURES='pnm'
- FEATURES='tga'
- FEATURES='dds'
- FEATURES='tiff'
- FEATURES='webp'
- FEATURES='hdr'
Expand All @@ -51,6 +52,14 @@ matrix:
script:
- rustup component add clippy
- cargo clippy
- os: linux
rust: nightly
name: "Public private dependencies"
script:
- mv ./Cargo.toml.public-private-dependencies ./Cargo.toml
- echo "#![deny(exported_private_dependencies)]" | cat - src/lib.rs > src/lib.rs.0
- mv src/lib.rs.0 src/lib.rs
- cargo check
script:
- if [ -n "${FEATURES+exists}" ]; then
cargo build -v --no-default-features --features "$FEATURES" &&
Expand All @@ -60,3 +69,7 @@ script:
- if [ -n "${DEFAULT_FEATURES+exists}" ]; then
cargo test -v;
fi
- if [ "$TRAVIS_RUST_VERSION" == "nightly" ] && [ -n "${DEFAULT_FEATURES+exists}" ]; then
cargo build -v --features=benchmarks &&
cargo build -v --benches --features=benchmarks;
fi
48 changes: 48 additions & 0 deletions CHANGES.md
Expand Up @@ -8,6 +8,54 @@ Rust image aims to be a pure-Rust implementation of various popular image format

## Changes

### Version 0.23.0-preview.0

This major release intends to improve the interface with regards to handling of
color format data for both decoding and encoding. This necessitated many
breaking changes anyways so it was used to improve the compliance to the
interface guidelines such as outstanding renaming.

WIP: This preview version is intended to allow an evaluation and feedback on
the new interface. It is not yet perfect with regards to color spaces but it
was designed mainly as an improvement over the current interface with regards
to in-memory color formats, first. We'll get to color spaces in a later major
version.

- Heavily reworked `ColorType`:
- This type is now used for denoting formats for which we support operations
on buffers in these memory representations. Particularly, all channels in
pixel types are assumed to be an integer number of bytes (In terms of the
Rust type system, these are `Sized` and one can crate slices of channel
values).
- An `ExtendedColorType` (WIP: do You have better name?) is used to express
more generic color formats for which the library has limited support but
can be converted/scaled/mapped into a `ColorType` buffer. This operation
might be fallible but, for example, includes sources with 1/2/4-bit
components.
- Both types are non-exhaustive to add more formats in a minor release.
- A work-in-progress (#1085) will further separate the color model from the
specific channel instantiation, e.g. both `8-bit RGB` and `16-bit BGR`
are instantiations of `RGB` color model.
- Reworked the `ImageDecoder` trait:
- `read_image` takes an output buffer argument instead of allocating all
memory on its own.
- The return type of `dimensions` now aligns with `GenericImage` sizes.
- The `colortype` method was renamed to `color_type` for conformity.
- The result of `encode` operations is now uniformly an `ImageResult<()>`.
- Removed public converters from some `tiff` and `png` types. This allows
upgrading the dependency across major versions without a major release in
`image` itself.
- The enums `ColorType`, `DynamicImage`, `imageops::FilterType`, `ImageFormat`
no longer re-export all of their variants in the top-level of the crate. This
removes the growing pollution in the documentation and usage.
- The capitalization of types such as `HDRDecoder` etc. has been adjusted to
adhere to the API guidelines. These are now spelled `HdrDecoder` etc. The
same change has been made on `ImageFormat` and other enum variants.
- The `Progress` type has finally received public access functions. Strange
that no one reported them missing.
- Introduced `PixelDensity` and `PixelDensityUnit` to store DPI information in
formats that support encoding this form of metadata (e.g. in `jpeg`).

### Version 0.22.5

- Added `GenericImage::copy_within`, specialized for `ImageBuffer`
Expand Down
55 changes: 15 additions & 40 deletions Cargo.toml
@@ -1,21 +1,13 @@
[package]
name = "image"
version = "0.22.5"
version = "0.23.0-preview.0"
edition = "2018"
license = "MIT"
description = "Imaging library written in Rust. Provides basic filters and decoders for the most common image formats."
authors = [
"ccgn",
"bvssvni <bvssvni@gmail.com>",
"nwin",
"TyOverby <ty@pre-alpha.com>",
"HeroicKatora",
"Calum",
"CensoredUsername <cens.username@gmail.com>",
"fintelia <fintelia@gmail.com>"
]
authors = ["The image-rs Developers"]
readme = "README.md"
documentation = "https://docs.rs/image"
repository = "https://github.com/image-rs/image.git"
repository = "https://github.com/image-rs/image"
homepage = "https://github.com/image-rs/image"
categories = ["multimedia::images", "multimedia::encoding"]
exclude = [
Expand All @@ -29,31 +21,16 @@ name = "image"
path = "./src/lib.rs"

[dependencies]
byteorder = "1.2.1"
bytemuck = "1"
byteorder = "1.3.2"
num-iter = "0.1.32"
num-rational = { version = "0.2.1", default-features = false }
num-traits = "0.2.0"

[dependencies.gif]
version = "0.10.0"
optional = true

[dependencies.jpeg-decoder]
version = "0.1"
default-features = false
optional = true

[dependencies.png]
version = "0.15"
optional = true

[dependencies.scoped_threadpool]
version = "0.1"
optional = true

[dependencies.tiff]
version = "0.3.1"
optional = true
gif = { version = "0.10.0", optional = true }
jpeg = { package = "jpeg-decoder", version = "0.1", default-features = false, optional = true }
png = { version = "0.15.2", optional = true }
scoped_threadpool = { version = "0.1", optional = true }
tiff = { version = "0.4.0", optional = true }

[dev-dependencies]
crc32fast = "1.2.0"
Expand All @@ -62,18 +39,16 @@ glob = "0.3"
quickcheck = "0.9"

[features]
default = ["gif_codec", "jpeg", "ico", "png_codec", "pnm", "tga", "tiff", "webp", "bmp", "hdr", "dxt", "jpeg_rayon"]
default = ["gif", "jpeg", "ico", "png", "pnm", "tga", "tiff", "webp", "bmp", "hdr", "dxt", "dds", "jpeg_rayon"]

gif_codec = ["gif"]
ico = ["bmp", "png_codec"]
jpeg = ["jpeg-decoder"]
png_codec = ["png"]
ico = ["bmp", "png"]
pnm = []
tga = []
webp = []
bmp = []
hdr = ["scoped_threadpool"]
dxt = []
jpeg_rayon = ["jpeg-decoder/rayon"]
dds = ["dxt"]
jpeg_rayon = ["jpeg/rayon"]

benchmarks = []
58 changes: 58 additions & 0 deletions Cargo.toml.public-private-dependencies
@@ -0,0 +1,58 @@
cargo-features = ["public-dependency"]

[package]
name = "image"
version = "0.23.0-preview.0"
edition = "2018"
license = "MIT"
description = "Imaging library written in Rust. Provides basic filters and decoders for the most common image formats."
authors = ["The image-rs Developers"]
readme = "README.md"
documentation = "https://docs.rs/image"
repository = "https://github.com/image-rs/image"
homepage = "https://github.com/image-rs/image"
categories = ["multimedia::images", "multimedia::encoding"]
exclude = [
"src/png/testdata/*",
"examples/*",
"tests/*",
]

[lib]
name = "image"
path = "./src/lib.rs"

[dependencies]
# Not yet public.
bytemuck = "1"
byteorder = "1.3.2"
num-iter = "0.1.32"
num-rational = "0.2.1"
# Public due to Pixel, otherwise quite useless.
num-traits = { version = "0.2.0", public = true }
gif = { version = "0.10.0", optional = true }
jpeg = { package = "jpeg-decoder", version = "0.1", default-features = false, optional = true }
png = { version = "0.15.2", optional = true }
scoped_threadpool = { version = "0.1", optional = true }
tiff = { version = "0.4.0", optional = true }

[dev-dependencies]
crc32fast = "1.2.0"
num-complex = "0.2.0"
glob = "0.3"
quickcheck = "0.9"

[features]
default = ["gif", "jpeg", "ico", "png", "pnm", "tga", "tiff", "webp", "bmp", "hdr", "dxt", "dds", "jpeg_rayon"]

ico = ["bmp", "png"]
pnm = []
tga = []
webp = []
bmp = []
hdr = ["scoped_threadpool"]
dxt = []
dds = ["dxt"]
jpeg_rayon = ["jpeg/rayon"]

benchmarks = []
21 changes: 12 additions & 9 deletions README.md
Expand Up @@ -29,14 +29,17 @@ https://docs.rs/image
| WebP | Lossy(Luma channel only) | No |
| PNM | PBM, PGM, PPM, standard PAM | Yes |

### 2.2 The ```ImageDecoder``` Trait
All image format decoders implement the ```ImageDecoder``` trait which provides the following methods:
+ **dimensions**: Return a tuple containing the width and height of the image
+ **colortype**: Return the color type of the image.
+ **row_len**: Returns the length in bytes of one decoded row of the image
+ **read_scanline**: Read one row from the image into buf Returns the row index
+ **read_image**: Decode the entire image and return it as a Vector
+ **load_rect**: Decode a specific region of the image
### 2.2 The ```ImageDecoder``` and ```ImageDecoderExt` Traits

All image format decoders implement the ```ImageDecoder``` trait which provide
basic methods for getting image metadata and decoding images. Some formats
additionally provide ```ImageDecoderExt``` implementations which allow for
decoding only part of an image at once.

The most important methods for decoders are...
+ **dimensions**: Return a tuple containing the width and height of the image.
+ **color_type**: Return the color type of the image data produced by this decoder.
+ **read_image**: Decode the entire image and return it as a Vec of bytes.

## 3 Pixels
```image``` provides the following pixel types:
Expand Down Expand Up @@ -249,7 +252,7 @@ fn main() {
let buffer: &[u8] = unimplemented!(); // Generate the image data

// Save the buffer as "image.png"
image::save_buffer("image.png", buffer, 800, 600, image::RGB(8)).unwrap()
image::save_buffer("image.png", buffer, 800, 600, image::ColorType::Rgb8).unwrap()
}

```
4 changes: 2 additions & 2 deletions benches/encode_jpeg.rs
Expand Up @@ -21,10 +21,10 @@ fn run_benchmark(b: &mut Bencher, color_type: image::ColorType) {

#[bench]
fn bench_rgb(b: &mut Bencher) {
run_benchmark(b, image::RGB(8));
run_benchmark(b, image::ColorType::Rgb8);
}

#[bench]
fn bench_gray(b: &mut Bencher) {
run_benchmark(b, image::Gray(8));
run_benchmark(b, image::ColorType::L8);
}
2 changes: 1 addition & 1 deletion benches/load.rs
Expand Up @@ -16,7 +16,7 @@ struct BenchDef<'a> {
const IMAGE_DIR: [&'static str; 3] = [".", "tests", "images"];
const BMP: BenchDef<'static> = BenchDef {
dir: &["bmp", "images"],
format: ImageFormat::BMP,
format: ImageFormat::Bmp,
};

fn bench_load(b: &mut test::Bencher, def: &BenchDef, filename: &str) {
Expand Down
4 changes: 2 additions & 2 deletions examples/opening.rs
Expand Up @@ -5,7 +5,7 @@ use std::env;
use std::fs::File;
use std::path::Path;

use image::GenericImageView;
use image::{ImageFormat, GenericImageView};

fn main() {
let file = if env::args().count() == 2 {
Expand All @@ -27,5 +27,5 @@ fn main() {
let fout = &mut File::create(&Path::new(&format!("{}.png", file))).unwrap();

// Write the contents of this image to the Writer in PNG format.
im.write_to(fout, image::PNG).unwrap();
im.write_to(fout, ImageFormat::Png).unwrap();
}
7 changes: 4 additions & 3 deletions examples/scaledown/main.rs
@@ -1,6 +1,7 @@
extern crate image;

use image::{FilterType, PNG};
use image::ImageFormat;
use image::imageops::FilterType;
use std::fmt;
use std::fs::File;
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -39,14 +40,14 @@ fn main() {
let scaled = img.resize(400, 400, filter);
println!("Scaled by {} in {}", name, Elapsed::from(&timer));
let mut output = File::create(&format!("test-{}.png", name)).unwrap();
scaled.write_to(&mut output, PNG).unwrap();
scaled.write_to(&mut output, ImageFormat::Png).unwrap();
}

for size in &[20_u32, 40, 100, 200, 400] {
let timer = Instant::now();
let scaled = img.thumbnail(*size, *size);
println!("Thumbnailed to {} in {}", size, Elapsed::from(&timer));
let mut output = File::create(format!("test-thumb{}.png", size)).unwrap();
scaled.write_to(&mut output, PNG).unwrap();
scaled.write_to(&mut output, ImageFormat::Png).unwrap();
}
}
7 changes: 4 additions & 3 deletions examples/scaleup/main.rs
@@ -1,6 +1,7 @@
extern crate image;

use image::{FilterType, PNG};
use image::ImageFormat;
use image::imageops::FilterType;
use std::fmt;
use std::fs::File;
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -39,12 +40,12 @@ fn main() {
let scaled = tiny.resize(32, 32, filter);
println!("Scaled by {} in {}", name, Elapsed::from(&timer));
let mut output = File::create(&format!("up2-{}.png", name)).unwrap();
scaled.write_to(&mut output, PNG).unwrap();
scaled.write_to(&mut output, ImageFormat::Png).unwrap();

let timer = Instant::now();
let scaled = tiny.resize(48, 48, filter);
println!("Scaled by {} in {}", name, Elapsed::from(&timer));
let mut output = File::create(&format!("up3-{}.png", name)).unwrap();
scaled.write_to(&mut output, PNG).unwrap();
scaled.write_to(&mut output, ImageFormat::Png).unwrap();
}
}