Page 1 of 1

Get coordinates from -trim

Posted: 2011-07-27T06:17:24-07:00
by Ilya87
I use -trim with -fuzz options to autocrop a batch of jpg. But this results in loss of quality.
So is there any posibility to direct cropping coordinates to jpegtran -crop WxH+X+Y and make lossless cropping?

Re: Get coordinates from -trim

Posted: 2011-07-27T10:23:50-07:00
by fmw42
you would have to use JP2000 in lossless mode (Jasper delegate library).

You could try adding -quality 100, but jpeg even at -quality 100 will still be slightly lossy.

What does this have to do with your title about getting coordinates from the trim? To do that you would need to save the result to png without using +repage after the trim. Then the verbose information for the file will contain the virtual canvas geometry with offset.

Re: Get coordinates from -trim

Posted: 2011-07-27T18:04:19-07:00
by anthony
WARNING: jpgtrans or any other lossless JPEG operation on image data itself is limited to cell boundaries. That is you can only crop to the cell dimensions, and not to pixel level. as such you are limited to either 8 or 16 pixel increments (depending on sub-sampling).

Actually breaking a 'cell' will require a decoding and re-encoding of the cells along the edges, and that only if you don't want to translate the image to a new origin.

See IM Examples, JPEG, lossless processing
http://www.imagemagick.org/Usage/formats/#jpg_lossless