1.2 ? '1536x1024' : '1024x1024'; } $ratio = max( 1 / 3, min( 3, $width / $height ) ); $w = $ratio <= 1 ? self::LONGEST * $ratio : self::LONGEST; $h = $ratio <= 1 ? self::LONGEST : self::LONGEST / $ratio; return self::to16( $w ) . 'x' . self::to16( $h ); } /** * Nearest multiple of 16, at least 16. * * @param float $value Pixels. */ private static function to16( float $value ): int { return max( 16, (int) round( $value / 16 ) * 16 ); } }