Joining 2 images
Sarah Reichelt
sarah.reichelt at gmail.com
Mon May 4 18:09:29 EDT 2009
On Mon, May 4, 2009 at 1:10 PM, Mark Smith <lists at futilism.com> wrote:
> I've nearly got it working without image magick.
>
> This works perfectly in the rev ide:
>
> function joinImages imgFile1, imgFile2
>
> set the textdata of the templateimage to url ("binfile:" & imgFile1)
> put the width of the templateimage into w1
> put the height of the templateimage into h1
> put the imagedata of the templateimage into tid1
>
> set the textdata of the templateimage to url ("binfile:" & imgFile2)
> put the width of the templateimage into w2
> put the height of the templateimage into h2
> put the imagedata of the templateimage into tid2
>
> put max(h1, h2) into h3
>
> put 0 into bytesDone1
> put 0 into bytesDone2
>
> repeat with n = 1 to h3
> if n <= h1 then
> put byte (bytesDone1 + 1) to (bytesDone1 + (w1 * 4))
> of tid1 after tid3
> else
> repeat w1 * 4
> put null after tid3
> end repeat
> end if
> add w1 * 4 to bytesDone1
>
> if n <= h2 then
> put byte (bytesDone2 + 1) to (bytesDone2 + (w2 * 4))
> of tid2 after tid3
> else
> repeat w2 * 4
> put null after tid3
> end repeat
> end if
> add w2 * 4 to bytesDone2
> end repeat
>
> set the width of the templateimage to w1 + w2
> set the height of the templateimage to h3
> set the imageData of the templateimage to tid3
>
> put "composite.jpg" into tFile
> export the templateimage to file tFile as JPEG
> return tFile
> end joinimages
>
> but all it produces on irev is a shocking pink rectangle :
> http://marksmith.on-rev.com/imagejoin.irev
>
> Perhaps there's a bug to do with imageData in the irev engine.
>
I got this working in the Rev IDE but only after changing the first 2
sections to use "formattedWidth" & formattedHeight".
In on-rev, this didn't work. It would get the width & height of the
first image, but the second image would be reported as 0 x 0. So I
changed back to your original and the width & height of the 2 starting
images were reported correctly, but the composite image had the right
height but a much larger width. See
<http://troz.on-rev.com/mergePics.irev>.
However I have solved the actual problem of having gaps between
images, using the margins style. You can see what I was doing here:
<http://troz.on-rev.com/numbers.irev>.
Cheers,
Sarah
P.S. I posted a question on the on-rev forum about ImageMagick so I'll
let you all know if/when I get a reply.
More information about the use-livecode
mailing list