Page 1 of 1

-trim and -extend does not modify clipping path correctly

Posted: 2018-10-04T10:33:57-07:00
by grburgos
There seems to be a bug that "-trim" and "-extent" they don't seem to modify the clip path correctly.

Example
For some reason the clipping path is changed and shows smaller than it should be.

I use Gimp 2.8 to open the file and look at the clipping path called "Path 1". You can notice that after I run the command

Code: Select all

convert origin.tiff -trim +repage -resize 500x500 -background white -gravity north -extent 500x500 result.tiff
the clipping path is smaller than the image of the product.
https://www.dropbox.com/s/lwlq4dwbihzxd ... h.png?dl=0

If I use the plain -resize command, the clipping path does align with the image.
https://www.dropbox.com/s/xddloukntpmxm ... h.png?dl=0

Code: Select all

convert origin.tiff  -resize 500x500 result.tiff

More details
http://www.imagemagick.org/discourse-se ... =1&t=34803

Re: -trim and -extend does not modify clipping path correctly

Posted: 2018-10-17T15:05:08-07:00
by dlemstra
This is not a bug but the expected result. The clipping path is never resized. Sometime you are lucky and you get the correct clip path because of how it stored in the image profile. I don't think we will be able to add support for this anytime soon.

Re: -trim and -extend does not modify clipping path correctly

Posted: 2018-10-18T06:29:26-07:00
by grburgos
If that would be the case then why does the -resize alone does adjust the clipping path but when I use the -extent the clipping path becomes incorrect.

If I use this:

Code: Select all

convert origin.tiff -trim +repage -resize 4800x4800 -background white -gravity center -extent 4800x4800 -compress lzw tiff.tiff
The source image is 800x600 and I'm requesting an image several times larger. If what you state that the clipping path is never modified. The clipping path would stay at a size less than 800x600. However, after I run the command above the clipping path is 3684x3707 in size.

Also, I tried removing the trim and I got the same image condition. I have already tried a plain -resize and the clipping path was kept. Which means that the -extent command is the one resizing the clipping path incorrectly.

Using IM 7.0.8-12

Re: -trim and -extend does not modify clipping path correctly

Posted: 2018-10-18T09:46:56-07:00
by dlemstra
The clip path is stored in a vector format and the positions are relative to the 0x0 position of the image. And that does not change when you resize the image. The relative position is still the same. But this changes when you extent the image. The start position of the clipping path is no longer at the same position. We don't modify the path when we resize the image. This show that the path still has the same size but now no longer starts at the correct position because you trimmed the image:

Code: Select all

convert origin.tiff -trim +repage -clip ( -size 615x532 xc:rgba(255,0,0,0.5) ) -compose over -composite test.png
We never touch the clipping path.