Link to home
Start Free TrialLog in
Avatar of simonlea
simonlea

asked on

Can CFImage "Mirror Print"?

Hi Experts,

I'm using CF8 (hosted at GoDaddy) and I want to "flip" an image to make a mirror image (NOT rotate). I can't see from the documentation that this is supported. Any ideas? Please note I want to do this programmatically (not image by image in PhotoShop etc).
ASKER CERTIFIED SOLUTION
Avatar of azadisaryev
azadisaryev
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jones911
Jones911

I'm not 100% if you can do it with GoDaddy hosting but here is the code to flip an image:


<!--- Get an image to flip, in this example the google logo --->
<cfimage action="read" source="http://www.google.com/intl/en_ALL/images/logo.gif" name="tempImage" />

<!--- Write it to the browser to prove its the correct way up --->
<cfimage action="writetobrowser" source="#tempImage#" />

<!--- Flip the image --->
<cfset imageFlip(tempImage) />

<!--- Write it to the browser to prove it's now upside down --->
<cfimage action="writetobrowser" source="#tempImage#" />

Open in new window

Avatar of _agx_
Avatar of simonlea

ASKER

Just trying Azadi's approach. "Write to Browser" is disabled at GoDaddy - but I should be able to work around by writing to directories under my control. Will let you all know...
> "Write to Browser" is disabled at GoDaddy

Unbelievable.  The joys of shared hosting..
That was just and example.  The key is:

<cfset imageFlip(tempImage) />


Which will work if they are running cf8
Yep - it does! For the benefit of others who find this question, the code that works (for me) is attached.

The "save image / display image" is a workaround for GoDaddy which does not support "write to browser" because that creates temporary files (which CF8 automatically cleans up I believe). Maybe I will write some clean up code to remove redundant images - or maybe I'll just clog up their servers until I get close to my disc usage limit. But wait! I don't have a disc usage limit!

Points to Azadi to be fair - his documentation link gave me the answer straight away. Thanks to others for incredibly quick responses.(for me)


<cfoutput>
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="blah/blah/15272.jpg" name="myImage">
<!--- Turn on antialiasing to improve image quality. --->
<cfset ImageSetAntialiasing(myImage,"on")>
<!--- Flip the image so that it is a mirror image of the source. --->
<cfset ImageFlip(myImage,"horizontal")>
<cfimage
    action = "write"
    destination = "blah/blah/M15272.jpg"
    source = "#myImage#"
    overwrite = "yes">
</cfoutput>

<img src="blah/blah/M15272.jpg">

Open in new window

Can't fault this one - straight to the documentation I hadn't found.
@simonlea

Sounds good.  I did not even see the other responses before posting, or I would not have bothered to respond ;-) I could see immediately they already gave the right answer!