ImageMagick icon indicating copy to clipboard operation
ImageMagick copied to clipboard

Not printing crop position

Open niklasravnsborg opened this issue 8 months ago • 2 comments

ImageMagick version

7.1.1-47

Operating system

Linux

Operating system, version and so on

macOs

Description

I want to use the following command to get the crop size and offset of my image (original size 924 × 614). It shows a cropped image size but it always only shows +0+0 as the offset which can't be correct.

➜  magick public/myimage.png -fuzz 20% -format "%@" -trim info:
865x405+0+0

Some other commands show more information:

➜  magick public/myimage.png -fuzz 20% -trim info:
public/myimage.png PNG 865x405 924x614+39+169 8-bit TrueColor sRGB 104002B 0.000u 0:00.000
➜  magick public/myimage.png info:
public/myimage.png PNG 924x614 924x614+0+0 8-bit TrueColor sRGB 104002B 0.010u 0:00.000

Seams not like intended behavior to me. I would expect the first command to return 865x405+39+169...

Steps to Reproduce

Run the commands from above on the image.

Images

Image

niklasravnsborg avatar Apr 13 '25 18:04 niklasravnsborg

You don't use both %@ and -trim in the same command if you only want the information

magick public/myimage.png -fuzz 20% -format "%@" info:

If you want the information and trim the image with an output, then

magick public/myimage.png -fuzz 20% -format "%@" -write info: -trim +repage result.png

fmw42 avatar Apr 13 '25 18:04 fmw42

@fmw42 Ah thank you. I should have just replaced

magick public/myimage.png -fuzz 20% -format "%@" -trim info: with magick public/myimage.png -fuzz 20% -format "%@" info:

This gives back the correct trim offset. I still find it a bit confusing, because if i wanted to use the command without the "%@", i have to include the -trim in order to get the trim offsets.

➜ magick public/myimage.png -fuzz 20% -trim info:
public/myimage.png PNG 2671x5073 2990x5305+155+169 8-bit Palette sRGB 256c 3.70275MiB 0.000u 0:00.000

➜ magick public/myimage.png -fuzz 20% info:
public/myimage.png PNG 2990x5305 2990x5305+0+0 8-bit Palette sRGB 256c 3.70275MiB 0.000u 0:00.000

➜  magick public/myimage.png -fuzz 20% -trim -format "%@" info:
2671x5073+0+0⏎

➜  magick public/myimage.png -fuzz 20% -format "%@" info:
2671x5073+155+169⏎

niklasravnsborg avatar May 08 '25 13:05 niklasravnsborg