开发者

ImageMagick and mogrify crop

开发者 https://www.devze.com 2023-03-04 04:05 出处:网络
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:

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!


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


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消