Sean,

The <cfdocument> is created in a different process entirely. After the information for a report is created and the images are uploaded, this website has someone manually check for completeness and accuracy before the pdf is created. That is how I figured out what happened. Images that were uploaded before the CF9 Upgrade appeared normal in the pdf; only images that were uploaded after the upgrade did not show up.

Here is the code that I used to manipulate the images with <cfimage> :
    <!---  ---   ---  --->
    <!--- File Upload --->
    <!---  ---   ---  --->
    <cffunction name="FileUpload" returntype="numeric" output="false">
    <cfargument name="TempPath"        type="string"  required="true" hint="Image temp upload path">
    <cfargument name="FileName"        type="string"  required="true">
    <cfargument name="RequestId"       type="numeric" required="true">
    <cfargument name="Caption"         type="string"  required="true">
    <cfargument name="FileExt"         type="string"  required="true">
    <cfargument name="PropertyId"      type="numeric" required="false" hint="Pass a property id to assign it to the db table.">
    <cfargument name="MaxPixels"       type="numeric" default="1024">

    <cfset var NewFileName    = Replace(arguments.FileName, " ", "_", "ALL")>
    <cfset var ImgInfo        = ''>
    <cfset var UploadDir      = ''>
    <cfset var ImgUUID        = createUUID()>
    <cfset var WebFileName    = ''>
    <cfset var NewLocation    = "">
    <cfset var InsertImage    = ''>
    <cfset var getInsertImage = ''>

        <cfif NewFileName IS NOT arguments.FileName>
            <cffile action="" destination="#arguments.TempPath#\#NewFileName#" source="#arguments.TempPath#\#arguments.FileName#">
        </cfif>

        <cfinvoke method="GetUploadDir" returnvariable="UploadDir"></cfinvoke>
        <cfset WebFileName = UploadDir.RelImgPath & ImgUUID & "." & arguments.FileExt>
        <cfset NewLocation = UploadDir.ImgPath    & ImgUUID & "." & arguments.FileExt>

        <cfimage action="" source="#arguments.TempPath#\#NewFileName#" structname="ImgInfo">

        <!--- Resize and Delete original --->
        <cfif     ImgInfo.width  GT arguments.MaxPixels AND ImgInfo.width  GT ImgInfo.height>
            <cfimage action="" width="#arguments.MaxPixels#" height="" source="#arguments.TempPath#\#NewFileName#" destination="#NewLocation#">
            <cffile  action="" file="#arguments.TempPath#\#NewFileName#">
        <cfelseif ImgInfo.height GT arguments.MaxPixels AND ImgInfo.height GT ImgInfo.width>
            <cfimage action="" width="" height="#arguments.MaxPixels#" source="#arguments.TempPath#\#NewFileName#" destination="#NewLocation#">
            <cffile  action="" file="#arguments.TempPath#\#NewFileName#">
        <cfelse>
            <cffile action="" source="#arguments.TempPath#\#NewFileName#" destination="#NewLocation#">
        </cfif>

        <cfinvoke component="#Request.CFCLocation#.inspection" method="GetInspectionRequest" returnvariable="InspectionRequest">
            <cfinvokeargument name="RequestId" value="#arguments.RequestId#">
        </cfinvoke>

        <cfquery datasource="#session.DBsource#" name="InsertImage">
            INSERT INTO tbl_upload_images
                       (account_id, inspection_form_id, inspection_request_id, filename, caption,
                        extension,  original_filename,  last_user,             upload_by, upload_date,
                        location,   <cfif isDefined("arguments.PropertyId")>property_id,</cfif> image_uuid)
            VALUES (<cfqueryparam cfsqltype="cf_sql_integer"  value="#InspectionRequest.account_id#">,
                    <cfqueryparam cfsqltype="cf_sql_integer"  value="#InspectionRequest.inspection_form_id#">,
                    <cfqueryparam cfsqltype="cf_sql_integer"  value="#InspectionRequest.inspection_request_id#">,
                    <cfqueryparam cfsqltype="cf_sql_varchar"  value="#WebFileName#"                   maxlength="200">,
                    <cfqueryparam cfsqltype="cf_sql_varchar"  value="#arguments.caption#"             maxlength="200">,

                    <cfqueryparam cfsqltype="cf_sql_varchar"  value="#Right(arguments.FileExt,10)#"   maxlength="10">,
                    <cfqueryparam cfsqltype="cf_sql_varchar"  value="#Right(arguments.FileName,100)#" maxlength="100">,
                    <cfqueryparam cfsqltype="cf_sql_smallint" value="#session.UserID#">,
                    <cfqueryparam cfsqltype="cf_sql_smallint" value="#session.UserID#">,
                    <cfqueryparam cfsqltype="cf_sql_timestamp" value="#Now()#">,

                    <cfqueryparam cfsqltype="cf_sql_varchar" value="#NewLocation#" maxlength="200">,
<cfif isDefined("arguments.PropertyId")>
                    <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.PropertyId#">,
</cfif>
                    <cfqueryparam cfsqltype="cf_sql_varchar" value="#ImgUUID#"     maxlength="38"> );
        </cfquery>
        <cfquery datasource="#session.DBsource#" name="getInsertImage">
            SELECT LAST_INSERT_ID() AS GENERATED_KEY;
            <!---SELECT @@identity as new_id--->
        </cfquery>

        <cfreturn getInsertImage.GENERATED_KEY>
    </cffunction><!--- File Upload --->

The first thing this code does is removes any spaces in the filename. (if necessary)
It the calls another method to determine the final location of the resized image.

Now we get to the meat:
    1) We determine the current image size.
    2) We determine if the longer side is larger than the max pixel width we want.
    3) If we are on the long side and we need to resize, we call cfimage to create the new file and delete the old.
    4) If the image did not need to be resized, we just move it out of the temp directory and into the new directory.

    In either case we use a UUID in order to have a unique file name.
    We then store the data into a table including the original filename and who uploaded it.

After uploading images with this function, the images appeared normal on the website, but appeared as grey boxes in the pdf. (Not the red "x" of a missing image in the pdf, but a solid grey box.)

On 09/08/2010 10:26 AM, W. Sean Harrison wrote:
Frank,

Are you pulling image info and resizing in the same process as you're
generating the CFDocument? You may want to try single threading the
image manipulation and PDF generation, or doing them separately.

...I'm hoping you see this resolved - I've got a huge app that
procesess images of avigation/easement projects before rendering PDF's
for the FAA, and I'm not about to upgrade until I see this particular
issue resolved!

--Sean


---------- Forwarded message ----------
From: Frank Moorman <[email protected]>
Date: Tue, Sep 7, 2010 at 5:14 PM
Subject: [ACFUG Discuss] CFIMAGE/CFDOCUMENT problem in CF9
To: [email protected]


All,

As I sent out late last week, I did an upgrade from CF7 to CF9 over the weekend.

Unfortunately even with all the testing we did we came across a
problem this afternoon.

Essentially, we allow inspectors to upload images that will eventually
be used to create a pdf inspection report.

The images are from digital cameras and we will resize them down to
1024x768. (roughly, we do keep the aspect ratio.)

Here is the problem, with CF7 we called the cf_magicktag to get image
size information, then we calculate the new size, and lastly call
cf_magicktag a second time to do the resize.

Unfortunately, cf_magicktag does not work well with CF9. I thought
that was ok because I would use the new CFIMAGE tag. Then this
afternoon the brown stuff hit the fan as I found out that any image
modified by CFIMAGE would not show up in A CFDOCUMENT.

Most of our pdfs that we created today with CFDOCUMENT had gray boxes
instead of images. Everything else on the pdf was fine, but no images.
I figured out that all the images uploaded before the upgrade
displayed correctly in reports, but no image uploaded after the
upgrade could be displayed in a pdf.

I did a search on the adobe forums and google and I only came up with
the following:

http://www.websavey.com/2010/02/coldfusion-images-not-loading-in-cfdocument-when-using-cfimage-

It sounds like the above person came across the same issue, but there
was no resolution.

I was able to fix the issue by using <CFIMAGE action="" ...> to
make up for <cf_magicktag>'s problem and then use <cf_magicktag> to do
the actual resize which fortunately works and the images now show up
again in pdfs.

However, at best, this is an ugly hack. I was wondering if anyone else
using CF9 (or possible CF8) has encountered this and how it was
resolved.

Also, does anyone know what I can do with my uploaded images? I am
going to try to see if I change the format (maybe from JPG to TIFF) if
that would fix my issue for everything uploaded today. (for space,
after the resizing, the originals are immediately deleted.) But, any
suggestions on this would also be appreciated.

Thanks,
Frank


-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

  
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to