"X resolution" error when using CFIMAGE
i've built uploader new photo gallery, , it's pretty basic. can either upload using new <cffileupload> box, or can ftp files "upload" directory. since entire site local still, i've been copying files want add database "upload" directory, running script. far i've created 49 albums , added on 3,400 pics.
that is, until latest round.
i have pics took on cruise couple of years ago. there fewer 400 of them. when copy files upload folder, pick album, click "submit", following errors <cfcatch>:
cfcatch.type = application
cfcatch.message = x resolution
cfcatch.detail = x resolution
that's get.
on upload form, there's <cfif> statement copies original images "/fullsize/" directory before processing if they're 1280px wide or less. otherwise resizes them using <cfimage>. in case, files 1280 wide, next <cfimage> tag 1 makes default viewing pic.
here's code i'm using:
<cfdirectory action="list" directory="#request.basepath#/manage/upload" name="uploads" sort="name asc" mode="777">
<cfsetting requesttimeout="#createtimespan(0,1,0,0)#">
<cftry>
<cfloop query="uploads">
<!--- calculate portrait or landscape --->
<cfimage source="#request.basepath#/manage/upload/#uploads.name#" name="thisimage">
<cfif thisimage.height gt thisimage.width>
<cfset imgheight="800">
<cfset imgwidth="">
<cfset thumbheight="180">
<cfset thumbwidth="">
<cfelse>
<cfset imgheight="">
<cfset imgwidth="800">
<cfset thumbheight="">
<cfset thumbwidth="180">
</cfif>
<!--- add pics database --->
<cfif isnull(imagegetexiftag(thisimage,"date/time original"))>
<cfset pictimestamp = uploads.datelastmodified>
<cfelse>
<cfset pictimestamp = replace(listfirst(imagegetexiftag(thisimage,"date/time original")," "),":","-","all") & " " & listlast(imagegetexiftag(thisimage,"date/time original")," ")>
</cfif>
<!--- create full size file --->
<cfif thisimage.width gt 1280>
<cfimage
action="resize"
width="1280"
height=""
source="#request.basepath#/manage/upload/#uploads.name#"
destination="#request.basepath#/gallery/fullsize/#uploads.name#">
<cfelse>
<cffile
action="copy"
source="#request.basepath#/manage/upload/#uploads.name#"
destination="#request.basepath#/gallery/fullsize/#uploads.name#"
mode="777">
</cfif>
<!--- create main photo --->
<cfimage
action="resize"
width="#imgwidth#"
height="#imgheight#"
source="#request.basepath#/manage/upload/#uploads.name#"
destination="#request.basepath#/gallery/#uploads.name#">
<!--- create thumbnail --->
<cfimage
action="resize"
width="#thumbwidth#"
height="#thumbheight#"
source="#request.basepath#/manage/upload/#uploads.name#"
destination="#request.basepath#/gallery/thumbnails/#uploads.name#">
<cfquery name="addpicstodb" datasource="#request.dsn#" timeout="#createtimespan(0,1,0,0)#">
insert photos
( pic_album
, pic_file
, pic_date
)
values ( <cfqueryparam value="#form.upload_album#" cfsqltype="cf_sql_numeric">
, <cfqueryparam value="#uploads.name#" cfsqltype="cf_sql_varchar">
, <cfqueryparam value="#pictimestamp#" cfsqltype="cf_sql_timestamp">
)
</cfquery>
<!--- clean upload directory --->
<cffile
action="delete"
file="#request.basepath#/manage/upload/#uploads.name#">
</cfloop>
<cfcatch type="any">
<cfoutput>#cfcatch.type# - #cfcatch.message# - #cfcatch.detail# - #cfcatch.extendedinfo#</cfoutput>
</cfcatch>
</cftry>
keep in mind has worked on 3,400 pics, perhaps different set of pics i'm uploading.
the pics around 600kb in size (jpegs), , 1280x853px in resolution. i've batch-renamed them unique file prefix avoid naming conflicts.
solved, sort of.
i had used nautilus rotate/resize extension on bunch of pics in set landscape/portrait properties somehow not retained. apparently messes things <cfimage> because when deleted first image in set (which portrait), upload went fine until got next portrait file. opened in image viewer, rotated it, rotated , saved it, , fine.
looks have ones rotated. :/
but @ least i'm able upload again.
More discussions in ColdFusion
adobe
Comments
Post a Comment