Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Please, give me an advice.
I need to create a square product photo automatically from the photos.
I manage to automatically crop the gray background to the product, but I can't make a square output.
I attach the original and the output I need.
Does anyone know how to do this?
Thanks!
You want to find the width, height and offsets of the trim, and increase either the height or width so they are equal, with a corresponding reduction in one offset, so you can do the crop. Is that correct?
This is the width, height and offsets of what a trim would give. You need to extract those numbers and do some arithmetic. The code for this depends on your script language.
With IM v7, the job can probably be done in a single command.
snibgo wrote: ↑2019-03-31T07:55:04-07:00
What version of IM? On what platform?
You want to find the width, height and offsets of the trim, and increase either the height or width so they are equal, with a corresponding reduction in one offset, so you can do the crop. Is that correct?
This is the width, height and offsets of what a trim would give. You need to extract those numbers and do some arithmetic. The code for this depends on your script language.
With IM v7, the job can probably be done in a single command.
Hello platform is Windows 10, version ImageMagick 7.0.8-35 Q16 x64 2019-03-25
The product always has a different dimension. I need to find his longer side and make a square cutout.
I found "convert" * .jpg "-bordercolor # e4e6e3 -border 10x10 -fuzz 25% -trim -set filename: f% t trimmed /% [filename: f] .jpg"
This works well to accurately cut the product. If it were possible to set the cutout sides to be the same, it would be great.
If in a .bat file, then I believe % need to be doubled to %%
The above will pad to square using the color found in the top left corner of the cropped image.
Thank you very much for your help!
Thank you for the advice. But I don't need this. The background is not exactly the same everywhere, so when it loads the color of one pixel and in that color fills the edges into a square, it is visible.
I really need to get a square cutout from the original.
From the images you show, it looks to me like your -trim is not effective, possibly due to noise or multiple surrounding layers of colors. Check the results from simply -trim and see if that is the case.