Cannot get ImageMagick to trim wasted alpha space around PNG image #1919
-
Image In Question: https://imgur.com/XwgIzXL I'm writing some backend server stuff in Golang and wanted to automatically trim +repage incoming PNG data to remove wasted space, make images line up better, etc... But I couldn't get it working in code. I then moved onto command line: BUT the resulting image is never cropped! I tried messing with fuzz values, order of operations, etc... always the same results. But I can open it in GIMP and use "Crop To Content" no problem, so I don't think the file is the issue. Am I doing something wrong? NOTE: I'm using ImageMagick installed via brew (version 7+) and the matching golang branch of v3 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Works for me on IM 7.0.10.7 Q16 Mac OSX.
two.png PNG 400x216 400x216+0+0 8-bit sRGB 61934B 0.000u 0:00.000 |
Beta Was this translation helpful? Give feedback.
-
-trim only removes constant colored regions around the outside. It does not remove transparency. If you want to remove transparency then turn alpha off using -alpha off. On the Mac in Preview, the window background color is gray and the window has a minimum size for which you cannot make it smaller. The window background color outside the image will be the same color as the transparent regions. It does not show a checkerboard pattern like some other tools. So it is hard to know where the image ends and window background starts, if the image is smaller than the minimum windows size. Perhaps that is your issue? |
Beta Was this translation helpful? Give feedback.
-trim only removes constant colored regions around the outside. It does not remove transparency. If you want to remove transparency then turn alpha off using -alpha off. On the Mac in Preview, the window background color is gray and the window has a minimum size for which you cannot make it smaller. The window background color outside the image will be the same color as the transparent regions. It does not show a checkerboard pattern like some other tools. So it is hard to know where the image ends and window background starts, if the image is smaller than the minimum windows size. Perhaps that is your issue?