Resize, rotate, shear and rotate an image based on Adobe InDesign coordinates
Posted: 2019-05-07T02:58:11-07:00
Hi,
I need to resize, crop and rotate/shear images based on Adobe InDesign metadata. This works to resize and crop. But I have problems with rotate and shear.
ImageMagick Version is:
- ImageMagick 7.0.8-14 Q16 x86_64
- MacOS 10.12
This is the original image:
https://www.dropbox.com/s/9mn52rjwy6trt ... t.jpg?dl=0
You can see the image placed in InDesign here:
https://www.dropbox.com/s/5co61xcfci7ym ... e.png?dl=0
For the version without rotate and shear, the following command works:
The result of this is correct.
But for the version with a rotation I get a wrong result. I tried:
and get the following result:
https://www.dropbox.com/s/kj9nnh39caemw ... 1.jpg?dl=0
with -distort SRT I got closer, but not 100% correct:
result:
https://www.dropbox.com/s/56j1eghx9cejl ... t.jpg?dl=0
The problem is that the X and Y positions are not completely correct. InDesign returns the same X and Y position for images with and without rotation because the upper left corner remains at the same point.
I did not found a way, to calculate the correct X-/Y-Position for ImageMagick based on this values.
The same problem, for the version with rotation and shear:
result:
https://www.dropbox.com/s/k32z1w27nmg4j ... r.jpg?dl=0
This is an overview of the results I get:
https://www.dropbox.com/s/xgzbfroo1qqio ... t.png?dl=0
Thanks in advanced.
Martin
I need to resize, crop and rotate/shear images based on Adobe InDesign metadata. This works to resize and crop. But I have problems with rotate and shear.
ImageMagick Version is:
- ImageMagick 7.0.8-14 Q16 x86_64
- MacOS 10.12
This is the original image:
https://www.dropbox.com/s/9mn52rjwy6trt ... t.jpg?dl=0
You can see the image placed in InDesign here:
https://www.dropbox.com/s/5co61xcfci7ym ... e.png?dl=0
For the version without rotate and shear, the following command works:
Code: Select all
convert test.jpg -resize 22x22% -crop 1018x687+59+20 test_out.jpg
But for the version with a rotation I get a wrong result. I tried:
Code: Select all
convert input.jpg -resize 22x22% -alpha set \( +clone -background none -rotate -3 \) -gravity center -compose Src -composite -crop 1018x687+59+20 output_rotate1.jpg
https://www.dropbox.com/s/kj9nnh39caemw ... 1.jpg?dl=0
with -distort SRT I got closer, but not 100% correct:
Code: Select all
convert input.jpg -resize 22x22% -distort ScaleRotateTranslate -3 -crop 1018x687+59+20 ouput_rotate_srt.jpg
https://www.dropbox.com/s/56j1eghx9cejl ... t.jpg?dl=0
The problem is that the X and Y positions are not completely correct. InDesign returns the same X and Y position for images with and without rotation because the upper left corner remains at the same point.
I did not found a way, to calculate the correct X-/Y-Position for ImageMagick based on this values.
The same problem, for the version with rotation and shear:
Code: Select all
convert input.jpg -resize 22x22% -alpha set \( +clone -background none -rotate -3 \) -gravity center -compose Src -composite -alpha set \( +clone -background none -shear 10x0 \) -gravity center -compose Src -composite -crop 1018x687+59+20 output_rotate_and_shear.jpg
https://www.dropbox.com/s/k32z1w27nmg4j ... r.jpg?dl=0
This is an overview of the results I get:
https://www.dropbox.com/s/xgzbfroo1qqio ... t.png?dl=0
Thanks in advanced.
Martin