Hi
I'm trying for weeks now and I'm not geting anywhere.
So I have an image and I have a matrix translate string : t320.804,-254.3717s1.1201,1.1201,0,0r45,0,0
Now I want to put the image (with the translation) onto a canvas of 800 x 600.
After that I want to crop the image (from the center) to 400x200
My first attempt was to create a real image of 800 x 600, then tried to put an image with a affine translation onto it. But somehow, the whole canvas was messed up.
Then I tried with a repage, but no luck either (I think I'm not using it properly).
Any suggestion to do this?
put image with translation on a canvas then crop it
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: put image with translation on a canvas then crop it
"-distort AffineProjection" takes 6 parameters: sx, rx, ry, sy, tx, ty. (See http://www.imagemagick.org/script/comma ... hp#distort .) You have 9 parameters.
"45" is a weird value for rx. Perhaps you want sin(45) = 0.7071.
Perhaps this is what you want:
"45" is a weird value for rx. Perhaps you want sin(45) = 0.7071.
Perhaps this is what you want:
Code: Select all
convert -size 150x100 gradient:red-blue sample.png
convert ^
sample.png ^
-virtual-pixel Black ^
+distort AffineProjection 1.1201,0.7071,0,1.1201,320.804,-254.3717 ^
+repage ^
-background Blue ^
-gravity Center ^
-extent 800x600 ^
-crop 400x200+0+0 +repage ^
t1.png
snibgo's IM pages: im.snibgo.com
Re: put image with translation on a canvas then crop it
well ... I tried your solution,
The image does rotate and scale, but it will be centered on the canvas. And that's not what I want. I need the image to be placed on the canvas with help of the transform t (so not centered) and after that , I will crop the image (from the center). So it can be that parts of the image will fall off after the crop.
The image does rotate and scale, but it will be centered on the canvas. And that's not what I want. I need the image to be placed on the canvas with help of the transform t (so not centered) and after that , I will crop the image (from the center). So it can be that parts of the image will fall off after the crop.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: put image with translation on a canvas then crop it
Sorry, I don't understand what you want. Perhaps this is closer to what you want:
Code: Select all
convert ^
t.png ^
-virtual-pixel Black ^
-distort SRT 1.1201,45 ^
+repage ^
-background Blue ^
-gravity NorthWest ^
-geometry +20.804+54.3717 ^
-size 800x600 xc:Blue ^
+swap -composite ^
-crop 400x200+0+0 +repage ^
t2.png
snibgo's IM pages: im.snibgo.com