Формат геометрии изображения Dragonfly не соответствует документации ImageMagick?

Документация ImageMagick говорит, что следующие допустимые формы аргументов геометрии изображения:

size    General description (actual behavior can vary for different options and settings)
scale%  Height and width both scaled by specified percentage.
scale-x%xscale-y%   Height and width individually scaled by specified percentages. (Only one % symbol needed.)
width   Width given, height automagically selected to preserve aspect ratio.
xheight Height given, width automagically selected to preserve aspect ratio.
widthxheight    Maximum values of height and width given, aspect ratio preserved.
widthxheight^   Minimum values of width and height given, aspect ratio preserved.
widthxheight!   Width and height emphatically given, original aspect ratio ignored.
widthxheight>   Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s).
widthxheight<   Enlarges an image with dimension(s) smaller than the corresponding width and/or height argument(s).
area@   Resize image to have specified area in pixels. Aspect ratio is preserved.
{size}{offset}  Specifying the offset (default is +0+0). Below, {size} refers to any of the forms above.
{size}{+-}x{+-}y    Horizontal and vertical offsets x and y, specified in pixels. Signs are required for both. Offsets are affected by ‑gravity setting. Offsets are not affected by % or other size operators.

Я так понимаю 100%Например, допустимая форма (соответствует scale% Форма, первая в списке выше). Но 100% не принимается Dragonfly, потому что Dragonfly использует это регулярное выражение для проверки аргументов геометрии:

^\d*x\d*[><%^!]?$|^\d+@$

В основном что-нибудь без x Стрекоза считается недействительной. Я неправильно понимаю документацию ImageMagick, или регулярное выражение Dragonfly неверно?

2 ответа

Вы правильно понимаете документацию Imagemagick. Очевидно, что Dragonfly не поддерживает геометрическую форму "% масштаба". Dragonfly может изменить регулярное выражение RESIZE_GEOMETRY на это:

^\d*x\d*[><%^!]?$|^\d+[@%]$

или вы можете обойти это, задав геометрические характеристики, например: "100x%"

На самом деле, я думаю, что мы могли бы использовать это регулярное выражение для создания системы сопоставления геометрии (предупреждение, огромное регулярное выражение).

(?<size>(?<w>(?:\d*(?:\.\d+)?)?%?)?(?:x(?<h>(?:\d*(?:\.\d+)?)?%?))?)(?<aspect>[!><@^])?(?<offset>(?<x>[+-]\d*(?:\.\d+)?)?(?<y>[+-]\d*(?:\.\d+)?)?)

К счастью, я объясняю, как найти регулярное выражение в этой сути. Если есть какая-либо ошибка, не стесняйтесь сказать.

Другие вопросы по тегам