Here's an ImageAppend() function for you. Pass it two image paths, and the
3rd Boolean flag is TRUE (default) to stack images on top of each other, or
FALSE to have them side by side. It returns an image object which you can
save, or write to the browser with <cfimage action="writetobrowser">.

--- Ben

<cffunction name="ImageAppend" returntype="any" output="yes">
        <cfargument name="image1" type="string" required="yes">
        <cfargument name="image2" type="string" required="yes">
        <cfargument name="vertical" type="boolean" required="no"
default="TRUE">
    
        <!--- Local vars --->
        <cfset var resultImage="">
        <cfset var img1=ImageRead(ARGUMENTS.image1)>
        <cfset var img2=ImageRead(ARGUMENTS.image2)>
        <cfset var imgHeight=0>
        <cfset var imgWidth=0>
        <cfset var img2x=0>
        <cfset var img2y=0>

        <!--- Calculate size of new image --->
        <cfif ARGUMENTS.vertical>
                <!--- Height is sum of both heights --->
                <cfset imgHeight=ImageGetHeight(img1)+ImageGetHeight(img2)>
                <!--- Width is greater of the two widths --->
                <cfset imgWidth=ImageGetWidth(img1)>
                <cfif ImageGetWidth(img2) GT imgWidth>
                        <cfset imgWidth=ImageGetWidth(img2)>
                </cfif>
                <!--- Location of second image --->
                <cfset img2x=0>
                <cfset img2y=ImageGetHeight(img1)>
        <cfelse>
                <!--- Width is sum of both widths --->
                <cfset imgWidth=ImageGetWidth(img1)+ImageGetWidth(img2)>
                <!--- Height is greater of the two heights --->
                <cfset imgHeight=ImageGetHeight(img1)>
                <cfif ImageGetHeight(img2) GT imgHeight>
                        <cfset imgHeight=ImageGetHeight(img2)>
                </cfif>
                <!--- Location of second image --->
                <cfset img2x=ImageGetWidth(img1)>
                <cfset img2y=0>
        </cfif>

        <!--- Next create new image --->
        <cfset resultImage=ImageNew("", imgWidth, imgHeight)>

        <!--- Paste first image --->
        <cfset ImagePaste(resultImage, img1, 0, 0)>

        <!--- Paste second image --->
        <cfset ImagePaste(resultImage, img2, img2x, img2y)>

        <cfreturn resultImage>
</cffunction>




-----Original Message-----
From: Ben Forta [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 29, 2008 2:18 PM
To: CF-Talk
Subject: RE: CFIMAGE- stacking images

ImageNew() to create a new blank image. ImageRead() and ImagePaste() to
paste first image, then another ImageNew() and ImagePaste() setting the x
and y so that it is where you want it relative to first image. Or just take
all of that and make a ImageAppend() function that dos it for you.

--- Ben


-----Original Message-----
From: Daniel Baughman [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 29, 2008 2:14 PM
To: CF-Talk
Subject: CFIMAGE- stacking images

Hello all,

I keep trying to find ways to use CFIMAGE but almost every time am forced to
use another tool...

Is there any way to append images?  IE I have one image, a photo, that I
want to append a polaroid-like bottom to. It seems this is outside the
functionality of the CFIMAGE tag.  Or am I missing something?

- Dan






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297673
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to