图形smagick gm转换-size -resize缩放小图像,即使使用“w x h >”

时间:2022-03-25 04:56:16

When using something like the following on an image that's 100x400 px I end up with a file that's 192x768 px:

当在一个100x400像素的图像上使用如下内容时,我最终得到的是一个192x768像素的文件:

gm convert -size 1024x768 #{source[:filename]} -resize \"1024x768>\" +profile \"*\" #{source[:web_filename]}

gm转换-size 1024x768 {source[:filename]} -resize \“1024x768>\”+profile \“*\”#源[:web_filename]}

The > in 1024x768> change[s] the dimensions of the image only if its width or height exceeds the geometry specification.

在1024x768>中的>只有当图像的宽度或高度超过几何规格时才会改变图像的尺寸[s]。

But I guess that does not work because a size of 1024x768 is specified in -size 1024x768.

但是我想这是行不通的,因为1024x768的大小是用-size 1024x768指定的。

I base that on the docs saying -size specifies the width x height of the image so it does not check the image headers.

我在文档的基础上说-size指定了图像的宽度x高度,所以它不会检查图像的标题。

I do not want to lose any performance advantage by not specifying -size, as suggested in the resize example but I don't want to scale up images either, so is there a better way to do this (or have I got the wrong end of the stick with what I said above)?

我不想失去任何性能优势不指定多大,但小弟弟的尺寸,建议在调整的例子但我不想扩大图像,所以有没有更好的方法(或我得到了不公平的待遇,我说上图)?

1 个解决方案

#1


0  

I do not understand what #{source[:filename]} or #{source[:web_filename]} represent in your command above, however, one thing I suspect you are misunderstanding is the -size parameter - the first parameter in your example.

我不理解在上面的命令中,#{源[:filename]}或#{source[:web_filename]}表示什么,但是,我怀疑您误解的一件事是-size参数—您的示例中的第一个参数。

The parameter -size only specifies the size of a canvas that GraphicsMagick is about to create itself, such as for a following xc:, a following gradient:, a following label:. It does not alter or change the size of anything.

参数大小只指定GraphicsMagick将要创建的画布的大小,比如以下的xc:,一个以下的渐变:,一个以下标签:。它不会改变或改变任何东西的大小。

# Create a solid blue canvas 100x100
gm convert -size 100x100 xc:blue ...

# Create a red-blue gradient 400x50
gm convert -size 400x50 gradient:red-blue ...

#1


0  

I do not understand what #{source[:filename]} or #{source[:web_filename]} represent in your command above, however, one thing I suspect you are misunderstanding is the -size parameter - the first parameter in your example.

我不理解在上面的命令中,#{源[:filename]}或#{source[:web_filename]}表示什么,但是,我怀疑您误解的一件事是-size参数—您的示例中的第一个参数。

The parameter -size only specifies the size of a canvas that GraphicsMagick is about to create itself, such as for a following xc:, a following gradient:, a following label:. It does not alter or change the size of anything.

参数大小只指定GraphicsMagick将要创建的画布的大小,比如以下的xc:,一个以下的渐变:,一个以下标签:。它不会改变或改变任何东西的大小。

# Create a solid blue canvas 100x100
gm convert -size 100x100 xc:blue ...

# Create a red-blue gradient 400x50
gm convert -size 400x50 gradient:red-blue ...