Link to home
Start Free TrialLog in
Avatar of Dan Schimo
Dan SchimoFlag for United States of America

asked on

trying to resize an Image, using CFimage tag.

Hello Experts,

I have to keep the image display on my cf page to 150 X 215 px. I tried cfimage tag to resize image but see broken image icons in page.

<cfoutput><cfimage action = "resize" height = "150" source = "#PathOfficeImageID#" width = "215" name = "cfimagevariable" thickness="1">
														<a href="#PathOfficeDocID#">
														<!--- <img height="150px" width="215px" alt="" title="" style="padding:15px;border:0px solid ##CCCCCC;" src="#PathOfficeImageID#"> --->
															 <cfimage action="writetobrowser" source="#cfimagevariable#">
														</a></cfoutput>

Open in new window


User generated image
SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America 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
ASKER CERTIFIED SOLUTION
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
please note: you have not used the
cfimage read

Open in new window

to read the image before you resize, that code is not in your snippet, i hope you are doing it, but not sure, so i added it
Avatar of Dan Schimo

ASKER

Thank you _agx_ and Randhawa for the response.

it is cf 11 server on a Unix box

looks like this is a permissions issue on the server. Is there a way we could do this without writing to any location? Like an in memory.

2http://internet-dev.jsi.com/CFFileServlet/_cf_image/_cfimg-1654481641203887019.PNG Failed to load resource: the server responded with a status of 404 (Not Found).

I am willing to try Jquery sol too, if you could suggest.
id you tried my code @dan

at least try it in separate page and paste the results whatever you had
Why not just apply the appropriate permissions? If that's the problem, fixing them would resolve the issue and allow you to use cfimage action="writeToBrowser"?

Is there a way we could do this without writing to any location? Like an in memory.
Not if you want to use <cfimage action=writeToBrowser>. It always writes temporary images to the physical location mentioned, ie {cf_root}/CFFileServlet/_cf_image/....  

Possible alternatives are:

A) It could be done without writing to a file, but would require 2 pages:

      1.  First page reads the image into a variable, resizes it and returns the binary using <cfcontent> and ImageGetBlob(imageVariable)
      2.  Second page would call 1st page via an image tag, ie
                <img src="pageThatDoesResize.cfm?params=xxx&.....">

B) Read the image into a variable. Do the resize. Then use ImageWrite() to save the image file to a directory with the right permissions and. Then display the saved file with a standard <img> tag.

Having said all that, image manipulation is resource intensive. If possible, it is better to resize only once rather than doing it on the fly - on every page load.
Thank you for help
Welcome.  So how did you finally solve the problem? Fix permissions?