Good Afternoon,
Using php I'm in the process of switching our POVScript based rendering engine to ImageMagick and while progress has been made I'm hitting one road block hopefully someone can shed some light on. Given two images A and B I'm trying to compose B on A given specific coords for the bounding box. So conceptually image B will fill a rectangle with corner coords which I then want to place at specific points on image A. This will have the effect of skewing the image as necessary as well. I've been playing with distortImage and while it "worked" with DISTORTION_BILINEAR I get a strong drop in quality and odd artifacts. Curious if there is a better method to do this?
Thanks for the help.
Image Composition using specific coords
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Image Composition using specific coords
you could try distort affine or affineprojection
you could change the filter (from EWA default) to something like triangle or cubic on the bilinear
sorry I do not use Imagick, so cannot give you exact details, but see http://us3.php.net/manual/en/book.imagick.php
alternately, use PHP exec() and the command line equivalent to see if you get better rendering or control e.g. the filter as I don't see any filter control on the IMagick page.
Perhaps one of the Imagick experts can give you better suggestions.
you could change the filter (from EWA default) to something like triangle or cubic on the bilinear
sorry I do not use Imagick, so cannot give you exact details, but see http://us3.php.net/manual/en/book.imagick.php
alternately, use PHP exec() and the command line equivalent to see if you get better rendering or control e.g. the filter as I don't see any filter control on the IMagick page.
Perhaps one of the Imagick experts can give you better suggestions.
Re: Image Composition using specific coords
Thanks for the reply.
Yeah I tried that documentation and it was a good start. I've been playing more with distortImage and I think it's promising. I'll explain a little further. I'm trying to compose a transparent image A on a jpg image B which is then composed on image C. Image B needs to be skewed to specific coords, (therefore also skewing A). I can skew a random image to look like what I need but I need the actual bounding box of that image to change as well.
Do you have an idea with regards to a command line solution? I'm not opposed to using exec.
Thanks again.
Yeah I tried that documentation and it was a good start. I've been playing more with distortImage and I think it's promising. I'll explain a little further. I'm trying to compose a transparent image A on a jpg image B which is then composed on image C. Image B needs to be skewed to specific coords, (therefore also skewing A). I can skew a random image to look like what I need but I need the actual bounding box of that image to change as well.
Do you have an idea with regards to a command line solution? I'm not opposed to using exec.
Thanks again.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Image Composition using specific coords
In command line you would use +distort rather than -distort. That allows the bounding box to change size. see http://www.imagemagick.org/Usage/distor ... rt_bestfit
Re: Image Composition using specific coords
Thanks for the points, I played around with the command line after your post and while I made progress I decided to give the php api one more shot and I was able to produce the results I wanted.
I ended up doing an affine distortImage and just played with the control points. With enough jiggering I was able to get the skew and perspective I needed.
Thanks for the help!
I ended up doing an affine distortImage and just played with the control points. With enough jiggering I was able to get the skew and perspective I needed.
Thanks for the help!