ImageMagick 和 mogrify 裁剪

发布于 2024-11-06 16:23:49 字数 699 浏览 4 评论 0原文

我在图像上进行裁剪时遇到问题(我的调整大小工作正常)

原始图像是 x ,调整大小后:

mogrify -resize x75 /my/path/image.jpg

我可以看到执行 getimagesize 后调整大小工作正常( ):

Array
(
    [0] => 148
    [1] => 75
    [2] => 2
    [3] => width="148" height="75"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)

裁剪命令是:

mogrify -crop 100x75! +0+0 /my/path/image.jpg

完成后,我尝试使用 getimagesize() 确认图像的大小正确,但出现以下错误,并且也无法访问图像。

Warning (2): getimagesize(/my/path/image.jpg) [function.getimagesize]: failed to open stream: No such file or directory

有什么想法吗?我对作物使用了错误的语法吗?

提前致谢!

I have having problems getting a crop to work on an image (I have got the resize working fine)

The orginal image is x and after a resize:

mogrify -resize x75 /my/path/image.jpg

i can see the resize has worked properly after performing getimagesize():

Array
(
    [0] => 148
    [1] => 75
    [2] => 2
    [3] => width="148" height="75"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)

the crop command is:

mogrify -crop 100x75! +0+0 /my/path/image.jpg

Once this is complete I try and confirm the image is the correct size by using getimagesize() but i get the following error and I also can't access the image.

Warning (2): getimagesize(/my/path/image.jpg) [function.getimagesize]: failed to open stream: No such file or directory

Any ideas? Am i using the wrong syntax for the crop?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烏雲後面有陽光 2024-11-13 16:23:49

看起来错误出在语法中,图像大小和裁剪位置之间没有空格。 它应该看起来像这样

mogrify -crop 100x75!+0+0 /my/path/image.jpg

以下是不正确

mogrify -crop 100x75! +0+0 /my/path/image.jpg

Looks like the error was in the syntax there is no space between the image size and crop position. it should look like this:

mogrify -crop 100x75!+0+0 /my/path/image.jpg

the below is incorrect:

mogrify -crop 100x75! +0+0 /my/path/image.jpg
小兔几 2024-11-13 16:23:49

我不记得以前使用过哪个路径,但我发现获得图像大小的唯一方法是使用文件的直接链接 http://www.blablabla - 你已经这样做了还是正在使用 PHP 路径?

在旁注中,我认为您应该将文件名设置两次才能打开然后保存文件?

mogrify -crop 100x75! +0+0 /my/path/image.jpg /my/path/image.jpg

我希望这对你有帮助,伙计......

I can't remember which path I used previously but I found that the only way I could get the image size was to use a direct link to the file http://www.blablabla - Have you done that or are you using the PHP path?

On a sidenote I thought you were meant to set the filename twice for it to open and then save the file?

mogrify -crop 100x75! +0+0 /my/path/image.jpg /my/path/image.jpg

I hope this helps you out mate...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文