Skip to content

Commit

Permalink
Fixed WebP resolution limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lamka02sk committed Nov 26, 2024
1 parent c3f0ece commit 8cb25eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "picturium"
version = "0.1.2"
version = "0.1.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
4 changes: 2 additions & 2 deletions src/services/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use libvips::VipsImage;
use log::{error, warn};
use crate::parameters::format::Format;
use crate::parameters::UrlParameters;
use crate::pipeline::{PipelineError, PipelineResult};
use crate::pipeline::{PipelineError, PipelineResult};

const WEBP_MAX_WIDTH: i32 = 16383; // px
const WEBP_MAX_HEIGHT: i32 = 16383; // px
Expand Down Expand Up @@ -124,7 +124,7 @@ pub fn validate_output_format(image: &VipsImage, url_parameters: &UrlParameters<
match output_format {
OutputFormat::Webp => {
let (width, height) = (image.get_width(), image.get_height());
let downsize = width > WEBP_MAX_WIDTH || height > WEBP_MAX_HEIGHT || (width * height) as f64 > WEBP_MAX_RESOLUTION;
let downsize = width > WEBP_MAX_WIDTH || height > WEBP_MAX_HEIGHT || (width * height) as f64 > (WEBP_MAX_RESOLUTION * 1_000_000.0);

if !downsize {
return Ok(output_format.clone());
Expand Down

0 comments on commit 8cb25eb

Please sign in to comment.