• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Just out of curiosity: imageDrawLine / imageDrawText

LEGEND ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Hello, all,

I've been playing around with imageDrawLine(s) and imageDrawText (only just recently discovered them), and I am confused about something that I hope someone can help clarify.

If I create a new image using imageNew, I can draw lines and text on it with no problems.

However, if I use CFIMAGE or imageNew to create an image from an existing .gif, it will not work.  It does not error - it just leaves a blank white space where the image should be.

Is it not possible to add lines or text to existing images??  Here's my code, so far:

<cfimage action="read" source="#app_root#img/500x500.gif" name="myImage" />

<cfset imageSetAntiAliasing(myImage,'on') />

<cfset imageSetDrawingColor(myImage,'black') />

<cfset attr = StructNew() />

<cfset attr.width = 5 />

<cfset attr.endcaps = "round" />

<cfset imageSetDrawingStroke(myImage,attr) />

   ... set x/y arrays ...

<cfset imageDrawLInes(myImage,x,y,true,false) />

<cfimage action="writetobrowser" source="#myImage#" format="png" />

As the code above is, this gives me a blank square 500 x 500.  No lines.  No text, if I use the imageDrawText tag.

If I change line 01 to <cfset myImage = imageNew('','500','500','rgb','white') />, then it gives me a white square with the lines drawn as I coded for.

What I am doing incorrectly?  Or does it not work with existing images?

V/r,

^_^

Views

221

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 18, 2016 May 18, 2016

Okay.. there is a bit of important information that I am not currently seeing in the instructions that would have been beneficial had I known about it from the get-go.

If you do not use imageSetDrawingColor(), then anything you write will not appear on the image.  I don't know if it puts the text there and it's just transparent, or if it just plain doesn't put text or lines in place.  But not setting the color before using the imageDrawText() tag will make it look like nothing is happening.

It is

...

Votes

Translate

Translate
LEGEND ,
May 17, 2016 May 17, 2016

Copy link to clipboard

Copied

Has ANYone used imageDrawLine or imageDrawText whom might be able to shed some light on my query?

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

I, finally, was able to gleam some information on this subject.  Previous Google searches only showed how to line/text draw on newly created, blank images.  After some cursing, and hair-pulling (my own, not anyone else), and shaking of fists at empty air while screaming at the gods of cyberspace, I did stumble across this.

It indicates that you _can_ draw on an existing image, although I haven't tried it, yet.  I'm going to give this a shot, and I'll report how my experiment went. 

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

LATEST

Okay.. there is a bit of important information that I am not currently seeing in the instructions that would have been beneficial had I known about it from the get-go.

If you do not use imageSetDrawingColor(), then anything you write will not appear on the image.  I don't know if it puts the text there and it's just transparent, or if it just plain doesn't put text or lines in place.  But not setting the color before using the imageDrawText() tag will make it look like nothing is happening.

It is now working.

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation