bumptech/glide · error · IllegalArgumentException

sizeMultiplier must be between 0 and 1

Error message

sizeMultiplier must be between 0 and 1

What it means

Thrown by BaseRequestOptions.sizeMultiplier(float) when the supplied value is less than 0f or greater than 1f. sizeMultiplier scales the Target's dimensions for the decode, so an out-of-range value is meaningless and rejected. The @FloatRange annotation gives static-analysis (lint/IDE) the same bound.

Source

Thrown at library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java:124

  /**
   * Applies a multiplier to the {@link com.bumptech.glide.request.target.Target}'s size before
   * loading the resource. Useful for loading thumbnails or trying to avoid loading huge resources
   * (particularly {@link Bitmap}s on devices with overly dense screens.
   *
   * @param sizeMultiplier The multiplier to apply to the {@link
   *     com.bumptech.glide.request.target.Target}'s dimensions when loading the resource.
   * @return This request builder.
   */
  @NonNull
  @CheckResult
  public T sizeMultiplier(@FloatRange(from = 0, to = 1) float sizeMultiplier) {
    if (isAutoCloneEnabled) {
      return clone().sizeMultiplier(sizeMultiplier);
    }

    if (sizeMultiplier < 0f || sizeMultiplier > 1f) {
      throw new IllegalArgumentException("sizeMultiplier must be between 0 and 1");
    }
    this.sizeMultiplier = sizeMultiplier;
    fields |= SIZE_MULTIPLIER;

    return selfOrThrowIfLocked();
  }

  /**
   * If set to {@code true}, uses a cached unlimited {@link java.util.concurrent.Executor} to run
   * the request.
   *
   * <p>This method should <em>ONLY</em> be used when a Glide load is started recursively on one of
   * Glide's threads as part of another request. Using this method in other scenarios can lead to
   * excessive memory usage and OOMs and/or a significant decrease in performance across an
   * application.
   *
   * <p>If both this method and {@link #useAnimationPool(boolean)} are set, this method will be
   * preferred and {@link #useAnimationPool(boolean)} will be ignored.

View on GitHub (pinned to eb14a895d8)

Solutions

  1. Pass a normalized fraction in [0f, 1f]: divide percentages by 100
  2. If you need larger-than-target output, use .override(width, height) or .override(Target.SIZE_ORIGINAL) instead of sizeMultiplier
  3. Add a runtime clamp: sizeMultiplier.coerceIn(0f, 1f) in Kotlin or Math.max(0f, Math.min(1f, v)) in Java
  4. Enable the @FloatRange lint check in Android Studio to catch the value at edit time

Example fix

// before
val pct = seekBar.progress // 0..100
Glide.with(view).load(url).sizeMultiplier(pct.toFloat()).into(imageView)

// after
Glide.with(view).load(url).sizeMultiplier(pct / 100f).into(imageView)
Defensive patterns

Strategy: validation

Validate before calling

fun safeMultiplier(pct: Int): Float = (pct / 100f).coerceIn(0f, 1f)
// then: options.sizeMultiplier(safeMultiplier(seekBar.progress))

Prevention

When it happens

Trigger: Calling .sizeMultiplier(x) with x < 0 or x > 1 on a RequestOptions/RequestBuilder. Common with computed values such as percentage / 100 forgotten, or passing a dimension pixel value directly.

Common situations: Computing a multiplier from a percentage but forgetting to divide by 100 (e.g. .sizeMultiplier(75f) instead of .sizeMultiplier(0.75f)); reading a value from a slider/SeekBar (0..100) without normalization; copy-paste from code that used absolute pixels.

Related errors


AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14). Data as JSON: /api/errors/f798738867f65f18. Report an issue: GitHub.