Re: Centering text written on an image

2008-08-26 Thread Kevin Roche
I think you have to figure out the offset, and start from there. So, you'll
need to determine the approximate width in pixels of your text string,


But the quetion is how? How can I find the width of the string?

I tried making a table of widths and that does not work really.

For example with the strings AWA and HWH with Arial font the A is wider than H 
the kerning means that HWH is wider. 

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

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


RE: Centering text written on an image

2008-08-26 Thread Rick Faircloth
Is there a way to add an extra step or two and make
an image of just your text, determine that width which
gives you your string width, then with that info in hand,
write your text onto your image?

Rick

 -Original Message-
 From: Kevin Roche [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 6:04 AM
 To: CF-Talk
 Subject: Re: Centering text written on an image
 
 I think you have to figure out the offset, and start from there. So, you'll
 need to determine the approximate width in pixels of your text string,
 
 
 But the quetion is how? How can I find the width of the string?
 
 I tried making a table of widths and that does not work really.
 
 For example with the strings AWA and HWH with Arial font the A is wider than 
 H the kerning means
that
 HWH is wider.
 
 

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

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


Re: Centering text written on an image

2008-08-26 Thread Azadi Saryev
that's exactly what i am doing for my client who wants to create custom
ads for their products (tours).
my situation is easier in a way that the ads are pre-st size and i have
a transparent .png of same size to put text on, add shadows etc, and
then overlay it over the product image. easy as pie with cf8 and
imageUtils.cfc from Ray/Ben  Co.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/



Rick Faircloth wrote:
 Is there a way to add an extra step or two and make
 an image of just your text, determine that width which
 gives you your string width, then with that info in hand,
 write your text onto your image?

 Rick


   
   

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

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


Re: Centering text written on an image

2008-08-26 Thread Raymond Camden
You will also find related functions in ImageUtils as well. If I
remember right we (CFC was made by Ben Nadel, myself, and others) also
have a generic 'getSize' func for text as well. Either way though, the
CFC makes this operation trivial.


On Fri, Aug 22, 2008 at 1:03 PM, Chris Blackwell [EMAIL PROTECTED] wrote:
 Hi,

 I want to add some text to an image but have it centered rather than
 left justified. Does anyone know how to do that?

 Kevin Roche

 http://imageutils.riaforge.org/ - getCenteredTextPosition()



 

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

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


Re: Centering text written on an image

2008-08-26 Thread Kevin Roche
Is there a way to add an extra step or two and make
an image of just your text, determine that width which
gives you your string width

I have no Idea how to do that. Can you tell me how to find the width of the 
text? 

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

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


Re: Centering text written on an image

2008-08-26 Thread Raymond Camden
Yes, again, the CFC has a way to get the height/width of _just_ a
textual component.

On Tue, Aug 26, 2008 at 7:42 AM, Kevin Roche
[EMAIL PROTECTED] wrote:
Is there a way to add an extra step or two and make
an image of just your text, determine that width which
gives you your string width

 I have no Idea how to do that. Can you tell me how to find the width of the 
 text?

 

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

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


RE: Centering text written on an image

2008-08-26 Thread Rick Faircloth
What I'm thinking is trying to avoid determining the
text width by creating an image of just the text and
measuring that.

Once you have that width information, you can use it
to determine how to center the text when you apply it
to the background image.

Such as:

Here's your text:

MyText

Create an image of just that text:


|MyText|


and determine width:  220px


Here's your background:

-
|   |
-

Background image width: 540px

Difference:  540px - 220px = 320px

Half that is left offset:  160px

Use that info (160px) as the basis for centering your text.

Does that make sense?

I know you can get the width of an image using javascript (jQuery recommended),
but the others have also pointed to some other potential resources... CFC's, 
etc.

Hope this helps...I'm going to need a solution to this at some point, too!

(Realize I haven't worked with applying text to images, yet,
so my approach may be totally off-base.  Just thinking out loud...which may
be a bad idea before coffee :o)

Rick


 -Original Message-
 From: Kevin Roche [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 8:43 AM
 To: CF-Talk
 Subject: Re: Centering text written on an image
 
 Is there a way to add an extra step or two and make
 an image of just your text, determine that width which
 gives you your string width
 
 I have no Idea how to do that. Can you tell me how to find the width of the 
 text?
 
 

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

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


RE: Centering text written on an image

2008-08-26 Thread Rick Faircloth
Ray's approach is the best way to go.
It's going to be better for the long run.

It's good to know that CFC is there, Ray.
I'm sure I'll be making using of it, too!

By the way...if it can be explained without
taking too much of your time...how does the
CFC measure the height and width of text
without resorting to an image, given all the
variables in font, size, etc.

Rick

 -Original Message-
 From: Raymond Camden [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 9:17 AM
 To: CF-Talk
 Subject: Re: Centering text written on an image
 
 Yes, again, the CFC has a way to get the height/width of _just_ a
 textual component.
 
 On Tue, Aug 26, 2008 at 7:42 AM, Kevin Roche
 [EMAIL PROTECTED] wrote:
 Is there a way to add an extra step or two and make
 an image of just your text, determine that width which
 gives you your string width
 
  I have no Idea how to do that. Can you tell me how to find the width of the 
  text?
 
 
 
 

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

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


Re: Centering text written on an image

2008-08-26 Thread Claude Schneegans
 how does the
CFC measure the height and width of text
without resorting to an image

Any decent text/Image processing library will provide some function to 
calculate
the physical length of a string given a specific font and size.
And I'm pretty sure Ray's CFC is using a decent library.

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

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


Re: Centering text written on an image

2008-08-26 Thread Kevin Roche
What I'm thinking is trying to avoid determining the
text width by creating an image of just the text and
measuring that.

Yes but how?

When you create an image in ColdFusion you have to give it a width and a height.

If you don't you get an error when you try and use it:

The image on which the operation was executed is undefined.
An image must have some non-zero positive dimensions for image operations to be 
applicable. 

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

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


Re: Centering text written on an image

2008-08-26 Thread Raymond Camden
It's using a bunch of Java code from an Adobe blogger (used with
permission). I forget the name, but it should be credited in the CFC
itself. I definitely can't take credit for the code, although I think
I handled the wrapping up in the method. That counts for something,
right? ;)

Anyway, that URL again: http://imageutils.riaforge.org


-Raymond


On Tue, Aug 26, 2008 at 8:56 AM, Claude Schneegans
[EMAIL PROTECTED] wrote:
  how does the
 CFC measure the height and width of text
 without resorting to an image

 Any decent text/Image processing library will provide some function to
 calculate
 the physical length of a string given a specific font and size.
 And I'm pretty sure Ray's CFC is using a decent library.

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

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


RE: Centering text written on an image

2008-08-26 Thread Rick Faircloth
Thanks, Claude.

I figured I could look at the CFC code, but it would most likely take
wy too long for me to figure out what was happening.

Good stuff to know.

Rick

 -Original Message-
 From: Claude Schneegans [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 9:57 AM
 To: CF-Talk
 Subject: Re: Centering text written on an image
 
  how does the
 CFC measure the height and width of text
 without resorting to an image
 
 Any decent text/Image processing library will provide some function to
 calculate
 the physical length of a string given a specific font and size.
 And I'm pretty sure Ray's CFC is using a decent library.



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

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


RE: Centering text written on an image

2008-08-26 Thread Rick Faircloth
This just shows my ignorance about text overlay.
I was hoping there was a way with CF 8 to just tell it
what font, size, and text and it would calculate the rest.
But, apparently not.  CF 9 should definitely incorporate that.

Ray's approach seems to be the best solution of all.
It's the only one I know of that integrated into CF and
can take only the font, size, and text and provide you
with dimensions, from the description we've gotten.

I'd definitely check into that.

http://imageutils.riaforge.org

Rick

 -Original Message-
 From: Kevin Roche [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 10:07 AM
 To: CF-Talk
 Subject: Re: Centering text written on an image
 
 What I'm thinking is trying to avoid determining the
 text width by creating an image of just the text and
 measuring that.
 
 Yes but how?
 
 When you create an image in ColdFusion you have to give it a width and a 
 height.
 
 If you don't you get an error when you try and use it:
 
 The image on which the operation was executed is undefined.
 An image must have some non-zero positive dimensions for image operations to 
 be applicable.
 
 

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

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


RE: Centering text written on an image

2008-08-22 Thread David Moore, Jr.
Are you doing this dynamically using cfimage or Photoshop or just how?
 
~David Subject: Centering text written on an image From: [EMAIL PROTECTED] 
To: cf-talk@houseoffusion.com Date: Fri, 22 Aug 2008 11:09:37 -0400  Hi,  
I want to add some text to an image but have it centered rather than left 
justified. Does anyone know how to do that?  Kevin Roche   

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

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


Re: Centering text written on an image

2008-08-22 Thread Kevin Roche
I am using ColdFusion to write some text on an image and I don't know in 
advance what the string is going to be so I can't guess where to start writing 
it.

Is there a way to say write this text around a particular point? 

I can check from the image how wide it is and work out where the centre is but 
I can't see how to either tell the ImageDrawText() function to center it or 
work out how wide the text will be once its written.

Kevin Roche


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

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


Re: Centering text written on an image

2008-08-22 Thread Alan Rother
Hey Kevin,

I ran into a similar problem. The main issue you are going to face is not
knowing how long the final rendered string will be once it's turned into a
graphic.

So far I've found no solution using the native CF8 image tools. If you
really HAVE to accomplish this then the only (easy) way I found to do is to
use ImageFlare from Efflare

http://efflare.com/


It has a much more robust engine when it comes to complex tasks like
generating graphics containing random types of text.

If you're going to go down this road ping me off list and I'll shoot you
some code samples.

[EMAIL PROTECTED]

=]

-- 
Alan Rother
Adobe Certified Advanced ColdFusion MX 7 Developer
Manager, Phoenix Cold Fusion User Group, AZCFUG.org


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

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


RE: Centering text written on an image

2008-08-22 Thread Dave Watts
 I am using ColdFusion to write some text on an image and I 
 don't know in advance what the string is going to be so I 
 can't guess where to start writing it.
 
 Is there a way to say write this text around a particular point? 
 
 I can check from the image how wide it is and work out where 
 the centre is but I can't see how to either tell the 
 ImageDrawText() function to center it or work out how wide 
 the text will be once its written.

I think you have to figure out the offset, and start from there. So, you'll
need to determine the approximate width in pixels of your text string, and
subtract half of that from the distance from the edge of your image to the
center.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

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

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


RE: Centering text written on an image

2008-08-22 Thread David Moore, Jr.
Kevin Wrote
 
 I am using ColdFusion to write some text on an image and I don't know in 
 advance what the string is going to be so I can't guess where to start 
 writing it.  Is there a way to say write this text around a particular 
 point?   I can check from the image how wide it is and work out where the 
 centre is but I can't see how to either tell the ImageDrawText() function to 
 center it or work out how wide the text will be once its written. 
The only way I know is to set the start point of the text. To do this you would 
take the TotalImageWidth - TextWidth/2 to find where the start point should be. 
That would be one way. 
 
~David
 
_
Talk to your Yahoo! Friends via Windows Live Messenger.  Find out how.
http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yahoo_082008

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

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


Re: Centering text written on an image

2008-08-22 Thread Chris Blackwell
 Hi,
 
 I want to add some text to an image but have it centered rather than 
 left justified. Does anyone know how to do that?
 
 Kevin Roche

http://imageutils.riaforge.org/ - getCenteredTextPosition()



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

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