Joining 2 images

Mark Smith lists at futilism.com
Sun May 3 23:10:52 EDT 2009


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.

best,

Mark



On 4 May 2009, at 02:14, Mark Smith wrote:

> In fact it is easy:
>
> if you want to join two images, "img1.jpg" and 'img2.jpg" it would  
> look like this:
>
> get shell("convert img1.jpg img2.jpg +append result.jpg")
>
> As far as I can tell, magick is not installed on on-rev - I'm not  
> sure how you'd go about installing it, as we don't seem to get  
> shell access. Perhaps a call to on-rev support?
>
> Best,
>
> Mark
>
> On 4 May 2009, at 01:58, Mark Smith wrote:
>
>> This may be easy to do in magick:
>>
>> http://www.imagemagick.org/script/command-line-options.php#append
>>
>> Best,
>>
>> Mark
>>
>> On 4 May 2009, at 01:56, Mark Smith wrote:
>>
>>> Sarah, others may know better, but I think you'll find this  
>>> difficult to do. The way one might do this in a stack would be to  
>>> import both images, then get the imageData of each, and join them  
>>> up.
>>>
>>> The imageData is actually just a list of pixel values as they are  
>>> rendered by rev. Typically, a jpeg or png image file does not  
>>> actually contain that data, it will contain a compressed version  
>>> which you can't just stick together in the same way.
>>>
>>> You may need to look into a command line tool like image magick  
>>> that you can make shell calls to, either to extract the imageData  
>>> or to do the whole job.
>>>
>>> Hopefully someone more knowledgable will be able to tell us I'm  
>>> wrong, but that's my understanding. :(
>>>
>>> best,
>>>
>>> Mark
>>>
>>>
>>> On 4 May 2009, at 00:12, Sarah Reichelt wrote:
>>>
>>>> Hi all you graphics gurus out there,
>>>>
>>>> I have 2 images, each 40 x 40 pixels.
>>>> I want to join then side by side to end up with an image 80 x 40.
>>>> Since this is for use in On-Rev, it has to work in script only, no
>>>> stack or image objects can be used.
>>>>
>>>> I am a complete noob when it come to graphics, but I know there are
>>>> people here who are experts, so if anyone has any suggestions, I  
>>>> would
>>>> be most grateful.
>>>>
>>>> Thanks,
>>>> Sarah
>>>> _______________________________________________
>>>> use-revolution mailing list
>>>> use-revolution at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your  
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your  
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list