尝试解决其他人不太好的代码问题。任何想法将不胜感激。它似乎在引入图像的<cfif>
轰炸:
<cfif LEN(qryCampers.std_image_filename[iRow + iCol]) GT 0>
如果我注释掉if(并且只保留与cfif
语句中的“no_image.gif”相关的部分)我们就是好的。该文件出现。
CF Server 8,SQL Server 2000,图像尺寸相对较小(全部低于30kb,宽度不超过300px),此代码在某些时候有效,而且只需要,它需要FOREVER加载PDF。此特定查询(仅12条记录)导致错误。
错误:
Invalid image format
The error occurred in D:\apps\Websites\Example\app\reports\dsp_camper_cards_preview.cfm: line 51
49 : <td width="40%" align="center" valign="middle">
50 : <cfif LEN(qryCampers.std_image_filename[iRow + iCol]) GT 0>
51 : <cfimage source="../photos/#qryCampers.std_image_filename[iRow + iCol]#" action="read" name="cardImage">
52 : <cfif cardImage.height GT cardImage.width>
53 : <img src="../photos/#qryCampers.std_image_filename[iRow + iCol]#" height="150">
cfdocument
代码:
<cfdocument filename="#fileName#" format="PDF" pagetype="letter"
margintop=".175" marginbottom=".125" marginright=".125" marginleft=".125"
orientation="portrait" unit="in" encryption="none" fontembed="Yes" backgroundvisible="No" overwrite="Yes">
<style type="text/css">
table, tr, td { font-size: 9px; font-family:Arial; }
</style>
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="center" bordercolor="000000">
<cfloop from="1" to="#Ceiling(qryCampers.recordcount/2)#" index="iRow">
<tr valign="top">
<cfloop from="#iRow - 1#" to="#iRow#" index="iCol">
<cfif LEN(qryCampers.student_id[iRow + iCol]) GT 0>
<cfquery name="qryMedInfo" datasource="#session.datasource#">
SELECT * FROM tbl_medical_info_form WHERE mif_std_id = #qryCampers.student_id[iRow + iCol]# AND mif_trip_year = '#DateFormat(Now(), '01/01/yyyy')#'
</cfquery>
<td width="50%">
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="center">
<tr valign="top">
<td height="25%">
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="center">
<tr valign="top">
<td width="40%" align="center" valign="middle">
<cfif LEN(qryCampers.std_image_filename[iRow + iCol]) GT 0>
<cfimage source="../photos/#qryCampers.std_image_filename[iRow + iCol]#" action="read" name="cardImage">
<cfif cardImage.height GT cardImage.width>
<img src="../photos/#qryCampers.std_image_filename[iRow + iCol]#" height="150">
<cfelseif cardImage.height LTE cardImage.width>
<img src="../photos/#qryCampers.std_image_filename[iRow + iCol]#" height="150">
</cfif>
<cfelse>
<img src="../images/no_image.gif" alt="" width="" height="150" border="0">
</cfif>
</td>
<td width="60%">
<cfif qryMedInfo.mif_c_alleriges EQ "Yes" OR LEN(qryMedInfo.mif_severe_allerigies) GT 0>
<font color="FF0000" style="font-size:16px;">ALLERGIES</font><br>
</cfif>
<cfif qryMedInfo.mif_r_alcohol EQ "Yes">
<font color="FF0000" style="font-size:16px;">ALLOWED TO DRINK</font><br>
<cfelse>
<font color="FF0000" style="font-size:16px;">NOT ALLOWED TO DRINK</font><br>
</cfif>
<u>Parent Note</u> : <cfif qryMedInfo.mif_c_alleriges EQ "Yes">#qryMedInfo.mif_history_comments#</cfif><br>
<u><font color="FF0000">SEVERE ALLERGIES</font></u> : #qryMedInfo.mif_severe_allerigies#<br>
<br>
<u>Conditions</u> : #qryMedInfo.mif_med_conditions_1#<br>
<cfif Len(qryMedInfo.mif_med_conditions_2) GT 0>#qryMedInfo.mif_med_conditions_2#<br></cfif>
<u>Medications</u> : <font color="FF0000">#TRIM(qryMedInfo.mif_med_taken_1)#</font><br>#TRIM(qryMedInfo.mif_med_taken_2)#<br>
<font color="FF0000"><u>CANNOT TAKE</u> : </font>
<cfif qryMedInfo.mif_r_aspirin EQ "No"> Aspirin,</cfif>
<cfif qryMedInfo.mif_r_pepto EQ "No"> Pepto Bismol,</cfif>
<cfif qryMedInfo.mif_r_non_aspirin EQ "No"> Non-Apsirin (Acetaminophen/Tylenol),</cfif>
<cfif qryMedInfo.mif_r_maalox EQ "No"> Maalox,</cfif>
<cfif qryMedInfo.mif_r_nsaid EQ "No"> NSAID (Ibuprofen/Advil, Motrin or Naproxensodium/Aleve),</cfif>
<cfif qryMedInfo.mif_r_immodium EQ "No"> Immodium,</cfif>
<cfif qryMedInfo.mif_r_benadryl EQ "No"> Benadryl,</cfif>
<cfif qryMedInfo.mif_r_simethicone EQ "No"> Simethicone (GasX),</cfif>
<cfif qryMedInfo.mif_r_sudafed EQ "No"> Pseudoephedrine/Sudafed,</cfif>
<cfif qryMedInfo.mif_r_tagamet EQ "No"> Tagamet or similar,</cfif>
<cfif qryMedInfo.mif_r_cough EQ "No"> Cough Medicine,</cfif>
<cfif qryMedInfo.mif_r_bandages EQ "No"> Bendages,</cfif>
<cfif qryMedInfo.mif_r_throat EQ "No"> Throat Lozenges,</cfif>
<cfif qryMedInfo.mif_r_antibiotic EQ "No"> Antibiotic Ointment,</cfif>
<cfif qryMedInfo.mif_r_ex_anesthetic EQ "No">External Anesthetic (Calamine or the like),</cfif>
<cfif qryMedInfo.mif_r_cortisone EQ "No"> Topical Cortisone Cream,</cfif>
<cfif qryMedInfo.mif_r_tylenol_pm EQ "No"> Tylenol PM</cfif>
<br>
</td>
</tr>
<tr>
<td colspan="2">
<font style="font-size:16px;font-weight:bold;color:0000ff;">
#qryCampers.std_first_name[iRow + iCol]# #qryCampers.std_last_name[iRow + iCol]#
</font><br>
<br>
<u>Emergency Contact</u> : #qryMedInfo.mif_emerg_name# <cf_phoneoutput startstring="#GetNumbers(qryMedInfo.mif_emerg_phone)#"><br>
<br>
<u>Father/Gaurdian</u> : #qryCampers.ftr_first_name[iRow + iCol]# #qryCampers.ftr_last_name[iRow + iCol]#
<u>(H)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.ftr_main_phone[iRow + iCol])#"> or <u>(C)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.ftr_cell_phone[iRow + iCol])#"><br>
<u>Mother/Gaurdian</u> : #qryCampers.mtr_first_name[iRow + iCol]# #qryCampers.mtr_last_name[iRow + iCol]#
<u>(H)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.mtr_main_phone[iRow + iCol])#"> or <u>(C)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.mtr_cell_phone[iRow + iCol])#"><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<cfelse>
<td width="50%"> </td>
</cfif>
</cfloop>
</tr>
<cfif iRow MOD 4 IS 0>
<tr>
<td> </td>
</tr>
</cfif>
</cfloop>
</table>
</cfdocument>
答案 0 :(得分:1)
听起来这一行<cfimage source="../photos/#qryCampers.std_image_filename[iRow + iCol]#" action="read" name="cardImage">
中找到的图像不是有效的图像格式。你确定它正在尝试阅读有图像吗?
答案 1 :(得分:1)
您是否尝试使用“isImage”?
<cfif trim(qryCampers.std_image_filename[iRow + iCol]) neq ''
AND isImage('../photos/#qryCampers.std_image_filename[iRow + iCol]#')>
我同意@Leeish的说法,CFImage标签正在获得一些它无法识别为图像的东西。我有时间有一个标记为jpg的jpg并且我可以在浏览器中查看它然后我试图在photoshop或类似的东西中将它拉出来我发现jpg本身存在aheader问题那是在阻止cfimage或cfx_ImageCR(我更喜欢)。
答案 2 :(得分:1)
就您的无效图片错误而言,我们遇到了类似无效格式和性能下降的问题。我们的解决方案是使用cfimage将图像转换为png然后再转换为jpg。我们是在图片上传时完成的,但您可以在您的情况下做同样的事情。
<cfimage source="#expandPath('\images\temp')#\#cffile.serverFile#" action="convert" destination="#expandPath('\images\temp')#\#cffile.serverFileName#.png" overwrite="yes">
<cfimage source="#expandPath('\images\temp')#\#cffile.serverFileName#.png" action="convert" destination="#expandPath('\images\temp')#\#cffile.serverFileName#.jpg" overwrite="yes">