Intervention/image · error · Intervention\Image\Exceptions\InvalidArgumentException

Invalid value for alignment

Error message

Invalid value for alignment

What it means

Error "Invalid value for alignment" thrown in Intervention/image.

Source

Thrown at src/Typography/Font.php:229

     */
    public function alignmentHorizontal(): Alignment
    {
        return $this->alignmentHorizontal;
    }

    /**
     * {@inheritdoc}
     *
     * @see FontInterface::setAlignmentHorizontal()
     *
     * @throws InvalidArgumentException
     */
    public function setAlignmentHorizontal(string|Alignment $alignment): FontInterface
    {
        try {
            $this->alignmentHorizontal = is_string($alignment) ? Alignment::from($alignment) : $alignment;
        } catch (ValueError | TypeError) {
            throw new InvalidArgumentException('Invalid value for alignment');
        }

        return $this;
    }

    /**
     * {@inheritdoc}
     *
     * @see FontInterface::alignmentVertical()
     */
    public function alignmentVertical(): Alignment
    {
        return $this->alignmentVertical;
    }

    /**
     * {@inheritdoc}
     *

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Use one of the accepted alignment values: 'left', 'center', 'right'
  2. Normalize user input (lowercase, trim) before calling align()
  3. Reject invalid alignment strings at the validation layer

When it happens

Trigger: Thrown at src/Typography/Font.php:229 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23). Data as JSON: /api/errors/31f3ce00e6005431. Report an issue: GitHub.